foaas-client 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/CHANGELOG.md +8 -0
- data/README.md +22 -1
- data/lib/foaas-client/client.rb +29 -7
- data/lib/foaas-client/version.rb +1 -1
- data/spec/foaas-client/client_spec.rb +89 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MzhlNzE3NDczZDY4Yzc3OWNlNjc1MWQxZmUzMTFjY2Y1YjIwYTg2Yw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MTE3MmJiNjUzMjM2MGFlZDVlZmM1YTEzOWNjYTMyMWZiYTRkZDNhNQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YTI0YTI4OWUyOTllZTNhYjRlMWRhZTI2MjcwMzU1Zjg1ZTJkYWY1ZjhjODg2
|
10
|
+
OTUwNWRhYTNiOTBkNWVhMDcwNTM0OTBiOWZlMTk4MGFlYmI5ZjZlOWZkODM4
|
11
|
+
OTdlODhkYzExZjIzMzc2NGZlZmVhNDQ3ZWMyZWViNWVkMjA2NzM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MmRkMWRhOGY1ZGFhNWNjN2E3N2YxMzI0YTRiOWQ4ZTAzMTc2ODAxZjBjYWZm
|
14
|
+
MTQ3OGIxNDZlZGVhNjkxZmI4NjJlZjdhZjZkMGMyOWIxM2E0MGNkYTliYzhj
|
15
|
+
NDJhZTI4N2I1MmZkOWQ0MmM4MWY0YzRmNjRlYWNhOGZlYjRlZGY=
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v1.2.0
|
4
|
+
|
5
|
+
* Implement the following FOAAS methods:
|
6
|
+
* Dalton
|
7
|
+
* Refactor the way the JSONP callback parameter is added to the FOAAS url
|
8
|
+
* Add support for i18n parameter
|
9
|
+
* Add support for shoutcloud parameter
|
10
|
+
|
3
11
|
## v1.1.0
|
4
12
|
|
5
13
|
* Fix example for JSONP response type (typo: `\` instead of `"`)
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ A client for [FOAAS](http://foaas.com).
|
|
7
7
|
|
8
8
|
## API Version
|
9
9
|
|
10
|
-
Version `0.1.
|
10
|
+
Version `0.1.4` of the FOAAS API is supported.
|
11
11
|
|
12
12
|
## Usage
|
13
13
|
|
@@ -20,6 +20,13 @@ fuck = Foaas::Client.new
|
|
20
20
|
fuck.off('Bob', 'Alice')
|
21
21
|
```
|
22
22
|
|
23
|
+
### i18n
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
fuck.off('Bob', 'Alice', i18n: :es)
|
27
|
+
#=> { 'message': 'Vete a la mierda, Bob.', 'subtitle': '-Alice' }
|
28
|
+
```
|
29
|
+
|
23
30
|
### Response Types
|
24
31
|
|
25
32
|
```ruby
|
@@ -39,6 +46,13 @@ fuck.off('Bob', 'Alice', :xml)
|
|
39
46
|
#=> '<?xml version="1.0" encoding="utf-8"?>...'
|
40
47
|
```
|
41
48
|
|
49
|
+
### Shoutcloud
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
fuck.off('Bob', 'Alice', shoutcloud: true)
|
53
|
+
#=> { 'message': 'FUCK OFF, BOB', 'subtitle': '- ALICE' }
|
54
|
+
```
|
55
|
+
|
42
56
|
### Methods
|
43
57
|
|
44
58
|
### Awesome
|
@@ -97,6 +111,13 @@ fuck.cool('Alice')
|
|
97
111
|
#=> { 'message' => 'Cool story, Bro', '- Alice' }
|
98
112
|
```
|
99
113
|
|
114
|
+
### Dalton
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
fuck.dalton('Bob', 'Alice')
|
118
|
+
#=> { 'msessage' => 'Bob: A fucking problem solving super-hero', 'subtitle' => '- Alice' }
|
119
|
+
```
|
120
|
+
|
100
121
|
#### Diabetes
|
101
122
|
|
102
123
|
```ruby
|
data/lib/foaas-client/client.rb
CHANGED
@@ -8,18 +8,20 @@ module Foaas
|
|
8
8
|
URL = Addressable::Template.new("http://foaas.com/{method}{/name}/{from}{/other}")
|
9
9
|
|
10
10
|
METHODS_ONE_PARAM = [:awesome, :because, :bye, :cool, :diabetes, :everyone, :everything, :fascinating, :flying, :life, :pink, :thanks, :this, :what]
|
11
|
-
METHODS_TWO_PARAMS = [:bus, :donut, :caniuse, :chainsaw, :king, :linus, :madison, :nugget, :off, :outside, :shakespeare, :you, :xmas, :yoda]
|
11
|
+
METHODS_TWO_PARAMS = [:bus, :donut, :caniuse, :chainsaw, :dalton, :king, :linus, :madison, :nugget, :off, :outside, :shakespeare, :you, :xmas, :yoda]
|
12
12
|
METHODS_THREE_PARAMS = [:ballmer, :field]
|
13
13
|
|
14
14
|
def method_missing(sym, *args, &block)
|
15
|
+
kwargs = {}
|
16
|
+
kwargs = args[-1] if args[-1].class == Hash
|
15
17
|
if METHODS_TWO_PARAMS.include? sym
|
16
|
-
make_request(URL.expand(method: sym, name: args[0], from: args[1]), args[2])
|
18
|
+
make_request(URL.expand(method: sym, name: args[0], from: args[1]), args[2], i18n=kwargs[:i18n], shoutcloud=kwargs[:shoutcloud])
|
17
19
|
elsif METHODS_ONE_PARAM.include? sym
|
18
|
-
make_request(URL.expand(method: sym, from: args[0]), args[1])
|
20
|
+
make_request(URL.expand(method: sym, from: args[0]), args[1], i18n=kwargs[:i18n], shoutcloud=kwargs[:shoutcloud])
|
19
21
|
elsif METHODS_THREE_PARAMS.include? sym
|
20
|
-
make_request(URL.expand(method: sym, name: args[0], from: args[1], other: args[2]), args[3])
|
22
|
+
make_request(URL.expand(method: sym, name: args[0], from: args[1], other: args[2]), args[3], i18n=kwargs[:i18n], shoutcloud=kwargs[:shoutcloud])
|
21
23
|
elsif sym == :thing
|
22
|
-
make_request(URL.expand(method: args[0], from: args[1]), args[2])
|
24
|
+
make_request(URL.expand(method: args[0], from: args[1]), args[2], i18n=kwargs[:i18n], shoutcloud=kwargs[:shoutcloud])
|
23
25
|
else
|
24
26
|
super(sym, *args, &block)
|
25
27
|
end
|
@@ -39,7 +41,8 @@ module Foaas
|
|
39
41
|
|
40
42
|
private
|
41
43
|
|
42
|
-
def make_request(url, type)
|
44
|
+
def make_request(url, type, i18n=nil, shoutcloud=false)
|
45
|
+
query_params = {}
|
43
46
|
url = url.to_s
|
44
47
|
accept_type = case type
|
45
48
|
when nil
|
@@ -47,11 +50,30 @@ module Foaas
|
|
47
50
|
when :text
|
48
51
|
'text/plain'
|
49
52
|
when :jsonp
|
50
|
-
|
53
|
+
query_params['callback'] = 'fuck'
|
51
54
|
:json
|
52
55
|
else
|
53
56
|
type
|
54
57
|
end
|
58
|
+
|
59
|
+
if i18n
|
60
|
+
query_params['i18n'] = i18n
|
61
|
+
end
|
62
|
+
|
63
|
+
if shoutcloud
|
64
|
+
query_params['shoutcloud'] = nil
|
65
|
+
end
|
66
|
+
|
67
|
+
if not query_params.empty?
|
68
|
+
url += '?' + query_params.map do |k,v|
|
69
|
+
if v
|
70
|
+
"#{k}=#{v}"
|
71
|
+
else
|
72
|
+
k.to_s
|
73
|
+
end
|
74
|
+
end.join('&')
|
75
|
+
end
|
76
|
+
|
55
77
|
response = RestClient.get url, { accept: accept_type }
|
56
78
|
response = JSON.parse(response) if type.nil?
|
57
79
|
response
|
data/lib/foaas-client/version.rb
CHANGED
@@ -24,6 +24,28 @@ describe Foaas::Client do
|
|
24
24
|
|
25
25
|
let(:url) { "http://foaas.com/#{method}/#{name}/#{from}/#{other}" }
|
26
26
|
|
27
|
+
context 'i18n specified' do
|
28
|
+
let(:accept) { :json }
|
29
|
+
let(:i18n) { 'es' }
|
30
|
+
|
31
|
+
let(:url) { "http://foaas.com/#{method}/#{name}/#{from}/#{other}?i18n=es" }
|
32
|
+
|
33
|
+
it 'sets the i18n parameter on the url' do
|
34
|
+
client.send(method, name, from, other, type, i18n: i18n)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'shoutcloud specified' do
|
39
|
+
let(:accept) { :json }
|
40
|
+
let(:shoutcloud) { true }
|
41
|
+
|
42
|
+
let(:url) { "http://foaas.com/#{method}/#{name}/#{from}/#{other}?shoutcloud" }
|
43
|
+
|
44
|
+
it 'sets the shoutcloud parameter on the url' do
|
45
|
+
client.send(method, name, from, other, type, shoutcloud: true)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
27
49
|
context 'type is' do
|
28
50
|
|
29
51
|
context 'not specified' do
|
@@ -117,6 +139,28 @@ describe Foaas::Client do
|
|
117
139
|
|
118
140
|
let(:url) { "http://foaas.com/#{method}/#{name}/#{from}" }
|
119
141
|
|
142
|
+
context 'i18n specified' do
|
143
|
+
let(:accept) { :json }
|
144
|
+
let(:i18n) { 'es' }
|
145
|
+
|
146
|
+
let(:url) { "http://foaas.com/#{method}/#{name}/#{from}?i18n=es" }
|
147
|
+
|
148
|
+
it 'sets the i18n parameter on the url' do
|
149
|
+
client.send(method, name, from, type, i18n: i18n)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
context 'shoutcloud specified' do
|
154
|
+
let(:accept) { :json }
|
155
|
+
let(:shoutcloud) { true }
|
156
|
+
|
157
|
+
let(:url) { "http://foaas.com/#{method}/#{name}/#{from}?shoutcloud" }
|
158
|
+
|
159
|
+
it 'sets the shoutcloud parameter on the url' do
|
160
|
+
client.send(method, name, from, type, shoutcloud: true)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
120
164
|
context 'type is' do
|
121
165
|
|
122
166
|
context 'not specified' do
|
@@ -207,6 +251,28 @@ describe Foaas::Client do
|
|
207
251
|
let(:from) { 'from' }
|
208
252
|
let(:type) { nil }
|
209
253
|
|
254
|
+
context 'i18n specified' do
|
255
|
+
let(:accept) { :json }
|
256
|
+
let(:i18n) { 'es' }
|
257
|
+
|
258
|
+
let(:url) { "http://foaas.com/#{method}/#{from}?i18n=es" }
|
259
|
+
|
260
|
+
it 'sets the i18n parameter on the url' do
|
261
|
+
client.send(method, from, type, i18n: i18n)
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
context 'shoutcloud specified' do
|
266
|
+
let(:accept) { :json }
|
267
|
+
let(:shoutcloud) { true }
|
268
|
+
|
269
|
+
let(:url) { "http://foaas.com/#{method}/#{from}?shoutcloud" }
|
270
|
+
|
271
|
+
it 'sets the shoutcloud parameter on the url' do
|
272
|
+
client.send(method, from, type, shoutcloud: true)
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
210
276
|
context 'type is' do
|
211
277
|
|
212
278
|
context 'not specified' do
|
@@ -294,6 +360,29 @@ describe Foaas::Client do
|
|
294
360
|
let(:from) { 'from' }
|
295
361
|
let(:type) { nil }
|
296
362
|
|
363
|
+
context 'i18n specified' do
|
364
|
+
let(:accept) { :json }
|
365
|
+
let(:i18n) { 'es' }
|
366
|
+
|
367
|
+
let(:url) { "http://foaas.com/#{thing}/#{from}?i18n=es" }
|
368
|
+
|
369
|
+
it 'sets the i18n parameter on the url' do
|
370
|
+
client.thing(thing, from, type, i18n: i18n)
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
|
375
|
+
context 'shoutcloud specified' do
|
376
|
+
let(:accept) { :json }
|
377
|
+
let(:shoutcloud) { true }
|
378
|
+
|
379
|
+
let(:url) { "http://foaas.com/#{thing}/#{from}?shoutcloud" }
|
380
|
+
|
381
|
+
it 'sets the shoutcloud parameter on the url' do
|
382
|
+
client.thing(thing, from, type, shoutcloud: true)
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
297
386
|
context 'type is' do
|
298
387
|
|
299
388
|
context 'not specified' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foaas-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Marsh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -110,17 +110,17 @@ require_paths:
|
|
110
110
|
- lib
|
111
111
|
required_ruby_version: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
|
-
- - '>='
|
113
|
+
- - ! '>='
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
117
|
requirements:
|
118
|
-
- - '>='
|
118
|
+
- - ! '>='
|
119
119
|
- !ruby/object:Gem::Version
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.4.3
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: A client for FOAAS
|