shellopts 2.9.1 → 2.9.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
  SHA256:
3
- metadata.gz: 3dcef062b0b6bf1df9e6596e7410dc51a85c2b990fecfc8e7fede565e162fc2e
4
- data.tar.gz: cf8bdddb542e324a0efcdef4fae00ce76338994263e4f603bd22149f5acd7777
3
+ metadata.gz: 66e69788996dbb1a8974cfaed3fb9bb41440af20c8e9fe2b3b01bdaa01141a2c
4
+ data.tar.gz: 4acccf9621525437415b118fe7011b59278cc803626103dff2dfd6ac2d06f9ba
5
5
  SHA512:
6
- metadata.gz: 93b9d18edd54a015170350865e460625cef1a6fa42918b386634912260c900041a76f486135813ef89341bec64355e2d29ef011f36f234143d42874d8fe0908a
7
- data.tar.gz: 8434df86e5ef6238975a018530509de6d7fcef69bbaa63d4e6b2f33f2d738e74c5232d691172ff6f475cbe78995e62c7966b51517202ba6a440517b76a4843df
6
+ metadata.gz: a0b9cfdb793d8761ca939dd7c9925b2fed4749996496d74eb070c9b086490d6f0cbafe536f242799cc8ba3254d8377f3f955bb62a16c4ba95b26bd894bd4da5c
7
+ data.tar.gz: ce8019b77f055221ebf8823dfb7dcb0268f0a3bb7893a82a1127e23901fdbda94735846f6e08a88704259951bede61a8edd627c20de18bc9e89d08a926e58ae3
@@ -1,3 +1,3 @@
1
1
  module ShellOpts
2
- VERSION = "2.9.1"
2
+ VERSION = "2.9.2"
3
3
  end
data/lib/shellopts.rb CHANGED
@@ -135,6 +135,7 @@ module ShellOpts
135
135
 
136
136
  # Use exceptions instead of ShellOpts's error methods. Default is
137
137
  # ShellOpts.exception that itself defalts to false. Mostly used for debug
138
+ # when you want a stack trace instead of a user-readable error message
138
139
  attr_accessor :exception
139
140
 
140
141
  # Debug: Internal variables made public
@@ -163,7 +164,10 @@ module ShellOpts
163
164
  @file = file
164
165
  @help = help
165
166
  @version_number = version_number || (version && find_version_number)
167
+ p version
166
168
  @version = !@version_number.nil? && version
169
+ p @version
170
+ exit
167
171
  @silent = silent
168
172
  @quiet = quiet
169
173
  @verbose = verbose
@@ -243,8 +247,7 @@ module ShellOpts
243
247
  self
244
248
  end
245
249
 
246
- # Compile +spec+ and interpret +argv+. Returns a tuple of a
247
- # ShellOpts::Program and ShellOpts::Args object
250
+ # Compile +spec+ and interpret +argv+. Returns a ShellOpts object
248
251
  #
249
252
  def process(spec, argv)
250
253
  compile(spec)
@@ -317,6 +320,26 @@ module ShellOpts
317
320
  IO.readlines(version_rb).grep(/^.*VERSION\s*=\s*"(.*?)".*$/) { $1 }.first
318
321
  end
319
322
 
323
+ def find_version_number
324
+ # Uninstalled program called using 'bundle exec'
325
+ if version_rb = Dir.glob(File.dirname(file) + "/../lib/*/version.rb").first
326
+ version = IO.readlines(version_rb).grep(/^.*VERSION\s*=\s*"(.*?)".*$/) { $1 }.first
327
+
328
+ # Installed program
329
+ elsif spec = Gem::Specification.find_by_path($0)
330
+ version = spec.version.to_s
331
+
332
+ # Installed program using RVM wrappers
333
+ else
334
+ spec = Gem::Specification.find_all
335
+ .select { |s| s.executables.include?(File.basename($0)) }
336
+ .max_by { |s| s.version }
337
+ version = spec&.version.to_s
338
+ end
339
+
340
+ version
341
+ end
342
+
320
343
  def handle_exceptions(&block)
321
344
  return yield if ::ShellOpts.exception
322
345
  begin
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shellopts
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.1
4
+ version: 2.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen