notu 2.0.6 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17025b3f45128e34a4b3783aaed736bd82db492214095ef237a2df2a7b5d91b4
4
- data.tar.gz: fd8df3818f39aa8e9ef55fe574282101b180c978588139d68340bc9cf2b76ee7
3
+ metadata.gz: 1e13444a530e59b3049d159ff447ba19c9525be2a861563e47dbe2fed586d728
4
+ data.tar.gz: b982c666ad9eac6e8fe23be668f7e3270fe528c0f1511fb0db63ebb46ddd0028
5
5
  SHA512:
6
- metadata.gz: dd7ce60b42983046ce151511ef094697e329f14bea4000f60f3a54f73b257755102eb93ac7bbb3ae411d69bdbb7f5add631ea7b8e1dcc0cee98d94f3edad2018
7
- data.tar.gz: 99e08c70c0dec86e1969ddc6e8a4d144894d0ebf1185e957f870ba2b3b2fdf9712605e787fe05c6021b86ee760037b750f22074a6538764e078e80d9028aa751
6
+ metadata.gz: 1864ecdf4fdccd1629f11c6f789bb354736512c026a55825544087474e4ef0b4c5e73aae863efbed1c8a9cfd84bb06cf9538388068049ed324d36ed4f753c834
7
+ data.tar.gz: 6c3f3c4041d49547898cad9ef090e2d54711cac2b304ad9e30d829917709302ab6b09aef9272fa4662a6edf7615189d88aca0cc4470bf5f10dd7d394a80e4f17
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.6
1
+ 3.0.0
@@ -9,7 +9,7 @@ module Notu
9
9
  def self.parse(data)
10
10
  data = data.gsub(/ /i, ' ').gsub(/\s+/, ' ')
11
11
  document = Nokogiri::HTML.parse(data, nil, 'UTF-8')
12
- raise ParseError.new('Invalid HTML document') if (document/'head').empty?
12
+ raise ParseError.new('Invalid HTML document') if (document / 'head').empty?
13
13
  document
14
14
  end
15
15
  private_class_method :parse
@@ -26,13 +26,13 @@ module Notu
26
26
  return response.body
27
27
  end
28
28
  end
29
- rescue Net::ReadTimeout, Timeout::Error, Timeout::Error, Zlib::BufError => exception
30
- raise NetworkError.new(exception) if options[:max_retries] < 1
29
+ rescue Timeout::Error, Zlib::BufError => e
30
+ raise NetworkError.new(e) if options[:max_retries] < 1
31
31
  options[:max_retries] -= 1
32
32
  sleep(options[:retry_sleep])
33
33
  get(url, options)
34
- rescue => exception
35
- raise NetworkError.new(exception)
34
+ rescue => e
35
+ raise NetworkError.new(e)
36
36
  end
37
37
 
38
38
  end
data/lib/notu/listing.rb CHANGED
@@ -13,13 +13,13 @@ module Notu
13
13
 
14
14
  def page_urls
15
15
  (1..pages_count).map do |index|
16
- library.url(path: path, query: params.merge('page' => index))
16
+ library.url(path:, query: params.merge('page' => index))
17
17
  end
18
18
  end
19
19
 
20
20
  def pages_count
21
- document = HtmlDocument.get(library.url(path: path, query: params))
22
- [1, (document/'ul.pagination-list li.pagination-page').text.split(/\s+/).map(&:to_i)].flatten.compact.max
21
+ document = HtmlDocument.get(library.url(path:, query: params))
22
+ [1, (document / 'ul.pagination-list li.pagination-page').text.split(/\s+/).map(&:to_i)].flatten.compact.max
23
23
  end
24
24
 
25
25
  def params
@@ -4,14 +4,14 @@ module Notu
4
4
 
5
5
  include Listing
6
6
 
7
- def each(&block)
7
+ def each
8
8
  return unless block_given?
9
9
  page_urls.each do |url|
10
10
  document = HtmlDocument.get(url)
11
- (document/'table.chartlist tbody tr').each do |element|
12
- artist = (element/'td.chartlist-artist a').first.try(:text) || next
13
- title = (element/'td.chartlist-name a').first.try(:text) || next
14
- yield(Track.new(artist: artist, title: title))
11
+ (document / 'table.chartlist tbody tr').each do |element|
12
+ artist = (element / 'td.chartlist-artist a').first.try(:text) || next
13
+ title = (element / 'td.chartlist-name a').first.try(:text) || next
14
+ yield(Track.new(artist:, title:))
15
15
  end
16
16
  end
17
17
  nil
@@ -10,7 +10,7 @@ module Notu
10
10
  '90 days' => 'LAST_90_DAYS',
11
11
  '365 days' => 'LAST_365_DAYS',
12
12
  'Overall' => '',
13
- }
13
+ }.freeze
14
14
 
15
15
  attr_reader :period
16
16
 
@@ -20,15 +20,15 @@ module Notu
20
20
  self.period = options['period']
21
21
  end
22
22
 
23
- def each(&block)
23
+ def each
24
24
  return unless block_given?
25
25
  page_urls.each do |url|
26
26
  document = HtmlDocument.get(url)
27
- (document/'table.chartlist tbody tr').each do |element|
28
- artist = (element/'td.chartlist-artist a').first.try(:text) || next
29
- title = (element/'td.chartlist-name a').first.try(:text) || next
30
- plays_count = (element/'td.chartlist-bar .chartlist-count-bar-value').text.gsub(/[^\d]/, '').presence || next
31
- yield(Track.new(artist: artist, plays_count: plays_count, title: title))
27
+ (document / 'table.chartlist tbody tr').each do |element|
28
+ artist = (element / 'td.chartlist-artist a').first.try(:text) || next
29
+ title = (element / 'td.chartlist-name a').first.try(:text) || next
30
+ plays_count = (element / 'td.chartlist-bar .chartlist-count-bar-value').text.gsub(/[^\d]/, '').presence || next
31
+ yield(Track.new(artist:, plays_count:, title:))
32
32
  end
33
33
  end
34
34
  nil
@@ -4,14 +4,14 @@ module Notu
4
4
 
5
5
  include Listing
6
6
 
7
- def each(&block)
7
+ def each
8
8
  return unless block_given?
9
9
  page_urls.each do |url|
10
10
  document = HtmlDocument.get(url)
11
- (document/'table.chartlist tbody tr').each do |element|
12
- artist = (element/'td.chartlist-artist a').first.try(:text) || next
13
- title = (element/'td.chartlist-name a').first.try(:text) || next
14
- yield(Track.new(artist: artist, title: title))
11
+ (document / 'table.chartlist tbody tr').each do |element|
12
+ artist = (element / 'td.chartlist-artist a').first.try(:text) || next
13
+ title = (element / 'td.chartlist-name a').first.try(:text) || next
14
+ yield(Track.new(artist:, title:))
15
15
  end
16
16
  end
17
17
  nil
data/notu.gemspec CHANGED
@@ -9,18 +9,21 @@ Gem::Specification.new do |s|
9
9
  s.description = 'API to get Last.fm tracks (most played, loved, etc.)'
10
10
  s.license = 'MIT'
11
11
 
12
- s.files = `git ls-files | grep -vE '^(spec/|test/|\\.|Gemfile|Rakefile)'`.split("\n")
13
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ s.files = %x(git ls-files | grep -vE '^(spec/|test/|\\.|Gemfile|Rakefile)').split("\n")
13
+ s.executables = %x(git ls-files -- bin/*).split("\n").map { |f| File.basename(f) }
14
14
  s.require_paths = ['lib']
15
15
 
16
- s.required_ruby_version = '>= 2.0.0'
16
+ s.required_ruby_version = '>= 3.1.0'
17
17
 
18
- s.add_dependency 'activesupport', '>= 4.1.0', '< 7.0.0'
19
- s.add_dependency 'nokogiri', '>= 1.6.0', '< 1.12.0'
18
+ s.add_dependency 'activesupport', '>= 7.0.0', '< 8.0.0'
19
+ s.add_dependency 'nokogiri', '>= 1.6.0', '< 1.14.0'
20
20
 
21
21
  s.add_development_dependency 'byebug', '>= 3.2.0', '< 12.0.0'
22
22
  s.add_development_dependency 'rake', '>= 10.3.0', '< 14.0.0'
23
23
  s.add_development_dependency 'rspec', '>= 3.1.0', '< 4.0.0'
24
+ s.add_development_dependency 'rubocop', '>= 1.25.0', '< 2.0.0'
25
+ s.add_development_dependency 'rubocop-rake', '>= 0.6.0', '< 1.0.0'
26
+ s.add_development_dependency 'rubocop-rspec', '>= 2.8.0', '< 3.0.0'
24
27
  s.add_development_dependency 'vcr', '>= 4.0.0', '< 7.0.0'
25
28
  s.add_development_dependency 'webmock', '>= 3.0.0', '< 4.0.0'
26
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notu
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis Toulotte
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-15 00:00:00.000000000 Z
11
+ date: 2022-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.1.0
19
+ version: 7.0.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 7.0.0
22
+ version: 8.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 4.1.0
29
+ version: 7.0.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 7.0.0
32
+ version: 8.0.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: nokogiri
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: 1.6.0
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: 1.12.0
42
+ version: 1.14.0
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: 1.6.0
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: 1.12.0
52
+ version: 1.14.0
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: byebug
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -110,6 +110,66 @@ dependencies:
110
110
  - - "<"
111
111
  - !ruby/object:Gem::Version
112
112
  version: 4.0.0
113
+ - !ruby/object:Gem::Dependency
114
+ name: rubocop
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: 1.25.0
120
+ - - "<"
121
+ - !ruby/object:Gem::Version
122
+ version: 2.0.0
123
+ type: :development
124
+ prerelease: false
125
+ version_requirements: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: 1.25.0
130
+ - - "<"
131
+ - !ruby/object:Gem::Version
132
+ version: 2.0.0
133
+ - !ruby/object:Gem::Dependency
134
+ name: rubocop-rake
135
+ requirement: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: 0.6.0
140
+ - - "<"
141
+ - !ruby/object:Gem::Version
142
+ version: 1.0.0
143
+ type: :development
144
+ prerelease: false
145
+ version_requirements: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: 0.6.0
150
+ - - "<"
151
+ - !ruby/object:Gem::Version
152
+ version: 1.0.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop-rspec
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: 2.8.0
160
+ - - "<"
161
+ - !ruby/object:Gem::Version
162
+ version: 3.0.0
163
+ type: :development
164
+ prerelease: false
165
+ version_requirements: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: 2.8.0
170
+ - - "<"
171
+ - !ruby/object:Gem::Version
172
+ version: 3.0.0
113
173
  - !ruby/object:Gem::Dependency
114
174
  name: vcr
115
175
  requirement: !ruby/object:Gem::Requirement
@@ -185,14 +245,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
245
  requirements:
186
246
  - - ">="
187
247
  - !ruby/object:Gem::Version
188
- version: 2.0.0
248
+ version: 3.1.0
189
249
  required_rubygems_version: !ruby/object:Gem::Requirement
190
250
  requirements:
191
251
  - - ">="
192
252
  - !ruby/object:Gem::Version
193
253
  version: '0'
194
254
  requirements: []
195
- rubygems_version: 3.2.15
255
+ rubygems_version: 3.3.3
196
256
  signing_key:
197
257
  specification_version: 4
198
258
  summary: API for Last.fm