metal-archives 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +32 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +46 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/lib/metal-archives.rb +159 -0
- data/metal-archives.gemspec +75 -0
- data/spec/html/album_result.html +123 -0
- data/spec/html/album_result2.html +146 -0
- data/spec/html/album_result3.html +121 -0
- data/spec/html/search_results.html +389 -0
- data/spec/metal-archives_spec.rb +142 -0
- data/spec/spec_helper.rb +12 -0
- metadata +167 -0
@@ -0,0 +1,142 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
3
|
+
|
4
|
+
describe "MetalArchives" do
|
5
|
+
context "has an Agent" do
|
6
|
+
context "searching by year" do
|
7
|
+
before do
|
8
|
+
search_results_html = File.open(File.dirname(__FILE__) + '/html/search_results.html')
|
9
|
+
@search_results = Nokogiri::HTML(search_results_html)
|
10
|
+
@mechanize = stub('Mechanize')
|
11
|
+
Mechanize.stub!(:new).and_return(@mechanize)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should GET the results page" do
|
15
|
+
@mechanize.stub!(:get).and_return(@search_results)
|
16
|
+
agent = MetalArchives::Agent.new
|
17
|
+
|
18
|
+
agent.search_by_year.should == @search_results
|
19
|
+
end
|
20
|
+
|
21
|
+
context "with a results page" do
|
22
|
+
it "should find the paginated result links" do
|
23
|
+
agent = MetalArchives::Agent.new
|
24
|
+
agent.stub!(:search_by_year).and_return(@search_results)
|
25
|
+
|
26
|
+
links = ['/advanced.php?release_year=2011']
|
27
|
+
(2..16).each do |i|
|
28
|
+
links << "/advanced.php?band_name=&band_status=&genre=&themes=&origin=0&location=&bandLabel=&release_name=&release_type=&label=&release_year=2011&p=#{i}"
|
29
|
+
end
|
30
|
+
agent.paginated_result_links.should == links
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should find the album links" do
|
34
|
+
@mechanize.stub!(:get).and_return(@search_results)
|
35
|
+
agent = MetalArchives::Agent.new
|
36
|
+
agent.stub!(:search_by_year).and_return(@search_results)
|
37
|
+
|
38
|
+
links = [
|
39
|
+
"release.php?id=296061", "release.php?id=295756", "release.php?id=294429", "release.php?id=295451", "release.php?id=295197",
|
40
|
+
"release.php?id=289824", "release.php?id=295519", "release.php?id=295457", "release.php?id=288298", "release.php?id=296048",
|
41
|
+
"release.php?id=290116", "release.php?id=295059", "release.php?id=291931", "release.php?id=296081", "release.php?id=295301",
|
42
|
+
"release.php?id=294242", "release.php?id=294032", "release.php?id=295436", "release.php?id=295797", "release.php?id=294481",
|
43
|
+
"release.php?id=290911", "release.php?id=295988", "release.php?id=295717", "release.php?id=293534", "release.php?id=295111",
|
44
|
+
"release.php?id=290063", "release.php?id=294761", "release.php?id=293839", "release.php?id=295202", "release.php?id=294083",
|
45
|
+
"release.php?id=294702", "release.php?id=265276", "release.php?id=293421", "release.php?id=295295", "release.php?id=293910",
|
46
|
+
"release.php?id=295567", "release.php?id=296037", "release.php?id=296064", "release.php?id=288749", "release.php?id=290749",
|
47
|
+
"release.php?id=295806", "release.php?id=294017", "release.php?id=296098", "release.php?id=294092", "release.php?id=295551",
|
48
|
+
"release.php?id=290740", "release.php?id=295410", "release.php?id=293189", "release.php?id=296140", "release.php?id=291295"
|
49
|
+
]
|
50
|
+
agent.album_links_from_url(agent.paginated_result_links.first).should == links
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "with an album page" do
|
56
|
+
context "with only a release year" do
|
57
|
+
it "should find the band information" do
|
58
|
+
search_results_html = File.open(File.dirname(__FILE__) + '/html/album_result.html')
|
59
|
+
@search_results = Nokogiri::HTML(search_results_html)
|
60
|
+
@mechanize = stub('Mechanize')
|
61
|
+
Mechanize.stub!(:new).and_return(@mechanize)
|
62
|
+
@mechanize.stub!(:get).and_return(@search_results)
|
63
|
+
agent = MetalArchives::Agent.new
|
64
|
+
album_link_from_url = "release.php?id=000001"
|
65
|
+
|
66
|
+
agent.album_from_url(album_link_from_url).should == {
|
67
|
+
:album => 'Fn-2+Fn-1=Fn',
|
68
|
+
:band => 'A Tree',
|
69
|
+
:label => 'Nazgûl Distro & Prod.',
|
70
|
+
:release_date => 'December 31st, 2011',
|
71
|
+
:release_type => 'Demo',
|
72
|
+
:url => 'release.php?id=000001'
|
73
|
+
}
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context "with only a release month and year" do
|
78
|
+
it "should find the band information" do
|
79
|
+
search_results_html = File.open(File.dirname(__FILE__) + '/html/album_result3.html')
|
80
|
+
@search_results = Nokogiri::HTML(search_results_html)
|
81
|
+
@mechanize = stub('Mechanize')
|
82
|
+
Mechanize.stub!(:new).and_return(@mechanize)
|
83
|
+
@mechanize.stub!(:get).and_return(@search_results)
|
84
|
+
agent = MetalArchives::Agent.new
|
85
|
+
album_link_from_url = "release.php?id=000001"
|
86
|
+
|
87
|
+
agent.album_from_url(album_link_from_url).should == {
|
88
|
+
:album => 'Flesh Torn in Twilight',
|
89
|
+
:band => 'Acephalix',
|
90
|
+
:label => 'Deific Mourning',
|
91
|
+
:release_date => 'April 30th, 2011',
|
92
|
+
:release_type => 'Demo',
|
93
|
+
:url => 'release.php?id=000001'
|
94
|
+
}
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context "with a release month, day, and year" do
|
99
|
+
it "should find the band information" do
|
100
|
+
search_results_html = File.open(File.dirname(__FILE__) + '/html/album_result2.html')
|
101
|
+
@search_results = Nokogiri::HTML(search_results_html)
|
102
|
+
@mechanize = stub('Mechanize')
|
103
|
+
Mechanize.stub!(:new).and_return(@mechanize)
|
104
|
+
@mechanize.stub!(:get).and_return(@search_results)
|
105
|
+
agent = MetalArchives::Agent.new
|
106
|
+
album_link_from_url = "release.php?id=000001"
|
107
|
+
|
108
|
+
agent.album_from_url(album_link_from_url).should == {
|
109
|
+
:album => 'The Mirror of Deliverance',
|
110
|
+
:band => 'A Dream of Poe',
|
111
|
+
:label => 'ARX Productions',
|
112
|
+
:release_date => 'February 25th, 2011',
|
113
|
+
:release_type => 'Full-length',
|
114
|
+
:url => 'release.php?id=000001'
|
115
|
+
}
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
it "ordinalizes a number" do
|
122
|
+
numbers = {
|
123
|
+
1 => '1st',
|
124
|
+
2 => '2nd',
|
125
|
+
3 => '3rd',
|
126
|
+
4 => '4th',
|
127
|
+
5 => '5th',
|
128
|
+
6 => '6th',
|
129
|
+
7 => '7th',
|
130
|
+
8 => '8th',
|
131
|
+
9 => '9th',
|
132
|
+
10 => '10th',
|
133
|
+
32 => '32nd',
|
134
|
+
43 => '43rd',
|
135
|
+
64 => '64th',
|
136
|
+
100 => '100th'
|
137
|
+
}
|
138
|
+
numbers.each do |k, v|
|
139
|
+
MetalArchives.ordinalize(k).should == v
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'metal-archives'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: metal-archives
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Danny Olson
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-02-11 00:00:00 -08:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: mechanize
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :runtime
|
31
|
+
prerelease: false
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rspec
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 2
|
42
|
+
- 3
|
43
|
+
- 0
|
44
|
+
version: 2.3.0
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: bundler
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 1
|
57
|
+
- 0
|
58
|
+
- 0
|
59
|
+
version: 1.0.0
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: jeweler
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ~>
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 1
|
72
|
+
- 5
|
73
|
+
- 2
|
74
|
+
version: 1.5.2
|
75
|
+
type: :development
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: *id004
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rcov
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
version: "0"
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *id005
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: mechanize
|
93
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ~>
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
segments:
|
99
|
+
- 1
|
100
|
+
- 0
|
101
|
+
- 0
|
102
|
+
version: 1.0.0
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: *id006
|
106
|
+
description: metal-archives provides an interface to search for album releases for a specific year, defaulting to the current one if none is provided.
|
107
|
+
email: dbolson@gmail.com
|
108
|
+
executables: []
|
109
|
+
|
110
|
+
extensions: []
|
111
|
+
|
112
|
+
extra_rdoc_files:
|
113
|
+
- LICENSE.txt
|
114
|
+
- README.rdoc
|
115
|
+
files:
|
116
|
+
- .document
|
117
|
+
- .rspec
|
118
|
+
- Gemfile
|
119
|
+
- Gemfile.lock
|
120
|
+
- LICENSE.txt
|
121
|
+
- README.rdoc
|
122
|
+
- Rakefile
|
123
|
+
- VERSION
|
124
|
+
- lib/metal-archives.rb
|
125
|
+
- metal-archives.gemspec
|
126
|
+
- spec/html/album_result.html
|
127
|
+
- spec/html/album_result2.html
|
128
|
+
- spec/html/album_result3.html
|
129
|
+
- spec/html/search_results.html
|
130
|
+
- spec/metal-archives_spec.rb
|
131
|
+
- spec/spec_helper.rb
|
132
|
+
has_rdoc: true
|
133
|
+
homepage: http://github.com/dbolson/metal-archives
|
134
|
+
licenses:
|
135
|
+
- MIT
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
hash: -2409445096831824830
|
147
|
+
segments:
|
148
|
+
- 0
|
149
|
+
version: "0"
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
none: false
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
segments:
|
156
|
+
- 0
|
157
|
+
version: "0"
|
158
|
+
requirements: []
|
159
|
+
|
160
|
+
rubyforge_project:
|
161
|
+
rubygems_version: 1.3.7
|
162
|
+
signing_key:
|
163
|
+
specification_version: 3
|
164
|
+
summary: metal-archives provides a way to search http://metal-archives.org/ for album release information.
|
165
|
+
test_files:
|
166
|
+
- spec/metal-archives_spec.rb
|
167
|
+
- spec/spec_helper.rb
|