plz 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/plz/arguments.rb +4 -4
- data/lib/plz/command_builder.rb +5 -5
- data/lib/plz/commands/help.rb +2 -1
- data/lib/plz/error.rb +1 -1
- data/lib/plz/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8341580e74e32f97c3702d6b9f783086329c036b
|
4
|
+
data.tar.gz: '08c81ffb4009bf9f42ec68042e08a620387933a4'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f9d1fddcc0b9e8db67399251e0a010da7acdd9cedce82d0ab6cacf1bb4638bcd852b245f27eb644bdedcf83f07488ffb8d01e2e1db3962c0d2d163c825b8af2
|
7
|
+
data.tar.gz: d10b8a62fad862d4551d46a6efb6bf60f9175120593caee05801a59affa839c01f780b3e5d1b2bc2cdc1aabee9dd9508abf7e193e66f8299478da6c577852057
|
data/CHANGELOG.md
CHANGED
data/lib/plz/arguments.rb
CHANGED
@@ -7,12 +7,12 @@ module Plz
|
|
7
7
|
|
8
8
|
# @return [String, nil] Given action name
|
9
9
|
def action_name
|
10
|
-
|
10
|
+
@argv[0]
|
11
11
|
end
|
12
12
|
|
13
13
|
# @return [String, nil] Given target name
|
14
14
|
def target_name
|
15
|
-
|
15
|
+
@argv[1]
|
16
16
|
end
|
17
17
|
|
18
18
|
# @return [Hash] Params parsed from given arguments & STDIN
|
@@ -23,7 +23,7 @@ module Plz
|
|
23
23
|
|
24
24
|
# @return [Hash] Headers parsed from given arguments
|
25
25
|
def headers
|
26
|
-
|
26
|
+
@argv[2..-1].inject({}) do |result, section|
|
27
27
|
case
|
28
28
|
when /(?<key>.+):(?<value>[^=]+)/ =~ section
|
29
29
|
result.merge(key => value)
|
@@ -56,7 +56,7 @@ module Plz
|
|
56
56
|
|
57
57
|
# @return [Hash] Params extracted from ARGV
|
58
58
|
def params_from_argv
|
59
|
-
@params_from_argv ||=
|
59
|
+
@params_from_argv ||= @argv[2..-1].inject({}) do |result, section|
|
60
60
|
case
|
61
61
|
when /(?<key>.+):=(?<value>.+)/ =~ section
|
62
62
|
begin
|
data/lib/plz/command_builder.rb
CHANGED
@@ -45,8 +45,8 @@ module Plz
|
|
45
45
|
when !has_link?
|
46
46
|
Commands::LinkNotFound.new(
|
47
47
|
pathname: schema_file_pathname,
|
48
|
-
action_name:
|
49
|
-
target_name:
|
48
|
+
action_name: action_name,
|
49
|
+
target_name: target_name,
|
50
50
|
)
|
51
51
|
when has_invalid_json_input?
|
52
52
|
Commands::InvalidJsonFromStdin.new
|
@@ -148,7 +148,7 @@ module Plz
|
|
148
148
|
# @example
|
149
149
|
# path_with_template #=> "/apps/%{id}"
|
150
150
|
def path_with_template
|
151
|
-
link.href.gsub(/{(
|
151
|
+
link.href.gsub(/{(.+?)}/) do |matched|
|
152
152
|
key = CGI.unescape($1).gsub(/[()]/, "").split("/").last
|
153
153
|
"%{#{key}}"
|
154
154
|
end
|
@@ -158,8 +158,8 @@ module Plz
|
|
158
158
|
# @exmaple
|
159
159
|
# path_keys #=> ["id"]
|
160
160
|
def path_keys
|
161
|
-
link.href.scan(/{(
|
162
|
-
CGI.unescape(
|
161
|
+
link.href.scan(/{(.+?)}/).map do |gr|
|
162
|
+
CGI.unescape(gr.first).gsub(/[()]/, "").split("/").last
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
data/lib/plz/commands/help.rb
CHANGED
@@ -17,11 +17,12 @@ module Plz
|
|
17
17
|
|
18
18
|
# @return [Array<String>]
|
19
19
|
def links
|
20
|
+
prog_name = File.basename($0)
|
20
21
|
@schema.properties.map do |target_name, schema|
|
21
22
|
schema.links.select do |link|
|
22
23
|
link.href && link.method && link.title
|
23
24
|
end.map do |link|
|
24
|
-
str = "
|
25
|
+
str = " #{prog_name} #{link.title.underscore} #{target_name}"
|
25
26
|
if key = link.href[/{(.+?)}/, 1]
|
26
27
|
path = CGI.unescape(key).gsub(/[()]/, "")
|
27
28
|
name = path.split("/").last
|
data/lib/plz/error.rb
CHANGED
data/lib/plz/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -236,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
236
|
version: '0'
|
237
237
|
requirements: []
|
238
238
|
rubyforge_project:
|
239
|
-
rubygems_version: 2.
|
239
|
+
rubygems_version: 2.5.2
|
240
240
|
signing_key:
|
241
241
|
specification_version: 4
|
242
242
|
summary: JSON Schema based command line HTTP client.
|