wadl 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README +1 -1
  2. data/lib/wadl/cli.rb +23 -14
  3. data/lib/wadl/version.rb +1 -1
  4. metadata +3 -3
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to wadl version 0.2.0
5
+ This documentation refers to wadl version 0.2.1
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -26,6 +26,7 @@
26
26
 
27
27
  require 'optparse'
28
28
  require 'yaml'
29
+ require 'cgi'
29
30
  require 'highline'
30
31
  require 'stringio'
31
32
  require 'wadl'
@@ -51,7 +52,7 @@ module WADL
51
52
  :authorize_url => '%s/oauth/authorize'
52
53
  }
53
54
 
54
- OPTION_RE = %r{\A--?(\w+)}
55
+ OPTION_RE = %r{\A--?(.+?)(?:=(.+))?\z}
55
56
  RESOURCE_PATH_RE = %r{[. /]}
56
57
 
57
58
  def self.execute(*args)
@@ -104,8 +105,8 @@ module WADL
104
105
 
105
106
  def resource
106
107
  @resource ||= begin
107
- path = [options[:api_base], *resource_path].compact.join('/')
108
- path.split(RESOURCE_PATH_RE).inject(api) { |m, n| m.send(:find_resource_by_path, n) }
108
+ path = [options[:api_base], *resource_path].compact.join('/').split(RESOURCE_PATH_RE)
109
+ path.inject(api) { |m, n| m.send(:find_resource_by_path, n) } or abort "Resource not found: #{path.join('/')}"
109
110
  end
110
111
  end
111
112
 
@@ -143,23 +144,25 @@ module WADL
143
144
  end
144
145
 
145
146
  def parse_arguments(arguments)
146
- @resource_path, @opts, skip = [], {}, false
147
+ @resource_path, @opts, skip_next = [], {}, false
148
+ @opts.update(options[:query]) if options[:query]
147
149
 
148
150
  arguments.each_with_index { |arg, index|
149
- if skip
150
- skip = false
151
+ if skip_next
152
+ skip_next = false
151
153
  next
152
154
  end
153
155
 
154
- case arg
155
- when OPTION_RE
156
- key, value = $1, arguments[index + 1]
157
-
158
- value =~ OPTION_RE ? value = '1' : skip = true
159
-
160
- opts[key] = value
156
+ if arg =~ OPTION_RE
157
+ key, value, next_arg = $1, $2, arguments[index + 1]
158
+ opts[key] = value || if next_arg =~ OPTION_RE
159
+ '1' # "true"
161
160
  else
162
- resource_path << arg
161
+ skip_next = true
162
+ next_arg
163
+ end
164
+ else
165
+ resource_path << arg
163
166
  end
164
167
  }
165
168
  end
@@ -248,6 +251,12 @@ module WADL
248
251
  options[:api_base] = api_base
249
252
  }
250
253
 
254
+ opts.on('-q', '--query QUERY', "Query string to pass to request") { |query|
255
+ options[:query] = CGI.parse(query).inject({}) { |params, (key, values)|
256
+ params[key] = values.last; params
257
+ }
258
+ }
259
+
251
260
  opts.separator ''
252
261
 
253
262
  opts.on('--skip-auth', "Skip any authentication") {
@@ -4,7 +4,7 @@ module WADL
4
4
 
5
5
  MAJOR = 0
6
6
  MINOR = 2
7
- TINY = 0
7
+ TINY = 1
8
8
 
9
9
  class << self
10
10
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wadl
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Leonard Richardson