optparse 0.1.1 → 0.2.0

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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +264 -0
  3. data/doc/optparse/argument_converters.rdoc +380 -0
  4. data/doc/optparse/creates_option.rdoc +7 -0
  5. data/doc/optparse/option_params.rdoc +509 -0
  6. data/doc/optparse/ruby/argument_keywords.rb +6 -0
  7. data/doc/optparse/ruby/argument_strings.rb +6 -0
  8. data/doc/optparse/ruby/argv.rb +2 -0
  9. data/doc/optparse/ruby/array.rb +6 -0
  10. data/doc/optparse/ruby/basic.rb +17 -0
  11. data/doc/optparse/ruby/block.rb +9 -0
  12. data/doc/optparse/ruby/collected_options.rb +8 -0
  13. data/doc/optparse/ruby/custom_converter.rb +9 -0
  14. data/doc/optparse/ruby/date.rb +6 -0
  15. data/doc/optparse/ruby/datetime.rb +6 -0
  16. data/doc/optparse/ruby/decimal_integer.rb +7 -0
  17. data/doc/optparse/ruby/decimal_numeric.rb +7 -0
  18. data/doc/optparse/ruby/default_values.rb +8 -0
  19. data/doc/optparse/ruby/descriptions.rb +15 -0
  20. data/doc/optparse/ruby/explicit_array_values.rb +9 -0
  21. data/doc/optparse/ruby/explicit_hash_values.rb +9 -0
  22. data/doc/optparse/ruby/false_class.rb +6 -0
  23. data/doc/optparse/ruby/float.rb +6 -0
  24. data/doc/optparse/ruby/help.rb +18 -0
  25. data/doc/optparse/ruby/help_banner.rb +7 -0
  26. data/doc/optparse/ruby/help_format.rb +25 -0
  27. data/doc/optparse/ruby/help_program_name.rb +7 -0
  28. data/doc/optparse/ruby/integer.rb +6 -0
  29. data/doc/optparse/ruby/long_names.rb +9 -0
  30. data/doc/optparse/ruby/long_optional.rb +6 -0
  31. data/doc/optparse/ruby/long_required.rb +6 -0
  32. data/doc/optparse/ruby/long_simple.rb +9 -0
  33. data/doc/optparse/ruby/long_with_negation.rb +6 -0
  34. data/doc/optparse/ruby/match_converter.rb +9 -0
  35. data/doc/optparse/ruby/matched_values.rb +6 -0
  36. data/doc/optparse/ruby/method.rb +11 -0
  37. data/doc/optparse/ruby/missing_options.rb +12 -0
  38. data/doc/optparse/ruby/mixed_names.rb +12 -0
  39. data/doc/optparse/ruby/name_abbrev.rb +9 -0
  40. data/doc/optparse/ruby/no_abbreviation.rb +10 -0
  41. data/doc/optparse/ruby/numeric.rb +6 -0
  42. data/doc/optparse/ruby/object.rb +6 -0
  43. data/doc/optparse/ruby/octal_integer.rb +7 -0
  44. data/doc/optparse/ruby/optional_argument.rb +9 -0
  45. data/doc/optparse/ruby/parse.rb +13 -0
  46. data/doc/optparse/ruby/parse_bang.rb +13 -0
  47. data/doc/optparse/ruby/proc.rb +13 -0
  48. data/doc/optparse/ruby/regexp.rb +6 -0
  49. data/doc/optparse/ruby/required_argument.rb +9 -0
  50. data/doc/optparse/ruby/shellwords.rb +6 -0
  51. data/doc/optparse/ruby/short_names.rb +9 -0
  52. data/doc/optparse/ruby/short_optional.rb +6 -0
  53. data/doc/optparse/ruby/short_range.rb +6 -0
  54. data/doc/optparse/ruby/short_required.rb +6 -0
  55. data/doc/optparse/ruby/short_simple.rb +9 -0
  56. data/doc/optparse/ruby/string.rb +6 -0
  57. data/doc/optparse/ruby/terminator.rb +6 -0
  58. data/doc/optparse/ruby/time.rb +6 -0
  59. data/doc/optparse/ruby/true_class.rb +6 -0
  60. data/doc/optparse/ruby/uri.rb +6 -0
  61. data/doc/optparse/tutorial.rdoc +835 -0
  62. data/lib/optparse/kwargs.rb +2 -0
  63. data/lib/optparse.rb +33 -75
  64. metadata +62 -7
  65. data/Rakefile +0 -10
  66. data/optparse.gemspec +0 -33
  67. data/rakelib/changelogs.rake +0 -34
  68. data/rakelib/epoch.rake +0 -5
  69. data/rakelib/version.rake +0 -47
@@ -5,6 +5,8 @@ class OptionParser
5
5
  # :call-seq:
6
6
  # define_by_keywords(options, method, **params)
7
7
  #
8
+ # :include: ../../doc/optparse/creates_option.rdoc
9
+ #
8
10
  def define_by_keywords(options, meth, **opts)
9
11
  meth.parameters.each do |type, name|
10
12
  case type
data/lib/optparse.rb CHANGED
@@ -48,6 +48,10 @@
48
48
  #
49
49
  # == OptionParser
50
50
  #
51
+ # === New to \OptionParser?
52
+ #
53
+ # See the {Tutorial}[./doc/optparse/tutorial_rdoc.html].
54
+ #
51
55
  # === Introduction
52
56
  #
53
57
  # OptionParser is a class for command-line option analysis. It is much more
@@ -240,14 +244,14 @@
240
244
  #
241
245
  # require 'optparse'
242
246
  #
243
- # params = {}
247
+ # options = {}
244
248
  # OptionParser.new do |parser|
245
249
  # parser.on('-a')
246
250
  # parser.on('-b NUM', Integer)
247
251
  # parser.on('-v', '--verbose')
248
- # end.parse!(into: params)
252
+ # end.parse!(into: options)
249
253
  #
250
- # p params
254
+ # p options
251
255
  #
252
256
  # Used:
253
257
  #
@@ -415,11 +419,13 @@
415
419
  #
416
420
  # === Further documentation
417
421
  #
418
- # The above examples should be enough to learn how to use this class. If you
419
- # have any questions, file a ticket at http://bugs.ruby-lang.org.
422
+ # The above examples, along with the accompanying
423
+ # {Tutorial}[./doc/optparse/tutorial_rdoc.html],
424
+ # should be enough to learn how to use this class.
425
+ # If you have any questions, file a ticket at http://bugs.ruby-lang.org.
420
426
  #
421
427
  class OptionParser
422
- OptionParser::Version = "0.1.1"
428
+ OptionParser::Version = "0.2.0"
423
429
 
424
430
  # :stopdoc:
425
431
  NoArgument = [NO_ARGUMENT = :NONE, nil].freeze
@@ -547,7 +553,7 @@ class OptionParser
547
553
  # Parses +arg+ and returns rest of +arg+ and matched portion to the
548
554
  # argument pattern. Yields when the pattern doesn't match substring.
549
555
  #
550
- def parse_arg(arg)
556
+ def parse_arg(arg) # :nodoc:
551
557
  pattern or return nil, [arg]
552
558
  unless m = pattern.match(arg)
553
559
  yield(InvalidArgument, arg)
@@ -572,7 +578,7 @@ class OptionParser
572
578
  # conversion. Yields at semi-error condition instead of raising an
573
579
  # exception.
574
580
  #
575
- def conv_arg(arg, val = [])
581
+ def conv_arg(arg, val = []) # :nodoc:
576
582
  if conv
577
583
  val = conv.call(*val)
578
584
  else
@@ -806,7 +812,7 @@ class OptionParser
806
812
  # +lopts+:: Long style option list.
807
813
  # +nlopts+:: Negated long style options list.
808
814
  #
809
- def update(sw, sopts, lopts, nsw = nil, nlopts = nil)
815
+ def update(sw, sopts, lopts, nsw = nil, nlopts = nil) # :nodoc:
810
816
  sopts.each {|o| @short[o] = sw} if sopts
811
817
  lopts.each {|o| @long[o] = sw} if lopts
812
818
  nlopts.each {|o| @long[o] = nsw} if nsw and nlopts
@@ -1300,7 +1306,7 @@ XXX
1300
1306
  # +prv+:: Previously specified argument.
1301
1307
  # +msg+:: Exception message.
1302
1308
  #
1303
- def notwice(obj, prv, msg)
1309
+ def notwice(obj, prv, msg) # :nodoc:
1304
1310
  unless !prv or prv == obj
1305
1311
  raise(ArgumentError, "argument #{msg} given twice: #{obj}",
1306
1312
  ParseError.filter_backtrace(caller(2)))
@@ -1314,64 +1320,7 @@ XXX
1314
1320
  # :call-seq:
1315
1321
  # make_switch(params, block = nil)
1316
1322
  #
1317
- # Creates an OptionParser::Switch from the parameters. The parsed argument
1318
- # value is passed to the given block, where it can be processed.
1319
- #
1320
- # See at the beginning of OptionParser for some full examples.
1321
- #
1322
- # +params+ can include the following elements:
1323
- #
1324
- # [Argument style:]
1325
- # One of the following:
1326
- # :NONE, :REQUIRED, :OPTIONAL
1327
- #
1328
- # [Argument pattern:]
1329
- # Acceptable option argument format, must be pre-defined with
1330
- # OptionParser.accept or OptionParser#accept, or Regexp. This can appear
1331
- # once or assigned as String if not present, otherwise causes an
1332
- # ArgumentError. Examples:
1333
- # Float, Time, Array
1334
- #
1335
- # [Possible argument values:]
1336
- # Hash or Array.
1337
- # [:text, :binary, :auto]
1338
- # %w[iso-2022-jp shift_jis euc-jp utf8 binary]
1339
- # { "jis" => "iso-2022-jp", "sjis" => "shift_jis" }
1340
- #
1341
- # [Long style switch:]
1342
- # Specifies a long style switch which takes a mandatory, optional or no
1343
- # argument. It's a string of the following form:
1344
- # "--switch=MANDATORY" or "--switch MANDATORY"
1345
- # "--switch[=OPTIONAL]"
1346
- # "--switch"
1347
- #
1348
- # [Short style switch:]
1349
- # Specifies short style switch which takes a mandatory, optional or no
1350
- # argument. It's a string of the following form:
1351
- # "-xMANDATORY"
1352
- # "-x[OPTIONAL]"
1353
- # "-x"
1354
- # There is also a special form which matches character range (not full
1355
- # set of regular expression):
1356
- # "-[a-z]MANDATORY"
1357
- # "-[a-z][OPTIONAL]"
1358
- # "-[a-z]"
1359
- #
1360
- # [Argument style and description:]
1361
- # Instead of specifying mandatory or optional arguments directly in the
1362
- # switch parameter, this separate parameter can be used.
1363
- # "=MANDATORY"
1364
- # "=[OPTIONAL]"
1365
- #
1366
- # [Description:]
1367
- # Description string for the option.
1368
- # "Run verbosely"
1369
- # If you give multiple description strings, each string will be printed
1370
- # line by line.
1371
- #
1372
- # [Handler:]
1373
- # Handler for the parsed argument value. Either give a block or pass a
1374
- # Proc or Method as an argument.
1323
+ # :include: ../doc/optparse/creates_option.rdoc
1375
1324
  #
1376
1325
  def make_switch(opts, block = nil)
1377
1326
  short, long, nolong, style, pattern, conv, not_pattern, not_conv, not_style = [], [], []
@@ -1509,6 +1458,8 @@ XXX
1509
1458
  # :call-seq:
1510
1459
  # define(*params, &block)
1511
1460
  #
1461
+ # :include: ../doc/optparse/creates_option.rdoc
1462
+ #
1512
1463
  def define(*opts, &block)
1513
1464
  top.append(*(sw = make_switch(opts, block)))
1514
1465
  sw[0]
@@ -1517,8 +1468,7 @@ XXX
1517
1468
  # :call-seq:
1518
1469
  # on(*params, &block)
1519
1470
  #
1520
- # Add option switch and handler. See #make_switch for an explanation of
1521
- # parameters.
1471
+ # :include: ../doc/optparse/creates_option.rdoc
1522
1472
  #
1523
1473
  def on(*opts, &block)
1524
1474
  define(*opts, &block)
@@ -1529,6 +1479,8 @@ XXX
1529
1479
  # :call-seq:
1530
1480
  # define_head(*params, &block)
1531
1481
  #
1482
+ # :include: ../doc/optparse/creates_option.rdoc
1483
+ #
1532
1484
  def define_head(*opts, &block)
1533
1485
  top.prepend(*(sw = make_switch(opts, block)))
1534
1486
  sw[0]
@@ -1537,7 +1489,9 @@ XXX
1537
1489
  # :call-seq:
1538
1490
  # on_head(*params, &block)
1539
1491
  #
1540
- # Add option switch like with #on, but at head of summary.
1492
+ # :include: ../doc/optparse/creates_option.rdoc
1493
+ #
1494
+ # The new option is added at the head of the summary.
1541
1495
  #
1542
1496
  def on_head(*opts, &block)
1543
1497
  define_head(*opts, &block)
@@ -1548,6 +1502,8 @@ XXX
1548
1502
  # :call-seq:
1549
1503
  # define_tail(*params, &block)
1550
1504
  #
1505
+ # :include: ../doc/optparse/creates_option.rdoc
1506
+ #
1551
1507
  def define_tail(*opts, &block)
1552
1508
  base.append(*(sw = make_switch(opts, block)))
1553
1509
  sw[0]
@@ -1557,7 +1513,9 @@ XXX
1557
1513
  # :call-seq:
1558
1514
  # on_tail(*params, &block)
1559
1515
  #
1560
- # Add option switch like with #on, but at tail of summary.
1516
+ # :include: ../doc/optparse/creates_option.rdoc
1517
+ #
1518
+ # The new option is added at the tail of the summary.
1561
1519
  #
1562
1520
  def on_tail(*opts, &block)
1563
1521
  define_tail(*opts, &block)
@@ -1780,7 +1738,7 @@ XXX
1780
1738
  # Traverses @stack, sending each element method +id+ with +args+ and
1781
1739
  # +block+.
1782
1740
  #
1783
- def visit(id, *args, &block)
1741
+ def visit(id, *args, &block) # :nodoc:
1784
1742
  @stack.reverse_each do |el|
1785
1743
  el.__send__(id, *args, &block)
1786
1744
  end
@@ -1791,7 +1749,7 @@ XXX
1791
1749
  #
1792
1750
  # Searches +key+ in @stack for +id+ hash and returns or yields the result.
1793
1751
  #
1794
- def search(id, key)
1752
+ def search(id, key) # :nodoc:
1795
1753
  block_given = block_given?
1796
1754
  visit(:search, id, key) do |k|
1797
1755
  return block_given ? yield(k) : k
@@ -1808,7 +1766,7 @@ XXX
1808
1766
  # +icase+:: Search case insensitive if true.
1809
1767
  # +pat+:: Optional pattern for completion.
1810
1768
  #
1811
- def complete(typ, opt, icase = false, *pat)
1769
+ def complete(typ, opt, icase = false, *pat) # :nodoc:
1812
1770
  if pat.empty?
1813
1771
  search(typ, opt) {|sw| return [sw, opt]} # exact match or...
1814
1772
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optparse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nobu Nakada
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-29 00:00:00.000000000 Z
11
+ date: 2021-10-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: OptionParser is a class for command-line option analysis.
14
14
  email:
@@ -18,8 +18,67 @@ extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - COPYING
21
+ - ChangeLog
21
22
  - README.md
22
- - Rakefile
23
+ - doc/optparse/argument_converters.rdoc
24
+ - doc/optparse/creates_option.rdoc
25
+ - doc/optparse/option_params.rdoc
26
+ - doc/optparse/ruby/argument_keywords.rb
27
+ - doc/optparse/ruby/argument_strings.rb
28
+ - doc/optparse/ruby/argv.rb
29
+ - doc/optparse/ruby/array.rb
30
+ - doc/optparse/ruby/basic.rb
31
+ - doc/optparse/ruby/block.rb
32
+ - doc/optparse/ruby/collected_options.rb
33
+ - doc/optparse/ruby/custom_converter.rb
34
+ - doc/optparse/ruby/date.rb
35
+ - doc/optparse/ruby/datetime.rb
36
+ - doc/optparse/ruby/decimal_integer.rb
37
+ - doc/optparse/ruby/decimal_numeric.rb
38
+ - doc/optparse/ruby/default_values.rb
39
+ - doc/optparse/ruby/descriptions.rb
40
+ - doc/optparse/ruby/explicit_array_values.rb
41
+ - doc/optparse/ruby/explicit_hash_values.rb
42
+ - doc/optparse/ruby/false_class.rb
43
+ - doc/optparse/ruby/float.rb
44
+ - doc/optparse/ruby/help.rb
45
+ - doc/optparse/ruby/help_banner.rb
46
+ - doc/optparse/ruby/help_format.rb
47
+ - doc/optparse/ruby/help_program_name.rb
48
+ - doc/optparse/ruby/integer.rb
49
+ - doc/optparse/ruby/long_names.rb
50
+ - doc/optparse/ruby/long_optional.rb
51
+ - doc/optparse/ruby/long_required.rb
52
+ - doc/optparse/ruby/long_simple.rb
53
+ - doc/optparse/ruby/long_with_negation.rb
54
+ - doc/optparse/ruby/match_converter.rb
55
+ - doc/optparse/ruby/matched_values.rb
56
+ - doc/optparse/ruby/method.rb
57
+ - doc/optparse/ruby/missing_options.rb
58
+ - doc/optparse/ruby/mixed_names.rb
59
+ - doc/optparse/ruby/name_abbrev.rb
60
+ - doc/optparse/ruby/no_abbreviation.rb
61
+ - doc/optparse/ruby/numeric.rb
62
+ - doc/optparse/ruby/object.rb
63
+ - doc/optparse/ruby/octal_integer.rb
64
+ - doc/optparse/ruby/optional_argument.rb
65
+ - doc/optparse/ruby/parse.rb
66
+ - doc/optparse/ruby/parse_bang.rb
67
+ - doc/optparse/ruby/proc.rb
68
+ - doc/optparse/ruby/regexp.rb
69
+ - doc/optparse/ruby/required_argument.rb
70
+ - doc/optparse/ruby/shellwords.rb
71
+ - doc/optparse/ruby/short_names.rb
72
+ - doc/optparse/ruby/short_optional.rb
73
+ - doc/optparse/ruby/short_range.rb
74
+ - doc/optparse/ruby/short_required.rb
75
+ - doc/optparse/ruby/short_simple.rb
76
+ - doc/optparse/ruby/string.rb
77
+ - doc/optparse/ruby/terminator.rb
78
+ - doc/optparse/ruby/time.rb
79
+ - doc/optparse/ruby/true_class.rb
80
+ - doc/optparse/ruby/uri.rb
81
+ - doc/optparse/tutorial.rdoc
23
82
  - lib/optionparser.rb
24
83
  - lib/optparse.rb
25
84
  - lib/optparse/ac.rb
@@ -31,10 +90,6 @@ files:
31
90
  - lib/optparse/version.rb
32
91
  - misc/rb_optparse.bash
33
92
  - misc/rb_optparse.zsh
34
- - optparse.gemspec
35
- - rakelib/changelogs.rake
36
- - rakelib/epoch.rake
37
- - rakelib/version.rake
38
93
  homepage: https://github.com/ruby/optparse
39
94
  licenses:
40
95
  - Ruby
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test/lib"
6
- t.ruby_opts << "-rhelper"
7
- t.test_files = FileList['test/**/test_*.rb']
8
- end
9
-
10
- task :default => :test
data/optparse.gemspec DELETED
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- name = File.basename(__FILE__, ".gemspec")
4
- version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
5
- break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
6
- /^\s*OptionParser::Version\s*=\s*"(.*)"/ =~ line and break $1
7
- end rescue nil
8
- end
9
-
10
- Gem::Specification.new do |spec|
11
- spec.name = name
12
- spec.version = version
13
- spec.authors = ["Nobu Nakada"]
14
- spec.email = ["nobu@ruby-lang.org"]
15
-
16
- spec.summary = %q{OptionParser is a class for command-line option analysis.}
17
- spec.description = %q{OptionParser is a class for command-line option analysis.}
18
- spec.homepage = "https://github.com/ruby/optparse"
19
- spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
20
- spec.licenses = ["Ruby", "BSD-2-Clause"]
21
-
22
- spec.metadata["homepage_uri"] = spec.homepage
23
- spec.metadata["source_code_uri"] = spec.homepage
24
-
25
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
26
- `git ls-files -z`.split("\x0").reject { |f|
27
- f.match(%r{\A(?:(?:test|spec|features)/|Gemfile|\.(?:editor|git))})
28
- }
29
- end
30
- spec.bindir = "exe"
31
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
- spec.require_paths = ["lib"]
33
- end
@@ -1,34 +0,0 @@
1
- task "build" => "changelogs"
2
-
3
- changelog = proc do |output, ver = nil, prev = nil|
4
- ver &&= Gem::Version.new(ver)
5
- range = [[prev], [ver, "HEAD"]].map {|ver, branch| ver ? "v#{ver.to_s}" : branch}.compact.join("..")
6
- IO.popen(%W[git log --format=fuller --topo-order --no-merges #{range}]) do |log|
7
- line = log.gets
8
- FileUtils.mkpath(File.dirname(output))
9
- File.open(output, "wb") do |f|
10
- f.print "-*- coding: utf-8 -*-\n\n", line
11
- log.each_line do |line|
12
- line.sub!(/^(?!:)(?:Author|Commit)?(?:Date)?: /, ' \&')
13
- line.sub!(/ +$/, '')
14
- f.print(line)
15
- end
16
- end
17
- end
18
- end
19
-
20
- tags = IO.popen(%w[git tag -l v[0-9]*]).grep(/v(.*)/) {$1}
21
- tags.sort_by! {|tag| tag.scan(/\d+/).map(&:to_i)}
22
- tags.inject(nil) do |prev, tag|
23
- task("logs/ChangeLog-#{tag}") {|t| changelog[t.name, tag, prev]}
24
- tag
25
- end
26
-
27
- desc "Make ChangeLog"
28
- task "ChangeLog", [:ver, :prev] do |t, ver: nil, prev: tags.last|
29
- changelog[t.name, ver, prev]
30
- end
31
-
32
- changelogs = ["ChangeLog", *tags.map {|tag| "logs/ChangeLog-#{tag}"}]
33
- task "changelogs" => changelogs
34
- CLOBBER.concat(changelogs) << "logs"
data/rakelib/epoch.rake DELETED
@@ -1,5 +0,0 @@
1
- task "build" => "date_epoch"
2
-
3
- task "date_epoch" do
4
- ENV["SOURCE_DATE_EPOCH"] = IO.popen(%W[git -C #{__dir__} log -1 --format=%ct], &:read).chomp
5
- end
data/rakelib/version.rake DELETED
@@ -1,47 +0,0 @@
1
- class << (helper = Bundler::GemHelper.instance)
2
- def mainfile
3
- "lib/#{File.basename(gemspec.loaded_from, ".gemspec")}.rb"
4
- end
5
-
6
- def update_version
7
- File.open(mainfile, "r+b") do |f|
8
- d = f.read
9
- if d.sub!(/^(\s*OptionParser::Version\s*=\s*)".*"/) {$1 + gemspec.version.to_s.dump}
10
- f.rewind
11
- f.truncate(0)
12
- f.print(d)
13
- end
14
- end
15
- end
16
-
17
- def commit_bump
18
- sh(%W[git -C #{File.dirname(gemspec.loaded_from)} commit -m bump\ up\ to\ #{gemspec.version}
19
- #{mainfile}])
20
- end
21
-
22
- def version=(v)
23
- gemspec.version = v
24
- update_version
25
- commit_bump
26
- end
27
- end
28
-
29
- major, minor, teeny = helper.gemspec.version.segments
30
-
31
- task "bump:teeny" do
32
- helper.version = Gem::Version.new("#{major}.#{minor}.#{teeny+1}")
33
- end
34
-
35
- task "bump:minor" do
36
- helper.version = Gem::Version.new("#{major}.#{minor+1}.0")
37
- end
38
-
39
- task "bump:major" do
40
- helper.version = Gem::Version.new("#{major+1}.0.0")
41
- end
42
-
43
- task "bump" => "bump:teeny"
44
-
45
- task "tag" do
46
- helper.__send__(:tag_version)
47
- end