dutch_top40 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e967e911197a4f3808c7fedc49e0a0f92d0271a527dec75bdea645c28da01a7c
4
- data.tar.gz: 22014cfa9241afb49854d2ad445f7d1fef29fba9a0fb72595bf0753a8abf1b7b
3
+ metadata.gz: cac142781191f70c98ade529228eb77889f100e01d56a921b77235e074fdb58e
4
+ data.tar.gz: c421ad5174499a51e8ae83bf76ecda996a0bff229a1af0b5a1b83e524ed56de4
5
5
  SHA512:
6
- metadata.gz: fab741620804eade95d2772a4ad208da5cf32c15f897f325df9f373f510380eebcbdeebf11a2627d1fac03798614e3e08eff763e9e8a8e82629df45b51cb9547
7
- data.tar.gz: 636e2d5be57eaeaa73b81c93a04c00371ec267900a88182da752d4ef3acbe1bc0e6e72a39ed39a0530158a73b70782cd2b8c80fd587ed059de07ed471c861854
6
+ metadata.gz: ee146cc1375899512f759fdf27c25447fd3ba938b48627efd29e95629f85c619d0984ed2e972074f3cb2466e35a4a779d0299f852711369a16ff2a2e8db5ad55
7
+ data.tar.gz: 7d2db0fbeef8fdf06e3cbbbbf76b962969367af7a017cc006ba3bee3e61ab2b50b84e1d0ce2e93955a8c01f2179c9b6746828d4d9ae85478e8898082cf9d7671
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dutch_top40 (0.1.2)
4
+ dutch_top40 (0.1.3)
5
5
  nokogiri
6
6
 
7
7
  GEM
data/lib/dutch_top40.rb CHANGED
@@ -5,4 +5,4 @@ require 'pry'
5
5
 
6
6
  require_relative './dutch_top40/cli'
7
7
  require_relative './dutch_top40/songs'
8
-
8
+ require_relative './dutch_top40/scraper'
@@ -5,7 +5,6 @@ class DutchTop40::CLI
5
5
  puts "Dutch Top40 - week #{Time.now.strftime("%U")}", ""
6
6
  puts "One moment, acquiring data."
7
7
  list_songs
8
- sleep(5)
9
8
  menu
10
9
  end
11
10
 
@@ -30,7 +29,7 @@ class DutchTop40::CLI
30
29
  when 1..@songs.size
31
30
  puts "Current rank #{input}."
32
31
  puts "#{@songs[input.to_i-1].title} - performing artist(s): #{@songs[input.to_i-1].name}"
33
- puts "weeks listed: #{@songs[input.to_i-1].listed} - last weeks rank #{@songs[input.to_i-1].last_weeks_rank}",""
32
+ puts "weeks in Top40: #{@songs[input.to_i-1].listed} - last weeks rank: #{@songs[input.to_i-1].last_weeks_rank}",""
34
33
  else
35
34
  puts "Invalid input!" unless input == 'exit' || input == 'list'
36
35
  if input == 'list'
@@ -0,0 +1,19 @@
1
+ class DutchTop40::Scraper
2
+
3
+ attr_accessor :title, :name, :listed, :last_weeks_rank
4
+
5
+ def self.scrape_songs
6
+ doc = Nokogiri::HTML(open("http://top40.nl"))
7
+ doc.search('.listScroller').search('.top40List').each do |song|
8
+ title = song.search('.songtitle').text.strip
9
+ name = song.search('.artist').text
10
+ listed = song.search('.details').text.split(' | ')[1].gsub(/Aantal weken: /,'').strip
11
+ if song.search('.details').text.split(' | ')[0].gsub(/Vorige week: #/,'').strip == '-'
12
+ last_weeks_rank = 'new entry'
13
+ else
14
+ last_weeks_rank = song.search('.details').text.split(' | ')[0].gsub(/Vorige week: #/,'').strip
15
+ end
16
+ DutchTop40::Songs.new(title, name, listed, last_weeks_rank)
17
+ end
18
+ end
19
+ end
@@ -14,18 +14,7 @@ class DutchTop40::Songs
14
14
 
15
15
 
16
16
  def self.list
17
- self.scrape_songs
18
- end
19
-
20
- def self.scrape_songs
21
- doc = Nokogiri::HTML(open("http://top40.nl"))
22
- doc.search('.listScroller').search('.top40List').each do |song|
23
- title = song.search('.songtitle').text.strip
24
- name = song.search('.artist').text
25
- listed = song.search('.details').text.split(' | ')[1].gsub(/Aantal weken: /,'').strip
26
- last_weeks_rank = song.search('.details').text.split(' | ')[0].gsub(/Vorige week: #/,'').strip
27
- self.new(title, name, listed, last_weeks_rank)
28
- end
17
+ DutchTop40::Scraper.scrape_songs
29
18
  @@songs
30
19
  end
31
20
 
@@ -1,3 +1,3 @@
1
1
  module DutchTop40
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dutch_top40
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - raspimeteo
@@ -61,6 +61,7 @@ files:
61
61
  - dutch_top40.gemspec
62
62
  - lib/dutch_top40.rb
63
63
  - lib/dutch_top40/cli.rb
64
+ - lib/dutch_top40/scraper.rb
64
65
  - lib/dutch_top40/songs.rb
65
66
  - lib/dutch_top40/version.rb
66
67
  homepage: https://github.com/raspimeteo/dutch_top40