gemsmith 7.7.0 → 8.0.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 (92) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/README.md +114 -118
  5. data/bin/gemsmith +2 -1
  6. data/lib/gemsmith/cli.rb +195 -99
  7. data/lib/gemsmith/cli_helpers.rb +8 -19
  8. data/lib/gemsmith/credentials.rb +2 -2
  9. data/lib/gemsmith/gem/inspector.rb +30 -0
  10. data/lib/gemsmith/gem/module_formatter.rb +51 -0
  11. data/lib/gemsmith/gem/requirement.rb +2 -0
  12. data/lib/gemsmith/{aids/gem_spec.rb → gem/specification.rb} +19 -26
  13. data/lib/gemsmith/generators/base.rb +33 -0
  14. data/lib/gemsmith/generators/bundler.rb +15 -0
  15. data/lib/gemsmith/generators/cli.rb +17 -0
  16. data/lib/gemsmith/generators/code_climate.rb +14 -0
  17. data/lib/gemsmith/generators/documentation.rb +28 -0
  18. data/lib/gemsmith/generators/gem.rb +17 -0
  19. data/lib/gemsmith/{skeletons/git_skeleton.rb → generators/git.rb} +13 -7
  20. data/lib/gemsmith/generators/git_hub.rb +14 -0
  21. data/lib/gemsmith/generators/guard.rb +13 -0
  22. data/lib/gemsmith/generators/pragma.rb +40 -0
  23. data/lib/gemsmith/generators/rails.rb +85 -0
  24. data/lib/gemsmith/generators/rake.rb +40 -0
  25. data/lib/gemsmith/generators/reek.rb +13 -0
  26. data/lib/gemsmith/generators/rspec.rb +23 -0
  27. data/lib/gemsmith/generators/rubocop.rb +16 -0
  28. data/lib/gemsmith/{skeletons/ruby_skeleton.rb → generators/ruby.rb} +5 -5
  29. data/lib/gemsmith/generators/scss_lint.rb +13 -0
  30. data/lib/gemsmith/generators/travis.rb +13 -0
  31. data/lib/gemsmith/git.rb +19 -0
  32. data/lib/gemsmith/identity.rb +1 -1
  33. data/lib/gemsmith/rake/builder.rb +65 -0
  34. data/lib/gemsmith/rake/{release.rb → publisher.rb} +14 -5
  35. data/lib/gemsmith/rake/tasks.rb +32 -20
  36. data/lib/gemsmith/template_helper.rb +28 -0
  37. data/lib/gemsmith/templates/%gem_name%/%gem_name%.gemspec.tt +30 -28
  38. data/lib/gemsmith/templates/%gem_name%/.codeclimate.yml.tt +36 -0
  39. data/lib/gemsmith/templates/%gem_name%/.rubocop.yml.tt +9 -1
  40. data/lib/gemsmith/templates/%gem_name%/.travis.yml.tt +4 -1
  41. data/lib/gemsmith/templates/%gem_name%/{CHANGELOG.md.tt → CHANGES.md.tt} +0 -0
  42. data/lib/gemsmith/templates/%gem_name%/Guardfile.tt +1 -1
  43. data/lib/gemsmith/templates/%gem_name%/README.md.tt +20 -18
  44. data/lib/gemsmith/templates/%gem_name%/Rakefile.tt +6 -1
  45. data/lib/gemsmith/templates/%gem_name%/bin/%gem_name%.tt +4 -4
  46. data/lib/gemsmith/templates/%gem_name%/bin/setup.tt +1 -1
  47. data/lib/gemsmith/templates/%gem_name%/lib/%gem_path%.rb.tt +4 -0
  48. data/lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt +54 -0
  49. data/lib/gemsmith/templates/%gem_name%/lib/{%gem_name% → %gem_path%}/engine.rb.tt +2 -4
  50. data/lib/gemsmith/templates/%gem_name%/lib/{%gem_name% → %gem_path%}/identity.rb.tt +3 -5
  51. data/lib/gemsmith/templates/%gem_name%/lib/generators/{%gem_name% → %gem_path%}/install/USAGE.tt +0 -0
  52. data/lib/gemsmith/templates/%gem_name%/lib/generators/{%gem_name% → %gem_path%}/install/install_generator.rb.tt +2 -5
  53. data/lib/gemsmith/templates/%gem_name%/lib/generators/{%gem_name% → %gem_path%}/upgrade/USAGE.tt +0 -0
  54. data/lib/gemsmith/templates/%gem_name%/lib/generators/{%gem_name% → %gem_path%}/upgrade/upgrade_generator.rb.tt +2 -5
  55. data/lib/gemsmith/templates/%gem_name%/lib/tasks/reek.rake.tt +6 -0
  56. data/lib/gemsmith/templates/%gem_name%/lib/tasks/scss_lint.rake.tt +6 -0
  57. data/lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt +83 -0
  58. data/lib/gemsmith/templates/%gem_name%/spec/rails_helper.rb.tt +14 -0
  59. data/lib/gemsmith/templates/%gem_name%/spec/spec_helper.rb.tt +29 -16
  60. data/lib/gemsmith/templates/%gem_name%/spec/support/shared_contexts/temp_dir.rb.tt +9 -0
  61. data/lib/tasks/reek.rake +8 -0
  62. data/lib/tasks/rspec.rake +2 -0
  63. data/lib/tasks/rubocop.rake +2 -0
  64. metadata +138 -149
  65. metadata.gz.sig +0 -0
  66. data/lib/gemsmith/aids/git.rb +0 -12
  67. data/lib/gemsmith/aids/spec.rb +0 -46
  68. data/lib/gemsmith/configuration.rb +0 -200
  69. data/lib/gemsmith/rake/build.rb +0 -38
  70. data/lib/gemsmith/skeletons/base_skeleton.rb +0 -29
  71. data/lib/gemsmith/skeletons/bundler_skeleton.rb +0 -15
  72. data/lib/gemsmith/skeletons/cli_skeleton.rb +0 -16
  73. data/lib/gemsmith/skeletons/documentation_skeleton.rb +0 -28
  74. data/lib/gemsmith/skeletons/gem_skeleton.rb +0 -17
  75. data/lib/gemsmith/skeletons/git_hub_skeleton.rb +0 -14
  76. data/lib/gemsmith/skeletons/guard_skeleton.rb +0 -13
  77. data/lib/gemsmith/skeletons/pry_skeleton.rb +0 -13
  78. data/lib/gemsmith/skeletons/rails_skeleton.rb +0 -61
  79. data/lib/gemsmith/skeletons/rake_skeleton.rb +0 -37
  80. data/lib/gemsmith/skeletons/rspec_skeleton.rb +0 -26
  81. data/lib/gemsmith/skeletons/rubocop_skeleton.rb +0 -15
  82. data/lib/gemsmith/skeletons/travis_skeleton.rb +0 -13
  83. data/lib/gemsmith/templates/%gem_name%/lib/%gem_name%.rb.tt +0 -6
  84. data/lib/gemsmith/templates/%gem_name%/lib/%gem_name%/cli.rb.tt +0 -40
  85. data/lib/gemsmith/templates/%gem_name%/lib/tasks/console.rake.tt +0 -7
  86. data/lib/gemsmith/templates/%gem_name%/spec/lib/%gem_name%/%gem_name%_spec.rb.tt +0 -7
  87. data/lib/gemsmith/templates/%gem_name%/spec/support/extensions/pry.rb.tt +0 -5
  88. data/lib/gemsmith/templates/%gem_name%/spec/support/kit/default_config.rb.tt +0 -18
  89. data/lib/gemsmith/templates/%gem_name%/spec/support/kit/stderr.rb.tt +0 -9
  90. data/lib/gemsmith/templates/%gem_name%/spec/support/kit/stdout.rb.tt +0 -9
  91. data/lib/gemsmith/templates/%gem_name%/spec/support/kit/temp_dir.rb.tt +0 -25
  92. data/lib/tasks/console.rake +0 -7
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gemsmith
4
+ # Provides helper methods for use by the Thor CLI. These methods are necessary to resolve %% file
5
+ # and folder variables and render dynamic content within the Thor ERB *templates* structure.
6
+ module TemplateHelper
7
+ def gem_name
8
+ configuration.dig :gem, :name
9
+ end
10
+
11
+ def gem_path
12
+ configuration.dig :gem, :path
13
+ end
14
+
15
+ def gem_class
16
+ configuration.dig :gem, :class
17
+ end
18
+
19
+ def rails_version
20
+ configuration.dig :versions, :rails
21
+ end
22
+
23
+ def render_namespace &block
24
+ body = capture(&block) if block_given?
25
+ concat Gem::ModuleFormatter.new(gem_class).render(body)
26
+ end
27
+ end
28
+ end
@@ -1,5 +1,5 @@
1
1
  $LOAD_PATH.push File.expand_path("../lib", __FILE__)
2
- require "<%= config.dig(:gem, :name) %>/identity"
2
+ require "<%= config.dig(:gem, :path) %>/identity"
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = <%= config.dig(:gem, :class) %>::Identity.name
@@ -7,52 +7,54 @@ Gem::Specification.new do |spec|
7
7
  spec.platform = <%= config.dig(:gem, :platform) %>
8
8
  spec.authors = ["<%= config.dig(:author, :name) %>"]
9
9
  spec.email = ["<%= config.dig(:author, :email) %>"]
10
- spec.homepage = "<%= config.dig(:gem, :home_url) %>"
10
+ spec.homepage = "<%= config.dig(:gem, :url) %>"
11
11
  spec.summary = ""
12
- spec.description = ""
13
12
  spec.license = "MIT"
14
13
 
15
- <%- if config.dig(:create, :security) -%>
16
- if ENV["RUBY_GEM_SECURITY"] == "enabled"
17
- spec.signing_key = File.expand_path("<%= config.dig(:gem, :private_key) %>")
18
- spec.cert_chain = [File.expand_path("<%= config.dig(:gem, :public_key) %>")]
14
+ <%- if config.dig(:generate, :security) -%>
15
+ if File.exist?(Gem.default_key_path) && File.exist?(Gem.default_cert_path)
16
+ spec.signing_key = Gem.default_key_path
17
+ spec.cert_chain = [Gem.default_cert_path]
19
18
  end
20
19
  <%- end -%>
21
20
 
22
- <%- if config.dig(:create, :cli) -%>
21
+ <%- if config.dig(:generate, :cli) -%>
23
22
  spec.add_dependency "thor", "~> 0.19"
24
- spec.add_dependency "thor_plus", "~> 3.1"
23
+ spec.add_dependency "thor_plus", "~> 4.0"
24
+ spec.add_dependency "runcom", "~> 0.2"
25
25
  <%- end -%>
26
- <%- if config.dig(:create, :rails) -%>
26
+ <%- if config.dig(:generate, :rails) -%>
27
27
  spec.add_dependency "rails", "~> <%= config.dig(:versions, :rails) %>"
28
28
  <%- end -%>
29
- spec.add_development_dependency "bundler", "~> 1.12"
30
29
  spec.add_development_dependency "rake", "~> 11.0"
31
30
  spec.add_development_dependency "gemsmith", "~> <%= Gemsmith::Identity.version[/\d{1}\.\d{1}/] %>"
32
- <%- if config.dig(:create, :pry) -%>
33
- spec.add_development_dependency "pry"
34
- spec.add_development_dependency "pry-byebug"
35
- spec.add_development_dependency "pry-state"
31
+ <%- if config.dig(:generate, :pry) -%>
32
+ spec.add_development_dependency "pry", "~> 0.10"
33
+ spec.add_development_dependency "pry-byebug", "~> 3.4"
34
+ spec.add_development_dependency "pry-state", "~> 0.1"
36
35
  <%- end -%>
37
- <%- if config.dig(:create, :rspec) -%>
38
- spec.add_development_dependency "<%= config.dig(:create, :rails) ? "rspec-rails" : "rspec" %>", "~> 3.4"
36
+ <%- if config.dig(:generate, :rspec) -%>
37
+ spec.add_development_dependency "<%= config.dig(:generate, :rails) ? "rspec-rails" : "rspec" %>", "~> 3.5"
39
38
  <%- end -%>
40
- <%- if config.dig(:create, :guard) -%>
41
- spec.add_development_dependency "rb-fsevent" # Guard file events for OSX.
42
- spec.add_development_dependency "guard-rspec"
43
- spec.add_development_dependency "terminal-notifier"
44
- spec.add_development_dependency "terminal-notifier-guard"
39
+ <%- if config.dig(:generate, :guard) -%>
40
+ spec.add_development_dependency "guard-rspec", "~> 4.7"
45
41
  <%- end -%>
46
- <%- if config.dig(:create, :rubocop) -%>
47
- spec.add_development_dependency "rubocop", "~> 0.40"
42
+ <%- if config.dig(:generate, :reek) -%>
43
+ spec.add_development_dependency "reek", "~> 4.5"
48
44
  <%- end -%>
49
- <%- if config.dig(:create, :code_climate) -%>
50
- spec.add_development_dependency "codeclimate-test-reporter"
45
+ <%- if config.dig(:generate, :rubocop) -%>
46
+ spec.add_development_dependency "rubocop", "~> 0.45"
47
+ <%- end -%>
48
+ <%- if config.dig(:generate, :scss_lint) -%>
49
+ spec.add_development_dependency "scss_lint", "~> 0.50"
50
+ <%- end -%>
51
+ <%- if config.dig(:generate, :code_climate) -%>
52
+ spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0"
51
53
  <%- end -%>
52
54
 
53
- spec.files = Dir["lib/**/*", "vendor/**/*"]
55
+ spec.files = Dir["lib/**/*"]
54
56
  spec.extra_rdoc_files = Dir["README*", "LICENSE*"]
55
- <%- if config.dig(:create, :cli) -%>
57
+ <%- if config.dig(:generate, :cli) -%>
56
58
  spec.executables << "<%= config.dig(:gem, :name) %>"
57
59
  <%- end -%>
58
60
  spec.require_paths = ["lib"]
@@ -0,0 +1,36 @@
1
+ ---
2
+ engines:
3
+ shellcheck:
4
+ enabled: true
5
+ bundler-audit:
6
+ enabled: true
7
+ reek:
8
+ enabled: <%= config.dig :generate, :reek %>
9
+ rubocop:
10
+ enabled: <%= config.dig :generate, :rubocop %>
11
+ scss-lint:
12
+ enabled: <%= config.dig :generate, :scss_lint %>
13
+ duplication:
14
+ enabled: true
15
+ config:
16
+ languages:
17
+ - ruby
18
+ - javascript
19
+ fixme:
20
+ enabled: true
21
+ config:
22
+ strings:
23
+ - TODO
24
+ - FIX
25
+ - DUPLICATE
26
+ ratings:
27
+ paths:
28
+ - "app/**/*"
29
+ - "bin/**/*"
30
+ - "lib/**/*"
31
+ - "**.rb"
32
+ - "**.js"
33
+ exclude_paths:
34
+ - "spec/**/*"
35
+ - "vendor/**/*"
36
+ - ".codeclimate.yml"
@@ -1,4 +1,4 @@
1
- <%- if config.dig(:create, :rails) -%>
1
+ <%- if config.dig(:generate, :rails) -%>
2
2
  AllCops:
3
3
  Exclude:
4
4
  - "spec/dummy/**/*"
@@ -22,6 +22,8 @@ Style/PercentLiteralDelimiters:
22
22
  "%i": "[]"
23
23
  "%I": "[]"
24
24
  "%r": "()"
25
+ Style/SafeNavigation:
26
+ Enabled: false
25
27
  Style/SignalException:
26
28
  EnforcedStyle: semantic
27
29
  Style/SingleLineBlockParams:
@@ -32,5 +34,11 @@ Style/StringLiterals:
32
34
  EnforcedStyle: double_quotes
33
35
  Style/StringLiteralsInInterpolation:
34
36
  EnforcedStyle: double_quotes
37
+ Style/VariableNumber:
38
+ EnforcedStyle: snake_case
39
+ Metrics/BlockLength:
40
+ Exclude:
41
+ - "**/*.gemspec"
42
+ - "spec/**/*"
35
43
  Metrics/LineLength:
36
44
  Max: 120
@@ -1,10 +1,13 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - <%= config.dig(:versions, :ruby) %>
4
- <%- if config.dig(:create, :rails) -%>
4
+ <%- if config.dig(:generate, :rails) -%>
5
5
  gemfile:
6
6
  - gemfiles/rails-<%= config.dig(:versions, :rails) %>.x.gemfile
7
7
  <%- end -%>
8
8
  script: bundle exec rake
9
+ <%- if config.dig(:generate, :code_climate) -%>
10
+ after_script: bundle exec codeclimate-test-reporter
11
+ <%- end -%>
9
12
  notifications:
10
13
  email: false
@@ -2,7 +2,7 @@ guard :rspec, cmd: "bundle exec rspec" do
2
2
  watch(%r(^spec/.+_spec\.rb$))
3
3
  watch(%r(^lib/(.+)\.rb$)) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
4
  watch("spec/spec_helper.rb") { "spec" }
5
- <%- if config.dig(:create, :rails) -%>
5
+ <%- if config.dig(:generate, :rails) -%>
6
6
 
7
7
  # Rails
8
8
  watch(%r(^app/(.+)\.rb$)) { |m| "spec/#{m[1]}_spec.rb" }
@@ -1,17 +1,17 @@
1
1
  # <%= config.dig(:gem, :class) %>
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/<%= config.dig(:gem, :name) %>.svg)](http://badge.fury.io/rb/<%= config.dig(:gem, :name) %>)
4
- <%- if config.dig(:create, :code_climate) -%>
4
+ <%- if config.dig(:generate, :code_climate) -%>
5
5
  [![Code Climate GPA](https://codeclimate.com/github/<%= config.fetch :github_user %>/<%= config.dig(:gem, :name) %>.svg)](https://codeclimate.com/github/<%= config.fetch :github_user %>/<%= config.dig(:gem, :name) %>)
6
6
  [![Code Climate Coverage](https://codeclimate.com/github/<%= config.fetch :github_user %>/<%= config.dig(:gem, :name) %>/coverage.svg)](https://codeclimate.com/github/<%= config.fetch :github_user %>/<%= config.dig(:gem, :name) %>)
7
7
  <%- end -%>
8
- <%- if config.dig(:create, :gemnasium) -%>
8
+ <%- if config.dig(:generate, :gemnasium) -%>
9
9
  [![Gemnasium Status](https://gemnasium.com/<%= config.fetch :github_user %>/<%= config.dig(:gem, :name) %>.svg)](https://gemnasium.com/<%= config.fetch :github_user %>/<%= config.dig(:gem, :name) %>)
10
10
  <%- end -%>
11
- <%- if config.dig(:create, :travis) -%>
11
+ <%- if config.dig(:generate, :travis) -%>
12
12
  [![Travis CI Status](https://secure.travis-ci.org/<%= config.fetch :github_user %>/<%= config.dig(:gem, :name) %>.svg)](https://travis-ci.org/<%= config.fetch :github_user %>/<%= config.dig(:gem, :name) %>)
13
13
  <%- end -%>
14
- <%- if config.dig(:create, :patreon) -%>
14
+ <%- if config.dig(:generate, :patreon) -%>
15
15
  [![Patreon](https://img.shields.io/badge/patreon-donate-brightgreen.svg)](https://www.patreon.com/<%= config.fetch :github_user %>)
16
16
  <%- end -%>
17
17
 
@@ -24,21 +24,22 @@
24
24
 
25
25
  # Requirements
26
26
 
27
- 0. [MRI <%= config.dig(:versions, :ruby) %>](https://www.ruby-lang.org)
28
- <%- if config.dig(:create, :rails) -%>
27
+ 0. [Ruby <%= config.dig(:versions, :ruby) %>](https://www.ruby-lang.org)
28
+ <%- if config.dig(:generate, :rails) -%>
29
29
  0. [Ruby on Rails](http://rubyonrails.org).
30
30
  <%- end -%>
31
31
 
32
32
  # Setup
33
33
 
34
- <%- if config.dig(:create, :security) -%>
34
+ <%- if config.dig(:generate, :security) -%>
35
35
  For a secure install, type the following (recommended):
36
36
 
37
37
  gem cert --add <(curl --location --silent <%= config.dig :organization, :url %>/gem-public.pem)
38
38
  gem install <%= config.dig(:gem, :name) %> --trust-policy MediumSecurity
39
39
 
40
- NOTE: A HighSecurity trust policy would be best but MediumSecurity enables signed gem verification while
41
- allowing the installation of unsigned dependencies since they are beyond the scope of this gem.
40
+ NOTE: A HighSecurity trust policy would be best but MediumSecurity enables signed gem verification
41
+ while allowing the installation of unsigned dependencies since they are beyond the scope of this
42
+ gem.
42
43
 
43
44
  For an insecure install, type the following (not recommended):
44
45
 
@@ -49,7 +50,7 @@ To install, type the following:
49
50
  gem install <%= config.dig(:gem, :name) %>
50
51
  <%- end -%>
51
52
 
52
- <%- unless config.dig(:create, :cli) -%>
53
+ <%- unless config.dig(:generate, :cli) -%>
53
54
  Add the following to your Gemfile:
54
55
 
55
56
  gem "<%= config.dig(:gem, :name) %>"
@@ -57,7 +58,7 @@ Add the following to your Gemfile:
57
58
 
58
59
  # Usage
59
60
 
60
- <%- if config.dig(:create, :rspec) -%>
61
+ <%- if config.dig(:generate, :rspec) -%>
61
62
  # Tests
62
63
 
63
64
  To test, run:
@@ -69,14 +70,14 @@ To test, run:
69
70
 
70
71
  Read [Semantic Versioning](http://semver.org) for details. Briefly, it means:
71
72
 
72
- - Patch (x.y.Z) - Incremented for small, backwards compatible bug fixes.
73
- - Minor (x.Y.z) - Incremented for new, backwards compatible public API enhancements and/or bug fixes.
73
+ - Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
74
+ - Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
74
75
  - Major (X.y.z) - Incremented for any backwards incompatible public API changes.
75
76
 
76
77
  # Code of Conduct
77
78
 
78
- Please note that this project is released with a [CODE OF CONDUCT](CODE_OF_CONDUCT.md). By participating in this project
79
- you agree to abide by its terms.
79
+ Please note that this project is released with a [CODE OF CONDUCT](CODE_OF_CONDUCT.md). By
80
+ participating in this project you agree to abide by its terms.
80
81
 
81
82
  # Contributions
82
83
 
@@ -85,13 +86,14 @@ Read [CONTRIBUTING](CONTRIBUTING.md) for details.
85
86
  # License
86
87
 
87
88
  Copyright (c) <%= config.fetch :year %> [<%= config.dig :organization, :name %>](<%= config.dig :organization, :url %>).
88
- Read the [LICENSE](LICENSE.md) for details.
89
+ Read [LICENSE](LICENSE.md) for details.
89
90
 
90
91
  # History
91
92
 
92
- Read the [CHANGELOG](CHANGELOG.md) for details.
93
+ Read [CHANGES](CHANGES.md) for details.
93
94
  Built with [Gemsmith](https://github.com/bkuhlmann/gemsmith).
94
95
 
95
96
  # Credits
96
97
 
97
- Developed by [<%= config.dig(:author, :name) %>](<%= config.dig :author, :url %>) at [<%= config.dig :organization, :name %>](<%= config.dig :organization, :url %>).
98
+ Developed by [<%= config.dig(:author, :name) %>](<%= config.dig :author, :url %>) at
99
+ [<%= config.dig :organization, :name %>](<%= config.dig :organization, :url %>).
@@ -1,2 +1,7 @@
1
- require "gemsmith/rake/setup"
1
+ begin
2
+ require "gemsmith/rake/setup"
3
+ rescue LoadError => error
4
+ puts error.message
5
+ end
6
+
2
7
  Dir.glob("lib/tasks/*.rake").each { |file| load file }
@@ -1,8 +1,8 @@
1
- #! /usr/bin/ruby
1
+ #! /usr/bin/env ruby
2
2
 
3
- require "<%= config.dig(:gem, :name) %>"
4
- require "<%= config.dig(:gem, :name) %>/cli"
5
- require "<%= config.dig(:gem, :name) %>/identity"
3
+ require "<%= config.dig(:gem, :path) %>"
4
+ require "<%= config.dig(:gem, :path) %>/cli"
5
+ require "<%= config.dig(:gem, :path) %>/identity"
6
6
 
7
7
  Process.setproctitle <%= config.dig(:gem, :class) %>::Identity.version_label
8
8
  <%= config.dig(:gem, :class) %>::CLI.start
@@ -1,4 +1,4 @@
1
- #! /bin/bash
1
+ #! /usr/bin/env bash
2
2
 
3
3
  set -o nounset # Exit, with error message, when attempting to use an undefined variable.
4
4
  set -o errexit # Abort script at first error, when a command exits with non-zero status.
@@ -0,0 +1,4 @@
1
+ require "<%= config.dig(:gem, :path) %>/identity"
2
+ <%- if config.dig(:generate, :rails) -%>
3
+ require "<%= config.dig(:gem, :path) %>/engine"
4
+ <%- end -%>
@@ -0,0 +1,54 @@
1
+ require "yaml"
2
+ require "thor"
3
+ require "thor/actions"
4
+ require "thor_plus/actions"
5
+ require "runcom"
6
+
7
+ <% render_namespace do %>
8
+ # The Command Line Interface (CLI) for the gem.
9
+ class CLI < Thor
10
+ include Thor::Actions
11
+ include ThorPlus::Actions
12
+
13
+ package_name <%= config.dig(:gem, :class) %>::Identity.version_label
14
+
15
+ def self.configuration
16
+ Runcom::Configuration.new file_name: Identity.file_name
17
+ end
18
+
19
+ def initialize args = [], options = {}, config = {}
20
+ super args, options, config
21
+ end
22
+
23
+ desc "-c, [--config]", %(Manage gem configuration ("#{configuration.computed_path}").)
24
+ map %w[-c --config] => :config
25
+ method_option :edit,
26
+ aliases: "-e",
27
+ desc: "Edit gem configuration.",
28
+ type: :boolean, default: false
29
+ method_option :info,
30
+ aliases: "-i",
31
+ desc: "Print gem configuration.",
32
+ type: :boolean, default: false
33
+ def config
34
+ path = self.class.configuration.computed_path
35
+
36
+ if options.edit? then `#{editor} #{path}`
37
+ elsif options.info? then say(path)
38
+ else help(:config)
39
+ end
40
+ end
41
+
42
+ desc "-v, [--version]", "Show gem version."
43
+ map %w[-v --version] => :version
44
+ def version
45
+ say <%= config.dig(:gem, :class) %>::Identity.version_label
46
+ end
47
+
48
+ desc "-h, [--help=COMMAND]", "Show this message or get help for a command."
49
+ map %w[-h --help] => :help
50
+ def help task = nil
51
+ say and super
52
+ end
53
+ end
54
+ <% end %>
@@ -1,8 +1,6 @@
1
- # frozen_string_literal: true
2
-
3
- module <%= config.dig(:gem, :class) %>
1
+ <% render_namespace do %>
4
2
  # Defines and registers the Rails engine.
5
3
  class Engine < ::Rails::Engine
6
4
  isolate_namespace <%= config.dig(:gem, :class) %>
7
5
  end
8
- end
6
+ <% end %>
@@ -1,6 +1,4 @@
1
- # frozen_string_literal: true
2
-
3
- module <%= config.dig(:gem, :class) %>
1
+ <% render_namespace do %>
4
2
  # Gem identity information.
5
3
  module Identity
6
4
  def self.name
@@ -18,11 +16,11 @@ module <%= config.dig(:gem, :class) %>
18
16
  def self.version_label
19
17
  "#{label} #{version}"
20
18
  end
21
- <%- if config.dig(:create, :cli) -%>
19
+ <%- if config.dig(:generate, :cli) -%>
22
20
 
23
21
  def self.file_name
24
22
  ".#{name}rc"
25
23
  end
26
24
  <%- end -%>
27
25
  end
28
- end
26
+ <% end %>
@@ -1,13 +1,10 @@
1
- # frozen_string_literal: true
2
-
3
- module <%= config.dig(:gem, :class) %>
1
+ <% render_namespace do %>
4
2
  # Generator for installing new files.
5
3
  class InstallGenerator < Rails::Generators::Base
6
4
  source_root File.join(File.dirname(__FILE__), "..", "templates")
7
5
 
8
6
  desc "Installs additional <%= config.dig(:gem, :class) %> resources."
9
7
  def install
10
- # TODO: Add install code.
11
8
  end
12
9
  end
13
- end
10
+ <% end %>