metallum 0.2.2 → 0.2.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.
- data/CHANGELOG +3 -1
 - data/lib/metallum/album.rb +44 -42
 - data/lib/metallum/band.rb +50 -48
 - data/lib/metallum/version.rb +1 -1
 - metadata +1 -1
 
    
        data/CHANGELOG
    CHANGED
    
    | 
         @@ -12,4 +12,6 @@ Peco Danajlovski <vortexmk@gmail.com> 
     | 
|
| 
       12 
12 
     | 
    
         
             
            * Implemented fetching of all album urls from band's discography
         
     | 
| 
       13 
13 
     | 
    
         
             
            * Refactored the classes into separate files
         
     | 
| 
       14 
14 
     | 
    
         
             
            * Implemented fetching basic info for albums
         
     | 
| 
       15 
     | 
    
         
            -
            *  
     | 
| 
      
 15 
     | 
    
         
            +
            * Moved Band and Album under Metallum namespace
         
     | 
| 
      
 16 
     | 
    
         
            +
            * Fixed gem dependencies
         
     | 
| 
      
 17 
     | 
    
         
            +
            * Version bump to 0.2.3
         
     | 
    
        data/lib/metallum/album.rb
    CHANGED
    
    | 
         @@ -1,54 +1,56 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
              
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
                 
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            module Metallum
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Album
         
     | 
| 
      
 3 
     | 
    
         
            +
                
         
     | 
| 
      
 4 
     | 
    
         
            +
                def initialize(album_page) 
         
     | 
| 
      
 5 
     | 
    
         
            +
                  @page = album_page
         
     | 
| 
      
 6 
     | 
    
         
            +
                end
         
     | 
| 
       6 
7 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
                def title
         
     | 
| 
      
 9 
     | 
    
         
            +
                  element = @page.search("//h1[@class='album_name']")
         
     | 
| 
      
 10 
     | 
    
         
            +
                  element.text
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
       11 
12 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 13 
     | 
    
         
            +
                def band_name
         
     | 
| 
      
 14 
     | 
    
         
            +
                  element = @page.search("//h2[@class='band_name']")
         
     | 
| 
      
 15 
     | 
    
         
            +
                  element.text
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
       16 
17 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 18 
     | 
    
         
            +
                def album_type
         
     | 
| 
      
 19 
     | 
    
         
            +
                  element = @page.search("//div[@id='album_info']//dl[1]//dd[1]")
         
     | 
| 
      
 20 
     | 
    
         
            +
                  element.text
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
       21 
22 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 23 
     | 
    
         
            +
                def release_date
         
     | 
| 
      
 24 
     | 
    
         
            +
                  element = @page.search("//div[@id='album_info']//dl[1]//dd[2]")
         
     | 
| 
      
 25 
     | 
    
         
            +
                  element.text
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
       26 
27 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
      
 28 
     | 
    
         
            +
                def record_label
         
     | 
| 
      
 29 
     | 
    
         
            +
                  element = @page.search("//div[@id='album_info']//dl[2]//dd[1]")
         
     | 
| 
      
 30 
     | 
    
         
            +
                  element.text
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
       31 
32 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
      
 33 
     | 
    
         
            +
                def track_list
         
     | 
| 
      
 34 
     | 
    
         
            +
                  tracks = []
         
     | 
| 
      
 35 
     | 
    
         
            +
                  elements = @page.search("//div[@id='album_tabs_tracklist']//table//tbody//tr[@class='odd' or @class='even']")
         
     | 
| 
      
 36 
     | 
    
         
            +
                  elements.each do |element|
         
     | 
| 
      
 37 
     | 
    
         
            +
                    track = Track.new
         
     | 
| 
      
 38 
     | 
    
         
            +
                    track.title = element.children[2].text.strip
         
     | 
| 
      
 39 
     | 
    
         
            +
                    track.duration = element.children[4].text.strip
         
     | 
| 
      
 40 
     | 
    
         
            +
                    tracks << track
         
     | 
| 
      
 41 
     | 
    
         
            +
                  end
         
     | 
| 
      
 42 
     | 
    
         
            +
                  return tracks
         
     | 
| 
       40 
43 
     | 
    
         
             
                end
         
     | 
| 
       41 
     | 
    
         
            -
                 
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
              
         
     | 
| 
       44 
     | 
    
         
            -
              class Track
         
     | 
| 
      
 44 
     | 
    
         
            +
                
         
     | 
| 
      
 45 
     | 
    
         
            +
                class Track
         
     | 
| 
       45 
46 
     | 
    
         | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
      
 47 
     | 
    
         
            +
                  attr_accessor :title, :duration
         
     | 
| 
       47 
48 
     | 
    
         | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
      
 49 
     | 
    
         
            +
                  def initialize
         
     | 
| 
      
 50 
     | 
    
         
            +
                    @duration = "0:00"
         
     | 
| 
      
 51 
     | 
    
         
            +
                  end
         
     | 
| 
       51 
52 
     | 
    
         | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
      
 54 
     | 
    
         
            +
                   
         
     | 
| 
       52 
55 
     | 
    
         
             
              end
         
     | 
| 
       53 
     | 
    
         
            -
                 
         
     | 
| 
       54 
56 
     | 
    
         
             
            end
         
     | 
    
        data/lib/metallum/band.rb
    CHANGED
    
    | 
         @@ -1,62 +1,64 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            module Metallum
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Band
         
     | 
| 
       2 
3 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
      
 4 
     | 
    
         
            +
                def initialize(band_page, discography_page)
         
     | 
| 
      
 5 
     | 
    
         
            +
                  @page = band_page
         
     | 
| 
      
 6 
     | 
    
         
            +
                  @discography = discography_page
         
     | 
| 
      
 7 
     | 
    
         
            +
                end
         
     | 
| 
       7 
8 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 9 
     | 
    
         
            +
                def name
         
     | 
| 
      
 10 
     | 
    
         
            +
                  element = @page.search("h1[@class='band_name']")
         
     | 
| 
      
 11 
     | 
    
         
            +
                  element.text.strip!
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
       12 
13 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
      
 14 
     | 
    
         
            +
                def country
         
     | 
| 
      
 15 
     | 
    
         
            +
                  element = @page.search("//div[@id='band_info']//dl//dd[1]//a")
         
     | 
| 
      
 16 
     | 
    
         
            +
                  element.children[0].text
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
       17 
18 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 19 
     | 
    
         
            +
                def location
         
     | 
| 
      
 20 
     | 
    
         
            +
                  element = @page.search("//div[@id='band_info']//dl[1]//dd[2]")
         
     | 
| 
      
 21 
     | 
    
         
            +
                  element.text
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
       22 
23 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 24 
     | 
    
         
            +
                def status
         
     | 
| 
      
 25 
     | 
    
         
            +
                  element = @page.search("//div[@id='band_info']//dl[1]//dd[3]")
         
     | 
| 
      
 26 
     | 
    
         
            +
                  element.text
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
       27 
28 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 29 
     | 
    
         
            +
                def year_formed
         
     | 
| 
      
 30 
     | 
    
         
            +
                  element = @page.search("//div[@id='band_info']//dl//dd[4]")
         
     | 
| 
      
 31 
     | 
    
         
            +
                  element.text
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
       32 
33 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
      
 34 
     | 
    
         
            +
                def genre
         
     | 
| 
      
 35 
     | 
    
         
            +
                  element = @page.search("//div[@id='band_info']//dl[2]//dd[1]")
         
     | 
| 
      
 36 
     | 
    
         
            +
                  element.text
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
       37 
38 
     | 
    
         | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
      
 39 
     | 
    
         
            +
                def lyrical_themes
         
     | 
| 
      
 40 
     | 
    
         
            +
                  element = @page.search("//div[@id='band_info']//dl[2]//dd[2]")
         
     | 
| 
      
 41 
     | 
    
         
            +
                  element.text
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
       42 
43 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
      
 44 
     | 
    
         
            +
                def record_label
         
     | 
| 
      
 45 
     | 
    
         
            +
                  element = @page.search("//div[@id='band_info']//dl[2]//dd[3]")
         
     | 
| 
      
 46 
     | 
    
         
            +
                  element.text
         
     | 
| 
      
 47 
     | 
    
         
            +
                end
         
     | 
| 
       47 
48 
     | 
    
         | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
      
 49 
     | 
    
         
            +
                def photo_url
         
     | 
| 
      
 50 
     | 
    
         
            +
                  element = @page.search("//a[@id='photo']//img")
         
     | 
| 
      
 51 
     | 
    
         
            +
                  element.attribute("src").text
         
     | 
| 
      
 52 
     | 
    
         
            +
                end
         
     | 
| 
       52 
53 
     | 
    
         | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
      
 54 
     | 
    
         
            +
                def logo_url
         
     | 
| 
      
 55 
     | 
    
         
            +
                  element = @page.search("//a[@id='logo']//img")
         
     | 
| 
      
 56 
     | 
    
         
            +
                  element.attribute("src").text
         
     | 
| 
      
 57 
     | 
    
         
            +
                end
         
     | 
| 
       57 
58 
     | 
    
         | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
      
 59 
     | 
    
         
            +
                def album_urls
         
     | 
| 
      
 60 
     | 
    
         
            +
                  elements = @discography.search("//tbody//tr//td[1]/a").map { |el| el.attribute("href").text }
         
     | 
| 
      
 61 
     | 
    
         
            +
                end
         
     | 
| 
       61 
62 
     | 
    
         | 
| 
      
 63 
     | 
    
         
            +
              end
         
     | 
| 
       62 
64 
     | 
    
         
             
            end
         
     | 
    
        data/lib/metallum/version.rb
    CHANGED