lastrb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'yajl-ruby'
4
+ gem 'yard'
5
+
6
+ group :test do
7
+ gem 'mocha'
8
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,16 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ mocha (0.9.8)
5
+ rake
6
+ rake (0.8.7)
7
+ yajl-ruby (0.7.7)
8
+ yard (0.5.8)
9
+
10
+ PLATFORMS
11
+ ruby
12
+
13
+ DEPENDENCIES
14
+ mocha
15
+ yajl-ruby
16
+ yard
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Ramon Soares
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,21 @@
1
+ = Lastrb
2
+
3
+ Another ruby library for last.fm webservices.
4
+
5
+ == Installing Lastrb
6
+
7
+ == Configuration
8
+
9
+ == Note on Patches/Pull Requests
10
+
11
+ * Fork the project.
12
+ * Make your feature addition or bug fix.
13
+ * Add tests for it. This is important so I don't break it in a
14
+ future version unintentionally.
15
+ * Commit, do not mess with rakefile, version, or history.
16
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
17
+ * Send me a pull request. Bonus points for topic branches.
18
+
19
+ == Copyright
20
+
21
+ Copyright (c) 2010 Ramon Soares. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,54 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "lastrb"
8
+ gem.summary = "Another ruby library for last.fm webservices"
9
+ gem.description = "Another ruby library for last.fm webservices"
10
+ gem.email = "eu@ramonsoares.com"
11
+ gem.homepage = "http://github.com/ramon/lastrb"
12
+ gem.authors = ["Ramon Soares"]
13
+ gem.add_development_dependency "yard"
14
+ gem.add_dependency "httparty"
15
+ gem.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*", 'lib/jeweler/templates/.gitignore']
16
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
+ end
22
+
23
+ require 'rake/testtask'
24
+ Rake::TestTask.new(:test) do |test|
25
+ test.libs << 'lib' << 'test'
26
+ test.pattern = 'test/**/test_*.rb'
27
+ test.verbose = true
28
+ end
29
+
30
+ begin
31
+ require 'rcov/rcovtask'
32
+ Rcov::RcovTask.new do |test|
33
+ test.libs << 'test'
34
+ test.pattern = 'test/**/test_*.rb'
35
+ test.verbose = true
36
+ end
37
+ rescue LoadError
38
+ task :rcov do
39
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
40
+ end
41
+ end
42
+
43
+ task :test => :check_dependencies
44
+
45
+ task :default => :test
46
+
47
+ begin
48
+ require 'yard'
49
+ YARD::Rake::YardocTask.new
50
+ rescue LoadError
51
+ task :yardoc do
52
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
53
+ end
54
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,28 @@
1
+ module Lastrb
2
+ class Artist < Base
3
+ attr_accessor :artist
4
+ attr_accessor :username
5
+ @username = nil
6
+
7
+ def initialize(name)
8
+ self.artist = name
9
+ super
10
+ end
11
+
12
+ def get_info(query = {}, options={})
13
+ query.merge!({ :method => 'artist.getinfo', :artist => self.artist })
14
+ options.merge!({ :query => query})
15
+
16
+ self.class.get('/', options)
17
+ end
18
+
19
+ def search(query = {}, options={})
20
+ query.merge!({ :method => 'artist.search', :artist => self.artist })
21
+ options.merge!({ :query => query})
22
+
23
+ self.class.get('/', options)
24
+ end
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,12 @@
1
+ require 'httparty'
2
+
3
+ module Lastrb
4
+ class Base
5
+ include HTTParty
6
+
7
+ base_uri "http://ws.audioscrobbler.com/2.0"
8
+ default_params :format => 'json', :lang => Lastrb.lang, :api_key => Lastrb.key
9
+ format :json
10
+ debug_output $stderr
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module Lastrb
2
+ VERSION = '0.0.0'.freeze
3
+ end
data/lib/lastrb.rb ADDED
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+
3
+ module Lastrb
4
+ autoload :Base, 'lastrb/base'
5
+ autoload :Artist, 'lastrb/artist'
6
+
7
+ class << self
8
+
9
+ attr_accessor :lang
10
+ @lang = 'en'
11
+
12
+ attr_accessor :key
13
+ @key = nil
14
+
15
+ attr_accessor :secret
16
+ @secret = nil
17
+
18
+ def setup
19
+ yield self
20
+ end
21
+
22
+ protected
23
+ attr_accessor :session_key
24
+ @session_key = nil
25
+ end
26
+ end
27
+
data/test/helper.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ require 'lastrb'
7
+ require 'mocha'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,17 @@
1
+ require 'helper'
2
+
3
+ class TestLastrb < Test::Unit::TestCase
4
+ def test_set_valid_config
5
+ Lastrb::Config[:key] = "123465"
6
+ assert_equal Lastrb::Config[:key], "123465"
7
+ end
8
+
9
+ def test_set_invalid_config
10
+ Lastrb::Config[:not_fount] = "123456"
11
+ assert_nil Lastrb::Config[:not_found]
12
+ end
13
+
14
+ def test_get_invalid_config_return_nil
15
+ assert_nil Lastrb::Config[:test]
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lastrb
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
+ - Ramon Soares
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-08-09 00:00:00 -03:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: yard
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :development
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: httparty
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :runtime
45
+ version_requirements: *id002
46
+ description: Another ruby library for last.fm webservices
47
+ email: eu@ramonsoares.com
48
+ executables: []
49
+
50
+ extensions: []
51
+
52
+ extra_rdoc_files:
53
+ - LICENSE
54
+ - README.rdoc
55
+ files:
56
+ - Gemfile
57
+ - Gemfile.lock
58
+ - LICENSE
59
+ - README.rdoc
60
+ - Rakefile
61
+ - VERSION
62
+ - lib/lastrb.rb
63
+ - lib/lastrb/artist.rb
64
+ - lib/lastrb/base.rb
65
+ - lib/lastrb/version.rb
66
+ - test/helper.rb
67
+ - test/test_lastrb.rb
68
+ has_rdoc: true
69
+ homepage: http://github.com/ramon/lastrb
70
+ licenses: []
71
+
72
+ post_install_message:
73
+ rdoc_options:
74
+ - --charset=UTF-8
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ segments:
83
+ - 0
84
+ version: "0"
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ requirements: []
94
+
95
+ rubyforge_project:
96
+ rubygems_version: 1.3.7
97
+ signing_key:
98
+ specification_version: 3
99
+ summary: Another ruby library for last.fm webservices
100
+ test_files:
101
+ - test/helper.rb
102
+ - test/test_lastrb.rb