brainz_releases 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NDY3OGQ1NmJjNDcyOTNmYzgwZjBhYzMzZGY2NGY1MzUzY2ZiMWI0Mg==
5
+ data.tar.gz: !binary |-
6
+ YzEwNDIyMzNhYWQ3ZjczZmY5NTI5YzBhMTJiYzg0ZTliNjgzNmVhMA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ YmM2NDY2Zjk4NTg5OGY0ZjgxOGM0OThiZDcxNWI4ZGQwZTkwMmI1NTFkNmEy
10
+ ZWZjZjc1MjJiYWRmYmU0Y2VlMWZiMGE2NDI1M2U0OWJkYzMxNDZiYTRiM2Uw
11
+ ZmU0MDA0OTdjMmRlODEyMzI5N2IxMjU1NDMxMDVjOTQ4YTRkZDI=
12
+ data.tar.gz: !binary |-
13
+ ZWQyZjI3N2ZlNzFmYWQ1NDBmNTE5MzE4ZGYzMzAyZWFiYjliMmNkNmY5YmM4
14
+ YWZkZWYxZTBjNWIxMDUyYmFiMDc4N2UyZjRiNTgxYTdhYjE3YjI1NDFjYTBm
15
+ NWQxYzM4MTY3MTY4MmY4ZjZhOTQ0YjI2Yzg4MDY3NDljMzJjNWE=
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ .DS_Store
data/README.rdoc CHANGED
@@ -18,9 +18,9 @@ Example:
18
18
  search.start_date = Date.parse("1/1/2011") # Optional – defaults to 1 month ago
19
19
  search.end_date = Date.parse("5/5/2011") # Optional – defaults to 1 month in the future
20
20
  end
21
-
21
+
22
22
  release = releases.first
23
-
23
+
24
24
  # A BrainzReleases::Release object has a number of methods to easily access the attributes returned by the MusicBrainz api
25
25
  # For example...
26
26
  release.title # => "Fi"
@@ -10,23 +10,23 @@ module BrainzReleases
10
10
  class Error < StandardError; end
11
11
  class ResponseError < Error; end
12
12
  class ConfigError < Error; end
13
-
13
+
14
14
  attr_accessor :name, :mbid, :start_date, :end_date, :user_agent
15
-
15
+
16
16
  def self.search(*args, &block)
17
17
  Search.new(*args, &block).results
18
18
  end
19
-
19
+
20
20
  def initialize(*args, &block)
21
21
  (block.arity < 1 ? self.instance_eval(&block) : block.call(self)) if block
22
22
  raise ConfigError, "You must provide a :name or :mbid parameter" if [name, mbid].all?(&:nil?)
23
23
  raise ConfigError, "You must provide a user_agent parameter to identify your requests" if user_agent.nil?
24
24
  end
25
-
25
+
26
26
  def start_date
27
27
  @start_date ||= Date.today << 1
28
28
  end
29
-
29
+
30
30
  def end_date
31
31
  @end_date ||= Date.today >> 1
32
32
  end
@@ -46,21 +46,21 @@ module BrainzReleases
46
46
  when "200"
47
47
  @releases_xml = Nokogiri::XML(response.body)
48
48
  else
49
- raise ResponseError, "There is a problem accessing the Music Brainz api"
49
+ raise ResponseError, "There is a problem accessing the Music Brainz api. Response code: #{response.code} \n #{response.inspect}"
50
50
  end
51
51
  end
52
52
 
53
53
  # Returns an array of BrainzReleases::Release objects
54
54
  def results
55
- (releases = []).tap do
55
+ (releases = []).tap do
56
56
  releases_xml.xpath('//xmlns:release').each do |node|
57
57
  releases << BrainzReleases::Release.build_from_node(node)
58
58
  end
59
59
  end
60
60
  end
61
-
62
- private
63
-
61
+
62
+ private
63
+
64
64
  def query
65
65
  CGI.escape("#{artist_param} AND date:[#{start_date.to_s} TO #{end_date.to_s}]")
66
66
  end
@@ -1,3 +1,3 @@
1
1
  module BrainzReleases
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -2,10 +2,10 @@ require 'spec_helper.rb'
2
2
 
3
3
  describe BrainzReleases do
4
4
 
5
- describe "::search" do
5
+ describe "::search" do
6
6
  it "should call search" do
7
7
  BrainzReleases::Search.should_receive(:search)
8
- BrainzReleases.search do |search|
8
+ BrainzReleases.search do |search|
9
9
  search.mbid = "123"
10
10
  end
11
11
  end
data/spec/release_spec.rb CHANGED
@@ -2,14 +2,13 @@ require 'spec_helper.rb'
2
2
 
3
3
  describe BrainzReleases::Release do
4
4
 
5
-
6
5
  describe "build_from_node" do
7
-
6
+
8
7
  before do
9
8
  node = Nokogiri::XML(File.read("spec/fixtures/ok.xml")).xpath('//xmlns:release').first
10
9
  @release = BrainzReleases::Release.build_from_node(node)
11
10
  end
12
-
11
+
13
12
  it "should set the attributes" do
14
13
  @release.mbid.should == "4a46ee61-75b5-4e2b-ac2e-81ef2ccec0f9"
15
14
  @release.artist_name.should == "Bibio"
@@ -22,10 +21,10 @@ describe BrainzReleases::Release do
22
21
  @release.label.should == "Mush Records"
23
22
  @release.country.should == "US"
24
23
  end
25
-
24
+
26
25
  it "should be able to list the attributes as a hash" do
27
26
  @release.attributes.should == {
28
- :mbid => "4a46ee61-75b5-4e2b-ac2e-81ef2ccec0f9",
27
+ :mbid => "4a46ee61-75b5-4e2b-ac2e-81ef2ccec0f9",
29
28
  :artist_name => "Bibio",
30
29
  :artist_mbid => "9f9953f0-68bb-4ce3-aace-2f44c87f0aa3",
31
30
  :title => "Fi",
@@ -37,7 +36,7 @@ describe BrainzReleases::Release do
37
36
  :country => "US"
38
37
  }
39
38
  end
40
-
39
+
41
40
  end
42
41
 
43
42
  end
data/spec/search_spec.rb CHANGED
@@ -17,7 +17,7 @@ describe BrainzReleases::Search do
17
17
  search.mbid = "123"
18
18
  end
19
19
  end
20
-
20
+
21
21
  it "should initialize the user agent" do
22
22
  @brainz_search.user_agent.should == "Testing/0.1"
23
23
  end
@@ -44,7 +44,7 @@ describe BrainzReleases::Search do
44
44
  lambda {BrainzReleases::Search.new { |search| search.user_agent = "Foo"}}.should raise_exception(BrainzReleases::Search::ConfigError)
45
45
  end
46
46
  end
47
-
47
+
48
48
  context "when the user agent is missing" do
49
49
  it "should raise an exception" do
50
50
  lambda {BrainzReleases::Search.new { |search| search.mbid = "123"}}.should raise_exception(BrainzReleases::Search::ConfigError)
@@ -85,7 +85,7 @@ describe BrainzReleases::Search do
85
85
  end
86
86
  end
87
87
 
88
- it "should use the mbid" do
88
+ it "should use the mbid" do
89
89
  @brainz_search.uri.should == URI.parse("http://musicbrainz.org/ws/2/release/?type=xml&query=arid%3A123+AND+date%3A%5B2011-01-01+TO+2011-05-05%5D")
90
90
  end
91
91
 
metadata CHANGED
@@ -1,72 +1,65 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: brainz_releases
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 6
9
- version: 0.0.6
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Paul Sturgess
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2012-05-10 00:00:00 +01:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- requirement: &id001 !ruby/object:Gem::Requirement
22
- requirements:
23
- - - ~>
24
- - !ruby/object:Gem::Version
25
- segments:
26
- - 1
27
- - 4
28
- version: "1.4"
11
+ date: 2013-04-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
29
14
  name: nokogiri
30
- prerelease: false
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.4'
31
20
  type: :runtime
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
- requirement: &id002 !ruby/object:Gem::Requirement
35
- requirements:
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
36
24
  - - ~>
37
- - !ruby/object:Gem::Version
38
- segments:
39
- - 2
40
- - 6
41
- version: "2.6"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.4'
27
+ - !ruby/object:Gem::Dependency
42
28
  name: rspec
43
- prerelease: false
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '2.6'
44
34
  type: :development
45
- version_requirements: *id002
46
- - !ruby/object:Gem::Dependency
47
- requirement: &id003 !ruby/object:Gem::Requirement
48
- requirements:
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
49
38
  - - ~>
50
- - !ruby/object:Gem::Version
51
- segments:
52
- - 1
53
- - 3
54
- - 0
55
- version: 1.3.0
39
+ - !ruby/object:Gem::Version
40
+ version: '2.6'
41
+ - !ruby/object:Gem::Dependency
56
42
  name: fakeweb
57
- prerelease: false
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 1.3.0
58
48
  type: :development
59
- version_requirements: *id003
60
- description: Uses the MusicBrainz XML Web Service (version 2) to extract the releases for an artist and turns them into nice ruby objects.
61
- email:
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.3.0
55
+ description: Uses the MusicBrainz XML Web Service (version 2) to extract the releases
56
+ for an artist and turns them into nice ruby objects.
57
+ email:
62
58
  - paulsturgess@gmail.com
63
59
  executables: []
64
-
65
60
  extensions: []
66
-
67
61
  extra_rdoc_files: []
68
-
69
- files:
62
+ files:
70
63
  - .DS_Store
71
64
  - .gitignore
72
65
  - Gemfile
@@ -83,37 +76,31 @@ files:
83
76
  - spec/release_spec.rb
84
77
  - spec/search_spec.rb
85
78
  - spec/spec_helper.rb
86
- has_rdoc: true
87
79
  homepage: https://github.com/paulsturgess/brainz_releases
88
80
  licenses: []
89
-
81
+ metadata: {}
90
82
  post_install_message:
91
83
  rdoc_options: []
92
-
93
- require_paths:
84
+ require_paths:
94
85
  - lib
95
- required_ruby_version: !ruby/object:Gem::Requirement
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- segments:
100
- - 0
101
- version: "0"
102
- required_rubygems_version: !ruby/object:Gem::Requirement
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- segments:
107
- - 0
108
- version: "0"
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
109
96
  requirements: []
110
-
111
97
  rubyforge_project: brainz_releases
112
- rubygems_version: 1.3.6
98
+ rubygems_version: 2.0.0
113
99
  signing_key:
114
- specification_version: 3
115
- summary: Provides a ruby interface for extracting the releases for an artist from MusicBrainz
116
- test_files:
100
+ specification_version: 4
101
+ summary: Provides a ruby interface for extracting the releases for an artist from
102
+ MusicBrainz
103
+ test_files:
117
104
  - spec/brainz_releases_spec.rb
118
105
  - spec/fixtures/ok.xml
119
106
  - spec/release_spec.rb