herdic 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/herdic.rb +3 -1
- data/lib/herdic/client.rb +18 -13
- data/lib/herdic/printer.rb +1 -1
- data/lib/herdic/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76bb219a1e205279d9c5fe7ea6387d028e6f7d61
|
4
|
+
data.tar.gz: 26bfb9573646e1fef72de5d946fff6d118fa3746
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 954aa0df95280a8232b542a714895a453a9d2a0919a2637692e1b0df668561ec7809bfeec58d8c85f88cbc8c0e20996a8f5c920c8ee69c7cc6516699c12af942
|
7
|
+
data.tar.gz: 0d969818ec0da955b19b4086d3aded6dfb691eb081bbaa868e71f060b99d83e8edd6fbaa6995fc3e015b3c880a8d058dfe860e5de2d1ac5325379bacb916e1f5
|
data/lib/herdic.rb
CHANGED
@@ -16,7 +16,8 @@ module Herdic
|
|
16
16
|
:herdic_path,
|
17
17
|
:store_path,
|
18
18
|
:edit_request_file,
|
19
|
-
:config_filename
|
19
|
+
:config_filename,
|
20
|
+
:editor
|
20
21
|
|
21
22
|
def initialize
|
22
23
|
@pwd = File.expand_path '.'
|
@@ -24,6 +25,7 @@ module Herdic
|
|
24
25
|
@store_path = File.join @herdic_path, 'store'
|
25
26
|
@edit_request_file = File.join @herdic_path, 'edit_request.yaml'
|
26
27
|
@config_filename = 'herdic.yaml'
|
28
|
+
@editor = '/usr/bin/env vim'
|
27
29
|
end
|
28
30
|
|
29
31
|
end
|
data/lib/herdic/client.rb
CHANGED
@@ -42,7 +42,7 @@ module Herdic
|
|
42
42
|
def run_all
|
43
43
|
if @options['e']
|
44
44
|
FileUtils.cp @file, Herdic.edit_request_file
|
45
|
-
system "
|
45
|
+
system "%s '%s'" % [Herdic.editor, Herdic.edit_request_file]
|
46
46
|
|
47
47
|
@specs = Loader.new Herdic.edit_request_file, @file
|
48
48
|
else
|
@@ -64,11 +64,27 @@ module Herdic
|
|
64
64
|
private def run(spec)
|
65
65
|
setup_spec spec
|
66
66
|
|
67
|
+
@printer.title @meta
|
68
|
+
@printer.request @header, @body
|
69
|
+
|
70
|
+
response = get_response
|
71
|
+
|
72
|
+
body = response.body
|
73
|
+
|
74
|
+
if 'application/json' == response.content_type
|
75
|
+
body = JSON.parse body
|
76
|
+
register response, body
|
77
|
+
end
|
78
|
+
|
79
|
+
@printer.response response, body
|
80
|
+
end
|
81
|
+
|
82
|
+
private def get_response
|
67
83
|
uri = URI.parse @meta['endpoint']
|
68
84
|
http = Net::HTTP.new uri.host, uri.port
|
69
85
|
http.use_ssl = @options['use-ssl']
|
70
86
|
|
71
|
-
|
87
|
+
http.start do
|
72
88
|
case @meta['method']
|
73
89
|
when 'GET', 'POST', 'PATCH', 'PUT', 'DELETE'
|
74
90
|
http.send_request @meta['method'], uri.request_uri, @body.to_query, @header
|
@@ -76,15 +92,6 @@ module Herdic
|
|
76
92
|
raise "Unsupported method: #{@meta['method']}"
|
77
93
|
end
|
78
94
|
end
|
79
|
-
|
80
|
-
body = response.body
|
81
|
-
body = JSON.parse body if 'application/json' == response.content_type
|
82
|
-
|
83
|
-
@printer.title @meta
|
84
|
-
@printer.request @header, @body
|
85
|
-
@printer.response response, body
|
86
|
-
|
87
|
-
register response, body
|
88
95
|
end
|
89
96
|
|
90
97
|
private def setup_spec(spec)
|
@@ -98,8 +105,6 @@ module Herdic
|
|
98
105
|
end
|
99
106
|
|
100
107
|
private def register(response, body)
|
101
|
-
return unless 'application/json' == response.content_type
|
102
|
-
|
103
108
|
@register.each do |name, path|
|
104
109
|
next if path.empty?
|
105
110
|
|
data/lib/herdic/printer.rb
CHANGED
data/lib/herdic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: herdic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuki Iwanaga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|