plz 0.1.6 → 0.1.7

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: 642e6be4ba4938db67f02e0bfc072f0d2bf3291f
4
- data.tar.gz: fac1d6ec41c76c29a54deebb6a9296643f56daab
3
+ metadata.gz: 8341580e74e32f97c3702d6b9f783086329c036b
4
+ data.tar.gz: '08c81ffb4009bf9f42ec68042e08a620387933a4'
5
5
  SHA512:
6
- metadata.gz: 1592d03c612d45db63045cf60ddc01d0f682b4b682b4fdd6f4d5678c04bc53571829fcb10d7edbc61c64d9e5421c7ad8dc05f4af5b93c7611416871d0fc4d732
7
- data.tar.gz: 079242cf0921724a56a0dc74efc3d27d22976963ed2323e596b0101a5b03d6773e376a487f4ea6c423d3982792ff15d0422752ccfb365534f4576a58766db27d
6
+ metadata.gz: 7f9d1fddcc0b9e8db67399251e0a010da7acdd9cedce82d0ab6cacf1bb4638bcd852b245f27eb644bdedcf83f07488ffb8d01e2e1db3962c0d2d163c825b8af2
7
+ data.tar.gz: d10b8a62fad862d4551d46a6efb6bf60f9175120593caee05801a59affa839c01f780b3e5d1b2bc2cdc1aabee9dd9508abf7e193e66f8299478da6c577852057
@@ -1,3 +1,8 @@
1
+ ## v0.1.7
2
+
3
+ - Support multi path parameters
4
+ - Improve program name on help message
5
+
1
6
  ## v0.1.6
2
7
 
3
8
  - Fix rouge version with `< 2.0.0`
@@ -7,12 +7,12 @@ module Plz
7
7
 
8
8
  # @return [String, nil] Given action name
9
9
  def action_name
10
- ARGV[0]
10
+ @argv[0]
11
11
  end
12
12
 
13
13
  # @return [String, nil] Given target name
14
14
  def target_name
15
- ARGV[1]
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
- ARGV[2..-1].inject({}) do |result, section|
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 ||= ARGV[2..-1].inject({}) do |result, section|
59
+ @params_from_argv ||= @argv[2..-1].inject({}) do |result, section|
60
60
  case
61
61
  when /(?<key>.+):=(?<value>.+)/ =~ section
62
62
  begin
@@ -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: nil,
49
- target_name: nil
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(/{(.+)}/) do |matched|
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(/{(.+)}/).map do |str|
162
- CGI.unescape($1).gsub(/[()]/, "").split("/").last
161
+ link.href.scan(/{(.+?)}/).map do |gr|
162
+ CGI.unescape(gr.first).gsub(/[()]/, "").split("/").last
163
163
  end
164
164
  end
165
165
 
@@ -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 = " plz #{link.title.underscore} #{target_name}"
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
@@ -1,6 +1,6 @@
1
1
  module Plz
2
2
  class Error < StandardError
3
- USAGE = "Usage: plz <action> <target> [headers|params] [options]"
3
+ USAGE = "Usage: #{File.basename($0)} <action> <target> [headers|params] [options]"
4
4
  end
5
5
 
6
6
  class UnparsableJsonParam < Error
@@ -1,3 +1,3 @@
1
1
  module Plz
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
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.6
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: 2016-12-01 00:00:00.000000000 Z
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.4.5.1
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.