ruby-resty 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -190,6 +190,14 @@ ruby-resty --alias nyan
190
190
 
191
191
  Don't forget to run the tests with `rake`
192
192
 
193
+ # License
194
+
195
+ Copyright (c) 2013 Austen Ito
196
+
197
+ Ruby-Resty is released under the [MIT License][4]
198
+
193
199
  [1]: https://github.com/micha/resty
194
200
  [2]: https://github.com/pry/pry
195
201
  [3]: https://github.com/pry/pry/wiki/Custom-commands
202
+ [4]: http://opensource.org/licenses/MIT
203
+
data/lib/resty/request.rb CHANGED
@@ -28,7 +28,7 @@ module Resty
28
28
  options[:url] = url
29
29
  options[:user] = global_options.username if global_options.username
30
30
  options[:password] = global_options.password if global_options.password
31
- options[:payload] = data if Resty::Request.data_required?(method)
31
+ options[:payload] = JSON.dump(data) if Resty::Request.data_required?(method)
32
32
  end
33
33
  end
34
34
 
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Resty
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/ruby-resty.gemspec CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |gem|
14
14
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
15
  gem.require_paths = ['lib']
16
16
  gem.executables << 'ruby-resty'
17
+ gem.license = 'MIT'
17
18
 
18
19
  gem.add_dependency 'active_support'
19
20
  gem.add_dependency 'hashie'
@@ -38,7 +38,7 @@ describe Resty::Request do
38
38
  it "creates resource" do
39
39
  RestClient::Request.should have_received(:new).with(url: "foo.com/api/merchants",
40
40
  method: "post",
41
- payload: {"foo" => "bar"},
41
+ payload: JSON.dump({"foo" => "bar"}),
42
42
  headers: {header: "value"})
43
43
  end
44
44
 
@@ -111,8 +111,8 @@ describe "method_command", :vcr do
111
111
  @result.request.headers.should eq(name: "nyaaa", color: "green")
112
112
  end
113
113
 
114
- it "returns 200" do
115
- @result.response.code.should eq(200)
114
+ it "returns 201" do
115
+ @result.response.code.should eq(201)
116
116
  end
117
117
 
118
118
  it "returns created object" do
data/spec/server.rb CHANGED
@@ -23,11 +23,13 @@ options '/api/nyan' do
23
23
  end
24
24
 
25
25
  put '/api/nyan' do
26
+ JSON.parse(request.body.read)
26
27
  [204]
27
28
  end
28
29
 
29
30
  post '/api/nyan' do
30
- JSON.dump(params)
31
+ data = JSON.parse(request.body.read)
32
+ [201, JSON.dump(data)]
31
33
  end
32
34
 
33
35
  patch '/api/nyan' do
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://nyan:cat@localhost:4567/api/nyan
5
+ uri: http://localhost:4567/api/nyan
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: nyan=cat
@@ -19,69 +19,71 @@ http_interactions:
19
19
  - Ruby
20
20
  response:
21
21
  status:
22
- code: 200
23
- message: "OK "
22
+ code: 401
23
+ message: "Unauthorized "
24
24
  headers:
25
25
  Content-Type:
26
- - text/html;charset=utf-8
26
+ - text/plain
27
27
  Content-Length:
28
- - "14"
29
- X-Xss-Protection:
30
- - 1; mode=block
28
+ - "0"
29
+ Www-Authenticate:
30
+ - Basic realm=""
31
31
  X-Content-Type-Options:
32
32
  - nosniff
33
- X-Frame-Options:
34
- - SAMEORIGIN
35
33
  Server:
36
34
  - WEBrick/1.3.1 (Ruby/1.9.3/2012-04-20)
37
35
  Date:
38
- - Sun, 07 Jul 2013 19:42:37 GMT
36
+ - Sun, 07 Jul 2013 19:43:10 GMT
39
37
  Connection:
40
38
  - Keep-Alive
41
39
  body:
42
40
  encoding: US-ASCII
43
- string: "{\"nyan\":\"cat\"}"
41
+ string: ""
44
42
  http_version:
45
- recorded_at: Sun, 07 Jul 2013 19:42:37 GMT
43
+ recorded_at: Sun, 07 Jul 2013 19:43:10 GMT
46
44
  - request:
47
45
  method: post
48
- uri: http://localhost:4567/api/nyan
46
+ uri: http://nyan:cat@localhost:4567/api/nyan
49
47
  body:
50
- encoding: US-ASCII
51
- string: nyan=cat
48
+ encoding: UTF-8
49
+ string: "{\"nyan\":\"cat\"}"
52
50
  headers:
53
51
  Accept:
54
52
  - "*/*; q=0.5, application/xml"
55
53
  Accept-Encoding:
56
54
  - gzip, deflate
55
+ Name:
56
+ - nyaaa
57
+ Color:
58
+ - green
57
59
  Content-Length:
58
- - "8"
59
- Content-Type:
60
- - application/x-www-form-urlencoded
60
+ - "14"
61
61
  User-Agent:
62
62
  - Ruby
63
63
  response:
64
64
  status:
65
- code: 401
66
- message: "Unauthorized "
65
+ code: 201
66
+ message: "Created "
67
67
  headers:
68
68
  Content-Type:
69
- - text/plain
69
+ - text/html;charset=utf-8
70
70
  Content-Length:
71
71
  - "0"
72
- Www-Authenticate:
73
- - Basic realm=""
72
+ X-Xss-Protection:
73
+ - 1; mode=block
74
74
  X-Content-Type-Options:
75
75
  - nosniff
76
+ X-Frame-Options:
77
+ - SAMEORIGIN
76
78
  Server:
77
79
  - WEBrick/1.3.1 (Ruby/1.9.3/2012-04-20)
78
80
  Date:
79
- - Sun, 07 Jul 2013 19:43:10 GMT
81
+ - Sat, 13 Jul 2013 01:25:43 GMT
80
82
  Connection:
81
83
  - Keep-Alive
82
84
  body:
83
85
  encoding: US-ASCII
84
86
  string: ""
85
87
  http_version:
86
- recorded_at: Sun, 07 Jul 2013 19:43:10 GMT
88
+ recorded_at: Sat, 13 Jul 2013 01:25:43 GMT
87
89
  recorded_with: VCR 2.5.0
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://nyan:cat@localhost:4567/api/nyan
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{\"nyan\":\"cat\"}"
9
+ headers:
10
+ Accept:
11
+ - "*/*; q=0.5, application/xml"
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Name:
15
+ - nyaaa
16
+ Color:
17
+ - green
18
+ Content-Length:
19
+ - "14"
20
+ User-Agent:
21
+ - Ruby
22
+ response:
23
+ status:
24
+ code: 201
25
+ message: "Created "
26
+ headers:
27
+ Content-Type:
28
+ - text/html;charset=utf-8
29
+ Content-Length:
30
+ - "14"
31
+ X-Xss-Protection:
32
+ - 1; mode=block
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ X-Frame-Options:
36
+ - SAMEORIGIN
37
+ Server:
38
+ - WEBrick/1.3.1 (Ruby/1.9.3/2012-04-20)
39
+ Date:
40
+ - Sat, 13 Jul 2013 01:28:32 GMT
41
+ Connection:
42
+ - Keep-Alive
43
+ body:
44
+ encoding: US-ASCII
45
+ string: "{\"nyan\":\"cat\"}"
46
+ http_version:
47
+ recorded_at: Sat, 13 Jul 2013 01:28:32 GMT
48
+ recorded_with: VCR 2.5.0
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://nyan:cat@localhost:4567/api/nyan
5
+ uri: http://localhost:4567/api/nyan
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: nyan=cat
@@ -19,69 +19,71 @@ http_interactions:
19
19
  - Ruby
20
20
  response:
21
21
  status:
22
- code: 200
23
- message: "OK "
22
+ code: 401
23
+ message: "Unauthorized "
24
24
  headers:
25
25
  Content-Type:
26
- - text/html;charset=utf-8
26
+ - text/plain
27
27
  Content-Length:
28
- - "14"
29
- X-Xss-Protection:
30
- - 1; mode=block
28
+ - "0"
29
+ Www-Authenticate:
30
+ - Basic realm=""
31
31
  X-Content-Type-Options:
32
32
  - nosniff
33
- X-Frame-Options:
34
- - SAMEORIGIN
35
33
  Server:
36
34
  - WEBrick/1.3.1 (Ruby/1.9.3/2012-04-20)
37
35
  Date:
38
- - Sun, 07 Jul 2013 19:42:37 GMT
36
+ - Sun, 07 Jul 2013 19:43:10 GMT
39
37
  Connection:
40
38
  - Keep-Alive
41
39
  body:
42
40
  encoding: US-ASCII
43
- string: "{\"nyan\":\"cat\"}"
41
+ string: ""
44
42
  http_version:
45
- recorded_at: Sun, 07 Jul 2013 19:42:37 GMT
43
+ recorded_at: Sun, 07 Jul 2013 19:43:10 GMT
46
44
  - request:
47
45
  method: post
48
- uri: http://localhost:4567/api/nyan
46
+ uri: http://nyan:cat@localhost:4567/api/nyan
49
47
  body:
50
- encoding: US-ASCII
51
- string: nyan=cat
48
+ encoding: UTF-8
49
+ string: "{\"nyan\":\"cat\"}"
52
50
  headers:
53
51
  Accept:
54
52
  - "*/*; q=0.5, application/xml"
55
53
  Accept-Encoding:
56
54
  - gzip, deflate
55
+ Name:
56
+ - nyaaa
57
+ Color:
58
+ - green
57
59
  Content-Length:
58
- - "8"
59
- Content-Type:
60
- - application/x-www-form-urlencoded
60
+ - "14"
61
61
  User-Agent:
62
62
  - Ruby
63
63
  response:
64
64
  status:
65
- code: 401
66
- message: "Unauthorized "
65
+ code: 201
66
+ message: "Created "
67
67
  headers:
68
68
  Content-Type:
69
- - text/plain
69
+ - text/html;charset=utf-8
70
70
  Content-Length:
71
- - "0"
72
- Www-Authenticate:
73
- - Basic realm=""
71
+ - "14"
72
+ X-Xss-Protection:
73
+ - 1; mode=block
74
74
  X-Content-Type-Options:
75
75
  - nosniff
76
+ X-Frame-Options:
77
+ - SAMEORIGIN
76
78
  Server:
77
79
  - WEBrick/1.3.1 (Ruby/1.9.3/2012-04-20)
78
80
  Date:
79
- - Sun, 07 Jul 2013 19:43:10 GMT
81
+ - Sat, 13 Jul 2013 01:28:32 GMT
80
82
  Connection:
81
83
  - Keep-Alive
82
84
  body:
83
85
  encoding: US-ASCII
84
- string: ""
86
+ string: "{\"nyan\":\"cat\"}"
85
87
  http_version:
86
- recorded_at: Sun, 07 Jul 2013 19:43:10 GMT
88
+ recorded_at: Sat, 13 Jul 2013 01:28:32 GMT
87
89
  recorded_with: VCR 2.5.0
@@ -4,8 +4,8 @@ http_interactions:
4
4
  method: post
5
5
  uri: http://nyan:cat@localhost:4567/api/nyan
6
6
  body:
7
- encoding: US-ASCII
8
- string: nyan=cat
7
+ encoding: UTF-8
8
+ string: "{\"nyan\":\"cat\"}"
9
9
  headers:
10
10
  Accept:
11
11
  - "*/*; q=0.5, application/xml"
@@ -16,15 +16,13 @@ http_interactions:
16
16
  Color:
17
17
  - green
18
18
  Content-Length:
19
- - "8"
20
- Content-Type:
21
- - application/x-www-form-urlencoded
19
+ - "14"
22
20
  User-Agent:
23
21
  - Ruby
24
22
  response:
25
23
  status:
26
- code: 200
27
- message: "OK "
24
+ code: 201
25
+ message: "Created "
28
26
  headers:
29
27
  Content-Type:
30
28
  - text/html;charset=utf-8
@@ -39,12 +37,12 @@ http_interactions:
39
37
  Server:
40
38
  - WEBrick/1.3.1 (Ruby/1.9.3/2012-04-20)
41
39
  Date:
42
- - Mon, 08 Jul 2013 15:08:52 GMT
40
+ - Sat, 13 Jul 2013 01:28:32 GMT
43
41
  Connection:
44
42
  - Keep-Alive
45
43
  body:
46
44
  encoding: US-ASCII
47
45
  string: "{\"nyan\":\"cat\"}"
48
46
  http_version:
49
- recorded_at: Mon, 08 Jul 2013 15:08:52 GMT
47
+ recorded_at: Sat, 13 Jul 2013 01:28:32 GMT
50
48
  recorded_with: VCR 2.5.0
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: put
5
- uri: http://nyan:cat@localhost:4567/api/nyan
5
+ uri: http://localhost:4567/api/nyan
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: nyan=cat
@@ -19,61 +19,63 @@ http_interactions:
19
19
  - Ruby
20
20
  response:
21
21
  status:
22
- code: 204
23
- message: "No Content "
22
+ code: 401
23
+ message: "Unauthorized "
24
24
  headers:
25
+ Content-Type:
26
+ - text/plain
27
+ Content-Length:
28
+ - "0"
29
+ Www-Authenticate:
30
+ - Basic realm=""
25
31
  X-Content-Type-Options:
26
32
  - nosniff
27
33
  Server:
28
34
  - WEBrick/1.3.1 (Ruby/1.9.3/2012-04-20)
29
35
  Date:
30
- - Sun, 07 Jul 2013 19:42:37 GMT
36
+ - Sun, 07 Jul 2013 19:43:10 GMT
31
37
  Connection:
32
- - close
38
+ - Keep-Alive
33
39
  body:
34
40
  encoding: US-ASCII
35
41
  string: ""
36
42
  http_version:
37
- recorded_at: Sun, 07 Jul 2013 19:42:37 GMT
43
+ recorded_at: Sun, 07 Jul 2013 19:43:10 GMT
38
44
  - request:
39
45
  method: put
40
- uri: http://localhost:4567/api/nyan
46
+ uri: http://nyan:cat@localhost:4567/api/nyan
41
47
  body:
42
- encoding: US-ASCII
43
- string: nyan=cat
48
+ encoding: UTF-8
49
+ string: "{\"nyan\":\"cat\"}"
44
50
  headers:
45
51
  Accept:
46
52
  - "*/*; q=0.5, application/xml"
47
53
  Accept-Encoding:
48
54
  - gzip, deflate
55
+ Name:
56
+ - nyaaa
57
+ Color:
58
+ - green
49
59
  Content-Length:
50
- - "8"
51
- Content-Type:
52
- - application/x-www-form-urlencoded
60
+ - "14"
53
61
  User-Agent:
54
62
  - Ruby
55
63
  response:
56
64
  status:
57
- code: 401
58
- message: "Unauthorized "
65
+ code: 204
66
+ message: "No Content "
59
67
  headers:
60
- Content-Type:
61
- - text/plain
62
- Content-Length:
63
- - "0"
64
- Www-Authenticate:
65
- - Basic realm=""
66
68
  X-Content-Type-Options:
67
69
  - nosniff
68
70
  Server:
69
71
  - WEBrick/1.3.1 (Ruby/1.9.3/2012-04-20)
70
72
  Date:
71
- - Sun, 07 Jul 2013 19:43:10 GMT
73
+ - Sat, 13 Jul 2013 01:28:32 GMT
72
74
  Connection:
73
- - Keep-Alive
75
+ - close
74
76
  body:
75
77
  encoding: US-ASCII
76
78
  string: ""
77
79
  http_version:
78
- recorded_at: Sun, 07 Jul 2013 19:43:10 GMT
80
+ recorded_at: Sat, 13 Jul 2013 01:28:32 GMT
79
81
  recorded_with: VCR 2.5.0
@@ -4,8 +4,8 @@ http_interactions:
4
4
  method: put
5
5
  uri: http://nyan:cat@localhost:4567/api/nyan
6
6
  body:
7
- encoding: US-ASCII
8
- string: nyan=cat
7
+ encoding: UTF-8
8
+ string: "{\"nyan\":\"cat\"}"
9
9
  headers:
10
10
  Accept:
11
11
  - "*/*; q=0.5, application/xml"
@@ -16,9 +16,7 @@ http_interactions:
16
16
  Color:
17
17
  - green
18
18
  Content-Length:
19
- - "8"
20
- Content-Type:
21
- - application/x-www-form-urlencoded
19
+ - "14"
22
20
  User-Agent:
23
21
  - Ruby
24
22
  response:
@@ -31,12 +29,12 @@ http_interactions:
31
29
  Server:
32
30
  - WEBrick/1.3.1 (Ruby/1.9.3/2012-04-20)
33
31
  Date:
34
- - Mon, 08 Jul 2013 15:08:57 GMT
32
+ - Sat, 13 Jul 2013 01:28:32 GMT
35
33
  Connection:
36
34
  - close
37
35
  body:
38
36
  encoding: US-ASCII
39
37
  string: ""
40
38
  http_version:
41
- recorded_at: Mon, 08 Jul 2013 15:08:57 GMT
39
+ recorded_at: Sat, 13 Jul 2013 01:28:32 GMT
42
40
  recorded_with: VCR 2.5.0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-resty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-10 00:00:00.000000000 Z
12
+ date: 2013-07-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: active_support
@@ -322,13 +322,15 @@ files:
322
322
  - spec/vcr/method_command/patch_returns_204.yml
323
323
  - spec/vcr/method_command/patch_sends_headers.yml
324
324
  - spec/vcr/method_command/post_returns_200.yml
325
+ - spec/vcr/method_command/post_returns_201.yml
325
326
  - spec/vcr/method_command/post_returns_created_object.yml
326
327
  - spec/vcr/method_command/post_sends_headers.yml
327
328
  - spec/vcr/method_command/put_returns_204.yml
328
329
  - spec/vcr/method_command/put_sends_headers.yml
329
330
  - templates/ruby_resty.yml
330
331
  homepage: ''
331
- licenses: []
332
+ licenses:
333
+ - MIT
332
334
  post_install_message:
333
335
  rdoc_options: []
334
336
  require_paths:
@@ -380,6 +382,7 @@ test_files:
380
382
  - spec/vcr/method_command/patch_returns_204.yml
381
383
  - spec/vcr/method_command/patch_sends_headers.yml
382
384
  - spec/vcr/method_command/post_returns_200.yml
385
+ - spec/vcr/method_command/post_returns_201.yml
383
386
  - spec/vcr/method_command/post_returns_created_object.yml
384
387
  - spec/vcr/method_command/post_sends_headers.yml
385
388
  - spec/vcr/method_command/put_returns_204.yml