noms-optconfig 1.5.3 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/bin/bash-showconfig CHANGED
@@ -20,7 +20,7 @@
20
20
  domain="$1"
21
21
  shift 1
22
22
 
23
- SCRIPT_VERSION=$(ruby -rubygems -e 'require "optconfig/version"; puts Optconfig::VERSION')
23
+ SCRIPT_VERSION=$(ruby -rubygems -e 'require "noms/optconfig/version"; puts NOMS::Optconfig::VERSION')
24
24
 
25
25
  echo -n "Using "; which optconfig.sh
26
26
  . optconfig.sh
data/bin/optconfig.sh CHANGED
@@ -33,7 +33,7 @@ opt_new_gen()
33
33
  optspec="$1"
34
34
  shift 1
35
35
  ruby -rubygems \
36
- -e 'require "optconfig"' \
36
+ -e 'require "noms/optconfig"' \
37
37
  -e 'require "json"' \
38
38
  -e 'require "bashon"' \
39
39
  -e '$VERSION = "'$SCRIPT_VERSION'"' \
@@ -41,7 +41,7 @@ opt_new_gen()
41
41
  -e 'd = ARGV.shift' \
42
42
  -e 'opttext = ARGV.shift' \
43
43
  -e 'optspec = JSON.load(opttext)' \
44
- -e 'opt = Optconfig.new(d, optspec)' \
44
+ -e 'opt = NOMS::Optconfig.new(d, optspec)' \
45
45
  -e 'puts opt.map { |k,v| v.to_bashon("opt", d, k) }.join(";") + ";" +' \
46
46
  -e ' "opt_#{d}_vrb() { local l=\"$1\"; shift 1; test $l -le $(opt_#{d}_verbose) && echo $*; };" + ' \
47
47
  -e ' "opt_#{d}_dbg() { local l=\"$1\"; shift 1; test $l -le $(opt_#{d}_debug) && echo \"DBG(#{d}):\" $*; };" + ' \
data/bin/ruby-showconfig CHANGED
@@ -14,9 +14,9 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require 'optconfig'
17
+ require 'noms/optconfig'
18
18
 
19
- $VERSION = Optconfig::VERSION
19
+ $VERSION = NOMS::Optconfig::VERSION
20
20
 
21
21
  lib_location = $LOADED_FEATURES.find { |f| f =~ /optconfig.rb$/ }
22
22
 
@@ -24,7 +24,7 @@ puts "Using #{lib_location}"
24
24
 
25
25
  domain = ARGV.shift
26
26
  optspec = JSON.load(ARGV.shift)
27
- opt = Optconfig.new(domain, optspec)
27
+ opt = NOMS::Optconfig.new(domain, optspec)
28
28
  puts opt.to_json
29
29
 
30
30
  # = NAME
@@ -15,7 +15,11 @@
15
15
  # limitations under the License.
16
16
  # */
17
17
 
18
- module BashOn
18
+ class NOMS
19
+
20
+ end
21
+
22
+ module NOMS::BashOn
19
23
  def name_key(name)
20
24
  name.join('_').gsub(/[^a-zA-Z0-9\_]/, '_')
21
25
  end
@@ -262,7 +266,7 @@ EOF
262
266
  end
263
267
 
264
268
  class Object
265
- include BashOn
269
+ include NOMS::BashOn
266
270
  def to_bashon(*name)
267
271
  if name.empty?
268
272
  "#{self.to_s}"
@@ -273,7 +277,7 @@ class Object
273
277
  end
274
278
 
275
279
  class TrueClass
276
- include BashOn
280
+ include NOMS::BashOn
277
281
  def to_bashon(*name)
278
282
  if name.empty?
279
283
  "true"
@@ -284,7 +288,7 @@ class TrueClass
284
288
  end
285
289
 
286
290
  class FalseClass
287
- include BashOn
291
+ include NOMS::BashOn
288
292
  def to_bashon(*name)
289
293
  if name.empty?
290
294
  "false"
@@ -295,7 +299,7 @@ class FalseClass
295
299
  end
296
300
 
297
301
  class NilClass
298
- include BashOn
302
+ include NOMS::BashOn
299
303
  def to_bashon(*name)
300
304
  if name.empty?
301
305
  ""
@@ -306,7 +310,7 @@ class NilClass
306
310
  end
307
311
 
308
312
  class String
309
- include BashOn
313
+ include NOMS::BashOn
310
314
 
311
315
  def bq
312
316
  self.gsub("'", "'\''")
@@ -321,9 +325,17 @@ class String
321
325
  end
322
326
  end
323
327
 
328
+ unless Array.method_defined?(:nitems)
329
+ class Array
330
+ def nitems
331
+ count { |x| !x.nil? }
332
+ end
333
+ end
334
+ end
335
+
324
336
  # Enumerable?
325
337
  class Array
326
- include BashOn
338
+ include NOMS::BashOn
327
339
  def to_bashon(*name)
328
340
  "function #{name_key(name)} { echo " +
329
341
  (0 .. (self.nitems-1)).map { |i|
@@ -335,7 +347,7 @@ class Array
335
347
  end
336
348
 
337
349
  class Hash
338
- include BashOn
350
+ include NOMS::BashOn
339
351
  def to_bashon(*name)
340
352
  "function #{name_key(name)} { case \"$1\" in " +
341
353
  self.map { |k, v| "#{k}) echo '#{name_key(name + [k])}';;" }.join(' ') +
@@ -17,7 +17,11 @@
17
17
 
18
18
  require 'getoptlong'
19
19
 
20
- class Longopt < Hash
20
+ class NOMS
21
+
22
+ end
23
+
24
+ class NOMS::Longopt < Hash
21
25
 
22
26
  attr_accessor :optspec
23
27
 
@@ -170,7 +174,7 @@ class Longopt < Hash
170
174
  @@manpage = <<'EOF'
171
175
  =head1 NAME
172
176
 
173
- Longopt - Convenience class similar to Perl Getopt::Long
177
+ NOMS::Longopt - Convenience class similar to Perl Getopt::Long
174
178
 
175
179
  =head1 SYNOPSIS
176
180
 
@@ -31,9 +31,13 @@ require 'rubygems'
31
31
  require 'longopt'
32
32
  require 'json'
33
33
 
34
- class Optconfig < Hash
34
+ class NOMS
35
35
 
36
- require 'optconfig/version'
36
+ end
37
+
38
+ class NOMS::Optconfig < Hash
39
+
40
+ require 'noms/optconfig/version'
37
41
 
38
42
  attr_accessor :domain, :optspec, :config, :default
39
43
 
@@ -1,5 +1,5 @@
1
1
  class Optconfig
2
2
 
3
- VERSION = '1.5.3'
3
+ VERSION = '1.6.0'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noms-optconfig
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -59,8 +59,8 @@ dependencies:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '2.11'
62
- description: Optconfig presents a standardized way to parse configuration files and
63
- command-line arguments
62
+ description: NOMS::Optconfig presents a standardized way to parse configuration files
63
+ and command-line arguments
64
64
  email:
65
65
  - jbrinkley@evernote.com
66
66
  executables:
@@ -68,10 +68,10 @@ executables:
68
68
  extensions: []
69
69
  extra_rdoc_files: []
70
70
  files:
71
- - lib/optconfig.rb
72
- - lib/optconfig/version.rb
73
- - lib/longopt.rb
74
- - lib/bashon.rb
71
+ - lib/noms/optconfig.rb
72
+ - lib/noms/optconfig/version.rb
73
+ - lib/noms/longopt.rb
74
+ - lib/noms/bashon.rb
75
75
  - bin/ruby-showconfig
76
76
  - bin/optconfig.sh
77
77
  - bin/bash-showconfig