plz 0.1.1 → 0.1.2
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +1 -0
- data/lib/plz/command_builder.rb +10 -4
- data/lib/plz/commands/help.rb +1 -1
- data/lib/plz/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: 563b65752c68fef28a7af0476353f50b787f005d
|
4
|
+
data.tar.gz: 2d3b4defa4993fd73b8ce8f31c657eef5bfd9ea4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 281b82b1fede8f9265ebb648d08363b491ab484c6928eee2557729be25cc9fd443eaf161195a5e9d427a1f233cfdde8d7becf475600b0dff83eca5dcc2a21775
|
7
|
+
data.tar.gz: 4207525be60422943dd2cffe5980cc6b3ebe7b7031b4603f0f53e39040a5ded2bb30856a1cbaae50b3eb477c6d64982a8a0ca45ed8e7ca434463ee72394313c8
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -69,6 +69,7 @@ Plz takes some command line options.
|
|
69
69
|
$ plz --help
|
70
70
|
Usage: plz <action> <target> [headers|params] [options]
|
71
71
|
-h, --help Display help message
|
72
|
+
-H, --host API host
|
72
73
|
--no-color Disable coloring output
|
73
74
|
--no-response-body Hide response body
|
74
75
|
--no-response-header Hide response header
|
data/lib/plz/command_builder.rb
CHANGED
@@ -184,12 +184,17 @@ module Plz
|
|
184
184
|
link.method.to_s.upcase
|
185
185
|
end
|
186
186
|
|
187
|
-
#
|
187
|
+
# @return [String, nil] Base URL of the API
|
188
|
+
def base_url
|
189
|
+
@base_url ||= options[:host] || base_url_from_schema
|
190
|
+
end
|
191
|
+
|
192
|
+
# Extracts the base url of the API from JSON Schema
|
188
193
|
# @return [String, nil]
|
189
194
|
# @example
|
190
|
-
#
|
191
|
-
def
|
192
|
-
|
195
|
+
# base_url_from_schema #=> "https://api.example.com/"
|
196
|
+
def base_url_from_schema
|
197
|
+
json_schema.links.find do |link|
|
193
198
|
if link.href && link.rel == "self"
|
194
199
|
return link.href
|
195
200
|
end
|
@@ -227,6 +232,7 @@ module Plz
|
|
227
232
|
@options ||= Slop.parse!(@argv) do
|
228
233
|
banner Error::USAGE
|
229
234
|
on "h", "help", "Display help message"
|
235
|
+
on "H", "host=", "API host"
|
230
236
|
on "no-color", "Disable coloring output"
|
231
237
|
on "no-response-body", "Hide response body"
|
232
238
|
on "no-response-header", "Hide response header"
|
data/lib/plz/commands/help.rb
CHANGED
@@ -22,7 +22,7 @@ module Plz
|
|
22
22
|
link.href && link.method && link.title
|
23
23
|
end.map do |link|
|
24
24
|
str = " plz #{link.title.underscore} #{target_name}"
|
25
|
-
if key = link.href[/{(
|
25
|
+
if key = link.href[/{(.+?)}/, 1]
|
26
26
|
path = CGI.unescape(key).gsub(/[()]/, "")
|
27
27
|
name = path.split("/").last
|
28
28
|
if property = JsonPointer.evaluate(@schema.data, path)
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|