brainz_releases 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -14,7 +14,7 @@ Example:
14
14
  releases = BrainzReleases.search do |search|
15
15
  search.user_agent = "YourAppName/x.x" # Required – A string to identify your requests containing your app name and version number (this is required by the MusicBrainz API)
16
16
  search.mbid = "9f9953f0-68bb-4ce3-aace-2f44c87f0aa3" # MusicBrainz artist ID
17
- search.name = "Bonobo" # Only necessary if you don't know the MusicBrainz ID
17
+ search.name = "Bonobo" # Optional – Only necessary if you don't know the MusicBrainz ID
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
@@ -31,7 +31,7 @@ Example:
31
31
  release.track_count # => "17"
32
32
  release.country # => "US"
33
33
  release.mbid # => "4a46ee61-75b5-4e2b-ac2e-81ef2ccec0f9"
34
- release.artist # => "Bibio"
34
+ release.artist_name # => "Bibio"
35
35
  release.artist_mbid # => "9f9953f0-68bb-4ce3-aace-2f44c87f0aa3"
36
36
 
37
37
 
@@ -9,8 +9,8 @@ Gem::Specification.new do |s|
9
9
  s.authors = ["Paul Sturgess"]
10
10
  s.email = ["paulsturgess@gmail.com"]
11
11
  s.homepage = "https://github.com/paulsturgess/brainz_releases"
12
- s.summary = "Provides a ruby inteface for extracting the releases for an artist from MusicBrainz"
13
- s.description = "Uses the MusicBrainz XML Web Service (version 2) to extract the releases for an artist and turn them into nice ruby objects."
12
+ s.summary = "Provides a ruby interface for extracting the releases for an artist from MusicBrainz"
13
+ s.description = "Uses the MusicBrainz XML Web Service (version 2) to extract the releases for an artist and turns them into nice ruby objects."
14
14
 
15
15
  s.rubyforge_project = "brainz_releases"
16
16
 
@@ -1,7 +1,7 @@
1
1
  module BrainzReleases
2
2
  class Release
3
3
 
4
- attr_accessor :mbid, :title, :release_type, :date_available, :artist, :artist_mbid, :label, :track_count, :country, :format
4
+ attr_accessor :mbid, :title, :release_type, :date_available, :artist_name, :artist_mbid, :label, :track_count, :country, :format
5
5
 
6
6
  def initialize(*args, &block)
7
7
  self.instance_eval(&block) if block
@@ -10,7 +10,7 @@ module BrainzReleases
10
10
  def self.build_from_node(node)
11
11
  Release.new do |release|
12
12
  release.mbid = node["id"]
13
- release.artist = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:artist-credit/xmlns:name-credit/xmlns:artist/xmlns:name").first.content rescue nil
13
+ release.artist_name = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:artist-credit/xmlns:name-credit/xmlns:artist/xmlns:name").first.content rescue nil
14
14
  release.artist_mbid = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:artist-credit/xmlns:name-credit/xmlns:artist").first['id']
15
15
  release.title = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:title").first.content rescue nil
16
16
  release.release_type = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:release-group").first['type']
@@ -22,5 +22,10 @@ module BrainzReleases
22
22
  end
23
23
  end
24
24
 
25
+ # Returns a hash of all the attributes with their names as keys and the values of the attributes as values.
26
+ def attributes
27
+ Hash[instance_variables.map { |name| [name[1..-1].to_sym, instance_variable_get(name)] }]
28
+ end
29
+
25
30
  end
26
31
  end
@@ -2,7 +2,7 @@ require 'nokogiri'
2
2
  require 'open-uri'
3
3
  require 'net/http'
4
4
  require 'CGI'
5
- require 'Date'
5
+ require 'Date' unless defined?(Date) == "constant"
6
6
 
7
7
  module BrainzReleases
8
8
  class Search
@@ -1,3 +1,3 @@
1
1
  module BrainzReleases
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/spec/release_spec.rb CHANGED
@@ -12,7 +12,7 @@ describe BrainzReleases::Release do
12
12
 
13
13
  it "should set the attributes" do
14
14
  @release.mbid.should == "4a46ee61-75b5-4e2b-ac2e-81ef2ccec0f9"
15
- @release.artist.should == "Bibio"
15
+ @release.artist_name.should == "Bibio"
16
16
  @release.artist_mbid.should == "9f9953f0-68bb-4ce3-aace-2f44c87f0aa3"
17
17
  @release.title.should == "Fi"
18
18
  @release.release_type.should == "Album"
@@ -23,6 +23,21 @@ describe BrainzReleases::Release do
23
23
  @release.country.should == "US"
24
24
  end
25
25
 
26
+ it "should be able to list the attributes as a hash" do
27
+ @release.attributes.should == {
28
+ :mbid => "4a46ee61-75b5-4e2b-ac2e-81ef2ccec0f9",
29
+ :artist_name => "Bibio",
30
+ :artist_mbid => "9f9953f0-68bb-4ce3-aace-2f44c87f0aa3",
31
+ :title => "Fi",
32
+ :release_type => "Album",
33
+ :date_available => "2005-02-08",
34
+ :track_count => "17",
35
+ :format => "CD",
36
+ :label => "Mush Records",
37
+ :country => "US"
38
+ }
39
+ end
40
+
26
41
  end
27
42
 
28
43
  end
metadata CHANGED
@@ -1,61 +1,57 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: brainz_releases
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
4
5
  prerelease:
5
- version: 0.0.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Paul Sturgess
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-09-13 00:00:00 +01:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2011-12-07 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: nokogiri
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70173419819720 !ruby/object:Gem::Requirement
20
17
  none: false
21
- requirements:
18
+ requirements:
22
19
  - - ~>
23
- - !ruby/object:Gem::Version
24
- version: "1.4"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.4'
25
22
  type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: rspec
29
23
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70173419819720
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70173419819180 !ruby/object:Gem::Requirement
31
28
  none: false
32
- requirements:
29
+ requirements:
33
30
  - - ~>
34
- - !ruby/object:Gem::Version
35
- version: "2.6"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.6'
36
33
  type: :development
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: fakeweb
40
34
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70173419819180
36
+ - !ruby/object:Gem::Dependency
37
+ name: fakeweb
38
+ requirement: &70173419818640 !ruby/object:Gem::Requirement
42
39
  none: false
43
- requirements:
40
+ requirements:
44
41
  - - ~>
45
- - !ruby/object:Gem::Version
42
+ - !ruby/object:Gem::Version
46
43
  version: 1.3.0
47
44
  type: :development
48
- version_requirements: *id003
49
- description: Uses the MusicBrainz XML Web Service (version 2) to extract the releases for an artist and turn them into nice ruby objects.
50
- email:
45
+ prerelease: false
46
+ version_requirements: *70173419818640
47
+ description: Uses the MusicBrainz XML Web Service (version 2) to extract the releases
48
+ for an artist and turns them into nice ruby objects.
49
+ email:
51
50
  - paulsturgess@gmail.com
52
51
  executables: []
53
-
54
52
  extensions: []
55
-
56
53
  extra_rdoc_files: []
57
-
58
- files:
54
+ files:
59
55
  - .DS_Store
60
56
  - .gitignore
61
57
  - Gemfile
@@ -72,35 +68,32 @@ files:
72
68
  - spec/release_spec.rb
73
69
  - spec/search_spec.rb
74
70
  - spec/spec_helper.rb
75
- has_rdoc: true
76
71
  homepage: https://github.com/paulsturgess/brainz_releases
77
72
  licenses: []
78
-
79
73
  post_install_message:
80
74
  rdoc_options: []
81
-
82
- require_paths:
75
+ require_paths:
83
76
  - lib
84
- required_ruby_version: !ruby/object:Gem::Requirement
77
+ required_ruby_version: !ruby/object:Gem::Requirement
85
78
  none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: "0"
90
- required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
84
  none: false
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: "0"
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
96
89
  requirements: []
97
-
98
90
  rubyforge_project: brainz_releases
99
- rubygems_version: 1.6.2
91
+ rubygems_version: 1.8.10
100
92
  signing_key:
101
93
  specification_version: 3
102
- summary: Provides a ruby inteface for extracting the releases for an artist from MusicBrainz
103
- test_files:
94
+ summary: Provides a ruby interface for extracting the releases for an artist from
95
+ MusicBrainz
96
+ test_files:
104
97
  - spec/brainz_releases_spec.rb
105
98
  - spec/fixtures/ok.xml
106
99
  - spec/release_spec.rb