chore: refactored to slightly cleaner file structure (more to do here)

pull/1/head
Adam Pash 8 years ago
parent 67e212ffac
commit 97087bd626

@ -2,7 +2,7 @@ import assert from 'assert'
import cheerio from 'cheerio'
import { clean } from './test-helpers'
import HTML from './fixtures/html'
import HTML from '../fixtures/html'
import {
brsToPs
} from './index'

@ -2,7 +2,7 @@ import assert from 'assert'
import cheerio from 'cheerio'
import { clean } from './test-helpers'
import HTML from './fixtures/html'
import HTML from '../fixtures/html'
import {
convertToParagraphs
} from './index'

@ -0,0 +1,9 @@
// DOM manipulation
export { default as stripUnlikelyCandidates } from './strip-unlikely-candidates'
export { default as brsToPs } from './brs-to-ps'
export { default as paragraphize } from './paragraphize'
export { default as convertToParagraphs } from './convert-to-paragraphs'
// Scoring
// export { default as getWeight } from './get-weight'

@ -2,7 +2,7 @@ import assert from 'assert'
import cheerio from 'cheerio'
import { clean } from './test-helpers'
import HTML from './fixtures/html'
import HTML from '../fixtures/html'
import {
paragraphize
} from './index'

@ -2,7 +2,7 @@ import assert from 'assert'
import cheerio from 'cheerio'
import { clean } from './test-helpers'
import HTML from './fixtures/html'
import HTML from '../fixtures/html'
import {
stripUnlikelyCandidates
} from './index'

@ -1,5 +1,5 @@
export { default as getWeight } from './get-weight'
export { default as stripUnlikelyCandidates } from './strip-unlikely-candidates'
export { default as brsToPs } from './brs-to-ps'
export { default as paragraphize } from './paragraphize'
export { default as convertToParagraphs } from './convert-to-paragraphs'
// DOM manipulation
export * from './dom'
// Scoring
export * from './scoring'

@ -1,7 +1,7 @@
import assert from 'assert'
import cheerio from 'cheerio'
import HTML from './fixtures/html'
import HTML from '../fixtures/html'
import {
getWeight
} from './index'

@ -0,0 +1,2 @@
// Scoring
export { default as getWeight } from './get-weight'

@ -1,4 +1 @@
// Given a node, determine if it's article-like enough to return
export function nodeIsSufficient(node) {
return node.text().trim().length >= 100
}
export { default as nodeIsSufficient } from './node-is-sufficient'

@ -1,23 +0,0 @@
import assert from 'assert'
import cheerio from 'cheerio'
import HTML from './fixtures/html'
import {
nodeIsSufficient
} from './index'
describe('Utils', () => {
describe('nodeIsSufficient(node)', () => {
it("returns false if node text length < 100 chars", () => {
const $ = cheerio.load(HTML.tooShort)
const sufficient = nodeIsSufficient($.root())
assert.equal(sufficient, false)
})
it("returns true if node text length > 100 chars", () => {
const $ = cheerio.load(HTML.longEnough)
const sufficient = nodeIsSufficient($.root())
assert.equal(sufficient, true)
})
})
})

@ -0,0 +1,5 @@
// Given a node, determine if it's article-like enough to return
export default function nodeIsSufficient(node) {
return node.text().trim().length >= 100
}

@ -0,0 +1,23 @@
import assert from 'assert'
import cheerio from 'cheerio'
import HTML from './fixtures/html'
import {
nodeIsSufficient
} from './index'
describe('Utils', () => {
describe('nodeIsSufficient(node)', () => {
it("returns false if node text length < 100 chars", () => {
const $ = cheerio.load(HTML.tooShort)
const sufficient = nodeIsSufficient($.root())
assert.equal(sufficient, false)
})
it("returns true if node text length > 100 chars", () => {
const $ = cheerio.load(HTML.longEnough)
const sufficient = nodeIsSufficient($.root())
assert.equal(sufficient, true)
})
})
})
Loading…
Cancel
Save