next-big-sound 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,56 @@
2
2
 
3
3
  This is the start of a ruby api wrapper for nextbigsound.com. This gem will provide a reasonable ruby wrapper for all methods in the public API.
4
4
 
5
+ This code was written by jeff at musicxray.com if you think you can do better send us and email and we can chat about job opportunities.
6
+
7
+ <b>installation:</b>
8
+
9
+ gem install xml-simple
10
+
11
+ gem install next-big-sound
12
+
13
+ <b>usage:</b>
14
+
15
+ require 'rubygems'
16
+ require 'next-big-sound'
17
+
18
+ nbs = NBS::Base.new('YOUR_API_KEY')
19
+
20
+ searchobj = nbs.search("The Killers")
21
+
22
+ # retrieve list of artists that returned from the search
23
+ searchobj.artists
24
+
25
+ # get the id of the artist
26
+ searchobj.artists.first.artist_id # can be useful to store for later use.
27
+
28
+ # get the first artist that you find and find
29
+ # all associated profiles. myspace, ilike ....
30
+
31
+ profiles = searchobj.artists.first.profiles
32
+
33
+ # get the url for a specific service
34
+
35
+ profiles["MYSPACE"]
36
+
37
+ # in addition. There is are magic method for retrieving data
38
+ # if you want myspace plays for example you would get it like this
39
+
40
+ artist = searchobj.artists.first
41
+
42
+ # this will fetch you a month worth of myspace plays data
43
+ artist.myspace_plays("1/1/2010","2/1/2010")
44
+
45
+ # this will find all fans for a particular artist across all
46
+ # services.
47
+ artist.all_fans("1/1/2010","2/1/2010")
48
+
49
+ # The data points are returned as an array of datasets
50
+ # One dataset per profile Datasets can be sorted by date
51
+
52
+ # TODO: this stuff is still be implemented.
53
+
54
+
5
55
  == Note on Patches/Pull Requests
6
56
 
7
57
  * Fork the project.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -32,12 +32,9 @@ module NBS
32
32
 
33
33
  def method_missing(method_name,*args)
34
34
  if splits = method_name.to_s.split("_")
35
- puts args.inspect
36
35
  sdate = Date.parse(args[0].to_s)
37
36
  edate = Date.parse(args[1].to_s)
38
37
  opts = options.merge({"service"=>splits[0],"metric"=>splits[1],"start"=>sdate.to_s,"end"=>edate.to_s})
39
- puts opts.inspect
40
- puts "http://api.nextbigsound.com/v1_1/getDataForArtist?#{opts.to_url_params}"
41
38
  return Net::HTTP.get(URI.parse("#{NBS::NBS_CONFIG["base_url"]}getDataForArtist?#{opts.to_url_params}")).to_s
42
39
  else
43
40
  raise "Sorry that method does not exist. The proper format for finding data is service_metric(start,end)"
@@ -13,22 +13,19 @@ module NBS
13
13
  self.api_key = api_key
14
14
  self.base_url = base_url
15
15
  end
16
-
17
16
  def fetch
18
17
  self.xml=Net::HTTP.get(URI.parse("#{NBS::NBS_CONFIG["base_url"]}search?#{self.options.to_url_params}")).to_s
19
18
  end
20
-
21
19
  def artists
22
- hash = Hash.from_xml(self.xml)
20
+ hash = Hash.from_xml(self.to_xml)
23
21
  a = []
24
22
  hash["Results"][0]["Result"].each do |item|
25
23
  a << Artist.new(item["NBSArtistID"][0],item["NBSArtistName"][0])
26
24
  end
27
25
  return a
28
26
  end
29
-
30
27
  def to_xml
31
- self.xml
28
+ self.xml ||=fetch
32
29
  end
33
30
  end
34
31
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{next-big-sound}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["jeff durand"]
12
- s.date = %q{2010-03-26}
12
+ s.date = %q{2010-03-27}
13
13
  s.description = %q{A simple wrapper class for the Next Big Sound api. docs for the api can be found at api.nextbigsound.com}
14
14
  s.email = %q{jeff.durand@gmail.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - jeff durand
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-26 00:00:00 -04:00
17
+ date: 2010-03-27 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency