mostscrobbled 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
@@ -2,7 +2,9 @@
2
2
 
3
3
  Extracts the artists from a {last.fm}[http://last.fm] user's music library and turns them into nice ruby objects.
4
4
 
5
- {Official Documentation}[http://rubydoc.info/github/paulsturgess/mostscrobbled/master/frames]
5
+ * {Official Documentation}[http://rubydoc.info/gems/mostscrobbled/frames]
6
+ * {Ruby Gems}[https://rubygems.org/gems/mostscrobbled]
7
+ * {Github}[https://github.com/paulsturgess/mostscrobbled]
6
8
 
7
9
  == Usage
8
10
 
@@ -28,6 +30,8 @@ Example:
28
30
  my_favourite_artist.mbid # => "9f9953f0-68bb-4ce3-aace-2f44c87f0aa3"
29
31
  my_favourite_artist.image_small # => "http://userserve-ak.last.fm/serve/34/39790231.jpg"
30
32
 
33
+ See the {documentation}[http://rubydoc.info/gems/mostscrobbled/0.0.1/Mostscrobbled/Artist] for the full list of methods
34
+
31
35
  == Installation
32
36
 
33
37
  gem install mostscrobbled
data/lib/mostscrobbled.rb CHANGED
@@ -1,5 +1,11 @@
1
1
  module Mostscrobbled
2
-
2
+
3
+ # The main call to find the artists for an account on last.fm
4
+ #
5
+ # == Required paramaters
6
+ # * :username - A last.fm username
7
+ # * :api_key - A last.fm api key
8
+ #
3
9
  def self.find(opts = {})
4
10
  begin
5
11
  Mostscrobbled::LastFm::Connection.new(opts).artists
@@ -5,11 +5,10 @@ module Mostscrobbled
5
5
 
6
6
  def initialize(attrs = {}, *args)
7
7
  super(*args)
8
- attrs.each do |k,v|
9
- self.send "#{k}=", v
10
- end
8
+ attrs.each { |key,value| send("#{key}=", value) }
11
9
  end
12
-
10
+
11
+ # Creates an instance of Mostscrobbled::Artist from an xml node returned by the last.fm api
13
12
  def self.build_artist(node)
14
13
  (artist = Artist.new).tap do
15
14
  [:name, :playcount, :tagcount, :mbid, :url, :streamable].each do |attribute|
@@ -21,5 +20,10 @@ module Mostscrobbled
21
20
  end
22
21
  end
23
22
 
23
+ # Returns a hash of all the attributes with their names as keys and the values of the attributes as values.
24
+ def attributes
25
+ Hash[instance_variables.map { |name| [name[1..-1].to_sym, instance_variable_get(name)] }]
26
+ end
27
+
24
28
  end
25
29
  end
@@ -14,7 +14,7 @@ module Mostscrobbled
14
14
 
15
15
  def initialize(opts = {})
16
16
  raise ConfigError, missing_options(opts).map{ |argument| ":#{argument} argument missing" }.join(" and ") unless missing_options(opts).empty?
17
- opts.keys.each{ |key| send("#{key}=", opts[key]) }
17
+ opts.each{ |key,value| send("#{key}=", value) }
18
18
  end
19
19
 
20
20
  # Returns an array of MostscrobbledArtist objects
@@ -28,10 +28,12 @@ module Mostscrobbled
28
28
  end
29
29
  end
30
30
 
31
+ # The uri used to call the last.fm api
31
32
  def artists_uri(page_number = nil)
32
33
  URI.parse("http://ws.audioscrobbler.com/2.0/?method=library.getartists&api_key=#{api_key}&user=#{username}#{"&page=#{page_number + 1}" if page_number}")
33
34
  end
34
35
 
36
+ # The parsed XML returned from the last.fm api
35
37
  def artists_xml(page_number = nil)
36
38
  uri = artists_uri(page_number)
37
39
  http = Net::HTTP.new(uri.host)
@@ -46,6 +48,7 @@ module Mostscrobbled
46
48
  end
47
49
  end
48
50
 
51
+ # The total number of pages returned by the last.fm api
49
52
  def total_artist_pages
50
53
  artists_xml.xpath('//artists').first["totalPages"].to_i
51
54
  end
@@ -1,3 +1,3 @@
1
1
  module Mostscrobbled
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/license.txt ADDED
@@ -0,0 +1,21 @@
1
+ (The MIT License)
2
+
3
+ Copyright (C) 2011 by Paul Sturgess
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Paul Sturgess"]
10
10
  s.email = ["paulsturgess@gmail.com"]
11
- s.homepage = ""
11
+ s.homepage = "https://github.com/paulsturgess/mostscrobbled"
12
12
  s.summary = "Extracts your most scrobbled artists from last.fm and turns them into nice ruby objects"
13
13
  s.description = "Uses the last.fm api to analyse your scrobbles library and extracts the artists out in order of number of scrobbles"
14
14
 
data/spec/artist_spec.rb CHANGED
@@ -15,7 +15,11 @@ describe Mostscrobbled::Artist do
15
15
 
16
16
  it "should set the scrobbles_count" do
17
17
  artist.playcount.should == 200
18
- end
18
+ end
19
+
20
+ it "should be able to list the attributes as a hash" do
21
+ artist.attributes.should == {:name => "Bibio", :mbid => "123", :playcount => 200}
22
+ end
19
23
  end
20
24
 
21
25
  end
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mostscrobbled
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.0.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ segments_generated: true
10
+ version: 0.0.2
6
11
  platform: ruby
7
12
  authors:
8
13
  - Paul Sturgess
@@ -10,42 +15,55 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-07-13 00:00:00 +01:00
18
+ date: 2011-12-04 00:00:00 +00:00
14
19
  default_executable:
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
17
- name: nokogiri
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
20
- none: false
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
21
23
  requirements:
22
24
  - - ~>
23
25
  - !ruby/object:Gem::Version
26
+ segments:
27
+ - 1
28
+ - 4
29
+ segments_generated: true
24
30
  version: "1.4"
31
+ requirement: *id001
32
+ name: nokogiri
33
+ prerelease: false
25
34
  type: :runtime
26
- version_requirements: *id001
27
35
  - !ruby/object:Gem::Dependency
28
- name: rspec
29
- prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
31
- none: false
36
+ version_requirements: &id002 !ruby/object:Gem::Requirement
32
37
  requirements:
33
38
  - - ~>
34
39
  - !ruby/object:Gem::Version
40
+ segments:
41
+ - 2
42
+ - 0
43
+ - 0
44
+ - beta
45
+ - 22
46
+ segments_generated: true
35
47
  version: 2.0.0.beta.22
48
+ requirement: *id002
49
+ name: rspec
50
+ prerelease: false
36
51
  type: :development
37
- version_requirements: *id002
38
52
  - !ruby/object:Gem::Dependency
39
- name: fakeweb
40
- prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
42
- none: false
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
43
54
  requirements:
44
55
  - - ~>
45
56
  - !ruby/object:Gem::Version
57
+ segments:
58
+ - 1
59
+ - 3
60
+ - 0
61
+ segments_generated: true
46
62
  version: 1.3.0
63
+ requirement: *id003
64
+ name: fakeweb
65
+ prerelease: false
47
66
  type: :development
48
- version_requirements: *id003
49
67
  description: Uses the last.fm api to analyse your scrobbles library and extracts the artists out in order of number of scrobbles
50
68
  email:
51
69
  - paulsturgess@gmail.com
@@ -65,6 +83,7 @@ files:
65
83
  - lib/mostscrobbled/artist.rb
66
84
  - lib/mostscrobbled/last_fm.rb
67
85
  - lib/mostscrobbled/version.rb
86
+ - license.txt
68
87
  - mostscrobbled.gemspec
69
88
  - spec/artist_spec.rb
70
89
  - spec/fixtures/artists_failed.xml
@@ -73,7 +92,7 @@ files:
73
92
  - spec/most_scrobbled_spec.rb
74
93
  - spec/spec_helper.rb
75
94
  has_rdoc: true
76
- homepage: ""
95
+ homepage: https://github.com/paulsturgess/mostscrobbled
77
96
  licenses: []
78
97
 
79
98
  post_install_message:
@@ -82,21 +101,25 @@ rdoc_options: []
82
101
  require_paths:
83
102
  - lib
84
103
  required_ruby_version: !ruby/object:Gem::Requirement
85
- none: false
86
104
  requirements:
87
105
  - - ">="
88
106
  - !ruby/object:Gem::Version
107
+ segments:
108
+ - 0
109
+ segments_generated: true
89
110
  version: "0"
90
111
  required_rubygems_version: !ruby/object:Gem::Requirement
91
- none: false
92
112
  requirements:
93
113
  - - ">="
94
114
  - !ruby/object:Gem::Version
115
+ segments:
116
+ - 0
117
+ segments_generated: true
95
118
  version: "0"
96
119
  requirements: []
97
120
 
98
121
  rubyforge_project: mostscrobbled
99
- rubygems_version: 1.6.2
122
+ rubygems_version: 1.3.6
100
123
  signing_key:
101
124
  specification_version: 3
102
125
  summary: Extracts your most scrobbled artists from last.fm and turns them into nice ruby objects