foaas-client 0.0.0 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0a23ada1b0746e38f8bd9193043ad0814ed200e2
4
+ data.tar.gz: 5ff1439e07fcee8aa1cb46b89d5e6577dd82a468
5
+ SHA512:
6
+ metadata.gz: 4a68ccdf4fc92ff705c82108ccdd5d016f21fc6dfdc34effa81a234bf3f26fb0062640ece308c8e4d16db777d8b9297d6b2b2889ced389c6e6c5d78eea3de14a
7
+ data.tar.gz: 2c27e49551364bf2055ffd8911a24f1b9a63b97bff8d4f430cc8ebf3adef55ac1ba3ade69253cbc63cee7cbc51011fc2ece3480e147e76f2a517ae8e82bfa8f2
data/CHANGELOG.md ADDED
@@ -0,0 +1,28 @@
1
+ # Changelog
2
+
3
+ ## v0.1.0
4
+
5
+ * Implement the following FOAAS methods:
6
+ * Outside
7
+ * Fascinating
8
+ * Raise `NoMethodError` if unsupported method is called on `Foaas::Client`
9
+ * Fix errors in README
10
+
11
+ ## v0.0.0
12
+
13
+ * Implement the following FOAAS methods:
14
+ * Everyone
15
+ * Everything
16
+ * Life
17
+ * Pink
18
+ * That
19
+ * This
20
+ * Chainsaw
21
+ * Donut
22
+ * King
23
+ * Linus
24
+ * Off
25
+ * Shakespeare
26
+ * Thanks
27
+ * You
28
+ * Thing
data/CHANGELOG.md~ ADDED
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+
3
+ ## v0.0.0
4
+
5
+ * Implement the following FOAAS methods
6
+ * Everyone
7
+ * Everything
8
+ * Life
9
+ * Pink
10
+ * That
11
+ * This
12
+ * Chainsaw
13
+ * Donut
14
+ * King
15
+ * Linus
16
+ * Off
17
+ * Shakespeare
18
+ * Thanks
19
+ * You
20
+ * Thing
data/README.md CHANGED
@@ -1,9 +1,5 @@
1
-
2
1
  # Foaas Client
3
2
 
4
- [![Build Status](https://travis-ci.org/petedmarsh/foaas-client.png)](https://travis-ci.org/petedmarsh/foaas-client)
5
- [![Code Climate](https://codeclimate.com/github/petedmarsh/foaas-client.png)](https://codeclimate.com/github/petedmarsh/foaas-client)
6
-
7
3
  A client for [FOAAS](http://foaas.com).
8
4
 
9
5
  ## API Version
@@ -14,96 +10,136 @@ Version `0.0.2` of the FOAAS API is supported.
14
10
 
15
11
  ### Basic Example
16
12
 
17
- require 'foaas-client'
13
+ ```ruby
14
+ require 'foaas-client'
18
15
 
19
- fuck = Foaas::Client.new
20
- fuck.off('Bob', 'Alice')
21
- #=> { 'message' => 'Fuck off, Bob.' 'subtitle' => '- Alice'}
16
+ fuck = Foaas::Client.new
17
+ fuck.off('Bob', 'Alice')
18
+ ```
22
19
 
23
20
  ### Response Types
24
21
 
25
- fuck.off('Bob', 'Alice', :json)
26
- #=> { 'message' => 'Fuck off, Bob.' 'subtitle' => '- Alice'}
22
+ ```ruby
23
+ fuck.off('Bob', 'Alice', :json)
24
+ #=> { 'message' => 'Fuck off, Bob.' 'subtitle' => '- Alice' }
27
25
 
28
- fuck.off('Bob', 'Alice', :text)
29
- #=> 'Fuck off, Bob. - Alice'
26
+ fuck.off('Bob', 'Alice', :text)
27
+ #=> 'Fuck off, Bob. - Alice'
30
28
 
31
- fuck.off('Bob', 'Alice', :html)
32
- #=> '<html>...</html>'
29
+ fuck.off('Bob', 'Alice', :html)
30
+ #=> '<html>...</html>'
31
+ ```
33
32
 
34
33
  ### Methods
35
34
 
36
35
  #### Everyone
37
36
 
38
- fuck.everyone('Alice')
39
- #=> { 'message' => 'Everyone can go and fuck off.', 'subtitle' => '- Alice'}
37
+ ```ruby
38
+ fuck.everyone('Alice')
39
+ #=> { 'message' => 'Everyone can go and fuck off.', 'subtitle' => '- Alice' }
40
+ ```
40
41
 
41
42
  #### Everything
42
43
 
43
- fuck.everything('Alice')
44
- #=> { 'message' => 'Fuck everything.', 'subtitle' => '- Alice'}
44
+ ```ruby
45
+ fuck.everything('Alice')
46
+ #=> { 'message' => 'Fuck everything.', 'subtitle' => '- Alice' }
47
+ ```
48
+
49
+ #### Fascinating
50
+
51
+ ```ruby
52
+ fuck.fascinating('Alice')
53
+ #=> { 'message' => 'Fascinating story, in what chapter do you shut the fuck up?', 'subtitle' => '- Alice' }
54
+ ```
45
55
 
46
56
  #### Life
47
57
 
48
- fuck.donut('Alice')
49
- #=> { 'message' => 'Fuck my life.', 'subtitle' => '- Alice'}
58
+ ```ruby
59
+ fuck.donut('Alice')
60
+ #=> { 'message' => 'Fuck my life.', 'subtitle' => '- Alice' }
61
+ ```
50
62
 
51
63
  #### Pink
52
64
 
53
- fuck.donut('Alice')
54
- #=> { 'message' => 'Well, Fuck me pink.', 'subtitle' => '- Alice'}
65
+ ```ruby
66
+ fuck.donut('Alice')
67
+ #=> { 'message' => 'Well, Fuck me pink.', 'subtitle' => '- Alice' }
68
+ ```
55
69
 
56
70
  #### That
57
71
 
58
- fuck.that('Alice')
59
- #=> { 'message' => 'Fuck that', 'subtitle' => '- Alice'}
72
+ ```ruby
73
+ fuck.that('Alice')
74
+ #=> { 'message' => 'Fuck that', 'subtitle' => '- Alice' }
75
+ ```
60
76
 
61
77
  #### This
62
78
 
63
- fuck.this('Alice')
64
- #=> { 'message' => 'Fuck this.', 'subtitle' => '- Alice'}
79
+ ```ruby
80
+ fuck.this(Alice')
81
+ #=> { 'message' => 'Fuck this.', 'subtitle' => '- Alice' }
82
+ ```
65
83
 
66
84
  #### Chainsaw
67
85
 
68
- fuck.chainsaw('Bob', 'Alice')
69
- #=> { 'message' => 'Fuck me gently with a chainsaw, Bob. Do I look like Mother Teresa?', 'subtitle' => '- Alice'}
86
+ ```ruby
87
+ fuck.chainsaw('Bob', 'Alice')
88
+ #=> { 'message' => 'Fuck me gently with a chainsaw, Bob. Do I look like Mother Teresa?', 'subtitle' => '- Alice' }
89
+ ```
70
90
 
71
91
  #### Donut
72
92
 
73
- fuck.donut('Bob', 'Alice')
74
- #=> { 'message' => 'Bob, go and take a flying fuck at a rolling donut.', 'subtitle' => '- Alice'}
93
+ ```ruby
94
+ fuck.donut('Bob', 'Alice')
95
+ #=> { 'message' => 'Bob, go and take a flying fuck at a rolling donut.', 'subtitle' => '- Alice' }
96
+ ```
75
97
 
76
98
  #### King
77
99
 
78
- fuck.king('Bob', 'Alice')
79
- #=> { 'message' => 'Oh fuck off, just really fuck off you total dickface. Christ Bob, you are fucking thick.', 'subtitle' => '- Alice'}
100
+ ```ruby
101
+ fuck.king('Bob', 'Alice')
102
+ #=> { 'message' => 'Oh fuck off, just really fuck off you total dickface. Christ Bob, you are fucking thick.', 'subtitle' => '- Alice' }
103
+ ```
80
104
 
81
105
  #### Linus
82
106
 
83
- fuck.linus('Bob', 'Alice')
84
- #=> { 'message' => 'Bob, there aren't enough swear-words in the English language, so now I'll have to call you perkeleen vittupää just to express my disgust and frustration with this crap.', 'subtitle' => '- Alice'}
107
+ ```ruby
108
+ fuck.linus('Bob', 'Alice')
109
+ #=> { 'message' => 'Bob, there aren't enough swear-words in the English language, so now I'll have to call you perkeleen vittupää just to express my disgust and frustration with this crap.', 'subtitle' => '- Alice' }
110
+ ```
85
111
 
86
112
  #### Off
87
113
 
88
- fuck.off('Bob', 'Alice')
89
- #=> { 'message' => 'Fuck off, Bob.', 'subtitle' => '- Alice'}
114
+ ```ruby
115
+ fuck.off('Bob', 'Alice')
116
+ #=> { 'message' => 'Fuck off, Bob.', 'subtitle' => '- Alice' }
117
+ ```
90
118
 
91
119
  #### Shakespeare
92
120
 
93
- fuck.shakespeare('Bob', 'Alice')
94
- #=> { 'message' => 'Thou clay-brained guts, thou knotty-pated fool, thou whoreson obscene greasy tallow-catch!', 'subtitle' => '- Alice'}
121
+ ```ruby
122
+ fuck.shakespeare('Bob', 'Alice')
123
+ #=> { 'message' => 'Thou clay-brained guts, thou knotty-pated fool, thou whoreson obscene greasy tallow-catch!', 'subtitle' => '- Alice' }
124
+ ```
95
125
 
96
126
  #### Thanks
97
127
 
98
- fuck.thanks('Bob', 'Alice')
99
- #=> { 'message' => 'Fuck you very much', 'subtitle' => '- Alice'}
128
+ ```ruby
129
+ fuck.thanks('Bob', 'Alice')
130
+ #=> { 'message' => 'Fuck you very much', 'subtitle' => '- Alice' }
131
+ ```
100
132
 
101
133
  #### You
102
134
 
103
- fuck.you('Bob', 'Alice')
104
- #=> { 'message' => 'Fuck you, Bob.', 'subtitle' => '- Alice'}
135
+ ```ruby
136
+ fuck.you('Bob', 'Alice')
137
+ #=> { 'message' => 'Fuck you, Bob.', 'subtitle' => '- Alice' }
138
+ ```
105
139
 
106
140
  #### Thing
107
141
 
108
- fuck.thing('it', 'Alice')
109
- #=> { 'message' => 'Fuck it.', 'subtitle' => '- Alice'}
142
+ ```ruby
143
+ fuck.thing('it', 'Alice')
144
+ #=> { 'message' => 'Fuck it.', 'subtitle' => '- Alice' }
145
+ ```
@@ -7,17 +7,25 @@ module Foaas
7
7
 
8
8
  URL = Addressable::Template.new("http://foaas.com/{method}{/name}/{from}")
9
9
 
10
- def method_missing(sym, *args)
11
- case sym
12
- when :off, :you, :donut, :shakespeare, :linus, :king, :chainsaw
10
+ METHODS_ONE_PARAM = [:this, :everything, :everyone, :pink, :life, :thanks, :flying, :fascinating]
11
+ METHODS_TWO_PARAMS = [:off, :you, :donut, :shakespeare, :linus, :king, :chainsaw, :outside]
12
+
13
+ def method_missing(sym, *args, &block)
14
+ if METHODS_TWO_PARAMS.include? sym
13
15
  make_request(URL.expand(method: sym, name: args[0], from: args[1]), args[2])
14
- when :this, :everything, :everyone, :pink, :life, :thanks, :flying
16
+ elsif METHODS_ONE_PARAM.include? sym
15
17
  make_request(URL.expand(method: sym, from: args[0]), args[1])
16
- when :thing
18
+ elsif sym == :thing
17
19
  make_request(URL.expand(method: args[0], from: args[1]), args[2])
20
+ else
21
+ super(sym, *args, &block)
18
22
  end
19
23
  end
20
24
 
25
+ def respond_to?(sym, include_private = false)
26
+ METHODS_ONE_PARAM.include?(sym) or METHODS_TWO_PARAMS.include?(sym) or sym == :thing or super(sym, include_private)
27
+ end
28
+
21
29
  private
22
30
 
23
31
  def make_request(url, type)
@@ -1,3 +1,3 @@
1
1
  module Foaas
2
- VERSION = '0.0.0'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -4,15 +4,19 @@ require 'foaas-client/client'
4
4
 
5
5
  describe Foaas::Client do
6
6
 
7
- let(:client) { Foaas::Client.new }
8
-
9
- before do
10
- RestClient.should_receive(:get).with(url, { accept: accept }).and_return('{ "message" : "", "subtitle" : ""}')
7
+ it 'raises an exception if a method is unsupported' do
8
+ expect { client.not_a_foaas_method }.to raise_error NoMethodError
11
9
  end
12
10
 
13
- [:off, :you, :donut, :shakespeare, :linus, :king, :chainsaw].each do |method|
11
+ let(:client) { Foaas::Client.new }
12
+
13
+ Foaas::Client::METHODS_TWO_PARAMS.each do |method|
14
14
  describe "##{method}" do
15
15
 
16
+ before do
17
+ RestClient.should_receive(:get).with(url, { accept: accept }).and_return('{ "message" : "", "subtitle" : ""}')
18
+ end
19
+
16
20
  let(:name) { 'name' }
17
21
  let(:from) { 'from' }
18
22
  let(:type) { nil }
@@ -63,7 +67,7 @@ describe Foaas::Client do
63
67
  let(:type) { :text }
64
68
  let(:accept) { 'text/plain' }
65
69
 
66
- it 'specifies application/json as the accept type' do
70
+ it 'specifies text/plain as the accept type' do
67
71
  client.send(method, name, from, type)
68
72
  end
69
73
  end
@@ -76,9 +80,13 @@ describe Foaas::Client do
76
80
  end
77
81
 
78
82
 
79
- [:this, :everything, :everyone, :pink, :life, :thanks, :flying].each do |method|
83
+ Foaas::Client::METHODS_ONE_PARAM.each do |method|
80
84
  describe "##{method}" do
81
85
 
86
+ before do
87
+ RestClient.should_receive(:get).with(url, { accept: accept }).and_return('{ "message" : "", "subtitle" : ""}')
88
+ end
89
+
82
90
  let(:url) { "http://foaas.com/#{method}/#{from}" }
83
91
  let(:from) { 'from' }
84
92
  let(:type) { nil }
@@ -127,7 +135,7 @@ describe Foaas::Client do
127
135
  let(:type) { :text }
128
136
  let(:accept) { 'text/plain'}
129
137
 
130
- it 'specifies application/json as the accept type' do
138
+ it 'specifies text/plain as the accept type' do
131
139
  client.send(method, from, type)
132
140
  end
133
141
  end
@@ -141,6 +149,10 @@ describe Foaas::Client do
141
149
 
142
150
  describe '#thing' do
143
151
 
152
+ before do
153
+ RestClient.should_receive(:get).with(url, { accept: accept }).and_return('{ "message" : "", "subtitle" : ""}')
154
+ end
155
+
144
156
  let(:url) { "http://foaas.com/#{thing}/#{from}" }
145
157
  let(:thing) { 'thing' }
146
158
  let(:from) { 'from' }
@@ -189,7 +201,7 @@ describe Foaas::Client do
189
201
  let(:type) { :text }
190
202
  let(:accept) { 'text/plain' }
191
203
 
192
- it 'specifies application/json as the accept type' do
204
+ it 'specifies text/plain as the accept type' do
193
205
  client.thing(thing, from, type)
194
206
  end
195
207
  end
@@ -200,4 +212,34 @@ describe Foaas::Client do
200
212
 
201
213
  end
202
214
 
215
+ describe '#respond_to?' do
216
+
217
+ let(:sym) { nil }
218
+
219
+ subject do
220
+ client.respond_to?(sym)
221
+ end
222
+
223
+ (Foaas::Client::METHODS_ONE_PARAM + Foaas::Client::METHODS_TWO_PARAMS + [:thing]).each do |method|
224
+
225
+ context "for :#{method}" do
226
+
227
+ let(:sym) { method }
228
+
229
+ it { should be_true }
230
+
231
+ end
232
+
233
+ context 'for non-FOAAS methods' do
234
+
235
+ let(:sym) { :not_a_foaas_method }
236
+
237
+ it { should be_false }
238
+
239
+ end
240
+
241
+ end
242
+
243
+ end
244
+
203
245
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foaas-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Peter Marsh
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-29 00:00:00.000000000 Z
11
+ date: 2013-08-11 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rest-client
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: addressable
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: bundler
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rake
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -100,6 +89,8 @@ extra_rdoc_files: []
100
89
  files:
101
90
  - .gitignore
102
91
  - .travis.yml
92
+ - CHANGELOG.md
93
+ - CHANGELOG.md~
103
94
  - Gemfile
104
95
  - LICENSE
105
96
  - README.md
@@ -113,33 +104,26 @@ files:
113
104
  homepage: http://github.com/petedmarsh/foaas-client
114
105
  licenses:
115
106
  - MIT
107
+ metadata: {}
116
108
  post_install_message:
117
109
  rdoc_options: []
118
110
  require_paths:
119
111
  - lib
120
112
  required_ruby_version: !ruby/object:Gem::Requirement
121
- none: false
122
113
  requirements:
123
- - - ! '>='
114
+ - - '>='
124
115
  - !ruby/object:Gem::Version
125
116
  version: '0'
126
- segments:
127
- - 0
128
- hash: 1217615916135071898
129
117
  required_rubygems_version: !ruby/object:Gem::Requirement
130
- none: false
131
118
  requirements:
132
- - - ! '>='
119
+ - - '>='
133
120
  - !ruby/object:Gem::Version
134
121
  version: '0'
135
- segments:
136
- - 0
137
- hash: 1217615916135071898
138
122
  requirements: []
139
123
  rubyforge_project:
140
- rubygems_version: 1.8.24
124
+ rubygems_version: 2.0.3
141
125
  signing_key:
142
- specification_version: 3
126
+ specification_version: 4
143
127
  summary: A client for FOAAS
144
128
  test_files:
145
129
  - spec/foaas-client/client_spec.rb