party_cc 0.0.4 → 0.0.5
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.
- checksums.yaml +8 -8
- data/README.md +1 -1
- data/lib/party_cc/httparty.rb +16 -11
- data/lib/party_cc/version.rb +1 -1
- data/lib/party_cc.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjZkYTQzZTIxNzA5NDk3MTQ2NjU3MmJjY2QxY2E5M2M1Y2U5MmNhNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Yjc3NzIxZmQ4YTYyZjg5YmFiM2ZhMDIzMTg0NjlhZjY4Nzc1M2QwYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWNjYWFlODA1ODAwZjE1N2Q5ZTAyZDExMWQwN2UwZTcxMmFmN2RjYmU2ZTky
|
10
|
+
NGJkYTUwNThjN2ZhMDdjNTkyYjU2OGI5NDQxMmY4NTY3NTQ3ZDJhODQwNmRm
|
11
|
+
Nzk5NTZkMmU1M2I3ODljMzg3ZjA4MGNlYjY3YjE1YjNlNTNlYWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDcwMWFlYzFlNjZlZDhkYzhkNzgwNzY1NzIyNDlhMWY2ZGI1ZjAyYjkwMGI1
|
14
|
+
OTE0ZDgzODEyYzUwNmY4NDcyYmM2NDM0YTg2OGM0ODNkODEzYmZiMmZkZTVi
|
15
|
+
ZGNlNzM2NWViMTkxMDRlOGZjNzRiNmU1NWFiMzg4YjJiMTBlNjM=
|
data/README.md
CHANGED
@@ -23,7 +23,7 @@ Just require gem and it will generate two files.
|
|
23
23
|
require 'party_cc'
|
24
24
|
```
|
25
25
|
|
26
|
-
The stub_request will be written down to disk in the format 'stub_#{method}\_#{path}\_#{timestamp}.txt'
|
26
|
+
The stub_request will be written down to disk in the format 'stub_#{method}\_#{path}\_#{timestamp}.txt'
|
27
27
|
The request response will be written down to disk in the format 'response_#{method}\_#{path}\_#{timestamp}.txt'
|
28
28
|
|
29
29
|
## Contributing
|
data/lib/party_cc/httparty.rb
CHANGED
@@ -1,15 +1,24 @@
|
|
1
1
|
module HTTParty
|
2
2
|
class << self
|
3
|
-
def decode_ruby buffer
|
4
|
-
buffer.string
|
5
|
-
.gsub('=>', ': ')
|
6
|
-
.gsub('nil', 'null')
|
7
|
-
end
|
8
3
|
|
9
4
|
def generate_stub method, response_filename, url, params
|
10
5
|
%Q|stub_request(:#{method}, '#{url}')
|
11
6
|
.with(#{params})
|
12
|
-
.to_return('#{response_filename}')|
|
7
|
+
.to_return(File.new('#{response_filename}'))|
|
8
|
+
end
|
9
|
+
|
10
|
+
def pp_body body
|
11
|
+
buffer = StringIO.new
|
12
|
+
|
13
|
+
jsonified = JSON.load body
|
14
|
+
PP.pp(jsonified, buffer)
|
15
|
+
|
16
|
+
buffer
|
17
|
+
rescue
|
18
|
+
xmldoc = REXML::Document.new body
|
19
|
+
xmldoc.write buffer
|
20
|
+
|
21
|
+
buffer
|
13
22
|
end
|
14
23
|
|
15
24
|
request_methods = ['get', 'post', 'patch', 'put', 'delete', 'head', 'options']
|
@@ -27,11 +36,7 @@ module HTTParty
|
|
27
36
|
base_file_name = "#{method}_\#{path}_\#{stmp}.txt"
|
28
37
|
response_file_name = "response_\#{base_file_name}"
|
29
38
|
|
30
|
-
|
31
|
-
|
32
|
-
PP.pp(rsp, rsp_buffer)
|
33
|
-
|
34
|
-
prettied_rsp = decode_ruby rsp_buffer
|
39
|
+
prettied_rsp = pp_body(rsp.response.body).string
|
35
40
|
|
36
41
|
File.write("stub_\#{base_file_name}", generate_stub(:#{method}, response_file_name, *args))
|
37
42
|
File.open(response_file_name, 'w') do |f|
|
data/lib/party_cc/version.rb
CHANGED
data/lib/party_cc.rb
CHANGED