usps-imis-api 0.11.38 → 0.11.39

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
  SHA256:
3
- metadata.gz: 8696718e5b2fdfe5d0f31f13c4b1183e078a2a96d707c89bf1ac57f1de7b2519
4
- data.tar.gz: 1b06739853b3ed21b2d308219ee9f212aac43d530674ae13fdf1297411d7832a
3
+ metadata.gz: 490015ad8f86bea9afbc0eb9065a6b5e92432bc7c3bca8ec7faa2a6e61c2bd24
4
+ data.tar.gz: 5376fcdd8ea7e4a3e31832ecc8b399b51949d39449f0be5a1d74ca24b8452b26
5
5
  SHA512:
6
- metadata.gz: 2c0b9a60ba2076b79bd123ba7219988f04bb25a687d6fc5c3d6ce11cc6e62c4ba4de0b4fbd983aa906b0f0780c1d2d6f965ec5b7b929e38a72271a3e0cdcbfe4
7
- data.tar.gz: 2b19a230584337980aea3effba0a4784a2bfef41df9acf3b3bf867c6612a32d174c729a45835f6cfcd1f8602b59ca6423108b6eb5449f728647abb890ffb4ed7
6
+ metadata.gz: 7cfc0becb2b9969998b472970bd07ca0ebdd8427d64bf74e17adf8aa7be59e11c1db21d77d853b567a8397f61f7fa816a7977f0c0873b7269d9ac755e4cf179c
7
+ data.tar.gz: a26a68da79680d9b2f095d42caafee5b2a62bfd5ac9c01b278f367a7a996248dff7ff173f5498da46231e2e66cf7a8c8b26b45dc5471149e0e0e14a406bd1b54
data/lib/usps/imis/api.rb CHANGED
@@ -72,7 +72,7 @@ module Usps
72
72
  #
73
73
  # @param id [Integer, String] iMIS ID to select for future requests
74
74
  #
75
- # @return [Integer] iMIS ID
75
+ # @return [Integer, String] iMIS ID
76
76
  #
77
77
  def imis_id=(id)
78
78
  raise Errors::LockedIdError if lock_imis_id
@@ -113,13 +113,29 @@ module Usps
113
113
  @options = parse_options.compact
114
114
  @arguments = ARGV # Not currently used
115
115
 
116
- Optimist.educate if ARGV.empty? && defaults? # DEV: This shadows setting the --version flag by default
116
+ # Set the default behavior to --help instead of --version
117
+ #
118
+ # Passing any subcommands as arguments will cause this conditional to fail
119
+ #
120
+ # If this is disabled:
121
+ #
122
+ # - The default behavior is to print just the version label to the terminal
123
+ # - CommandLine::Performers#perform! *must* expect a `version:` pattern,
124
+ # and will return a quoted string of the version label
125
+ #
126
+ Optimist.educate if ARGV.empty? && defaults?
117
127
 
118
128
  # :nocov:
119
129
  @options[:data] = read_stdin if stdin?
120
130
  # :nocov:
121
131
 
122
132
  @options[:data] = JSON.parse(@options[:data]) if @options[:data]
133
+
134
+ # Support shorthand for setting `certificate` param on queries
135
+ return unless @options[:query] && @options[:certificate]
136
+
137
+ @options[:data] ||= {}
138
+ @options[:data]['certificate'] = @options.delete(:certificate)
123
139
  end
124
140
 
125
141
  private
@@ -143,7 +159,12 @@ module Usps
143
159
  def read_stdin = $stdin.read.chomp
144
160
  # :nocov:
145
161
 
146
- def defaults? = options[:log_level] == 'info' && options.except(:log_level).values.none?
162
+ def defaults?
163
+ options_with_defaults = OPTIONS.select { |_, data| data[1]&.key?(:default) }
164
+
165
+ options_with_defaults.all? { |option, data| data[1].nil? || options[option] == data[1][:default] } &&
166
+ options.except(*options_with_defaults.keys).values.none?
167
+ end
147
168
  end
148
169
  end
149
170
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.11.38'
5
+ VERSION = '0.11.39'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usps-imis-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.38
4
+ version: 0.11.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander