yasuri 3.3.0 → 3.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,77 +1,68 @@
1
1
 
2
- # Author:: TAC (tac@tac42.net)
3
2
 
4
3
  require_relative 'spec_helper'
5
4
 
6
- ########
7
- # Text #
8
- ########
9
5
  describe 'Yasuri' do
10
6
  include_context 'httpserver'
11
7
 
12
- before do
13
- @uri = uri
14
- end
15
-
16
8
  describe '::TextNode' do
17
- before { @node = Yasuri::TextNode.new('/html/body/p[1]', "title") }
18
-
19
9
  it 'scrape text text <p>Hello,Yasuri</p>' do
20
- actual = @node.scrape(@uri)
10
+ node = Yasuri::TextNode.new('/html/body/p[1]', "title")
11
+ actual = node.scrape(uri)
21
12
  expect(actual).to eq "Hello,Yasuri"
22
13
  end
23
14
 
24
15
  it 'return empty text if no match node' do
25
16
  no_match_node = Yasuri::TextNode.new('/html/body/no_match_node', "title")
26
- actual = no_match_node.scrape(@uri)
17
+ actual = no_match_node.scrape(uri)
27
18
  expect(actual).to be_empty
28
19
  end
29
20
 
30
21
  it 'fail with invalid xpath' do
31
22
  invalid_xpath = '/html/body/no_match_node['
32
23
  node = Yasuri::TextNode.new(invalid_xpath, "title")
33
- expect { node.scrape(@uri) }.to raise_error(Nokogiri::XML::XPath::SyntaxError)
24
+ expect { node.scrape(uri) }.to raise_error(Nokogiri::XML::XPath::SyntaxError)
34
25
  end
35
26
 
36
27
  it "can be defined by DSL, return single TextNode title" do
37
28
  generated = Yasuri.text_title '/html/body/p[1]'
38
- original = Yasuri::TextNode.new('/html/body/p[1]', "title")
39
- compare_generated_vs_original(generated, original, @uri)
29
+ original = Yasuri::TextNode.new('/html/body/p[1]', "title")
30
+ compare_generated_vs_original(generated, original, uri)
40
31
  end
41
32
 
42
- it "can be truncated with regexp" do
43
- node = Yasuri.text_title '/html/body/p[1]', truncate:/^[^,]+/
44
- actual = node.scrape(@uri)
33
+ it "can truncate head by regexp" do
34
+ node = Yasuri.text_title '/html/body/p[1]', truncate: /^[^,]+/
35
+ actual = node.scrape(uri)
45
36
  expect(actual).to eq "Hello"
46
37
  end
47
38
 
48
- it "return first captured if matched given capture pattern" do
49
- node = Yasuri.text_title '/html/body/p[1]', truncate:/H(.+)i/
50
- actual = node.scrape(@uri)
51
- expect(actual).to eq "ello,Yasur"
39
+ it "can truncate tail by regexp" do
40
+ node = Yasuri.text_title '/html/body/p[1]', truncate: /[^,]+$/
41
+ actual = node.scrape(uri)
42
+ expect(actual).to eq "Yasuri"
52
43
  end
53
44
 
54
- it "can be truncated with regexp" do
55
- node = Yasuri.text_title '/html/body/p[1]', truncate:/[^,]+$/
56
- actual = node.scrape(@uri)
57
- expect(actual).to eq "Yasuri"
45
+ it "return first captured if matched given capture pattern" do
46
+ node = Yasuri.text_title '/html/body/p[1]', truncate: /H(.+)i/
47
+ actual = node.scrape(uri)
48
+ expect(actual).to eq "ello,Yasur"
58
49
  end
59
50
 
60
51
  it "return empty string if truncated with no match to regexp" do
61
- node = Yasuri.text_title '/html/body/p[1]', truncate:/^hoge/
62
- actual = node.scrape(@uri)
52
+ node = Yasuri.text_title '/html/body/p[1]', truncate: /^hoge/
53
+ actual = node.scrape(uri)
63
54
  expect(actual).to be_empty
64
55
  end
65
56
 
66
57
  it "return symbol method applied string" do
67
58
  node = Yasuri.text_title '/html/body/p[1]', proc: :upcase
68
- actual = node.scrape(@uri)
59
+ actual = node.scrape(uri)
69
60
  expect(actual).to eq "HELLO,YASURI"
70
61
  end
71
62
 
72
63
  it "return apply multi arguments" do
73
- node = Yasuri.text_title '/html/body/p[1]', proc: :upcase, truncate:/H(.+)i/
74
- actual = node.scrape(@uri)
64
+ node = Yasuri.text_title '/html/body/p[1]', proc: :upcase, truncate: /H(.+)i/
65
+ actual = node.scrape(uri)
75
66
  expect(actual).to eq "ELLO,YASUR"
76
67
  end
77
68
  end
data/yasuri.gemspec CHANGED
@@ -1,33 +1,38 @@
1
- # coding: utf-8
1
+
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'yasuri/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "yasuri"
8
- spec.version = Yasuri::VERSION
9
- spec.authors = ["TAC"]
10
- spec.email = ["tac@tac42.net"]
11
- spec.summary = %q{Yasuri is easy scraping library.}
12
- spec.description = %q{Yasuri is an easy web-scraping library for supporting "Mechanize".}
13
- spec.homepage = "https://github.com/tac0x2a/yasuri"
14
- spec.license = "MIT"
7
+ spec.name = 'yasuri'
8
+ spec.version = Yasuri::VERSION
9
+ spec.authors = ['TAC']
10
+ spec.email = ['tac@tac42.net']
11
+ spec.summary = %q{Yasuri is easy scraping library.}
12
+ spec.description = %q{Yasuri is an easy web-scraping library for supporting 'Mechanize'.}
13
+ spec.homepage = 'https://github.com/tac0x2a/yasuri'
14
+ spec.license = 'MIT'
15
15
 
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
- spec.bindir = "exe"
19
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
- spec.require_paths = ["lib"]
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.bindir = 'exe'
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ['lib']
21
+ spec.required_ruby_version = '>= 2.7.0'
21
22
 
22
- spec.add_development_dependency "bundler"
23
- spec.add_development_dependency "rake"
24
- spec.add_development_dependency "rspec"
25
- spec.add_development_dependency "fuubar"
26
- spec.add_development_dependency "glint"
27
- spec.add_development_dependency "coveralls"
28
- spec.add_development_dependency "simplecov"
29
- spec.add_development_dependency "codeclimate-test-reporter"
23
+ spec.add_development_dependency 'bundler'
24
+ spec.add_development_dependency 'codeclimate-test-reporter'
25
+ spec.add_development_dependency 'coveralls'
26
+ spec.add_development_dependency 'fuubar'
27
+ spec.add_development_dependency 'glint'
28
+ spec.add_development_dependency 'rake'
29
+ spec.add_development_dependency 'rspec'
30
+ spec.add_development_dependency 'rubocop'
31
+ spec.add_development_dependency 'rubocop-performance'
32
+ spec.add_development_dependency 'rubocop-rspec'
33
+ spec.add_development_dependency 'rubocop-rubycw'
34
+ spec.add_development_dependency 'simplecov'
30
35
 
31
- spec.add_dependency "mechanize"
32
- spec.add_dependency "thor"
36
+ spec.add_dependency 'mechanize'
37
+ spec.add_dependency 'thor'
33
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yasuri
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - TAC
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-27 00:00:00.000000000 Z
11
+ date: 2021-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: codeclimate-test-reporter
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
42
+ name: coveralls
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: coveralls
84
+ name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: simplecov
98
+ name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,7 +109,63 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: codeclimate-test-reporter
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-performance
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop-rubycw
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: simplecov
113
169
  requirement: !ruby/object:Gem::Requirement
114
170
  requirements:
115
171
  - - ">="
@@ -150,7 +206,7 @@ dependencies:
150
206
  - - ">="
151
207
  - !ruby/object:Gem::Version
152
208
  version: '0'
153
- description: Yasuri is an easy web-scraping library for supporting "Mechanize".
209
+ description: Yasuri is an easy web-scraping library for supporting 'Mechanize'.
154
210
  email:
155
211
  - tac@tac42.net
156
212
  executables:
@@ -162,6 +218,8 @@ files:
162
218
  - ".github/workflows/ruby.yml"
163
219
  - ".gitignore"
164
220
  - ".rspec"
221
+ - ".rubocop.yml"
222
+ - ".rubocop_todo.yml"
165
223
  - ".ruby-version"
166
224
  - ".travis.yml"
167
225
  - Gemfile
@@ -208,7 +266,6 @@ files:
208
266
  - spec/yasuri_cli_spec.rb
209
267
  - spec/yasuri_links_node_spec.rb
210
268
  - spec/yasuri_map_spec.rb
211
- - spec/yasuri_node_spec.rb
212
269
  - spec/yasuri_paginate_node_spec.rb
213
270
  - spec/yasuri_spec.rb
214
271
  - spec/yasuri_struct_node_spec.rb
@@ -226,7 +283,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
226
283
  requirements:
227
284
  - - ">="
228
285
  - !ruby/object:Gem::Version
229
- version: '0'
286
+ version: 2.7.0
230
287
  required_rubygems_version: !ruby/object:Gem::Requirement
231
288
  requirements:
232
289
  - - ">="
@@ -260,7 +317,6 @@ test_files:
260
317
  - spec/yasuri_cli_spec.rb
261
318
  - spec/yasuri_links_node_spec.rb
262
319
  - spec/yasuri_map_spec.rb
263
- - spec/yasuri_node_spec.rb
264
320
  - spec/yasuri_paginate_node_spec.rb
265
321
  - spec/yasuri_spec.rb
266
322
  - spec/yasuri_struct_node_spec.rb
@@ -1,11 +0,0 @@
1
-
2
- # Author:: TAC (tac@tac42.net)
3
-
4
- require_relative 'spec_helper'
5
-
6
- ########
7
- # Node #
8
- ########
9
- describe 'Yasuri' do
10
-
11
- end