gemsmith 7.7.0 → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +114 -118
- data/bin/gemsmith +2 -1
- data/lib/gemsmith/cli.rb +195 -99
- data/lib/gemsmith/cli_helpers.rb +8 -19
- data/lib/gemsmith/credentials.rb +2 -2
- data/lib/gemsmith/gem/inspector.rb +30 -0
- data/lib/gemsmith/gem/module_formatter.rb +51 -0
- data/lib/gemsmith/gem/requirement.rb +2 -0
- data/lib/gemsmith/{aids/gem_spec.rb → gem/specification.rb} +19 -26
- data/lib/gemsmith/generators/base.rb +33 -0
- data/lib/gemsmith/generators/bundler.rb +15 -0
- data/lib/gemsmith/generators/cli.rb +17 -0
- data/lib/gemsmith/generators/code_climate.rb +14 -0
- data/lib/gemsmith/generators/documentation.rb +28 -0
- data/lib/gemsmith/generators/gem.rb +17 -0
- data/lib/gemsmith/{skeletons/git_skeleton.rb → generators/git.rb} +13 -7
- data/lib/gemsmith/generators/git_hub.rb +14 -0
- data/lib/gemsmith/generators/guard.rb +13 -0
- data/lib/gemsmith/generators/pragma.rb +40 -0
- data/lib/gemsmith/generators/rails.rb +85 -0
- data/lib/gemsmith/generators/rake.rb +40 -0
- data/lib/gemsmith/generators/reek.rb +13 -0
- data/lib/gemsmith/generators/rspec.rb +23 -0
- data/lib/gemsmith/generators/rubocop.rb +16 -0
- data/lib/gemsmith/{skeletons/ruby_skeleton.rb → generators/ruby.rb} +5 -5
- data/lib/gemsmith/generators/scss_lint.rb +13 -0
- data/lib/gemsmith/generators/travis.rb +13 -0
- data/lib/gemsmith/git.rb +19 -0
- data/lib/gemsmith/identity.rb +1 -1
- data/lib/gemsmith/rake/builder.rb +65 -0
- data/lib/gemsmith/rake/{release.rb → publisher.rb} +14 -5
- data/lib/gemsmith/rake/tasks.rb +32 -20
- data/lib/gemsmith/template_helper.rb +28 -0
- data/lib/gemsmith/templates/%gem_name%/%gem_name%.gemspec.tt +30 -28
- data/lib/gemsmith/templates/%gem_name%/.codeclimate.yml.tt +36 -0
- data/lib/gemsmith/templates/%gem_name%/.rubocop.yml.tt +9 -1
- data/lib/gemsmith/templates/%gem_name%/.travis.yml.tt +4 -1
- data/lib/gemsmith/templates/%gem_name%/{CHANGELOG.md.tt → CHANGES.md.tt} +0 -0
- data/lib/gemsmith/templates/%gem_name%/Guardfile.tt +1 -1
- data/lib/gemsmith/templates/%gem_name%/README.md.tt +20 -18
- data/lib/gemsmith/templates/%gem_name%/Rakefile.tt +6 -1
- data/lib/gemsmith/templates/%gem_name%/bin/%gem_name%.tt +4 -4
- data/lib/gemsmith/templates/%gem_name%/bin/setup.tt +1 -1
- data/lib/gemsmith/templates/%gem_name%/lib/%gem_path%.rb.tt +4 -0
- data/lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt +54 -0
- data/lib/gemsmith/templates/%gem_name%/lib/{%gem_name% → %gem_path%}/engine.rb.tt +2 -4
- data/lib/gemsmith/templates/%gem_name%/lib/{%gem_name% → %gem_path%}/identity.rb.tt +3 -5
- data/lib/gemsmith/templates/%gem_name%/lib/generators/{%gem_name% → %gem_path%}/install/USAGE.tt +0 -0
- data/lib/gemsmith/templates/%gem_name%/lib/generators/{%gem_name% → %gem_path%}/install/install_generator.rb.tt +2 -5
- data/lib/gemsmith/templates/%gem_name%/lib/generators/{%gem_name% → %gem_path%}/upgrade/USAGE.tt +0 -0
- data/lib/gemsmith/templates/%gem_name%/lib/generators/{%gem_name% → %gem_path%}/upgrade/upgrade_generator.rb.tt +2 -5
- data/lib/gemsmith/templates/%gem_name%/lib/tasks/reek.rake.tt +6 -0
- data/lib/gemsmith/templates/%gem_name%/lib/tasks/scss_lint.rake.tt +6 -0
- data/lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt +83 -0
- data/lib/gemsmith/templates/%gem_name%/spec/rails_helper.rb.tt +14 -0
- data/lib/gemsmith/templates/%gem_name%/spec/spec_helper.rb.tt +29 -16
- data/lib/gemsmith/templates/%gem_name%/spec/support/shared_contexts/temp_dir.rb.tt +9 -0
- data/lib/tasks/reek.rake +8 -0
- data/lib/tasks/rspec.rake +2 -0
- data/lib/tasks/rubocop.rake +2 -0
- metadata +138 -149
- metadata.gz.sig +0 -0
- data/lib/gemsmith/aids/git.rb +0 -12
- data/lib/gemsmith/aids/spec.rb +0 -46
- data/lib/gemsmith/configuration.rb +0 -200
- data/lib/gemsmith/rake/build.rb +0 -38
- data/lib/gemsmith/skeletons/base_skeleton.rb +0 -29
- data/lib/gemsmith/skeletons/bundler_skeleton.rb +0 -15
- data/lib/gemsmith/skeletons/cli_skeleton.rb +0 -16
- data/lib/gemsmith/skeletons/documentation_skeleton.rb +0 -28
- data/lib/gemsmith/skeletons/gem_skeleton.rb +0 -17
- data/lib/gemsmith/skeletons/git_hub_skeleton.rb +0 -14
- data/lib/gemsmith/skeletons/guard_skeleton.rb +0 -13
- data/lib/gemsmith/skeletons/pry_skeleton.rb +0 -13
- data/lib/gemsmith/skeletons/rails_skeleton.rb +0 -61
- data/lib/gemsmith/skeletons/rake_skeleton.rb +0 -37
- data/lib/gemsmith/skeletons/rspec_skeleton.rb +0 -26
- data/lib/gemsmith/skeletons/rubocop_skeleton.rb +0 -15
- data/lib/gemsmith/skeletons/travis_skeleton.rb +0 -13
- data/lib/gemsmith/templates/%gem_name%/lib/%gem_name%.rb.tt +0 -6
- data/lib/gemsmith/templates/%gem_name%/lib/%gem_name%/cli.rb.tt +0 -40
- data/lib/gemsmith/templates/%gem_name%/lib/tasks/console.rake.tt +0 -7
- data/lib/gemsmith/templates/%gem_name%/spec/lib/%gem_name%/%gem_name%_spec.rb.tt +0 -7
- data/lib/gemsmith/templates/%gem_name%/spec/support/extensions/pry.rb.tt +0 -5
- data/lib/gemsmith/templates/%gem_name%/spec/support/kit/default_config.rb.tt +0 -18
- data/lib/gemsmith/templates/%gem_name%/spec/support/kit/stderr.rb.tt +0 -9
- data/lib/gemsmith/templates/%gem_name%/spec/support/kit/stdout.rb.tt +0 -9
- data/lib/gemsmith/templates/%gem_name%/spec/support/kit/temp_dir.rb.tt +0 -25
- data/lib/tasks/console.rake +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b1e5311577e90d181cad13d15213dc594450040
|
4
|
+
data.tar.gz: 777ee65fe3019ece41362faf8875a9b1c79ded58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
60
|
-
|
61
|
-
-
|
62
|
-
-
|
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/
|
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
|
83
|
-
allowing the installation of unsigned dependencies since they are beyond the scope of this
|
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: <
|
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
|
-
:
|
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: <
|
115
|
-
: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: "
|
123
|
-
:
|
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
|
-
:
|
132
|
-
:
|
133
|
-
:
|
134
|
-
:
|
135
|
-
:
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
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, [--
|
148
|
-
gemsmith -
|
149
|
-
gemsmith -
|
150
|
-
gemsmith -
|
151
|
-
gemsmith -
|
152
|
-
gemsmith -
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
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
|
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
|
184
|
-
rake clean #
|
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 #
|
189
|
-
rake
|
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
|
252
|
-
automatically. You will be prompted for the GPG Passphrase each time but that is to
|
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
|
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
|
261
|
+
By default, the following Rake task will publish your gem to [RubyGems](https://rubygems.org):
|
274
262
|
|
275
|
-
rake
|
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,
|
279
|
-
publish your gem to an alternate/private gem server instead. This can be done by
|
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
|
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
|
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
|
304
|
-
this is your first time publishing a gem and no gem credentials have been
|
305
|
-
|
306
|
-
|
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
|
313
|
-
in your default editor and remove the line(s) you don't need. Upon next publish
|
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
|
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
|
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
|
338
|
+
Read [LICENSE](LICENSE.md) for details.
|
344
339
|
|
345
340
|
# History
|
346
341
|
|
347
|
-
Read
|
342
|
+
Read [CHANGES](CHANGES.md) for details.
|
348
343
|
|
349
344
|
# Credits
|
350
345
|
|
351
|
-
Developed by [Brooke Kuhlmann](https://www.alchemists.io) at
|
346
|
+
Developed by [Brooke Kuhlmann](https://www.alchemists.io) at
|
347
|
+
[Alchemists](https://www.alchemists.io).
|
data/bin/gemsmith
CHANGED
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 "
|
8
|
-
require "
|
9
|
-
require "
|
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/
|
16
|
-
require "gemsmith/
|
17
|
-
require "gemsmith/
|
18
|
-
require "gemsmith/
|
19
|
-
require "gemsmith/
|
20
|
-
require "gemsmith/
|
21
|
-
require "gemsmith/
|
22
|
-
require "gemsmith/
|
23
|
-
require "gemsmith/
|
24
|
-
require "gemsmith/
|
25
|
-
require "gemsmith/
|
26
|
-
require "gemsmith/
|
27
|
-
require "gemsmith/
|
28
|
-
require "gemsmith/
|
29
|
-
require "gemsmith/
|
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/
|
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
|
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.
|
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
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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 =
|
71
|
-
@gem_spec = Aids::GemSpec
|
131
|
+
@configuration = {}
|
72
132
|
end
|
73
133
|
|
74
|
-
desc "-g, [--generate=
|
134
|
+
desc "-g, [--generate=GEM]", "Generate new gem."
|
75
135
|
map %w[-g --generate] => :generate
|
76
|
-
method_option :cli,
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
method_option :
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
method_option :
|
85
|
-
|
86
|
-
|
87
|
-
|
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.
|
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 "-
|
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
|
-
|
129
|
-
info("Opening: #{result}") unless result.nil? || result.empty?
|
206
|
+
process_gem name, "edit"
|
130
207
|
end
|
131
208
|
|
132
|
-
desc "-r, [--read=
|
209
|
+
desc "-r, [--read=GEM]", "Open a gem in default browser."
|
133
210
|
map %w[-r --read] => :read
|
134
211
|
def read name
|
135
|
-
|
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 "-
|
145
|
-
map %w[-
|
146
|
-
|
147
|
-
|
148
|
-
|
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=
|
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
|
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
|
-
|
168
|
-
|
169
|
-
|
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
|