rdio 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/lib/rdio.rb +1 -0
  2. data/lib/rdio/api.rb +8 -8
  3. data/lib/rdio/call.rb +102 -0
  4. metadata +5 -4
data/lib/rdio.rb CHANGED
@@ -13,6 +13,7 @@ require 'rdio/api'
13
13
  require 'rdio/oauth'
14
14
  require 'rdio/datatypes'
15
15
  require 'rdio/types'
16
+ require 'rdio/call' #TODO
16
17
 
17
18
  module Rdio
18
19
  VERSION = '0.0.1'
data/lib/rdio/api.rb CHANGED
@@ -230,14 +230,14 @@ module Rdio
230
230
  method = 'getTopCharts'
231
231
  cls = TODO
232
232
  case type
233
- when 'Artist':
234
- cls = Artist
235
- when 'Album':
236
- cls = Album
237
- when 'Track':
238
- cls = Track
239
- when 'Playlist':
240
- cls = Playlist
233
+ when 'Artist'
234
+ cls = Artist
235
+ when 'Album'
236
+ cls = Album
237
+ when 'Track'
238
+ cls = Track
239
+ when 'Playlist'
240
+ cls = Playlist
241
241
  end
242
242
  args = {:type=>type}
243
243
  return_object cls,method,args
data/lib/rdio/call.rb ADDED
@@ -0,0 +1,102 @@
1
+ module Rdio
2
+
3
+ class Call
4
+
5
+ def real_main(argv)
6
+
7
+ # Check the command line for the key,secret,etc...
8
+ args = []
9
+ while true
10
+ arg = argv.shift
11
+ break if not arg
12
+ case arg
13
+ when '--consumer-key'
14
+ key = argv.shift
15
+ when '-h','--help'
16
+ print_help
17
+ return 0
18
+ when '--consumer-secret'
19
+ secret = argv.shift
20
+ when '--authenticate'
21
+ authenticate = true
22
+ when '-i','--indent'
23
+ indent = true
24
+ else
25
+ args << arg
26
+ end
27
+ end
28
+
29
+ # Look in the environment if not key or consumer token were given on
30
+ # the command line
31
+ key = ENV['RDIO_KEY'] if not key
32
+ secret = ENV['RDIO_SECRET'] if not secret
33
+
34
+ if not key
35
+ STDERR.puts 'consumer key required'
36
+ return 1
37
+ end
38
+
39
+ if not secret
40
+ STDERR.puts 'consumer secret required'
41
+ return 1
42
+ end
43
+
44
+ if args.length < 1
45
+ STDERR.puts 'method name required'
46
+ return 1
47
+ end
48
+
49
+ base = Rdio::BaseApi.new key,secret
50
+ method = args.shift
51
+ rdio_args = {}
52
+ args.each do |str|
53
+ parts = str.split /\=/
54
+ key = parts[0]
55
+ val = parts.length == 1 ? true : parts[1]
56
+ rdio_args[key] = val
57
+ end
58
+
59
+ res = base.call method,rdio_args,authenticate
60
+ if indent
61
+ begin
62
+ require 'rubygems'
63
+ require 'json'
64
+ json = JSON.parse res
65
+ return JSON.pretty_generate json
66
+ rescue Exception => e
67
+ STDERR.puts e
68
+ STDERR.puts 'You must install the json gem to use the indent \'feature\''
69
+ return res
70
+ end
71
+ else
72
+ return res
73
+ end
74
+
75
+ end
76
+
77
+ def main(args)
78
+ res = real_main args
79
+ return res if res.is_a? Fixnum
80
+ puts res
81
+ return 0
82
+ end
83
+
84
+ private
85
+
86
+ def print_help
87
+ STDERR.puts <<HERE
88
+ Usage: #{File.basename $0} options? method [key=val]?
89
+ where options include
90
+ --consumer-key str Use the key for authentication
91
+ --consumer-secret str Use the secret for authentication
92
+ --authentication Use two-legged authentication
93
+ --indent || -i Indent the output
94
+ --help || -h Print this message
95
+ and
96
+ - method is the name of the REST method to call
97
+ - key=value are argument pairs to pass
98
+ HERE
99
+ end
100
+ end
101
+
102
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdio
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 7
10
- version: 0.0.7
9
+ - 8
10
+ version: 0.0.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeffrey Palm
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-25 00:00:00 -04:00
18
+ date: 2011-04-10 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -52,6 +52,7 @@ files:
52
52
  - lib/rdio/base.rb
53
53
  - lib/rdio/datatypes.rb
54
54
  - lib/rdio/types.rb
55
+ - lib/rdio/call.rb
55
56
  has_rdoc: true
56
57
  homepage: http://github.com/spudtrooper/rdiorb
57
58
  licenses: []