wadl 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/Rakefile +4 -8
- data/{examples → example}/README +0 -0
- data/{examples → example}/YahooSearch.rb +0 -0
- data/{examples → example}/YahooSearch.wadl +0 -0
- data/{examples → example}/config.yaml +0 -0
- data/{examples → example}/crummy.rb +0 -0
- data/{examples → example}/crummy.wadl +0 -0
- data/{examples → example}/delicious.rb +0 -0
- data/{examples → example}/delicious.wadl +0 -0
- data/{examples → example}/yahoo.rb +0 -0
- data/{examples → example}/yahoo.wadl +0 -0
- data/lib/wadl/cli.rb +44 -9
- data/lib/wadl/version.rb +1 -1
- data/test/{test_wadl.rb → wadl_test.rb} +0 -0
- metadata +23 -26
data/README
CHANGED
data/Rakefile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require %q{lib/wadl/version}
|
1
|
+
require File.expand_path(%q{../lib/wadl/version}, __FILE__)
|
2
2
|
|
3
3
|
begin
|
4
4
|
require 'hen'
|
@@ -10,14 +10,10 @@ begin
|
|
10
10
|
:summary => %q{Ruby client for the Web Application Description Language.},
|
11
11
|
:authors => ['Leonard Richardson', 'Jens Wille'],
|
12
12
|
:email => ['leonardr@segfault.org', 'jens.wille@uni-koeln.de'],
|
13
|
-
:homepage =>
|
14
|
-
:files => FileList['lib/**/*.rb'].to_a,
|
15
|
-
:extra_files => FileList['[A-Z]*', 'examples/*', 'test/**/*.rb', 'bin/*'].to_a,
|
13
|
+
:homepage => :blackwinter,
|
16
14
|
:dependencies => %w[rest-open-uri mime-types]
|
17
15
|
}
|
18
16
|
}}
|
19
|
-
rescue LoadError
|
20
|
-
|
17
|
+
rescue LoadError => err
|
18
|
+
warn "Please install the `hen' gem. (#{err})"
|
21
19
|
end
|
22
|
-
|
23
|
-
### Place your custom Rake tasks here.
|
data/{examples → example}/README
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/wadl/cli.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# #
|
4
4
|
# A component of wadl, the super cheap Ruby WADL client. #
|
5
5
|
# #
|
6
|
-
# Copyright (C) 2010 Jens Wille
|
6
|
+
# Copyright (C) 2010-2011 Jens Wille #
|
7
7
|
# #
|
8
8
|
# Authors: #
|
9
9
|
# Jens Wille <jens.wille@uni-koeln.de> #
|
@@ -34,7 +34,7 @@ require 'wadl'
|
|
34
34
|
begin
|
35
35
|
require 'oauth/cli'
|
36
36
|
rescue LoadError
|
37
|
-
warn "For OAuth support, install the
|
37
|
+
warn "For OAuth support, install the `oauth' library."
|
38
38
|
end
|
39
39
|
|
40
40
|
module WADL
|
@@ -52,8 +52,11 @@ module WADL
|
|
52
52
|
:authorize_url => '%s/oauth/authorize'
|
53
53
|
}
|
54
54
|
|
55
|
-
OPTION_RE
|
56
|
-
RESOURCE_PATH_RE
|
55
|
+
OPTION_RE = %r{\A--?(.+?)(?:=(.+))?\z}
|
56
|
+
RESOURCE_PATH_RE = %r{[. /]}
|
57
|
+
QUERY_SEPARATOR_RE = %r{[&;]}n
|
58
|
+
ARRAY_SUFFIX_RE = %r{\[\]\z}
|
59
|
+
HASH_SUFFIX_RE = %r{\[(.+)\]\z}
|
57
60
|
|
58
61
|
def self.execute(*args)
|
59
62
|
new.execute(*args)
|
@@ -155,18 +158,52 @@ module WADL
|
|
155
158
|
|
156
159
|
if arg =~ OPTION_RE
|
157
160
|
key, value, next_arg = $1, $2, arguments[index + 1]
|
158
|
-
|
161
|
+
|
162
|
+
add_param(opts, key, value || if next_arg =~ OPTION_RE
|
159
163
|
'1' # "true"
|
160
164
|
else
|
161
165
|
skip_next = true
|
162
166
|
next_arg
|
163
|
-
end
|
167
|
+
end)
|
164
168
|
else
|
165
169
|
resource_path << arg
|
166
170
|
end
|
167
171
|
}
|
168
172
|
end
|
169
173
|
|
174
|
+
def parse_query(query)
|
175
|
+
params = {}
|
176
|
+
|
177
|
+
query.split(QUERY_SEPARATOR_RE).each { |pair|
|
178
|
+
add_param(params, *pair.split('=', 2).map { |v| CGI.unescape(v) })
|
179
|
+
}
|
180
|
+
|
181
|
+
params
|
182
|
+
end
|
183
|
+
|
184
|
+
def add_param(params, key, value)
|
185
|
+
case key
|
186
|
+
when HASH_SUFFIX_RE
|
187
|
+
sub = $1
|
188
|
+
|
189
|
+
if (param = params[key]).is_a?(Hash)
|
190
|
+
param[sub] = value
|
191
|
+
return
|
192
|
+
else
|
193
|
+
value = { sub => value }
|
194
|
+
end
|
195
|
+
when ARRAY_SUFFIX_RE
|
196
|
+
if (param = params[key]).is_a?(Array)
|
197
|
+
param << value
|
198
|
+
return
|
199
|
+
else
|
200
|
+
value = [value]
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
params[key] = value
|
205
|
+
end
|
206
|
+
|
170
207
|
def basic_auth_resource
|
171
208
|
user, pass = options.values_at(:user, :password)
|
172
209
|
pass ||= ask("Password for user #{user}: ") { |q| q.echo = false }
|
@@ -252,9 +289,7 @@ module WADL
|
|
252
289
|
}
|
253
290
|
|
254
291
|
opts.on('-q', '--query QUERY', "Query string to pass to request") { |query|
|
255
|
-
options[:query] =
|
256
|
-
params[key] = values.last; params
|
257
|
-
}
|
292
|
+
options[:query] = parse_query(query)
|
258
293
|
}
|
259
294
|
|
260
295
|
opts.separator ''
|
data/lib/wadl/version.rb
CHANGED
File without changes
|
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:
|
5
|
-
prerelease:
|
4
|
+
hash: 19
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Leonard Richardson
|
@@ -16,8 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date:
|
20
|
-
default_executable:
|
19
|
+
date: 2011-04-26 00:00:00 Z
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
23
22
|
name: rest-open-uri
|
@@ -56,9 +55,9 @@ executables:
|
|
56
55
|
extensions: []
|
57
56
|
|
58
57
|
extra_rdoc_files:
|
58
|
+
- README
|
59
59
|
- COPYING
|
60
60
|
- ChangeLog
|
61
|
-
- README
|
62
61
|
files:
|
63
62
|
- lib/wadl.rb
|
64
63
|
- lib/wadl/resource_and_address.rb
|
@@ -86,37 +85,35 @@ files:
|
|
86
85
|
- lib/wadl/response_format.rb
|
87
86
|
- lib/wadl/cheap_schema.rb
|
88
87
|
- lib/wadl/resources.rb
|
88
|
+
- bin/wadl
|
89
89
|
- README
|
90
90
|
- ChangeLog
|
91
91
|
- Rakefile
|
92
92
|
- TODO
|
93
93
|
- COPYING
|
94
|
-
-
|
95
|
-
-
|
96
|
-
-
|
97
|
-
-
|
98
|
-
-
|
99
|
-
-
|
100
|
-
-
|
101
|
-
-
|
102
|
-
-
|
103
|
-
-
|
104
|
-
- test/
|
105
|
-
- bin/wadl
|
106
|
-
has_rdoc: true
|
94
|
+
- example/yahoo.wadl
|
95
|
+
- example/README
|
96
|
+
- example/YahooSearch.rb
|
97
|
+
- example/crummy.rb
|
98
|
+
- example/yahoo.rb
|
99
|
+
- example/crummy.wadl
|
100
|
+
- example/delicious.wadl
|
101
|
+
- example/config.yaml
|
102
|
+
- example/YahooSearch.wadl
|
103
|
+
- example/delicious.rb
|
104
|
+
- test/wadl_test.rb
|
107
105
|
homepage: http://github.com/blackwinter/wadl
|
108
106
|
licenses: []
|
109
107
|
|
110
108
|
post_install_message:
|
111
109
|
rdoc_options:
|
112
|
-
- --line-numbers
|
113
|
-
- --main
|
114
|
-
- README
|
115
|
-
- --inline-source
|
116
110
|
- --charset
|
117
111
|
- UTF-8
|
118
112
|
- --title
|
119
|
-
- wadl Application documentation
|
113
|
+
- wadl Application documentation (v0.2.2)
|
114
|
+
- --main
|
115
|
+
- README
|
116
|
+
- --line-numbers
|
120
117
|
- --all
|
121
118
|
require_paths:
|
122
119
|
- lib
|
@@ -141,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
138
|
requirements: []
|
142
139
|
|
143
140
|
rubyforge_project:
|
144
|
-
rubygems_version: 1.
|
141
|
+
rubygems_version: 1.7.2
|
145
142
|
signing_key:
|
146
143
|
specification_version: 3
|
147
144
|
summary: Ruby client for the Web Application Description Language.
|