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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 438be4824e988fa0a6ee8c9d115d1a3f0a484a96
4
- data.tar.gz: 3355e4e54c324e5bab8470a27b03f147c32ad17e
3
+ metadata.gz: 563b65752c68fef28a7af0476353f50b787f005d
4
+ data.tar.gz: 2d3b4defa4993fd73b8ce8f31c657eef5bfd9ea4
5
5
  SHA512:
6
- metadata.gz: 97b85d081396b16d302f8bb6471526197ebdab8b4df168cdc7e4b6260443eb302b2183491548047cbbc8d70ca3741527715e4097edc0cb49d2aec72f710ed79b
7
- data.tar.gz: 563281675be4f77725203203cb59e4a4306e51189b756f9d6bea9a2e06b8a4ee8ece3d3fae92425d1784491c1a65e1fe06317da54dfc597f14312e938ee5ba50
6
+ metadata.gz: 281b82b1fede8f9265ebb648d08363b491ab484c6928eee2557729be25cc9fd443eaf161195a5e9d427a1f233cfdde8d7becf475600b0dff83eca5dcc2a21775
7
+ data.tar.gz: 4207525be60422943dd2cffe5980cc6b3ebe7b7031b4603f0f53e39040a5ded2bb30856a1cbaae50b3eb477c6d64982a8a0ca45ed8e7ca434463ee72394313c8
@@ -1,3 +1,6 @@
1
+ ## 0.1.2
2
+ * Provide --host option to change API host
3
+
1
4
  ## 0.1.1
2
5
  * Provide support for reading STDIN
3
6
 
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
@@ -184,12 +184,17 @@ module Plz
184
184
  link.method.to_s.upcase
185
185
  end
186
186
 
187
- # Extracts the base url of the API
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
- # base_url #=> "https://api.example.com/"
191
- def base_url
192
- @base_url ||= json_schema.links.find do |link|
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"
@@ -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[/{(.+)}/, 1]
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)
@@ -1,3 +1,3 @@
1
1
  module Plz
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.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-14 00:00:00.000000000 Z
11
+ date: 2014-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport