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