Compare commits

...

7 commits

Author SHA1 Message Date
Simon Vieille a7d23b9027
fix ci syntax
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-09-29 16:37:56 +02:00
Simon Vieille 013fa584fa
remove jenkins stuff
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-03-31 21:34:27 +02:00
Simon Vieille 77a2b1bca7
update ci
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-03-31 17:57:16 +02:00
Simon Vieille edeb7024d0
add ci
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-03-31 17:55:52 +02:00
Simon Vieille 01a2b9bc0c
apply linter 2023-03-31 17:53:50 +02:00
Simon Vieille cf9dd3218e
update dependencies 2023-03-31 17:53:40 +02:00
Simon Vieille 5130a96edc
apply linter 2023-03-31 17:53:24 +02:00
15 changed files with 4021 additions and 317 deletions

18
.woodpecker.yml Normal file
View file

@ -0,0 +1,18 @@
steps:
dependencies:
image: node:16
pull: true
commands:
- npm i
osv-detector:
image: gitnet.fr/deblan/osv-detector:v0.10
commands:
- osv-detector package-lock.json
failure: ignore
tests:
image: node:16
pull: true
commands:
- npm run test

13
Jenkinsfile vendored
View file

@ -1,13 +0,0 @@
pipeline {
agent any
stages {
stage('mocha') {
steps {
sh 'npm install --dev'
sh 'npm run test'
}
}
}
}

View file

@ -1,7 +1,7 @@
Scraper
=======
[![Build Status](https://ci.gitnet.fr/buildStatus/icon?job=Gitnet%2Fscraper%2Fmaster)](https://ci.gitnet.fr/job/Gitnet/job/scraper/job/master/)
[![Build Status](https://ci.gitnet.fr/api/badges/deblan/scraper/status.svg)](https://ci.gitnet.fr/deblan/scraper)
This project is a basic tool to scrap a data from a website
using a CSS selector.

2921
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -4,16 +4,16 @@
"version": "1.3.0",
"main": "src/index.js",
"devDependencies": {
"mocha": "^8.1.3"
"mocha": "^10.2.0"
},
"dependencies": {
"cheerio": "^1.0.0-rc.3",
"extends-classes": "^1.0.5",
"minimist": "^1.2.5",
"request": "^2.88.2",
"request-promise": "^4.2.5",
"request-promise": "^4.2.6",
"striptags": "^3.1.1",
"trim": "^0.0.1"
"trim": "^1.0.1"
},
"scripts": {
"test": "mocha"

View file

@ -3,56 +3,56 @@
var Minimist = require('minimist');
class Input {
/**
* Constructor.
*
* @param object process
*/
constructor(process) {
this.args = Minimist(process.argv.slice(2))
this.node = process.argv[0]
this.script = process.argv[1]
/**
* Constructor.
*
* @param object process
*/
constructor(process) {
this.args = Minimist(process.argv.slice(2))
this.node = process.argv[0]
this.script = process.argv[1]
}
/**
* Return the value of the given name argument.
*
* @param string name
* @param mixed default
*
* @return mixed
*/
get(name, defaultValue) {
if (this.has(name)) {
return this.args[name]
}
/**
* Return the value of the given name argument.
*
* @param string name
* @param mixed default
*
* @return mixed
*/
get(name, defaultValue) {
if (this.has(name)) {
return this.args[name]
}
if (defaultValue !== undefined) {
return defaultValue
}
return null;
if (defaultValue !== undefined) {
return defaultValue
}
/**
* Check the given argument name exists.
*
* @param string name
*
* @return boolean
*/
has(name) {
return this.args.hasOwnProperty(name)
}
return null;
}
/**
* Return if args is empty.
*
* @return boolean
*/
empty() {
return Object.keys(this.args).length === 1
}
/**
* Check the given argument name exists.
*
* @param string name
*
* @return boolean
*/
has(name) {
return this.args.hasOwnProperty(name)
}
/**
* Return if args is empty.
*
* @return boolean
*/
empty() {
return Object.keys(this.args).length === 1
}
}
module.exports = Input

View file

@ -1,37 +1,37 @@
"use strict";
class Output {
/**
* Convert and print data to json.
*
* @param mixed data
*/
json(data, pretty) {
data = JSON.stringify(
data,
function(key, value) {
if (value === undefined) {
return null
}
/**
* Convert and print data to json.
*
* @param mixed data
*/
json(data, pretty) {
data = JSON.stringify(
data,
function(key, value) {
if (value === undefined) {
return null
}
return value
},
pretty ? 2 : null
);
return value
},
pretty ? 2 : null
);
return this.write(data)
}
return this.write(data)
}
/**
* Print data.
*
* @param mixed data
*/
write(data, level) {
level = level || 'log'
/**
* Print data.
*
* @param mixed data
*/
write(data, level) {
level = level || 'log'
console[level](data)
}
console[level](data)
}
}
module.exports = Output

View file

@ -1,5 +1,5 @@
const filter = function(value) {
return value.replace(/(\n|\r)/g, '')
return value.replace(/(\n|\r)/g, '')
}
module.exports = filter

View file

@ -1,5 +1,5 @@
const filter = function(value) {
return value.replace(/\s{2,}/g, ' ')
return value.replace(/\s{2,}/g, ' ')
}
module.exports = filter

View file

@ -1,7 +1,7 @@
const striptags = require('striptags')
const filter = function(value, tags) {
return striptags(value, tags)
return striptags(value, tags)
}
module.exports = filter

View file

@ -1,7 +1,7 @@
const trim = require('trim')
const filter = function(value) {
return trim(value)
return trim(value)
}
module.exports = filter

View file

@ -2,19 +2,19 @@ const filter = require('../src/filter/breaks')
const assert = require('assert')
describe('Check "breaks"', () => {
it('Should return empty string', () => {
assert.equal(filter("\n"), "")
})
it('Should return empty string', () => {
assert.equal(filter("\n"), "")
})
it('Should return empty string', () => {
assert.equal(filter("\r"), "")
})
it('Should return empty string', () => {
assert.equal(filter("\r"), "")
})
it('Should return "foo"', () => {
assert.equal(filter("foo"), "foo")
})
it('Should return "foo"', () => {
assert.equal(filter("foo"), "foo")
})
it('Should return "foobar"', () => {
assert.equal(filter("\r\nfoo\nbar\r\n"), "foobar")
})
it('Should return "foobar"', () => {
assert.equal(filter("\r\nfoo\nbar\r\n"), "foobar")
})
});

View file

@ -2,15 +2,15 @@ const filter = require('../src/filter/spaces')
const assert = require('assert')
describe('Check "spaces"', () => {
it('Should return ""', () => {
assert.equal(filter(""), "")
})
it('Should return ""', () => {
assert.equal(filter(""), "")
})
it('Should return "foo bar"', () => {
assert.equal(filter("foo bar"), "foo bar")
})
it('Should return "foo bar"', () => {
assert.equal(filter("foo bar"), "foo bar")
})
it('Should return "foo bar"', () => {
assert.equal(filter("foo \nbar"), "foo bar")
})
it('Should return "foo bar"', () => {
assert.equal(filter("foo \nbar"), "foo bar")
})
});

View file

@ -2,19 +2,19 @@ const filter = require('../src/filter/trim')
const assert = require('assert')
describe('Check "trim"', () => {
it('Should return ""', () => {
assert.equal(filter(""), "")
})
it('Should return ""', () => {
assert.equal(filter(""), "")
})
it('Should return ""', () => {
assert.equal(filter(" "), "")
})
it('Should return ""', () => {
assert.equal(filter(" "), "")
})
it('Should return "foo"', () => {
assert.equal(filter(" foo "), "foo")
})
it('Should return "foo"', () => {
assert.equal(filter(" foo "), "foo")
})
it('Should return "foo bar"', () => {
assert.equal(filter(" foo bar \n"), "foo bar")
})
it('Should return "foo bar"', () => {
assert.equal(filter(" foo bar \n"), "foo bar")
})
});

1160
yarn.lock

File diff suppressed because it is too large Load diff