ruby-getoptions 0.1.0 → 0.1.1

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.
Files changed (3) hide show
  1. checksums.yaml +7 -7
  2. data/lib/ruby-getoptions.rb +11 -11
  3. metadata +28 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 9df3d1191065b31d1c57c195ccb229713aac8504
4
- data.tar.gz: e8ab09210178a8e7ac149bdf2ab295365fc6afbe
5
- SHA512:
6
- metadata.gz: c28f7037039976785bcc6f02cb0e14eb655b0698d5aa7c17b754bc09d36248191ce97b496291ee9eb1affd80e9e3541ee455c4e57ca502880ebe6a1d6d4c0023
7
- data.tar.gz: a61c1bb65ffcbc6632fcf2081e220e771b2ea65b17a193ed3d5a212bd219286fa2118bc800eced29558619e1d767eedf34a3fe60ab6a260cca65b11cdf086f35
1
+ ---
2
+ SHA1:
3
+ data.tar.gz: 13dd49cce4ed3bf8622aed730442c129c63f5c68
4
+ metadata.gz: 547296f376d322de73f9be5091e8ef0f46693dab
5
+ SHA512:
6
+ data.tar.gz: 08dad8be638391eb49bcbce75b64a63a2cce6dbb60a9c96b59d9068af377f33ef9813c3764188757d72264bae157f2d091a85cbe366f4a32df095476a448c9e2
7
+ metadata.gz: 71a2f391014f5268399982ebb92e60453c34299205f3faee2602fa9d55f3af53bcfd110d3183e6fce21a9b04cace209efef7f58b361d9327831c67e2dc317c88
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2014 David Gamba
3
+ # Copyright (c) 2014-2015 David Gamba
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -96,7 +96,7 @@ private
96
96
  definitions = k.match(/^([^#{@valid_simbols}]+)[#{@valid_simbols}]?(.*?)$/)[1].split('|')
97
97
  unique_options.push(*definitions)
98
98
  arg_spec, *arg_opts = process_type(k.match(/^[^#{@valid_simbols}]+([#{@valid_simbols}]?(.*?))$/)[1])
99
- opt_map[definitions] = { arg_spec: arg_spec, arg_opts: arg_opts, opt_dest: v }
99
+ opt_map[definitions] = { :arg_spec => arg_spec, :arg_opts => arg_opts, :opt_dest => v }
100
100
  end
101
101
  unless unique_options.uniq.length == unique_options.length
102
102
  duplicate_elements = unique_options.find { |e| unique_options.count(e) > 1 }
@@ -228,7 +228,7 @@ private
228
228
  return nil
229
229
  end
230
230
  elsif matches.size > 1
231
- abort "[ERROR] option '#{opt}' matches multiple names '#{matches}'!"
231
+ abort "[ERROR] option '#{opt}' matches multiple names '#{matches.inspect}'!"
232
232
  end
233
233
  debug "matches: #{matches}"
234
234
  [matches[0], @option_map]
@@ -275,13 +275,13 @@ private
275
275
  when 'i'
276
276
  arg = 0 if optional && arg.nil?
277
277
  unless integer?(arg)
278
- abort "[ERROR] argument for option '#{opt_match}' is not of type 'Integer'!"
278
+ abort "[ERROR] argument for option '#{opt_match[0]}' is not of type 'Integer'!"
279
279
  end
280
280
  arg = arg.to_i
281
281
  when 'f'
282
282
  arg = 0 if optional && arg.nil?
283
283
  unless numeric?(arg)
284
- abort "[ERROR] argument for option '#{opt_match}' is not of type 'Float'!"
284
+ abort "[ERROR] argument for option '#{opt_match[0]}' is not of type 'Float'!"
285
285
  end
286
286
  arg = arg.to_f
287
287
  when 'o'
@@ -311,7 +311,7 @@ private
311
311
  debug "min: #{min}, max: #{max}"
312
312
  min -= 1
313
313
  max -= 1
314
- abort "[ERROR] missing argument for option '#{opt_match}'!" if args.size <= 0
314
+ abort "[ERROR] missing argument for option '#{opt_match[0]}'!" if args.size <= 0
315
315
  args, arg = process_desttype_arg(args, opt_match, optional)
316
316
  option_result[opt_def[:opt_dest]].push arg
317
317
  end
@@ -344,7 +344,7 @@ private
344
344
  debug "min: #{min}, max: #{max}"
345
345
  min -= 1
346
346
  max -= 1
347
- abort "[ERROR] missing argument for option '#{opt_match}'!" if args.size <= 0
347
+ abort "[ERROR] missing argument for option '#{opt_match[0]}'!" if args.size <= 0
348
348
  args, arg, key = process_desttype_hash_arg(args, opt_match, optional)
349
349
  option_result[opt_def[:opt_dest]][key] = arg
350
350
  end
@@ -380,28 +380,28 @@ private
380
380
  debug "arg: '#{arg}'"
381
381
  if arg.nil?
382
382
  debug "arg is nil"
383
- abort "[ERROR] missing argument for option '#{opt_match}'!"
383
+ abort "[ERROR] missing argument for option '#{opt_match[0]}'!"
384
384
  end
385
385
  [args, arg]
386
386
  end
387
387
 
388
388
  def self.process_desttype_hash_arg(args, opt_match, optional)
389
389
  if args[0].nil? || (!args[0].nil? && option?(args[0]))
390
- abort "[ERROR] missing argument for option '#{opt_match}'!"
390
+ abort "[ERROR] missing argument for option '#{opt_match[0]}'!"
391
391
  end
392
392
  input = args.shift
393
393
  if (matches = input.match(/^([^=]+)=(.*)$/))
394
394
  key = matches[1]
395
395
  arg = matches[2]
396
396
  else
397
- abort "[ERROR] argument for option '#{opt_match}' must be of type key=value!"
397
+ abort "[ERROR] argument for option '#{opt_match[0]}' must be of type key=value!"
398
398
  end
399
399
  debug "key: '#{key}', arg: '#{arg}'"
400
400
  arg = process_option_type(arg, opt_match, optional)
401
401
  debug "arg: '#{arg}'"
402
402
  if arg.nil?
403
403
  debug "arg is nil"
404
- abort "[ERROR] missing argument for option '#{opt_match}'!"
404
+ abort "[ERROR] missing argument for option '#{opt_match[0]}'!"
405
405
  end
406
406
  [args, arg, key]
407
407
  end
metadata CHANGED
@@ -1,44 +1,52 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ruby-getoptions
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - David Gamba
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-01 00:00:00.000000000 Z
11
+
12
+ date: 2014-09-01 00:00:00 Z
12
13
  dependencies: []
14
+
13
15
  description: The best looking option parser out there
14
16
  email: davidgamba@gmail.com
15
17
  executables: []
18
+
16
19
  extensions: []
20
+
17
21
  extra_rdoc_files: []
18
- files:
22
+
23
+ files:
19
24
  - lib/ruby-getoptions.rb
20
25
  homepage: https://github.com/DavidGamba/ruby-getoptions
21
- licenses:
26
+ licenses:
22
27
  - MIT
23
28
  metadata: {}
29
+
24
30
  post_install_message:
25
31
  rdoc_options: []
26
- require_paths:
32
+
33
+ require_paths:
27
34
  - lib
28
- required_ruby_version: !ruby/object:Gem::Requirement
29
- requirements:
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: '0'
33
- required_rubygems_version: !ruby/object:Gem::Requirement
34
- requirements:
35
- - - ">="
36
- - !ruby/object:Gem::Version
37
- version: '0'
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - &id001
38
+ - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: "0"
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - *id001
38
44
  requirements: []
45
+
39
46
  rubyforge_project:
40
- rubygems_version: 2.2.2
47
+ rubygems_version: 2.0.15
41
48
  signing_key:
42
49
  specification_version: 4
43
- summary: Ruby option parser based on Perl’s Getopt::Long
50
+ summary: "Ruby option parser based on Perl\xE2\x80\x99s Getopt::Long"
44
51
  test_files: []
52
+