optparse-plus 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a6f4cc35a11290f599df1ac89b367308b7de55d367f99d882287093ecdeeefc
4
- data.tar.gz: 96d1296f77e31242ee8f3bde8cc2b952cf57cb778fc920ba698963942394630e
3
+ metadata.gz: 2dc6a69b65fdd0706c484c857cd303b37d6c1703a12603ec8a01a2c87bc22702
4
+ data.tar.gz: 2f18e76a559a7513531167e58d0400cfab7974f9ef88d27439a772bf2c0b3c62
5
5
  SHA512:
6
- metadata.gz: 4583ffcc8828e30bd8c633946a41ead8511b4bef0b74451328c3b4dbedcc4fdd6a380ba5d5419acf6d1a0a6ea750eb68f113c876d9035d63474004c691847839
7
- data.tar.gz: 4cb6b962216b09ddb41f77817b2f3b9e5c086ad6b49378252ec23e1697bbe48f04b87d0213b087931dc3b2a09b1cc929a7d7f289dc7c8ef3a1a5163946e8f27d
6
+ metadata.gz: 9f916f4467a36335099d0428d3d2ccf8dba208c8f0d69860dc1cfe9008807dec94b576ab83283cf07a03c74db5e6875fa77bd28bcfded9a4948132e572de5b0e
7
+ data.tar.gz: a18fd5c85dc54229ac61e5884789c7941f0e8cec82023a95a1d20f6eb6825afc6054c2c69b42b58b45d60deb53b8191995f5bfd1816f45451735da4422b23681
@@ -0,0 +1,28 @@
1
+ version: 2.1
2
+ orbs:
3
+ # See https://circleci.com/developer/orbs/orb/circleci/ruby
4
+ ruby: circleci/ruby@1.1.2
5
+ jobs: # keyword
6
+ test: # my name for the job
7
+ parameters: # keyword
8
+ ruby-version: # my parameter name
9
+ type: string # type is a keyword
10
+ docker: # keyword
11
+ - image: cimg/base:stable
12
+ steps: # keyword
13
+ - checkout # magic name
14
+ - ruby/install: # ruby/ is from the orb name, install is a command in that orb
15
+ version: << parameters.ruby-version >> # magic nonsense for param subst (version param to the command)
16
+ - run:
17
+ command: "bin/setup"
18
+ - run:
19
+ command: "bin/ci"
20
+ workflows: # keyword
21
+ all-rubies: # my name for the workflow
22
+ jobs: # keyword
23
+ - test: # my name for the job
24
+ matrix: # keyword
25
+ parameters: # keyword
26
+ # All rubies being maintained per this page:
27
+ # https://www.ruby-lang.org/en/downloads/branches/
28
+ ruby-version: [ "2.5", "2.6", "2.7", "3.0" ]
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.0.0
data/README.rdoc CHANGED
@@ -16,12 +16,12 @@ Toward that end, this gem provides:
16
16
  * Simplified zero-config logging that is a better-than-<tt>puts</tt> <tt>puts</tt>.
17
17
  * Support for integration-testing your CLI using Test::Unit
18
18
 
19
+ {Read about the name change if you care}[https://github.com/davetron5000/optparse-plus/wiki/Name-Change]
20
+
19
21
  == Platforms
20
22
 
21
23
  This library only supports the latest versions of Ruby. JRuby support has been too difficult to keep up with, though the library should work for JRuby.
22
24
 
23
- See the {Travis config file}[./.travis.yml] for specifics.
24
-
25
25
  == Bootstrapping a new CLI App
26
26
 
27
27
  The +optparse_plus+ command-line app will bootstrap a new command-line app, setting up a proper gem structure, unit tests, and integration tests.
data/bin/ci ADDED
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+ echo "[bin/ci] Running unit tests"
5
+ bundle exec rake test
6
+
7
+ echo "[bin/ci] Running integration tests"
8
+ bundle exec rake test:integration
data/bin/optparse_plus CHANGED
@@ -1,130 +1,29 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require 'fileutils'
4
- require 'optparse'
5
- require 'optparse_plus'
6
- require 'optparse_plus/cli'
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'optparse_plus' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
7
10
 
8
- include FileUtils
9
- include OptparsePlus::Main
10
- include OptparsePlus::CLILogging
11
- include OptparsePlus::CLI
12
- include OptparsePlus::SH
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
13
14
 
14
- main do |app_name|
15
- check_and_prepare_basedir!(app_name,options[:force])
16
- using_readme = options[:readme]
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
17
16
 
18
- gemname = File.basename(app_name)
19
- module_name = gemname.split(/-/).map(&:capitalize).collect{ |segment| segment.split(/_/).map(&:capitalize).join('') }.join('::')
20
-
21
- debug "Creating project for gem #{gemname}"
22
-
23
- chdir File.dirname(app_name)
24
-
25
- require_file = nil
26
- sh! "bundle gem #{gemname} --no-color" do |stdout|
27
- require_file = stdout.split(/\n/).select { |file|
28
- file =~ /\.rb$/ && file !~ /version.rb$/
29
- }.first
30
- end
31
- rm_rf "#{gemname}/spec" # Don't want the default RSpec droppings
32
- rm_rf "#{gemname}/.rspec"
33
-
34
- require_file = gemname if require_file.nil?
35
- require_file.gsub!(/^.*lib\//,'')
36
-
37
- chdir gemname
38
-
39
- template_dirs_in(:full).each { |dir| mkdir_p dir }
40
-
41
- rspec = options[:rspec]
42
-
43
- ["Rakefile", ".gitignore", ].each do |file|
44
- copy_file file, :binding => binding
45
- end
46
-
47
- if rspec
48
- template_dirs_in(:rspec).each { |dir| mkdir_p dir }
49
- copy_file "spec/something_spec.rb", :from => :rspec, :binding => binding
50
- else
51
- template_dirs_in(:test_unit).each { |dir| mkdir_p dir }
52
- copy_file "test/unit/test_something.rb", :from => :test_unit, :binding => binding
53
- copy_file "test/integration/test_cli.rb", :from => :test_unit, :binding => binding
54
- end
55
-
56
-
57
- gemspec = "#{gemname}.gemspec"
58
- gem_variable = File.open(gemspec) { |x| x.read }.match(/(\w+)\.executables/)[1]
59
-
60
- license = options[:license]
61
- warn "warning: your app has no license" unless license
62
- license = nil if license == 'NONE'
63
- if license
64
- copy_file "#{options[:license]}_LICENSE.txt", :as => "LICENSE.txt"
65
- else
66
- #Remove the MIT license generated by `bundle gem`
67
- debug "Making sure no LICENSE.txt file exists at the root of the repo"
68
- FileUtils.rm_f "LICENSE.txt"
69
- end
70
-
71
- #Ensure the gemspec file mentions the correct license
72
- gemspec_content = File.read(gemspec)
73
- if gemspec_content =~ /(^\s*#{gem_variable}\.license\s*=\s*).*/
74
- gemspec_content.gsub!(/(^\s*#{gem_variable}\.license\s*=\s*).*/,"\\1#{license.to_s.inspect}")
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
75
20
  else
76
- gemspec_content.gsub!(/(^\s*#{gem_variable}\.name\s*=\s*.*)/,"\\1\n#{" #{gem_variable}.license".ljust(20)} = #{license.to_s.inspect.upcase}")
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
77
23
  end
78
- # RubyGems won't deal with a gemspec in this state and so Bundler won't even
79
- # work at all. This is not helpful, so replace the magic keys its looking for
80
- # with something else
81
- gemspec_content.gsub!(/TODO/,"to-do")
82
- gemspec_content.gsub!(/FIXME/,"fix me")
83
- gemspec_content.gsub!(/^.*\.homepage.*$/,"")
84
- File.open(gemspec,'w') {|f| f.write gemspec_content }
85
-
86
-
87
- copy_file "README.rdoc", :binding => binding if using_readme
88
-
89
- copy_file "bin/executable", :as => gemname, :executable => true, :binding => binding
90
-
91
- add_to_file gemspec, [
92
- " #{gem_variable}.add_development_dependency('rdoc')",
93
- " #{gem_variable}.add_dependency('optparse_plus', '~> #{OptparsePlus::VERSION}')",
94
- ], :before => /^end\s*$/
95
- ruby_major,ruby_minor,ruby_patch = RUBY_VERSION.split(/\./).map(&:to_i)
96
-
97
- if ruby_major >= 2 && ruby_minor >= 2
98
- add_to_file gemspec, [
99
- " #{gem_variable}.add_development_dependency('test-unit')",
100
- ], :before => /^end\s*$/
101
- end
102
-
103
- if rspec
104
- add_to_file gemspec, [
105
- " #{gem_variable}.add_development_dependency('rspec', '~> 3')",
106
- ], :before => /^end\s*$/
107
- end
108
- FileUtils.rm_f "README.md", verbose: true
109
-
110
- sh! %q(git add --all .)
111
24
  end
112
25
 
113
- options[:readme] = true
114
-
115
- description "Kick the bash habit by bootstrapping your Ruby command-line apps"
116
-
117
- on("--force","Overwrite files if they exist")
118
- on("--[no-]readme","[Do not ]produce a README file")
119
- on("--rspec", "Generate RSpec unit tests instead of Test::Unit")
120
-
121
- licenses = %w(mit apache gplv2 gplv3 custom NONE)
122
- on("-l LICENSE","--license",licenses,"Specify the license for your project",'(' + licenses.join('|') + ')')
123
-
124
- use_log_level_option
125
-
126
- arg :app_name, :required, "Name of your app, which is used for the gem name and executable name"
127
-
128
- version OptparsePlus::VERSION, :compact => true
26
+ require "rubygems"
27
+ require "bundler/setup"
129
28
 
130
- go!
29
+ load Gem.bin_path("optparse-plus", "optparse_plus")
data/bin/rake ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rake", "rake")
data/bin/setup ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ bundle check || bundle install
data/exe/optparse_plus ADDED
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'fileutils'
4
+ require 'optparse'
5
+ require 'optparse_plus.rb'
6
+ require 'optparse_plus/cli'
7
+
8
+ include FileUtils
9
+ include OptparsePlus::Main
10
+ include OptparsePlus::CLILogging
11
+ include OptparsePlus::CLI
12
+ include OptparsePlus::SH
13
+
14
+ main do |app_name|
15
+ check_and_prepare_basedir!(app_name,options[:force])
16
+ using_readme = options[:readme]
17
+
18
+ gemname = File.basename(app_name)
19
+ module_name = gemname.split(/-/).map(&:capitalize).collect{ |segment| segment.split(/_/).map(&:capitalize).join('') }.join('::')
20
+
21
+ debug "Creating project for gem #{gemname}"
22
+
23
+ chdir File.dirname(app_name)
24
+
25
+ require_file = nil
26
+ sh! "bundle gem #{gemname} --no-color" do |stdout|
27
+ require_file = stdout.split(/\n/).select { |file|
28
+ file =~ /\.rb$/ && file !~ /version.rb$/
29
+ }.first
30
+ end
31
+ rm_rf "#{gemname}/spec" # Don't want the default RSpec droppings
32
+ rm_rf "#{gemname}/.rspec"
33
+
34
+ require_file = gemname if require_file.nil?
35
+ require_file.gsub!(/^.*lib\//,'')
36
+
37
+ chdir gemname
38
+
39
+ template_dirs_in(:full).each { |dir| mkdir_p dir }
40
+
41
+ rspec = options[:rspec]
42
+
43
+ ["Rakefile", ".gitignore", ].each do |file|
44
+ copy_file file, :binding => binding
45
+ end
46
+
47
+ if rspec
48
+ template_dirs_in(:rspec).each { |dir| mkdir_p dir }
49
+ copy_file "spec/something_spec.rb", :from => :rspec, :binding => binding
50
+ else
51
+ template_dirs_in(:test_unit).each { |dir| mkdir_p dir }
52
+ copy_file "test/unit/test_something.rb", :from => :test_unit, :binding => binding
53
+ copy_file "test/integration/test_cli.rb", :from => :test_unit, :binding => binding
54
+ end
55
+
56
+
57
+ gemspec = "#{gemname}.gemspec"
58
+ gem_variable = File.open(gemspec) { |x| x.read }.match(/(\w+)\.executables/)[1]
59
+
60
+ license = options[:license]
61
+ warn "warning: your app has no license" unless license
62
+ license = nil if license == 'NONE'
63
+ if license
64
+ copy_file "#{options[:license]}_LICENSE.txt", :as => "LICENSE.txt"
65
+ else
66
+ #Remove the MIT license generated by `bundle gem`
67
+ debug "Making sure no LICENSE.txt file exists at the root of the repo"
68
+ FileUtils.rm_f "LICENSE.txt"
69
+ end
70
+
71
+ #Ensure the gemspec file mentions the correct license
72
+ gemspec_content = File.read(gemspec)
73
+ if gemspec_content =~ /(^\s*#{gem_variable}\.license\s*=\s*).*/
74
+ gemspec_content.gsub!(/(^\s*#{gem_variable}\.license\s*=\s*).*/,"\\1#{license.to_s.inspect}")
75
+ else
76
+ gemspec_content.gsub!(/(^\s*#{gem_variable}\.name\s*=\s*.*)/,"\\1\n#{" #{gem_variable}.license".ljust(20)} = #{license.to_s.inspect.upcase}")
77
+ end
78
+ # RubyGems won't deal with a gemspec in this state and so Bundler won't even
79
+ # work at all. This is not helpful, so replace the magic keys its looking for
80
+ # with something else
81
+ gemspec_content.gsub!(/TODO/,"to-do")
82
+ gemspec_content.gsub!(/FIXME/,"fix me")
83
+ gemspec_content.gsub!(/^.*\.homepage.*$/,"")
84
+ File.open(gemspec,'w') {|f| f.write gemspec_content }
85
+
86
+
87
+ copy_file "README.rdoc", :binding => binding if using_readme
88
+
89
+ copy_file "bin/executable", :as => gemname, :executable => true, :binding => binding
90
+
91
+ add_to_file gemspec, [
92
+ " #{gem_variable}.add_development_dependency('rdoc')",
93
+ " #{gem_variable}.add_dependency('optparse-plus', '~> #{OptparsePlus::VERSION}')",
94
+ ], :before => /^end\s*$/
95
+ ruby_major,ruby_minor,ruby_patch = RUBY_VERSION.split(/\./).map(&:to_i)
96
+
97
+ if ruby_major >= 2 && ruby_minor >= 2
98
+ add_to_file gemspec, [
99
+ " #{gem_variable}.add_development_dependency('test-unit')",
100
+ ], :before => /^end\s*$/
101
+ end
102
+
103
+ if rspec
104
+ add_to_file gemspec, [
105
+ " #{gem_variable}.add_development_dependency('rspec', '~> 3')",
106
+ ], :before => /^end\s*$/
107
+ end
108
+ FileUtils.rm_f "README.md", verbose: true
109
+
110
+ sh! %q(git add --all .)
111
+ end
112
+
113
+ options[:readme] = true
114
+
115
+ description "Kick the bash habit by bootstrapping your Ruby command-line apps"
116
+
117
+ on("--force","Overwrite files if they exist")
118
+ on("--[no-]readme","[Do not ]produce a README file")
119
+ on("--rspec", "Generate RSpec unit tests instead of Test::Unit")
120
+
121
+ licenses = %w(mit apache gplv2 gplv3 custom NONE)
122
+ on("-l LICENSE","--license",licenses,"Specify the license for your project",'(' + licenses.join('|') + ')')
123
+
124
+ use_log_level_option
125
+
126
+ arg :app_name, :required, "Name of your app, which is used for the gem name and executable name"
127
+
128
+ version OptparsePlus::VERSION, :compact => true
129
+
130
+ go!
@@ -1,3 +1,3 @@
1
1
  module OptparsePlus #:nodoc:
2
- VERSION = "3.0.0"
2
+ VERSION = "3.0.1"
3
3
  end
@@ -14,13 +14,13 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.executables = "optparse_plus"
18
+ s.bindir = "exe"
18
19
  s.require_paths = ["lib"]
19
20
  s.add_dependency("bundler")
20
21
  s.add_development_dependency("rake")
21
22
  s.add_development_dependency("rdoc","~> 6.0")
22
23
  s.add_development_dependency("sdoc")
23
- s.add_development_dependency("simplecov", "~> 0.5")
24
24
  s.add_development_dependency("clean_test", "~> 1.0.1")
25
25
  s.add_development_dependency("mocha")
26
26
  s.add_development_dependency("rspec") # needed for testing the generated tests
@@ -38,6 +38,7 @@ class TestBootstrap < BaseIntegrationTest
38
38
  gemspec = File.read("newgem/newgem.gemspec")
39
39
  refute_match(/TODO/,gemspec)
40
40
  refute_match(/FIXME/,gemspec)
41
+ refute_match(/optparse_plus/,gemspec)
41
42
  }
42
43
  end
43
44
 
@@ -1,12 +1,3 @@
1
- if RUBY_PLATFORM == 'java'
2
- puts "Simplecov seems to cause JRuby to barf, so use another ruby if you want to check coverage"
3
- else
4
- require 'simplecov'
5
- SimpleCov.start do
6
- add_filter "/test"
7
- end
8
- end
9
-
10
1
  require 'test/unit'
11
2
  require 'rspec/expectations'
12
3
  require 'clean_test/test_case'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optparse-plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - davetron5000
8
- autorequire:
9
- bindir: bin
8
+ autorequire:
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-10 00:00:00.000000000 Z
11
+ date: 2021-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: simplecov
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '0.5'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '0.5'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: clean_test
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -147,17 +133,19 @@ executables:
147
133
  extensions: []
148
134
  extra_rdoc_files: []
149
135
  files:
136
+ - ".circleci/config.yml"
150
137
  - ".gitignore"
151
- - ".ruby-gemset"
152
- - ".ruby-version"
153
- - ".travis.yml"
138
+ - ".tool-versions"
154
139
  - CHANGES.md
155
140
  - Gemfile
156
141
  - LICENSE.txt
157
142
  - README.rdoc
158
143
  - Rakefile
144
+ - bin/ci
159
145
  - bin/optparse_plus
160
- - fix.rb
146
+ - bin/rake
147
+ - bin/setup
148
+ - exe/optparse_plus
161
149
  - lib/optparse-plus.rb
162
150
  - lib/optparse_plus.rb
163
151
  - lib/optparse_plus/argv_parser.rb
@@ -217,7 +205,7 @@ files:
217
205
  homepage: http://github.com/davetron5000/optparse-plus
218
206
  licenses: []
219
207
  metadata: {}
220
- post_install_message:
208
+ post_install_message:
221
209
  rdoc_options: []
222
210
  require_paths:
223
211
  - lib
@@ -232,8 +220,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
220
  - !ruby/object:Gem::Version
233
221
  version: '0'
234
222
  requirements: []
235
- rubygems_version: 3.1.2
236
- signing_key:
223
+ rubygems_version: 3.2.3
224
+ signing_key:
237
225
  specification_version: 4
238
226
  summary: Wrapper around the Standard Library's Option Parser to make CLIs Easier
239
227
  test_files:
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- methadone
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.5.1
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- notifications:
2
- email:
3
- on_success: always
4
- script: 'bundle exec rake'
5
- rvm:
6
- - 2.4.3
7
- - 2.5.1
data/fix.rb DELETED
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "pathname"
4
- require "fileutils"
5
-
6
-
7
- ARGV.each do |filename|
8
- filename = Pathname(filename)
9
-
10
- contents = File.read(filename).split(/\n/)
11
- File.open(filename,"w") do |file|
12
- contents.each do |line|
13
- file.puts line.gsub(/methadone/,"optparse_plus").gsub(/Methadone/,"OptparsePlus")
14
- end
15
- end
16
-
17
- if filename.split.any? { |_| _ == "methadone" }
18
- new_filename = filename.split.map { |_|
19
- if _ == "methadone"
20
- "optparse_plus"
21
- else
22
- _
23
- end
24
- }.join
25
- FileUtils.mkdir_p new_filename.dirname
26
- FileUtils.mv filename new_filename
27
- end
28
-
29
- end