docparser 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +15 -3
  3. data/.rubocop_todo.yml +45 -0
  4. data/.travis.yml +1 -1
  5. data/Gemfile +5 -4
  6. data/README.md +2 -2
  7. data/Rakefile +3 -1
  8. data/docparser.gemspec +9 -9
  9. data/example.rb +2 -0
  10. data/lib/docparser.rb +2 -0
  11. data/lib/docparser/document.rb +20 -10
  12. data/lib/docparser/output.rb +9 -6
  13. data/lib/docparser/output/csv_output.rb +2 -0
  14. data/lib/docparser/output/html_output.rb +52 -49
  15. data/lib/docparser/output/json_output.rb +3 -1
  16. data/lib/docparser/output/multi_output.rb +3 -1
  17. data/lib/docparser/output/nil_output.rb +5 -6
  18. data/lib/docparser/output/xlsx_output.rb +2 -0
  19. data/lib/docparser/output/yaml_output.rb +4 -1
  20. data/lib/docparser/parser.rb +9 -13
  21. data/lib/docparser/version.rb +3 -1
  22. data/test/.rubocop.yml +6 -2
  23. data/test/.rubocop_todo.yml +23 -0
  24. data/test/lib/docparser/blackbox_test.rb +5 -4
  25. data/test/lib/docparser/document_test.rb +19 -14
  26. data/test/lib/docparser/output/csv_output_test.rb +5 -10
  27. data/test/lib/docparser/output/html_output_test.rb +5 -10
  28. data/test/lib/docparser/output/json_output_test.rb +8 -13
  29. data/test/lib/docparser/output/multi_output_test.rb +6 -12
  30. data/test/lib/docparser/output/nil_output_test.rb +4 -9
  31. data/test/lib/docparser/output/xlsx_output_test.rb +5 -10
  32. data/test/lib/docparser/output/yaml_output_test.rb +22 -27
  33. data/test/lib/docparser/output_test.rb +3 -8
  34. data/test/lib/docparser/parser_test.rb +2 -22
  35. data/test/lib/docparser/version_test.rb +2 -0
  36. data/test/support/hackaday/dl.rb +2 -0
  37. data/test/test_helper.rb +2 -3
  38. metadata +20 -35
  39. data/test/lib/docparser/logging_test.rb +0 -19
@@ -1,13 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../../../test_helper'
2
4
 
3
5
  describe DocParser::XLSXOutput do
4
- before do
5
- Log4r::Logger['docparser'].level = Log4r::ERROR
6
- end
7
- after do
8
- Log4r::Logger['docparser'].level = Log4r::INFO
9
- end
10
-
11
6
  it 'must create a file' do
12
7
  Dir.mktmpdir do |dir|
13
8
  filename = File.join(dir, 'test.xlsx')
@@ -31,7 +26,7 @@ describe DocParser::XLSXOutput do
31
26
  Dir.mktmpdir do |dir|
32
27
  filename = File.join(dir, 'test.xlsx')
33
28
  output = DocParser::XLSXOutput.new(filename: filename)
34
- output.add_row %w(aap noot mies)
29
+ output.add_row %w[aap noot mies]
35
30
  output.add_row ['aap', 'noot', 'mies;']
36
31
  output.close
37
32
  sheet = output.instance_variable_get(:@sheet)
@@ -45,8 +40,8 @@ describe DocParser::XLSXOutput do
45
40
  output = DocParser::XLSXOutput.new(filename: filename)
46
41
  output.header = 'test', 'the', 'header'
47
42
  output.rowcount.must_equal 0
48
- output.add_row %w(aap noot mies)
49
- output.add_row %w(aap noot mies)
43
+ output.add_row %w[aap noot mies]
44
+ output.add_row %w[aap noot mies]
50
45
  output.rowcount.must_equal 2
51
46
  end
52
47
  end
@@ -1,13 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../../../test_helper'
2
4
 
3
5
  describe DocParser::YAMLOutput do
4
- before do
5
- Log4r::Logger['docparser'].level = Log4r::ERROR
6
- end
7
- after do
8
- Log4r::Logger['docparser'].level = Log4r::INFO
9
- end
10
-
11
6
  it 'must create a file' do
12
7
  Dir.mktmpdir do |dir|
13
8
  filename = File.join(dir, 'test.yml')
@@ -31,7 +26,7 @@ describe DocParser::YAMLOutput do
31
26
  filename = File.join(dir, 'test.yml')
32
27
  output = DocParser::YAMLOutput.new(filename: filename)
33
28
  lambda do
34
- output.add_row %w(aap noot mies)
29
+ output.add_row %w[aap noot mies]
35
30
  end.must_raise(DocParser::MissingHeaderException)
36
31
  end
37
32
  end
@@ -41,24 +36,24 @@ describe DocParser::YAMLOutput do
41
36
  filename = File.join(dir, 'test.csv')
42
37
  output = DocParser::YAMLOutput.new(filename: filename)
43
38
  output.header = 'test', 'the', 'header'
44
- output.add_row %w(a b c)
45
- output.add_row %w(aap noot mies")
46
- output.add_row %w(aap noot) # testing empty column
39
+ output.add_row %w[a b c]
40
+ output.add_row %w[aap noot mies"]
41
+ output.add_row %w[aap noot] # testing empty column
47
42
  output.close
48
- open(filename).read.must_equal <<-YAMLEND
49
- ---
50
- test: a
51
- the: b
52
- header: c
53
- ---
54
- test: aap
55
- the: noot
56
- header: mies\"
57
- ---
58
- test: aap
59
- the: noot
60
- header: ''
61
- YAMLEND
43
+ open(filename).read.must_equal <<~YAMLEND
44
+ ---
45
+ test: a
46
+ the: b
47
+ header: c
48
+ ---
49
+ test: aap
50
+ the: noot
51
+ header: mies\"
52
+ ---
53
+ test: aap
54
+ the: noot
55
+ header: ''
56
+ YAMLEND
62
57
  end
63
58
  end
64
59
 
@@ -68,8 +63,8 @@ YAMLEND
68
63
  output = DocParser::YAMLOutput.new(filename: filename)
69
64
  output.header = 'test', 'the', 'header'
70
65
  output.rowcount.must_equal 0
71
- output.add_row %w(aap noot mies)
72
- output.add_row %w(aap noot mies)
66
+ output.add_row %w[aap noot mies]
67
+ output.add_row %w[aap noot mies]
73
68
  output.rowcount.must_equal 2
74
69
  end
75
70
  end
@@ -1,13 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../../test_helper'
2
4
 
3
5
  describe DocParser::Output do
4
- before do
5
- Log4r::Logger['docparser'].level = Log4r::ERROR
6
- end
7
- after do
8
- Log4r::Logger['docparser'].level = Log4r::INFO
9
- end
10
-
11
6
  it 'must create a file' do
12
7
  Dir.mktmpdir do |dir|
13
8
  filename = File.join(dir, 'test.csv')
@@ -32,7 +27,7 @@ describe DocParser::Output do
32
27
  output.header = 'test', 'the', 'header'
33
28
  end
34
29
  header = output.instance_variable_get(:@header)
35
- header.must_equal %w(test the header)
30
+ header.must_equal %w[test the header]
36
31
  $method_id.must_equal :header
37
32
  end
38
33
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../../test_helper'
2
4
  describe DocParser::Parser do
3
5
  before do
@@ -8,7 +10,6 @@ describe DocParser::Parser do
8
10
  SimpleCov.at_exit do
9
11
  SimpleCov.result.format!
10
12
  end
11
- Log4r::Logger['docparser'].level = Log4r::INFO
12
13
  end
13
14
 
14
15
  it 'should initialize correctly' do
@@ -16,27 +17,6 @@ describe DocParser::Parser do
16
17
  parser.must_be_instance_of DocParser::Parser
17
18
  end
18
19
 
19
- it 'should define a new logger' do
20
- DocParser::Parser.new(quiet: true)
21
- logger = Log4r::Logger['docparser::parser']
22
- logger.wont_be_nil
23
- logger.must_be_instance_of Log4r::Logger
24
- end
25
-
26
- it 'should set logger level depending on the quiet setting' do
27
- # rubocop : disable UselessAssignment
28
- parser = DocParser::Parser.new(quiet: true)
29
- logger = Log4r::Logger['docparser']
30
- old_output = logger.outputters.pop
31
- logger.level.must_equal Log4r::ERROR
32
- parser = DocParser::Parser.new(quiet: false)
33
- logger.level.must_equal Log4r::INFO
34
- parser = DocParser::Parser.new
35
- logger.level.must_equal Log4r::INFO
36
- logger.outputters.push old_output
37
- # rubocop : enable UselessAssignment
38
- end
39
-
40
20
  it 'should only process the files in range' do
41
21
  files = (0..20).map { |i| "file_#{i}" }
42
22
  parser = DocParser::Parser.new(quiet: true,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../../test_helper'
2
4
 
3
5
  describe DocParser do
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  (1..40).map do |i|
3
5
  system("wget -O file_#{i}.html http://hackaday.com/page/#{i}/")
4
6
  end
@@ -1,9 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'simplecov'
2
- require 'coveralls'
3
- Coveralls.wear!
4
4
  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
5
  SimpleCov::Formatter::HTMLFormatter,
6
- Coveralls::SimpleCov::Formatter
7
6
  ]
8
7
  SimpleCov.start do
9
8
  # add_filter '/test/'
metadata CHANGED
@@ -1,73 +1,59 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jurriaan Pruis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-15 00:00:00.000000000 Z
11
+ date: 2020-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: nokogiri
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 1.6.1
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 1.6.1
27
- - !ruby/object:Gem::Dependency
28
- name: parallel
14
+ name: axlsx
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - "~>"
32
18
  - !ruby/object:Gem::Version
33
- version: 1.3.2
19
+ version: 2.0.1
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: 1.3.2
26
+ version: 2.0.1
41
27
  - !ruby/object:Gem::Dependency
42
- name: axlsx
28
+ name: nokogiri
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: 2.0.1
33
+ version: 1.10.0
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: 2.0.1
40
+ version: 1.10.0
55
41
  - !ruby/object:Gem::Dependency
56
- name: log4r
42
+ name: parallel
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: 1.1.10
47
+ version: '1.10'
62
48
  type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: 1.1.10
54
+ version: '1.10'
69
55
  - !ruby/object:Gem::Dependency
70
- name: yard
56
+ name: github-markup
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - ">="
@@ -86,16 +72,16 @@ dependencies:
86
72
  requirements:
87
73
  - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: 1.4.1
75
+ version: 2.1.0
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: 1.4.1
82
+ version: 2.1.0
97
83
  - !ruby/object:Gem::Dependency
98
- name: github-markup
84
+ name: yard
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
87
  - - ">="
@@ -120,6 +106,7 @@ files:
120
106
  - ".coveralls.yml"
121
107
  - ".gitignore"
122
108
  - ".rubocop.yml"
109
+ - ".rubocop_todo.yml"
123
110
  - ".travis.yml"
124
111
  - ".yardops"
125
112
  - Gemfile
@@ -141,9 +128,9 @@ files:
141
128
  - lib/docparser/parser.rb
142
129
  - lib/docparser/version.rb
143
130
  - test/.rubocop.yml
131
+ - test/.rubocop_todo.yml
144
132
  - test/lib/docparser/blackbox_test.rb
145
133
  - test/lib/docparser/document_test.rb
146
- - test/lib/docparser/logging_test.rb
147
134
  - test/lib/docparser/output/csv_output_test.rb
148
135
  - test/lib/docparser/output/html_output_test.rb
149
136
  - test/lib/docparser/output/json_output_test.rb
@@ -212,23 +199,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
212
199
  requirements:
213
200
  - - ">="
214
201
  - !ruby/object:Gem::Version
215
- version: 2.0.0
202
+ version: '0'
216
203
  required_rubygems_version: !ruby/object:Gem::Requirement
217
204
  requirements:
218
205
  - - ">="
219
206
  - !ruby/object:Gem::Version
220
207
  version: '0'
221
208
  requirements: []
222
- rubyforge_project:
223
- rubygems_version: 2.2.2
209
+ rubygems_version: 3.1.2
224
210
  signing_key:
225
211
  specification_version: 4
226
212
  summary: DocParser is a Ruby Gem for webscraping
227
213
  test_files:
228
214
  - test/.rubocop.yml
215
+ - test/.rubocop_todo.yml
229
216
  - test/lib/docparser/blackbox_test.rb
230
217
  - test/lib/docparser/document_test.rb
231
- - test/lib/docparser/logging_test.rb
232
218
  - test/lib/docparser/output/csv_output_test.rb
233
219
  - test/lib/docparser/output/html_output_test.rb
234
220
  - test/lib/docparser/output/json_output_test.rb
@@ -285,4 +271,3 @@ test_files:
285
271
  - test/support/test_html.html
286
272
  - test/support/test_xml.xml
287
273
  - test/test_helper.rb
288
- has_rdoc:
@@ -1,19 +0,0 @@
1
- require_relative '../../test_helper'
2
-
3
- describe DocParser do
4
- it 'should have a valid logger' do
5
- logger = Log4r::Logger['docparser']
6
- logger.wont_be_nil
7
- logger.must_be_instance_of Log4r::Logger
8
- end
9
-
10
- it 'must have the correct loglevel by default' do
11
- Log4r::Logger['docparser'].level.must_equal Log4r::INFO
12
- end
13
-
14
- it 'should log to the correct output' do
15
- outputters = Log4r::Logger['docparser'].outputters
16
- outputters.length.must_equal 1
17
- outputters.first.must_be_instance_of Log4r::StdoutOutputter
18
- end
19
- end