dutch_top40 0.1.0 → 0.1.1

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: d7caabb20470d8653a1a6505b625ed1e6c41e14e640882d4529cc94d69f648b9
4
- data.tar.gz: c548fe86de7054fdd1edb2a0d545f72be1969f0dd483d1da7fa46293d56ce028
3
+ metadata.gz: 4b01291cceb6fb2ced22e223822b8746ac39cb16e13440fa6ca509c6b15d3ce1
4
+ data.tar.gz: 9373a3df2e58e1420386d05ae5b1a95b448f16db6104b18609ca456497af14f6
5
5
  SHA512:
6
- metadata.gz: 4e424407b679d7e9175b5cb7c81fd873779393f08d87b9776e233516010984d6430cf86eaf35cdfc59afd2b2ce9e25c3fb6b171b36db259d4eb8988d1892018f
7
- data.tar.gz: a530f64e4a9f7cf08690ea4c097a7b9d3f48d95e7f3440ff395d3002f385ec53373d0b846138e284f43660be619afc53fef411890e8e94d2d7327bdd28dd768c
6
+ metadata.gz: c87333635f044a5b02438fc3918344092bb8478816d97a77328e2c8f4d3833659538c8deb61d4315271b6651ea19d6a9fca23b4dca976f427bc2177634d5eb38
7
+ data.tar.gz: e6d7aad6762dd8958ca0fc7d57b1a0b06091046ce320ba8b03aea47815dccfbda00ca9c1c629b7fa79a093aff59e69a8111df0f1eeec0c6e81bae1831ccc178c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dutch_top40 (0.1.0)
4
+ dutch_top40 (0.1.1)
5
5
  nokogiri
6
6
 
7
7
  GEM
data/dutch_top40.gemspec CHANGED
@@ -28,5 +28,6 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ["lib"]
29
29
 
30
30
  spec.add_dependency "nokogiri"
31
+ spec.add_development_dependency "pry"
31
32
 
32
33
  end
data/lib/dutch_top40.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require_relative "./dutch_top40/version"
2
2
  require 'nokogiri'
3
3
  require 'open-uri'
4
+ require 'pry'
4
5
 
5
6
  require_relative './dutch_top40/cli'
6
7
  require_relative './dutch_top40/songs'
@@ -13,27 +13,25 @@ class DutchTop40::CLI
13
13
  @songs = DutchTop40::Songs.list
14
14
  print_songs
15
15
  puts
16
-
17
16
  end
18
17
 
19
18
  def print_songs
19
+ binding.pry
20
20
  @songs.each.with_index(1) do |song, index|
21
- puts "#{index}. #{song.values[0]}"
21
+ puts "#{index}. #{song.title}"
22
22
  end
23
23
  end
24
24
 
25
- def menu
26
-
25
+ def menu
27
26
  input = nil
28
-
29
27
  while input != 'exit'
30
28
  puts "Which song do you want more info on? Type list to see list again, type exit to quit.",""
31
29
  input = gets.strip.downcase
32
30
  case input.to_i
33
31
  when 1..@songs.size
34
32
  puts "Current rank #{input}."
35
- puts "#{@songs[input.to_i-1].values[0]} - performing artist(s): #{@songs[input.to_i-1].values[1]}"
36
- puts "weeks listed: #{@songs[input.to_i-1].values[2]} - last weeks rank #{@songs[input.to_i-1].values[3]}",""
33
+ puts "#{@songs[input.to_i-1].title} - performing artist(s): #{@songs[input.to_i-1].name}"
34
+ puts "weeks listed: #{@songs[input.to_i-1].listed} - last weeks rank #{@songs[input.to_i-1].last_weeks_rank}",""
37
35
  else
38
36
  puts "Invalid input!" unless input == 'exit' || input == 'list'
39
37
  if input == 'list'
@@ -43,10 +41,7 @@ class DutchTop40::CLI
43
41
  goodbye
44
42
  end
45
43
  end
46
-
47
44
  end
48
-
49
-
50
45
  end
51
46
 
52
47
  def goodbye
@@ -1,8 +1,16 @@
1
1
  class DutchTop40::Songs
2
2
 
3
- attr_accessor :title, :name, :listed, :last_week_rank
3
+ attr_accessor :title, :name, :listed, :last_weeks_rank
4
4
 
5
- @@all = []
5
+ @@songs = []
6
+
7
+ def initialize(title, name, listed, last_weeks_rank)
8
+ @title = title
9
+ @name = name
10
+ @listed = listed
11
+ @last_weeks_rank = last_weeks_rank
12
+ @@songs << self
13
+ end
6
14
 
7
15
 
8
16
  def self.list
@@ -10,17 +18,15 @@ class DutchTop40::Songs
10
18
  end
11
19
 
12
20
  def self.scrape_songs
13
- songs = []
14
21
  doc = Nokogiri::HTML(open("http://top40.nl"))
15
22
  doc.search('.listScroller').search('.top40List').each do |song|
16
- songs << {
17
- :title => song.search('.songtitle').text.strip,
18
- :name => song.search('.artist').text,
19
- :listed => song.search('.details').text.split(' | ')[1].gsub(/Aantal weken: /,'').strip,
20
- :last_week_rank => song.search('.details').text.split(' | ')[0].gsub(/Vorige week: #/,'').strip
21
- }
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)
22
28
  end
23
- songs
29
+ @@songs
24
30
  end
25
31
 
26
32
  end
@@ -1,3 +1,3 @@
1
1
  module DutchTop40
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - raspimeteo
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: Scrapes the listing of songs, as wel some artist info, weeks in the top
28
42
  40 and highest rank reached so far.
29
43
  email: