gemsmith 7.7.0 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34971a7bf833e06948419177cf190d1f1418a05a
4
- data.tar.gz: 03252013fd1be9ef11fde87968f293f61c52f867
3
+ metadata.gz: 7b1e5311577e90d181cad13d15213dc594450040
4
+ data.tar.gz: 777ee65fe3019ece41362faf8875a9b1c79ded58
5
5
  SHA512:
6
- metadata.gz: 7c4bcc823e16f4301cbfa7ace9ad5d40b1157ae59aaf3dee8b7f692dc84720d921f46f91fdc75f541e104e1b11b6493efecf5382d692e047ce83280225252d2e
7
- data.tar.gz: 166745da9434736b4a8f0a7a7300297c37bd212501dbdfa37aff2f916730c8f0ca7c685fd1460d8b3bb7028d47b9aa1d95970c28c762663680b9f56c49731887
6
+ metadata.gz: 9852fb4e6aa21e3880e3a034df9a1c8aa077705799ebd0fe261990db1a1fbe73e59c257ed69be945f1d7a0f65b7857ab667c9f6890c19eeb0fe1c16829b04b0e
7
+ data.tar.gz: 01f05a28bc1f0cc79d1ee9b727ec56f79f5dd548729ccfb44323b792d21705578a4b022dfea16588332dfa620929349d1a8d3e11147c241cdd00c13c7ef18b02
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -28,6 +28,7 @@ A command line interface for smithing new Ruby gems.
28
28
  - [Gem Specification Metadata](#gem-specification-metadata)
29
29
  - [Gem Credentials](#gem-credentials)
30
30
  - [Promotion](#promotion)
31
+ - [Troubleshooting](#troubleshooting)
31
32
  - [Versioning](#versioning)
32
33
  - [Code of Conduct](#code-of-conduct)
33
34
  - [Contributions](#contributions)
@@ -40,15 +41,21 @@ A command line interface for smithing new Ruby gems.
40
41
  # Features
41
42
 
42
43
  - Builds a gem skeleton with enhanced Bundler functionality.
44
+ - Uses [Refinements](https://github.com/bkuhlmann/refinements) Ruby core library enhancements.
43
45
  - Uses [Versionaire](https://github.com/bkuhlmann/versionaire) for semantic versioning.
46
+ - Uses [Runcom](https://github.com/bkuhlmann/runcom) for resource configuration management.
44
47
  - Uses [Milestoner](https://github.com/bkuhlmann/milestoner) for consistent project/gem versioning.
48
+ - Uses [Pragmater](https://github.com/bkuhlmann/pragmater) for Ruby source pragma directives.
45
49
  - Uses [Tocer](https://github.com/bkuhlmann/tocer) for README table of contents generation.
46
50
  - Supports [Thor](https://github.com/erikhuda/thor).
47
51
  - Supports [Ruby on Rails](http://rubyonrails.org).
52
+ - Supports [RubyGems Security](http://guides.rubygems.org/security).
48
53
  - Supports [Pry](http://pryrepl.org).
49
54
  - Supports [Guard](https://github.com/guard/guard).
50
55
  - Supports [RSpec](http://rspec.info).
56
+ - Supports [Reek](https://github.com/troessner/reek).
51
57
  - Supports [Rubocop](https://github.com/bbatsov/rubocop).
58
+ - Supports [SCSS Lint](https://github.com/brigade/scss-lint).
52
59
  - Supports [GitHub](https://github.com).
53
60
  - Supports [Code Climate](https://codeclimate.com).
54
61
  - Supports [Gemnasium](https://gemnasium.com).
@@ -56,14 +63,18 @@ A command line interface for smithing new Ruby gems.
56
63
  - Supports [Patreon](https://www.patreon.com).
57
64
  - Supports common settings and a structured layout for building new gems.
58
65
  - Supports publishing to public or private gem servers.
59
- - Provides commonly needed [README](README.md), [CHANGELOG](CHANGELOG.md), [CONTRIBUTING](CONTRIBUTING.md),
60
- [CODE OF CONDUCT](CODE_OF_CONDUCT.md), [LICENSE](LICENSE.md), etc. documentation.
61
- - Provides the ability to view source code of any gem within your favorite editor.
62
- - Provides the ability to view the documentation of any gem within your default browser.
66
+ - Provides common documentation:
67
+ - [README](README.md)
68
+ - [CHANGES](CHANGES.md)
69
+ - [CONTRIBUTING](CONTRIBUTING.md)
70
+ - [CODE OF CONDUCT](CODE_OF_CONDUCT.md)
71
+ - [LICENSE](LICENSE.md)
72
+ - Aids in viewing source code of semantically versioned gems within your favorite editor.
73
+ - Aids in viewing documentation of semantically versioned within your default browser.
63
74
 
64
75
  # Screencasts
65
76
 
66
- [![asciicast](https://asciinema.org/a/30728.png)](https://asciinema.org/a/30728)
77
+ [![asciicast](https://asciinema.org/a/92550.png)](https://asciinema.org/a/92550)
67
78
 
68
79
  # Requirements
69
80
 
@@ -79,8 +90,9 @@ For a secure install, type the following from the command line (recommended):
79
90
  gem cert --add <(curl --location --silent https://www.alchemists.io/gem-public.pem)
80
91
  gem install gemsmith --trust-policy MediumSecurity
81
92
 
82
- NOTE: A HighSecurity trust policy would be best but MediumSecurity enables signed gem verification while
83
- allowing the installation of unsigned dependencies since they are beyond the scope of this gem.
93
+ NOTE: A HighSecurity trust policy would be best but MediumSecurity enables signed gem verification
94
+ while allowing the installation of unsigned dependencies since they are beyond the scope of this
95
+ gem.
84
96
 
85
97
  For an insecure install, type the following (not recommended):
86
98
 
@@ -90,53 +102,48 @@ You can configure common settings for future gem builds by creating the followin
90
102
 
91
103
  ~/.gemsmithrc
92
104
 
93
- ...using the following settings (as a simple example):
94
-
95
- :author:
96
- :name: "Joe Smith"
97
- :email: "joe@example.com"
98
- :url: "https://www.example.com"
99
- :organization:
100
- :name: "ExampleSoft"
101
- :url: "https://www.example.com"
102
-
103
105
  The following defaults are used when no options are configured:
104
106
 
105
107
  :year: <current year>
106
- :github_user: <git config GitHub user>
108
+ :github_user: "<Git config GitHub user>",
107
109
  :gem:
110
+ :name: "undefined"
111
+ :path: "undefined"
112
+ :class: "Undefined"
108
113
  :platform: "Gem::Platform::RUBY"
109
- :home_url: ""
114
+ :url: "https://github.com/<author>/<gem name>"
110
115
  :license: "MIT"
111
- :private_key: "~/.ssh/gem-private.pem"
112
- :public_key: "~/.ssh/gem-public.pem"
113
116
  :author:
114
- :name: <git config user name>
115
- :email: <git config user email>
117
+ :name: "<Git config user name>"
118
+ :email: "<Git config user email>"
116
119
  :url: ""
117
120
  :organization:
118
121
  :name: ""
119
122
  :url: ""
120
123
  :versions:
121
- :ruby: <current Ruby version>
122
- :rails: "4.2"
123
- :create:
124
+ :ruby: "<current Ruby version>"
125
+ :rails: "5.0"
126
+ :generate:
124
127
  :cli: false
125
128
  :rails: false
126
129
  :security: true
127
130
  :pry: true
128
131
  :guard: true
129
132
  :rspec: true
133
+ :reek: true
130
134
  :rubocop: true
131
- :git-hub: false
132
- :code_climate: true
133
- :gemnasium: true
134
- :travis: true
135
- :patreon: true
136
-
137
- While Gemsmith is fully customizable, please keep in mind that these are *global* settings and, once set, will affect
138
- all future gem creations. Further customization is also provided via the CLI for a customizable experience per gem if
139
- necessary.
135
+ :scss_lint: false
136
+ :git_hub: false
137
+ :code_climate: false
138
+ :gemnasium: false
139
+ :travis: false
140
+ :patreon: false
141
+ :publish:
142
+ :sign: false
143
+
144
+ While Gemsmith is fully customizable, please keep in mind that these are *global* settings and, once
145
+ set, will affect all future gem creations. Further customization is also provided via the CLI for a
146
+ customizable experience per gem if necessary.
140
147
 
141
148
  # Usage
142
149
 
@@ -144,66 +151,49 @@ necessary.
144
151
 
145
152
  From the command line, type: `gemsmith --help`
146
153
 
147
- gemsmith -c, [--create=CREATE] # Create new gem. DEPRECATED (use --generate).
148
- gemsmith -e, [--edit] # Edit gem settings in default editor.
149
- gemsmith -g, [--generate=GENERATE] # Generate new gem.
150
- gemsmith -h, [--help=HELP] # Show this message or get help for a command.
151
- gemsmith -o, [--open=OPEN] # Open a gem in default editor.
152
- gemsmith -r, [--read=READ] # Open a gem in default browser.
153
- gemsmith -v, [--version] # Show gem version.
154
-
155
- For more gem creation options, type: `gemsmith --help --generate`
156
-
157
- -c, [--cli], [--no-cli] # Add CLI support.
158
- -r, [--rails], [--no-rails] # Add Rails support.
159
- -S, [--security], [--no-security] # Add security support.
160
- # Default: true
161
- -p, [--pry], [--no-pry] # Add Pry support.
162
- # Default: true
163
- -g, [--guard], [--no-guard] # Add Guard support.
164
- # Default: true
165
- -s, [--rspec], [--no-rspec] # Add RSpec support.
166
- # Default: true
167
- -R, [--rubocop], [--no-rubocop] # Add Rubocop support.
168
- # Default: true
169
- -H, [--git-hub], [--no-git-hub] # Add GitHub support.
170
- -C, [--code-climate], [--no-code-climate] # Add Code Climate support.
171
- # Default: true
172
- -G, [--gemnasium], [--no-gemnasium] # Add Gemnasium support.
173
- # Default: true
174
- -t, [--travis], [--no-travis] # Add Travis CI support.
175
- # Default: true
176
- -P, [--patreon], [--no-patreon] # Add Patreon support.
177
- # Default: true
154
+ gemsmith -c, [--config] # Manage gem configuration.
155
+ gemsmith -g, [--generate=GEM] # Generate new gem.
156
+ gemsmith -h, [--help=COMMAND] # Show this message or get help for a command.
157
+ gemsmith -o, [--open=GEM] # Open a gem in default editor.
158
+ gemsmith -r, [--read=GEM] # Open a gem in default browser.
159
+ gemsmith -v, [--version] # Show gem version.
160
+
161
+ For more gem generation options, type: `gemsmith --help --generate`
162
+
163
+ [--cli], [--no-cli] # Add CLI support.
164
+ [--rails], [--no-rails] # Add Rails support.
165
+ [--security], [--no-security] # Add security support.
166
+ # Default: true
167
+ [--pry], [--no-pry] # Add Pry support.
168
+ # Default: true
169
+ [--guard], [--no-guard] # Add Guard support.
170
+ # Default: true
171
+ [--rspec], [--no-rspec] # Add RSpec support.
172
+ # Default: true
173
+ [--reek], [--no-reek] # Add Reek support.
174
+ # Default: true
175
+ [--rubocop], [--no-rubocop] # Add Rubocop support.
176
+ # Default: true
177
+ [--scss-lint], [--no-scss-lint] # Add SCSS Lint support.
178
+ [--git-hub], [--no-git-hub] # Add GitHub support.
179
+ [--code-climate], [--no-code-climate] # Add Code Climate support.
180
+ [--gemnasium], [--no-gemnasium] # Add Gemnasium support.
181
+ [--travis], [--no-travis] # Add Travis CI support.
182
+ [--patreon], [--no-patreon] # Add Patreon support.
178
183
 
179
184
  ## Rake
180
185
 
181
- Once a gem skeleton has been created, the following tasks are available (i.e. `bundle exec rake -T`):
186
+ Once a gem skeleton has been created, the following tasks are available (i.e. `bundle exec rake
187
+ -T`):
182
188
 
183
- rake build # Build example-0.1.0.gem into the pkg directory
184
- rake clean # Remove any temporary products / Clean gem artifacts
185
- rake clobber # Remove any generated files
186
- rake console # Open IRB console for gem development environment
189
+ rake build # Build gemsmith-8.0.0.gem package
190
+ rake clean # Clean gem artifacts
187
191
  rake doc # Update README (table of contents)
188
- rake install # Build and install example-0.1.0.gem into system gems
189
- rake install:local # Build and install example-0.1.0.gem into system gems without network access
190
- rake publish # Build, tag v0.1.0 (signed), and push example-0.1.0.gem to RubyGems
191
- rake release[remote] # Build, tag v0.1.0 (unsigned), and push example-0.1.0.gem to RubyGems
192
- rake rubocop # Run RuboCop
193
- rake rubocop:auto_correct # Auto-correct RuboCop offenses
194
- rake spec # Run RSpec code examples
195
-
196
- Out of all Rake tasks listed above, the following are provided by [Bundler](http://bundler.io) and enhanced by
197
- Gemsmith:
198
-
199
- rake build - Cleans and regenerates the README table of contents in addition to building the gem.
200
- rake install - Inherits the `build` modifications mentioned above.
201
- rake install:local - Inherits the `build` modifications mentioned above.
202
- rake release - Identical to the `publish` tasks but does not securely sign the Git tag.
192
+ rake install # Install gemsmith-8.0.0.gem package
193
+ rake publish # Build, tag as v8.0.0 (unsigned), and push gemsmith-8.0.0.gem to RubyGems
203
194
 
204
195
  When building/testing your gem locally, a typical workflow is:
205
196
 
206
- 0. `gem uninstall <your gem name>`
207
197
  0. `bundle exec rake install`
208
198
  0. Test your gem locally.
209
199
  0. Repeat until satisfied.
@@ -212,9 +202,6 @@ When satified with your gem, builds are green, and ready to publish, run:
212
202
 
213
203
  bundle exec rake publish
214
204
 
215
- Alternatively, you can run `bundle exec rake release` if you don't wish to sign your gem releases (i.e default Bundler
216
- behavior) but the added security that `publish` provides is strongly recommended.
217
-
218
205
  # Tests
219
206
 
220
207
  To test, run:
@@ -248,8 +235,9 @@ Add your key to your global Git configuration in the `[user]` section. Example:
248
235
  [user]
249
236
  signingkey = <your GPG key>
250
237
 
251
- Now, when publishing your gems with Gemsmith (i.e. `bundle exec rake publish`), signing of your Git tag will happen
252
- automatically. You will be prompted for the GPG Passphrase each time but that is to be expected.
238
+ Now, when publishing your gems with Gemsmith (i.e. `bundle exec rake publish`), signing of your Git
239
+ tag will happen automatically. You will be prompted for the GPG Passphrase each time but that is to
240
+ be expected.
253
241
 
254
242
  ## Gem Certificates
255
243
 
@@ -259,8 +247,8 @@ To create a certificate for your gems, run the following:
259
247
  gem cert --build you@example.com
260
248
  chmod 600 gem-*.pem
261
249
 
262
- The resulting `*.pem` key files can be referenced via the `:private_key:` and `:public_key:` keys within the
263
- `~/.gemsmithrc` file.
250
+ The resulting `*.pem` key files can be referenced via the `:private_key:` and `:public_key:` keys
251
+ within the `~/.gemsmithrc` file.
264
252
 
265
253
  To learn more about gem certificates, read the following:
266
254
 
@@ -270,14 +258,13 @@ To learn more about gem certificates, read the following:
270
258
 
271
259
  # Private Gem Servers
272
260
 
273
- By default, the following Rake tasks will publish your gem to [RubyGems](https://rubygems.org):
261
+ By default, the following Rake task will publish your gem to [RubyGems](https://rubygems.org):
274
262
 
275
- rake release
276
- rake publish
263
+ bundle exec rake publish
277
264
 
278
- You can change this behavior by adding metadata to your gemspec that will allow the Rake tasks, mentioned above, to
279
- publish your gem to an alternate/private gem server instead. This can be done by updating your gem specification and
280
- RubyGems credentials.
265
+ You can change this behavior by adding metadata to your gemspec that will allow the Rake tasks,
266
+ mentioned above, to publish your gem to an alternate/private gem server instead. This can be done by
267
+ updating your gem specification and RubyGems credentials.
281
268
 
282
269
  ## Gem Specification Metadata
283
270
 
@@ -291,27 +278,28 @@ Add the following metadata to your gemspec:
291
278
  end
292
279
 
293
280
  The gemspec metadata keys and values *must* be strings per the
294
- [RubyGems Specification](http://guides.rubygems.org/specification-reference/#metadata). Each key represents the
295
- following:
281
+ [RubyGems Specification](http://guides.rubygems.org/specification-reference/#metadata). Each key
282
+ represents the following:
296
283
 
297
- - `allowed_push_key`: Provides a reference (look up) to the key defined the RubyGems credentials file so that sensitive
298
- credentials are not used within your gemspec.
284
+ - `allowed_push_key`: Provides a reference (look up) to the key defined the RubyGems credentials
285
+ file so that sensitive credentials are not used within your gemspec.
299
286
  - `allowed_push_host`: Provides the URL of the private gem server to push your gem to.
300
287
 
301
288
  ## Gem Credentials
302
289
 
303
- With your gem specification metadata established, you are ready to publish your gem to a public or private server. If
304
- this is your first time publishing a gem and no gem credentials have been configured, you'll be prompted for them. Gem
305
- credentials are stored in the RubyGems `~/.gem/credentials` file. From this point forward, future gem publishing will
306
- use your stored credentials instead. Multiple credentials can be stored in the `~/.gem/credentials` file. Example:
290
+ With your gem specification metadata established, you are ready to publish your gem to a public or
291
+ private server. If this is your first time publishing a gem and no gem credentials have been
292
+ configured, you'll be prompted for them. Gem credentials are stored in the RubyGems
293
+ `~/.gem/credentials` file. From this point forward, future gem publishing will use your stored
294
+ credentials instead. Multiple credentials can be stored in the `~/.gem/credentials` file. Example:
307
295
 
308
296
  ---
309
297
  :rubygems_api_key: 2a0b460650e67d9b85a60e183defa376
310
298
  :example_key: "Basic dXNlcjpwYXNzd29yZA=="
311
299
 
312
- Should you need to delete a credential (due to a bad login/password for example), you can open the `~/.gem/credentials`
313
- in your default editor and remove the line(s) you don't need. Upon next publish of your gem, you'll be prompted for the
314
- missing credentials.
300
+ Should you need to delete a credential (due to a bad login/password for example), you can open the
301
+ `~/.gem/credentials` in your default editor and remove the line(s) you don't need. Upon next publish
302
+ of your gem, you'll be prompted for the missing credentials.
315
303
 
316
304
  # Promotion
317
305
 
@@ -320,18 +308,25 @@ Once your gem is released, you might want to let the world know about your accom
320
308
  - [How to Spread the Word About Your Code](https://hacks.mozilla.org/2013/05/how-to-spread-the-word-about-your-code)
321
309
  - [RubyFlow](http://www.rubyflow.com)
322
310
 
311
+ # Troubleshooting
312
+
313
+ When running `bundle exec rake install` or `bundle exec rake publish` with modified, staged, or
314
+ uncommitted Git changes, the rake task will throw an error to this effect. When this occurs, it is
315
+ recommended that you commit your changes or [stash](https://git-scm.com/docs/git-stash) them before
316
+ proceeding.
317
+
323
318
  # Versioning
324
319
 
325
320
  Read [Semantic Versioning](http://semver.org) for details. Briefly, it means:
326
321
 
327
- - Patch (x.y.Z) - Incremented for small, backwards compatible bug fixes.
328
- - Minor (x.Y.z) - Incremented for new, backwards compatible public API enhancements and/or bug fixes.
322
+ - Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
323
+ - Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
329
324
  - Major (X.y.z) - Incremented for any backwards incompatible public API changes.
330
325
 
331
326
  # Code of Conduct
332
327
 
333
- Please note that this project is released with a [CODE OF CONDUCT](CODE_OF_CONDUCT.md). By participating in this project
334
- you agree to abide by its terms.
328
+ Please note that this project is released with a [CODE OF CONDUCT](CODE_OF_CONDUCT.md). By
329
+ participating in this project you agree to abide by its terms.
335
330
 
336
331
  # Contributions
337
332
 
@@ -340,12 +335,13 @@ Read [CONTRIBUTING](CONTRIBUTING.md) for details.
340
335
  # License
341
336
 
342
337
  Copyright (c) 2011 [Alchemists](https://www.alchemists.io).
343
- Read the [LICENSE](LICENSE.md) for details.
338
+ Read [LICENSE](LICENSE.md) for details.
344
339
 
345
340
  # History
346
341
 
347
- Read the [CHANGELOG](CHANGELOG.md) for details.
342
+ Read [CHANGES](CHANGES.md) for details.
348
343
 
349
344
  # Credits
350
345
 
351
- Developed by [Brooke Kuhlmann](https://www.alchemists.io) at [Alchemists](https://www.alchemists.io).
346
+ Developed by [Brooke Kuhlmann](https://www.alchemists.io) at
347
+ [Alchemists](https://www.alchemists.io).
data/bin/gemsmith CHANGED
@@ -1,4 +1,5 @@
1
- #! /usr/bin/ruby
1
+ #! /usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "gemsmith"
4
5
  require "gemsmith/cli"
data/lib/gemsmith/cli.rb CHANGED
@@ -4,31 +4,38 @@ require "yaml"
4
4
  require "thor"
5
5
  require "thor/actions"
6
6
  require "thor_plus/actions"
7
- require "gemsmith/aids/gem_spec"
8
- require "gemsmith/aids/git"
9
- require "gemsmith/aids/spec"
7
+ require "refinements/strings"
8
+ require "refinements/hashes"
9
+ require "runcom"
10
10
  require "gemsmith/errors/base"
11
11
  require "gemsmith/errors/requirement_conversion"
12
12
  require "gemsmith/errors/requirement_operator"
13
13
  require "gemsmith/errors/specification"
14
+ require "gemsmith/gem/inspector"
15
+ require "gemsmith/gem/module_formatter"
14
16
  require "gemsmith/gem/requirement"
15
- require "gemsmith/skeletons/base_skeleton"
16
- require "gemsmith/skeletons/bundler_skeleton"
17
- require "gemsmith/skeletons/cli_skeleton"
18
- require "gemsmith/skeletons/documentation_skeleton"
19
- require "gemsmith/skeletons/gem_skeleton"
20
- require "gemsmith/skeletons/git_skeleton"
21
- require "gemsmith/skeletons/git_hub_skeleton"
22
- require "gemsmith/skeletons/guard_skeleton"
23
- require "gemsmith/skeletons/pry_skeleton"
24
- require "gemsmith/skeletons/rails_skeleton"
25
- require "gemsmith/skeletons/rake_skeleton"
26
- require "gemsmith/skeletons/rspec_skeleton"
27
- require "gemsmith/skeletons/rubocop_skeleton"
28
- require "gemsmith/skeletons/ruby_skeleton"
29
- require "gemsmith/skeletons/travis_skeleton"
17
+ require "gemsmith/gem/specification"
18
+ require "gemsmith/generators/base"
19
+ require "gemsmith/generators/bundler"
20
+ require "gemsmith/generators/cli"
21
+ require "gemsmith/generators/code_climate"
22
+ require "gemsmith/generators/documentation"
23
+ require "gemsmith/generators/gem"
24
+ require "gemsmith/generators/git"
25
+ require "gemsmith/generators/git_hub"
26
+ require "gemsmith/generators/guard"
27
+ require "gemsmith/generators/pragma"
28
+ require "gemsmith/generators/rails"
29
+ require "gemsmith/generators/rake"
30
+ require "gemsmith/generators/reek"
31
+ require "gemsmith/generators/rspec"
32
+ require "gemsmith/generators/rubocop"
33
+ require "gemsmith/generators/ruby"
34
+ require "gemsmith/generators/scss_lint"
35
+ require "gemsmith/generators/travis"
30
36
  require "gemsmith/cli_helpers"
31
- require "gemsmith/configuration"
37
+ require "gemsmith/template_helper"
38
+ require "gemsmith/git"
32
39
 
33
40
  module Gemsmith
34
41
  # The Command Line Interface (CLI) for the gem.
@@ -37,115 +44,191 @@ module Gemsmith
37
44
  include Thor::Actions
38
45
  include ThorPlus::Actions
39
46
  include CLIHelpers
47
+ include TemplateHelper
48
+
49
+ using Refinements::Strings
50
+ using Refinements::Hashes
40
51
 
41
52
  package_name Gemsmith::Identity.version_label
42
53
 
43
- # Overwrites the Thor template source root.
54
+ # Overwrites Thor's template source root.
44
55
  def self.source_root
45
56
  File.expand_path File.join(File.dirname(__FILE__), "templates")
46
57
  end
47
58
 
48
- def self.skeletons
59
+ def self.configuration
60
+ Runcom::Configuration.new file_name: Identity.file_name, defaults: {
61
+ year: Time.now.year,
62
+ github_user: Git.github_user,
63
+ gem: {
64
+ name: "undefined",
65
+ path: "undefined",
66
+ class: "Undefined",
67
+ platform: "Gem::Platform::RUBY",
68
+ url: Git.github_url("undefined"),
69
+ license: "MIT"
70
+ },
71
+ author: {
72
+ name: Git.config_value("user.name"),
73
+ email: Git.config_value("user.email"),
74
+ url: ""
75
+ },
76
+ organization: {
77
+ name: "",
78
+ url: ""
79
+ },
80
+ versions: {
81
+ ruby: RUBY_VERSION,
82
+ rails: "5.0"
83
+ },
84
+ generate: {
85
+ cli: false,
86
+ rails: false,
87
+ security: true,
88
+ pry: true,
89
+ guard: true,
90
+ rspec: true,
91
+ reek: true,
92
+ rubocop: true,
93
+ scss_lint: false,
94
+ git_hub: false,
95
+ code_climate: false,
96
+ gemnasium: false,
97
+ travis: false,
98
+ patreon: false
99
+ },
100
+ publish: {
101
+ sign: false
102
+ }
103
+ }
104
+ end
105
+
106
+ def self.generators
49
107
  [
50
- Skeletons::GemSkeleton,
51
- Skeletons::DocumentationSkeleton,
52
- Skeletons::RakeSkeleton,
53
- Skeletons::CLISkeleton,
54
- Skeletons::RubySkeleton,
55
- Skeletons::RailsSkeleton,
56
- Skeletons::RspecSkeleton,
57
- Skeletons::RubocopSkeleton,
58
- Skeletons::GuardSkeleton,
59
- Skeletons::PrySkeleton,
60
- Skeletons::TravisSkeleton,
61
- Skeletons::BundlerSkeleton,
62
- Skeletons::GitHubSkeleton,
63
- Skeletons::GitSkeleton
108
+ Generators::Gem,
109
+ Generators::Documentation,
110
+ Generators::Rake,
111
+ Generators::CLI,
112
+ Generators::Ruby,
113
+ Generators::Rails,
114
+ Generators::Rspec,
115
+ Generators::Reek,
116
+ Generators::Rubocop,
117
+ Generators::SCSSLint,
118
+ Generators::CodeClimate,
119
+ Generators::Guard,
120
+ Generators::Travis,
121
+ Generators::Bundler,
122
+ Generators::GitHub,
123
+ Generators::Pragma,
124
+ Generators::Git
64
125
  ]
65
126
  end
66
127
 
67
128
  # Initialize.
68
129
  def initialize args = [], options = {}, config = {}
69
130
  super args, options, config
70
- @configuration = Configuration.new
71
- @gem_spec = Aids::GemSpec
131
+ @configuration = {}
72
132
  end
73
133
 
74
- desc "-g, [--generate=GENERATE]", "Generate new gem."
134
+ desc "-g, [--generate=GEM]", "Generate new gem."
75
135
  map %w[-g --generate] => :generate
76
- method_option :cli, aliases: "-c", desc: "Add CLI support.", type: :boolean, default: false
77
- method_option :rails, aliases: "-r", desc: "Add Rails support.", type: :boolean, default: false
78
- method_option :security, aliases: "-S", desc: "Add security support.", type: :boolean, default: true
79
- method_option :pry, aliases: "-p", desc: "Add Pry support.", type: :boolean, default: true
80
- method_option :guard, aliases: "-g", desc: "Add Guard support.", type: :boolean, default: true
81
- method_option :rspec, aliases: "-s", desc: "Add RSpec support.", type: :boolean, default: true
82
- method_option :rubocop, aliases: "-R", desc: "Add Rubocop support.", type: :boolean, default: true
83
- method_option :git_hub, aliases: "-H", desc: "Add GitHub support.", type: :boolean, default: false
84
- method_option :code_climate, aliases: "-C", desc: "Add Code Climate support.", type: :boolean, default: true
85
- method_option :gemnasium, aliases: "-G", desc: "Add Gemnasium support.", type: :boolean, default: true
86
- method_option :travis, aliases: "-t", desc: "Add Travis CI support.", type: :boolean, default: true
87
- method_option :patreon, aliases: "-P", desc: "Add Patreon support.", type: :boolean, default: true
136
+ method_option :cli,
137
+ desc: "Add CLI support.",
138
+ type: :boolean,
139
+ default: configuration.to_h.dig(:generate, :cli)
140
+ method_option :rails,
141
+ desc: "Add Rails support.",
142
+ type: :boolean,
143
+ default: configuration.to_h.dig(:generate, :rails)
144
+ method_option :security,
145
+ desc: "Add security support.",
146
+ type: :boolean,
147
+ default: configuration.to_h.dig(:generate, :security)
148
+ method_option :pry,
149
+ desc: "Add Pry support.",
150
+ type: :boolean,
151
+ default: configuration.to_h.dig(:generate, :pry)
152
+ method_option :guard,
153
+ desc: "Add Guard support.",
154
+ type: :boolean,
155
+ default: configuration.to_h.dig(:generate, :guard)
156
+ method_option :rspec,
157
+ desc: "Add RSpec support.",
158
+ type: :boolean,
159
+ default: configuration.to_h.dig(:generate, :rspec)
160
+ method_option :reek,
161
+ desc: "Add Reek support.",
162
+ type: :boolean,
163
+ default: configuration.to_h.dig(:generate, :reek)
164
+ method_option :rubocop,
165
+ desc: "Add Rubocop support.",
166
+ type: :boolean,
167
+ default: configuration.to_h.dig(:generate, :rubocop)
168
+ method_option :scss_lint,
169
+ desc: "Add SCSS Lint support.",
170
+ type: :boolean,
171
+ default: configuration.to_h.dig(:generate, :scss_lint)
172
+ method_option :git_hub,
173
+ desc: "Add GitHub support.",
174
+ type: :boolean,
175
+ default: configuration.to_h.dig(:generate, :git_hub)
176
+ method_option :code_climate,
177
+ desc: "Add Code Climate support.",
178
+ type: :boolean,
179
+ default: configuration.to_h.dig(:generate, :code_climate)
180
+ method_option :gemnasium,
181
+ desc: "Add Gemnasium support.",
182
+ type: :boolean,
183
+ default: configuration.to_h.dig(:generate, :gemnasium)
184
+ method_option :travis,
185
+ desc: "Add Travis CI support.",
186
+ type: :boolean,
187
+ default: configuration.to_h.dig(:generate, :travis)
188
+ method_option :patreon,
189
+ desc: "Add Patreon support.",
190
+ type: :boolean,
191
+ default: configuration.to_h.dig(:generate, :patreon)
88
192
  def generate name
89
193
  say
90
194
  info "Generating gem..."
91
195
 
92
- setup_configuration name, options
93
- self.class.skeletons.each { |skeleton| skeleton.create self, configuration: configuration }
196
+ setup_configuration name: name, options: options
197
+ self.class.generators.each { |generator| generator.run self, configuration: configuration }
94
198
 
95
199
  info "Gem generation finished."
96
200
  say
97
201
  end
98
202
 
99
- desc "-c, [--create=CREATE]", "Create new gem. DEPRECATED (use --generate)."
100
- map %w[-c --create] => :create
101
- method_option :cli, aliases: "-c", desc: "Add CLI support.", type: :boolean, default: false
102
- method_option :rails, aliases: "-r", desc: "Add Rails support.", type: :boolean, default: false
103
- method_option :security, aliases: "-S", desc: "Add security support.", type: :boolean, default: true
104
- method_option :pry, aliases: "-p", desc: "Add Pry support.", type: :boolean, default: true
105
- method_option :guard, aliases: "-g", desc: "Add Guard support.", type: :boolean, default: true
106
- method_option :rspec, aliases: "-s", desc: "Add RSpec support.", type: :boolean, default: true
107
- method_option :rubocop, aliases: "-R", desc: "Add Rubocop support.", type: :boolean, default: true
108
- method_option :git_hub, aliases: "-H", desc: "Add GitHub support.", type: :boolean, default: false
109
- method_option :code_climate, aliases: "-C", desc: "Add Code Climate support.", type: :boolean, default: true
110
- method_option :gemnasium, aliases: "-G", desc: "Add Gemnasium support.", type: :boolean, default: true
111
- method_option :travis, aliases: "-t", desc: "Add Travis CI support.", type: :boolean, default: true
112
- method_option :patreon, aliases: "-P", desc: "Add Patreon support.", type: :boolean, default: true
113
- def create name
114
- warn "[DEPRECATION]: --create (-c) is deprecated, use --generate (-g) instead."
115
- say
116
- info "Generating gem..."
117
-
118
- setup_configuration name, options
119
- self.class.skeletons.each { |skeleton| skeleton.create self, configuration: configuration }
120
-
121
- info "Gem generation finished."
122
- say
123
- end
124
-
125
- desc "-o, [--open=OPEN]", "Open a gem in default editor."
203
+ desc "-o, [--open=GEM]", "Open a gem in default editor."
126
204
  map %w[-o --open] => :open
127
205
  def open name
128
- result = process_gem name, "open_gem"
129
- info("Opening: #{result}") unless result.nil? || result.empty?
206
+ process_gem name, "edit"
130
207
  end
131
208
 
132
- desc "-r, [--read=READ]", "Open a gem in default browser."
209
+ desc "-r, [--read=GEM]", "Open a gem in default browser."
133
210
  map %w[-r --read] => :read
134
211
  def read name
135
- result = process_gem name, "open_homepage"
136
-
137
- if result.nil? || result.empty?
138
- error "Gem home page is not defined."
139
- else
140
- info "Reading: #{result}"
141
- end
212
+ error "Gem home page is not defined." unless process_gem(name, "visit")
142
213
  end
143
214
 
144
- desc "-e, [--edit]", "Edit gem settings in default editor."
145
- map %w[-e --edit] => :edit
146
- def edit
147
- info "Editing: #{configuration.file_path}..."
148
- `#{gem_spec.editor} #{configuration.file_path}`
215
+ desc "-c, [--config]", %(Manage gem configuration ("#{configuration.computed_path}").)
216
+ map %w[-c --config] => :config
217
+ method_option :edit,
218
+ aliases: "-e",
219
+ desc: "Edit gem configuration.",
220
+ type: :boolean, default: false
221
+ method_option :info,
222
+ aliases: "-i",
223
+ desc: "Print gem configuration.",
224
+ type: :boolean, default: false
225
+ def config
226
+ path = self.class.configuration.computed_path
227
+
228
+ if options.edit? then `#{editor} #{path}`
229
+ elsif options.info? then say(path)
230
+ else help(:config)
231
+ end
149
232
  end
150
233
 
151
234
  desc "-v, [--version]", "Show gem version."
@@ -154,7 +237,7 @@ module Gemsmith
154
237
  say Gemsmith::Identity.version_label
155
238
  end
156
239
 
157
- desc "-h, [--help=HELP]", "Show this message or get help for a command."
240
+ desc "-h, [--help=COMMAND]", "Show this message or get help for a command."
158
241
  map %w[-h --help] => :help
159
242
  def help task = nil
160
243
  say and super
@@ -162,11 +245,24 @@ module Gemsmith
162
245
 
163
246
  private
164
247
 
165
- attr_reader :configuration, :gem_spec
248
+ attr_reader :configuration
249
+
250
+ def setup_configuration name:, options: {}
251
+ symbolized_options = options.reduce({}) do |new_options, (key, value)|
252
+ new_options.merge! key.to_sym => value
253
+ end
166
254
 
167
- def setup_configuration name, options
168
- @configuration = Configuration.new gem_name: name, gem_class: name
169
- options.each { |key, value| configuration.public_send "create_#{key}=", value }
255
+ @configuration = self.class.configuration.to_h.merge(
256
+ gem: {
257
+ name: name,
258
+ path: name.snakecase,
259
+ class: name.camelcase,
260
+ platform: "Gem::Platform::RUBY",
261
+ url: Git.github_url(name),
262
+ license: "MIT"
263
+ },
264
+ generate: symbolized_options
265
+ )
170
266
  end
171
267
  end
172
268
  end