party_cc 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/party_cc/httparty.rb +19 -16
- data/lib/party_cc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjIwY2NjMDRmOGQxYzExYTZiZjk0YzUyNTVhZDFmNWRhOTliZmNhNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjE0N2RjY2MwYzIyNTViZTY5MjA1MWY2ODdmMjgxZmYwODM2M2VhZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjBiMTY2ZjFjMGUyOWY2MzAwODhmNDNhNzJhNWJhNjQ0MDc2NjI2MTEyMTI5
|
10
|
+
NzZmYmFiOTRmMGUyNzVhOTIzMWZiNGExMTY3MWRkY2E0YWE0ZjVjNjk3YzUx
|
11
|
+
Mzc0MDIyOGQyNDE5ZjdhNzc2OGJmY2FjNDRmNzkxMzNmNTdiZWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Y2MyYTQ2YjMzNzI0MzhjNDg1YjRmMDllNzRmN2IzODBjM2IyMDgyMGVhNDM4
|
14
|
+
OGZkZjE2YWRkYTEzYjIzNmJmNTE3YWY5ZDI1YmNhODRlNDNkZDg1YzYwOTMz
|
15
|
+
NDE3OTUxMmQ0MDM1ODQyYWY2YzA5M2QxNGZkZGU4ZmE5OGQ4Y2I=
|
data/lib/party_cc/httparty.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module HTTParty
|
2
2
|
class << self
|
3
3
|
|
4
|
-
def generate_stub
|
4
|
+
def generate_stub(method, response_filename, url, params={})
|
5
5
|
%Q|stub_request(:#{method}, '#{url}')
|
6
6
|
.with(#{params})
|
7
7
|
.to_return(File.new('#{response_filename}'))|
|
@@ -11,19 +11,22 @@ module HTTParty
|
|
11
11
|
buffer.string
|
12
12
|
.gsub('=>', ': ')
|
13
13
|
.gsub('nil', 'null')
|
14
|
+
rescue
|
15
|
+
buffer
|
14
16
|
end
|
15
17
|
|
16
|
-
def pp_body
|
18
|
+
def pp_body(body, type)
|
17
19
|
buffer = StringIO.new
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
case
|
21
|
+
when type.downcase.include?('json')
|
22
|
+
jsonified = JSON.load body
|
23
|
+
PP.pp(jsonified, buffer)
|
24
|
+
when type.downcase.include?('xml')
|
25
|
+
xmldoc = REXML::Document.new(body)
|
26
|
+
xmldoc.write(buffer)
|
27
|
+
else
|
28
|
+
PP.pp(body, buffer)
|
29
|
+
end
|
27
30
|
|
28
31
|
buffer
|
29
32
|
end
|
@@ -52,14 +55,14 @@ module HTTParty
|
|
52
55
|
base_file_name = "#{method}_\#{path}_\#{stmp}.txt"
|
53
56
|
response_file_name = "response_\#{base_file_name}"
|
54
57
|
|
55
|
-
prettied_rsp = decode_ruby(pp_body(rsp.response.body))
|
56
|
-
adjusted_headers = adjust_content_length_for_pretty_print
|
58
|
+
prettied_rsp = decode_ruby(pp_body(rsp.response.body, rsp.headers['content-type']))
|
59
|
+
adjusted_headers = adjust_content_length_for_pretty_print(prettied_rsp, rsp)
|
57
60
|
|
58
|
-
File.write("stub_\#{base_file_name}", generate_stub(:#{method}, response_file_name, *args))
|
59
61
|
File.open(response_file_name, 'w') do |f|
|
60
|
-
f.write
|
61
|
-
f.write
|
62
|
+
f.write(adjusted_headers)
|
63
|
+
f.write(prettied_rsp)
|
62
64
|
end
|
65
|
+
File.write("stub_\#{base_file_name}", generate_stub(:#{method}, response_file_name, *args))
|
63
66
|
|
64
67
|
rsp
|
65
68
|
end
|
data/lib/party_cc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: party_cc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- barberj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|