gracenote 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/lib/gracenote.rb +63 -0
  3. data/lib/gracenote/HTTP.rb +30 -0
  4. metadata +88 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 978a68be9df31b09d56f3a6e23809b547c842a63
4
+ data.tar.gz: bf5baaf385c0f8eb7ccb5b9863cad5fab1d220a9
5
+ SHA512:
6
+ metadata.gz: ecefd7a892b5b1e6023f1b87e65278247954860bac17a22761c544258adaafc8e9ad606de9192a1220f63cc7ad1d0bc6aeda321273004388cc16c0a99a63c1f7
7
+ data.tar.gz: 2b5f880d963145ca8a30b93ea09a39d9b748dabe55ddb0861bc0a8cc9542ead9382680b750554c5f027ff5e2f3a2e2da44e13beac7a851c981020e3e6f283d27
@@ -0,0 +1,63 @@
1
+ require "gracenote/version"
2
+ require "gracenote/HTTP"
3
+
4
+ class Gracenote << HTTP
5
+ def initialize (spec)
6
+ if(spec[:clientID].nil? || !(defined spec[:clientID] || spec[:clientID] == ""))
7
+ p "clientID cannot be nil"
8
+ return
9
+ end
10
+ if(spec[:clientTag].nil? || !(defined spec[:clientTag] || spec[:clientTag] == ""))
11
+ p "clientTag cannot be nil"
12
+ end
13
+
14
+ @clientID = spec[:clientID]
15
+ @clientTag = spec[:clientTag]
16
+ @userID = spec[:userID]
17
+ @apiURL = "https://" + @clientID + ".web.cddbp.net/webapi/xml/1.0/"
18
+ end
19
+
20
+ public
21
+ def registerUser (clientID = nil)
22
+ if(clientID.nil?)
23
+ clientID = @clientID + "-" + @clientTag
24
+ end
25
+
26
+ if(!(@userID.nil?) || defined @userID)
27
+ p "user already registered. No need to register again"
28
+ return @userID
29
+ end
30
+ #send req to server and get user ID
31
+ return @userID
32
+ end
33
+
34
+ def findTrack
35
+ end
36
+
37
+ def findAlbum
38
+ end
39
+
40
+ def findArtist
41
+ end
42
+
43
+ protected
44
+ #execute a query on gracenote webapi
45
+ def api (query)
46
+
47
+ end
48
+
49
+ def constructQueryReq
50
+ #construct the XML query
51
+ end
52
+
53
+ def constructQueryBody
54
+ end
55
+
56
+ def checkRES
57
+ end
58
+
59
+ def parseRES
60
+ end
61
+
62
+ end
63
+
@@ -0,0 +1,30 @@
1
+ #
2
+ # HTTP class for Gracenote
3
+ #
4
+ # Used to send get/post request to the webapi
5
+ #
6
+ require 'curb'
7
+ require 'rake'
8
+
9
+ class HTTP
10
+ def self.get(path, data='', cookie='')
11
+ uri = URI(path)
12
+ req = Net::HTTP.new(uri.host, uri.port)
13
+ req.use_ssl = (uri.scheme == "https") ? true : false
14
+
15
+ reqdata = Rack::Utils.build_nested_query(data)
16
+ resp = req.get( uri.path, reqdata, headers)
17
+ return resp
18
+ end
19
+
20
+ def self.post(path, data='', cookie='')
21
+ uri = URI(path)
22
+ req = Net::HTTP.new(uri.host, uri.port)
23
+ req.use_ssl = (uri.scheme == "https") ? true : false
24
+
25
+ reqdata = Rack::Utils.build_nested_query(data)
26
+ resp = req.request_post( uri.path, reqdata, headers)
27
+ return resp
28
+ end
29
+
30
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gracenote
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - nobelium
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: curb
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Gracenote web api gem
56
+ email:
57
+ - me@vignesh.info
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - lib/gracenote.rb
63
+ - lib/gracenote/HTTP.rb
64
+ homepage: ''
65
+ licenses:
66
+ - MIT
67
+ metadata: {}
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 2.0.3
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: This gem is a wrapper for the gracenote web api
88
+ test_files: []