metal-archives 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,24 +10,24 @@ Here is a quick and dirty example:
10
10
  require 'metal-archives'
11
11
 
12
12
  agent = MetalArchives::Agent.new
13
- links = []
13
+ urls = []
14
14
 
15
- agent.paginated_result_links.each do |search_result|
16
- link = agent.album_links_from_url(search_result)
17
- if link.nil?
15
+ agent.paginated_result_urls.each do |search_result|
16
+ url = agent.album_urls(search_result)
17
+ if url.nil?
18
18
  puts "\nThrew an exception so exit"
19
19
  break
20
20
  else
21
21
  print '.'
22
- links << link
22
+ urls << url
23
23
  end
24
24
  end
25
- links.flatten!
26
- puts "DONE: #{links.size}"
25
+ urls.flatten!
26
+ puts "DONE: #{urls.size}"
27
27
 
28
- if links.size >= 1
29
- puts "album information for the first result: #{agent.album_from_url(links.first).inspect}"
30
- puts "album information for the first result: #{agent.album_from_url(links.last).inspect}"
28
+ if urls.size >= 1
29
+ puts "album information for the first result: #{agent.album_from_url(urls.first).inspect}"
30
+ puts "album information for the first result: #{agent.album_from_url(urls.last).inspect}"
31
31
  end
32
32
 
33
33
  == Contributing to metal-archives
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -25,35 +25,35 @@ module MetalArchives
25
25
  end
26
26
  end
27
27
 
28
- # Finds all the links to the search results pages as they are paginated.
29
- def paginated_result_links
30
- # need the first page because it's not a link
31
- links = ["/advanced.php?release_year=#{@year}&p=1"]
28
+ # Finds all the url to the search results pages as they are paginated.
29
+ def paginated_result_urls
30
+ # need the first page because it's not a url
31
+ urls = ["/advanced.php?release_year=#{@year}&p=1"]
32
32
  begin
33
33
  search_by_year.search('body table:nth-child(2n) tr:first-child a').each do |link|
34
- links << link['href']
34
+ urls << link['href']
35
35
  end
36
36
  rescue Exception => e
37
- puts "\nError accessing metal-archives.com's paginated result links: #{e}"
37
+ puts "\nError accessing metal-archives.com's paginated result urls: #{e}"
38
38
  ensure
39
- return links
39
+ return urls
40
40
  end
41
41
  end
42
42
 
43
- # Finds all the links to the albums on a given search results page.
44
- def album_links_from_url(url)
45
- links = []
43
+ # Finds all the urls to the albums on a given search results page.
44
+ def album_urls(url)
45
+ urls = []
46
46
  begin
47
47
  page = @agent.get(SITE_URL + url)
48
48
  page.encoding = 'iso-8859-1' if !page.nil? && page.encoding != 'iso-8859-1' # needed for foreign characters
49
49
  page.search('body table:nth-child(2n) tr td:nth-child(3n) a').each do |link|
50
- links << link['href']
50
+ urls << link['href']
51
51
  end
52
52
  rescue Exception => e
53
- puts "\nError accessing metal-archives.com's album links from url: #{e}"
53
+ puts "\nError accessing metal-archives.com's album urls: #{e}"
54
54
  return nil
55
55
  end
56
- return links
56
+ return urls
57
57
  end
58
58
 
59
59
  # Finds the following fields on an album's page:
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{metal-archives}
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Danny Olson"]
@@ -26,22 +26,22 @@ describe "MetalArchives" do
26
26
  end
27
27
 
28
28
  context "with a results page" do
29
- it "should find the paginated result links" do
29
+ it "should find the paginated result urls" do
30
30
  agent = MetalArchives::Agent.new(2011)
31
31
  agent.stub!(:search_by_year).and_return(@search_results)
32
32
 
33
- links = (1..16).collect do |i|
33
+ urls = (1..16).collect do |i|
34
34
  "/advanced.php?release_year=2011&p=#{i}"
35
35
  end
36
- agent.paginated_result_links.should == links
36
+ agent.paginated_result_urls.should == urls
37
37
  end
38
38
 
39
- it "should find the album links" do
39
+ it "should find the album urls" do
40
40
  @mechanize.stub!(:get).and_return(@search_results)
41
41
  agent = MetalArchives::Agent.new(2011)
42
42
  agent.stub!(:search_by_year).and_return(@search_results)
43
43
 
44
- links = [
44
+ urls = [
45
45
  "release.php?id=296061", "release.php?id=295756", "release.php?id=294429", "release.php?id=295451", "release.php?id=295197",
46
46
  "release.php?id=289824", "release.php?id=295519", "release.php?id=295457", "release.php?id=288298", "release.php?id=296048",
47
47
  "release.php?id=290116", "release.php?id=295059", "release.php?id=291931", "release.php?id=296081", "release.php?id=295301",
@@ -53,7 +53,7 @@ describe "MetalArchives" do
53
53
  "release.php?id=295806", "release.php?id=294017", "release.php?id=296098", "release.php?id=294092", "release.php?id=295551",
54
54
  "release.php?id=290740", "release.php?id=295410", "release.php?id=293189", "release.php?id=296140", "release.php?id=291295"
55
55
  ]
56
- agent.album_links_from_url(agent.paginated_result_links.first).should == links
56
+ agent.album_urls(agent.paginated_result_urls.first).should == urls
57
57
  end
58
58
  end
59
59
  end
@@ -67,9 +67,9 @@ describe "MetalArchives" do
67
67
  Mechanize.stub!(:new).and_return(@mechanize)
68
68
  @mechanize.stub!(:get).and_return(@search_results)
69
69
  agent = MetalArchives::Agent.new(2011)
70
- album_link_from_url = "release.php?id=000001"
70
+ album_url = "release.php?id=000001"
71
71
 
72
- agent.album_from_url(album_link_from_url).should == {
72
+ agent.album_from_url(album_url).should == {
73
73
  :album => 'Fn-2+Fn-1=Fn',
74
74
  :band => 'A Tree',
75
75
  :label => 'Nazgûl Distro & Prod.',
@@ -88,9 +88,9 @@ describe "MetalArchives" do
88
88
  Mechanize.stub!(:new).and_return(@mechanize)
89
89
  @mechanize.stub!(:get).and_return(@search_results)
90
90
  agent = MetalArchives::Agent.new(2011)
91
- album_link_from_url = "release.php?id=000001"
91
+ album_url = "release.php?id=000001"
92
92
 
93
- agent.album_from_url(album_link_from_url).should == {
93
+ agent.album_from_url(album_url).should == {
94
94
  :album => 'Flesh Torn in Twilight',
95
95
  :band => 'Acephalix',
96
96
  :label => 'Deific Mourning',
@@ -109,9 +109,9 @@ describe "MetalArchives" do
109
109
  Mechanize.stub!(:new).and_return(@mechanize)
110
110
  @mechanize.stub!(:get).and_return(@search_results)
111
111
  agent = MetalArchives::Agent.new(2011)
112
- album_link_from_url = "release.php?id=000001"
112
+ album_url = "release.php?id=000001"
113
113
 
114
- agent.album_from_url(album_link_from_url).should == {
114
+ agent.album_from_url(album_url).should == {
115
115
  :album => 'The Mirror of Deliverance',
116
116
  :band => 'A Dream of Poe',
117
117
  :label => 'ARX Productions',
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 3
9
- version: 0.1.3
8
+ - 4
9
+ version: 0.1.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Danny Olson
@@ -143,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
143
  requirements:
144
144
  - - ">="
145
145
  - !ruby/object:Gem::Version
146
- hash: 834701885390149642
146
+ hash: 3280097642105159980
147
147
  segments:
148
148
  - 0
149
149
  version: "0"