gemsmith 5.6.0 → 6.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 +4 -3
- data/README.md +90 -54
- data/lib/gemsmith.rb +0 -1
- data/lib/gemsmith/aids/gem.rb +24 -0
- data/lib/gemsmith/aids/git.rb +10 -0
- data/lib/gemsmith/aids/spec.rb +41 -0
- data/lib/gemsmith/cli.rb +26 -11
- data/lib/gemsmith/cli_helpers.rb +20 -69
- data/lib/gemsmith/configuration.rb +189 -0
- data/lib/gemsmith/identity.rb +2 -2
- data/lib/gemsmith/rake/build.rb +17 -19
- data/lib/gemsmith/rake/tasks.rb +11 -9
- data/lib/gemsmith/skeletons/base_skeleton.rb +6 -9
- data/lib/gemsmith/skeletons/bundler_skeleton.rb +1 -1
- data/lib/gemsmith/skeletons/cli_skeleton.rb +3 -7
- data/lib/gemsmith/skeletons/documentation_skeleton.rb +17 -5
- data/lib/gemsmith/skeletons/gem_skeleton.rb +4 -4
- data/lib/gemsmith/skeletons/git_skeleton.rb +2 -2
- data/lib/gemsmith/skeletons/guard_skeleton.rb +2 -6
- data/lib/gemsmith/skeletons/pry_skeleton.rb +11 -0
- data/lib/gemsmith/skeletons/rails_skeleton.rb +21 -19
- data/lib/gemsmith/skeletons/rake_skeleton.rb +10 -15
- data/lib/gemsmith/skeletons/rspec_skeleton.rb +8 -12
- data/lib/gemsmith/skeletons/rubocop_skeleton.rb +3 -7
- data/lib/gemsmith/skeletons/ruby_skeleton.rb +1 -1
- data/lib/gemsmith/skeletons/travis_skeleton.rb +2 -6
- data/lib/gemsmith/templates/%gem_name%/%gem_name%.gemspec.tt +23 -29
- data/lib/gemsmith/templates/%gem_name%/.gitignore.tt +0 -1
- data/lib/gemsmith/templates/%gem_name%/.rubocop.yml.tt +3 -1
- data/lib/gemsmith/templates/%gem_name%/.ruby-version.tt +1 -1
- data/lib/gemsmith/templates/%gem_name%/.travis.yml.tt +3 -4
- data/lib/gemsmith/templates/%gem_name%/CODE_OF_CONDUCT.md.tt +18 -9
- data/lib/gemsmith/templates/%gem_name%/Guardfile.tt +1 -1
- data/lib/gemsmith/templates/%gem_name%/LICENSE.md.tt +1 -1
- data/lib/gemsmith/templates/%gem_name%/README.md.tt +25 -22
- data/lib/gemsmith/templates/%gem_name%/Rakefile.tt +1 -1
- data/lib/gemsmith/templates/%gem_name%/bin/%gem_name%.tt +5 -5
- data/lib/gemsmith/templates/%gem_name%/gemfiles/rails-%rails_version%.x.gemfile.tt +5 -0
- data/lib/gemsmith/templates/%gem_name%/lib/%gem_name%.rb.tt +3 -3
- data/lib/gemsmith/templates/%gem_name%/lib/%gem_name%/cli.rb.tt +7 -7
- data/lib/gemsmith/templates/%gem_name%/lib/%gem_name%/engine.rb.tt +2 -2
- data/lib/gemsmith/templates/%gem_name%/lib/%gem_name%/identity.rb.tt +5 -5
- data/lib/gemsmith/templates/%gem_name%/lib/generators/%gem_name%/install/USAGE.tt +2 -2
- data/lib/gemsmith/templates/%gem_name%/lib/generators/%gem_name%/install/install_generator.rb.tt +2 -2
- data/lib/gemsmith/templates/%gem_name%/lib/generators/%gem_name%/upgrade/USAGE.tt +2 -2
- data/lib/gemsmith/templates/%gem_name%/lib/generators/%gem_name%/upgrade/upgrade_generator.rb.tt +2 -2
- data/lib/gemsmith/templates/%gem_name%/lib/{%gem_name%/tasks → tasks}/rspec.rake.tt +0 -0
- data/lib/gemsmith/templates/%gem_name%/lib/{%gem_name%/tasks → tasks}/rubocop.rake.tt +0 -0
- data/lib/gemsmith/templates/%gem_name%/spec/lib/%gem_name%/%gem_name%_spec.rb.tt +1 -1
- data/lib/gemsmith/templates/%gem_name%/spec/spec_helper.rb.tt +5 -16
- data/lib/gemsmith/templates/%gem_name%/spec/support/extensions/pry.rb.tt +6 -0
- data/lib/{gemsmith/tasks → tasks}/rspec.rake +0 -0
- data/lib/{gemsmith/tasks → tasks}/rubocop.rake +0 -0
- metadata +47 -15
- metadata.gz.sig +0 -0
- data/lib/gemsmith/cli_options.rb +0 -103
- data/lib/gemsmith/kit.rb +0 -12
- data/lib/gemsmith/templates/%gem_name%/gemfiles/rails-4.1.x.gemfile.tt +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93a8b6f5bd33ee3d2ca49fd60ab5120a5ed16753
|
4
|
+
data.tar.gz: 02f7d1a50c6aca870805920c2a85994b7da63030
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c9fccafbe3aef91a6a794261f0f5a6213185784faf2128a5bceb1072af3bf8003c24b9a5a8ffd90457955e2187b8a347e17fbae040a052c286c0767a72837f3
|
7
|
+
data.tar.gz: 7830aa4aa2fd4b2d32f7bbb20d57caa607ad658aa142f423ee6a1d7e51bec3e1061ddb682e1a4a42e89785af2a628fea9ba75d3a00b40137948d3a22fe8e2fc1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
P
|
2
|
+
O�-�W�~~�����_��� ��y�7Z�-�j�p�a��tJ7_�-��#3���aT�A�
|
3
|
+
H�-�9�a8lQK�X;���w���%��;,W����!}+c 0l��?1^f��7���~.9E�"���$�Nf��Mg�y^���Y�҉�
|
4
|
+
���Ć��EI�Q˧~�� �*r/�l����AX?-x���0'%���<��+���� e���+%H4
|
data/README.md
CHANGED
@@ -5,11 +5,12 @@
|
|
5
5
|
[![Code Climate Coverage](https://codeclimate.com/github/bkuhlmann/gemsmith/coverage.svg)](https://codeclimate.com/github/bkuhlmann/gemsmith)
|
6
6
|
[![Gemnasium Status](https://gemnasium.com/bkuhlmann/gemsmith.svg)](https://gemnasium.com/bkuhlmann/gemsmith)
|
7
7
|
[![Travis CI Status](https://secure.travis-ci.org/bkuhlmann/gemsmith.svg)](http://travis-ci.org/bkuhlmann/gemsmith)
|
8
|
+
[![Patreon](https://img.shields.io/badge/patreon-donate-brightgreen.svg)](https://www.patreon.com/bkuhlmann)
|
8
9
|
|
9
10
|
A command line interface for smithing new Ruby gems.
|
10
11
|
|
11
|
-
<!--
|
12
|
-
|
12
|
+
<!-- Tocer[start]: Auto-generated, don't remove. -->
|
13
|
+
|
13
14
|
# Table of Contents
|
14
15
|
|
15
16
|
- [Features](#features)
|
@@ -31,32 +32,33 @@ A command line interface for smithing new Ruby gems.
|
|
31
32
|
- [History](#history)
|
32
33
|
- [Credits](#credits)
|
33
34
|
|
34
|
-
<!--
|
35
|
+
<!-- Tocer[finish]: Auto-generated, don't remove. -->
|
35
36
|
|
36
37
|
# Features
|
37
38
|
|
38
|
-
- Builds a gem skeleton with Bundler functionality
|
39
|
+
- Builds a gem skeleton with enhanced Bundler functionality.
|
39
40
|
- Supports common settings to be applied when creating new gems.
|
40
|
-
- Supports [Thor](https://github.com/wycats/thor) command line functionality.
|
41
|
+
- Supports [Thor](https://github.com/wycats/thor) command line interface (CLI) functionality.
|
41
42
|
- Supports [Ruby on Rails](http://rubyonrails.org).
|
42
|
-
- Supports [RSpec](http://rspec.info).
|
43
|
-
- Supports [Rubocop](https://github.com/bbatsov/rubocop).
|
44
43
|
- Supports [Pry](http://pryrepl.org).
|
45
44
|
- Supports [Guard](https://github.com/guard/guard).
|
45
|
+
- Supports [RSpec](http://rspec.info).
|
46
|
+
- Supports [Rubocop](https://github.com/bbatsov/rubocop).
|
46
47
|
- Supports [Code Climate](https://codeclimate.com).
|
47
48
|
- Supports [Gemnasium](https://gemnasium.com).
|
48
49
|
- Supports [Travis CI](http://travis-ci.org).
|
50
|
+
- Supports [Patreon](https://www.patreon.com).
|
49
51
|
- Provides the ability to open the source code of any gem within your favorite editor.
|
50
52
|
- Provides the ability to read the documentation of any gem within your default browser.
|
51
53
|
- Adds commonly needed [README](README.md), [CHANGELOG](CHANGELOG.md), [CONTRIBUTING](CONTRIBUTING.md),
|
52
|
-
[LICENSE](LICENSE.md), etc.
|
54
|
+
[CODE OF CONDUCT](CODE_OF_CONDUCT.md), [LICENSE](LICENSE.md), etc. documentation.
|
53
55
|
|
54
56
|
# Requirements
|
55
57
|
|
56
|
-
0. A UNIX-based system
|
57
|
-
0. [MRI 2.x.x](http://www.ruby-lang.org)
|
58
|
-
0. [RubyGems](http://rubygems.org)
|
59
|
-
0. [Bundler](https://github.com/carlhuda/bundler)
|
58
|
+
0. A UNIX-based system
|
59
|
+
0. [MRI 2.x.x](http://www.ruby-lang.org)
|
60
|
+
0. [RubyGems](http://rubygems.org)
|
61
|
+
0. [Bundler](https://github.com/carlhuda/bundler)
|
60
62
|
|
61
63
|
# Setup
|
62
64
|
|
@@ -74,37 +76,60 @@ For an insecure install, type the following (not recommended):
|
|
74
76
|
|
75
77
|
You can configure common settings for future gem builds by creating the following file:
|
76
78
|
|
77
|
-
~/.
|
78
|
-
|
79
|
-
...using the following settings (
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
:
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
79
|
+
~/.gemsmithrc
|
80
|
+
|
81
|
+
...using the following settings (as a simple example):
|
82
|
+
|
83
|
+
:author:
|
84
|
+
:name: "Joe Smith"
|
85
|
+
:email: "joe@example.com"
|
86
|
+
:url: "https://www.example.com"
|
87
|
+
:organization:
|
88
|
+
:name: "ExampleSoft"
|
89
|
+
:url: "https://www.example.com"
|
90
|
+
|
91
|
+
The following defaults are used when no options are configured:
|
92
|
+
|
93
|
+
:year: <current year>
|
94
|
+
:github_user: <git config GitHub user>
|
95
|
+
:gem:
|
96
|
+
:platform: "Gem::Platform::RUBY"
|
97
|
+
:home_url: ""
|
98
|
+
:license: "MIT"
|
99
|
+
:private_key: "~/.ssh/gem-private.pem"
|
100
|
+
:public_key: "~/.ssh/gem-public.pem"
|
101
|
+
:author:
|
102
|
+
:name: <git config user name>
|
103
|
+
:email: <git config user email>
|
104
|
+
:url: ""
|
105
|
+
:organization:
|
106
|
+
:name: ""
|
107
|
+
:url: ""
|
108
|
+
:versions:
|
109
|
+
:ruby: <current Ruby version>
|
110
|
+
:rails: "4.2"
|
111
|
+
:create:
|
112
|
+
:cli: false
|
113
|
+
:rails: false
|
114
|
+
:security: true
|
115
|
+
:pry: true
|
116
|
+
:guard: true
|
117
|
+
:rspec: true
|
118
|
+
:rubocop: true
|
119
|
+
:code_climate: true
|
120
|
+
:gemnasium: true
|
121
|
+
:travis: true
|
122
|
+
:patreon: true
|
123
|
+
|
124
|
+
While Gemsmith is fully customizable, please keep in mind that these are *global* settings and, once set, will affect
|
125
|
+
all future gem creations. Further customization is also provided via the CLI for a customizable experience per gem if
|
126
|
+
necessary.
|
102
127
|
|
103
128
|
# Usage
|
104
129
|
|
105
130
|
## Command Line Interface (CLI)
|
106
131
|
|
107
|
-
From the command line, type: gemsmith help
|
132
|
+
From the command line, type: `gemsmith --help`
|
108
133
|
|
109
134
|
gemsmith -c, [create=CREATE] # Create new gem.
|
110
135
|
gemsmith -e, [--edit] # Edit Gemsmith settings in default editor.
|
@@ -113,9 +138,9 @@ From the command line, type: gemsmith help
|
|
113
138
|
gemsmith -r, [read=READ] # Open a gem in default browser.
|
114
139
|
gemsmith -v, [--version] # Show Gemsmith version.
|
115
140
|
|
116
|
-
For more gem creation options, type: gemsmith help create
|
141
|
+
For more gem creation options, type: `gemsmith --help --create`
|
117
142
|
|
118
|
-
-
|
143
|
+
-c, [--cli], [--no-cli] # Add CLI support.
|
119
144
|
-r, [--rails], [--no-rails] # Add Rails support.
|
120
145
|
-S, [--security], [--no-security] # Add security support.
|
121
146
|
# Default: true
|
@@ -127,35 +152,45 @@ For more gem creation options, type: gemsmith help create
|
|
127
152
|
# Default: true
|
128
153
|
-R, [--rubocop], [--no-rubocop] # Add Rubocop support.
|
129
154
|
# Default: true
|
130
|
-
-
|
155
|
+
-C, [--code-climate], [--no-code-climate] # Add Code Climate support.
|
131
156
|
# Default: true
|
132
157
|
-G, [--gemnasium], [--no-gemnasium] # Add Gemnasium support.
|
133
158
|
# Default: true
|
134
159
|
-t, [--travis], [--no-travis] # Add Travis CI support.
|
135
160
|
# Default: true
|
161
|
+
-P, [--patreon], [--no-patreon] # Add Patreon support.
|
162
|
+
# Default: true
|
136
163
|
|
137
164
|
## Rake
|
138
165
|
|
139
166
|
Once a gem skeleton has been created, the following tasks are available within the project via Bundler (i.e. rake -T):
|
140
167
|
|
141
|
-
rake build # Build
|
168
|
+
rake build # Build gemsmith-6.0.0.gem into the pkg directory
|
142
169
|
rake clean # Clean gem artifacts
|
143
|
-
rake
|
144
|
-
rake install
|
145
|
-
rake
|
146
|
-
rake
|
147
|
-
rake release # Create tag
|
170
|
+
rake doc # Update README (table of contents)
|
171
|
+
rake install # Build and install gemsmith-6.0.0.gem into system gems
|
172
|
+
rake install:local # Build and install gemsmith-6.0.0.gem into system gems without network access
|
173
|
+
rake publish # Build, tag v6.0.0 (signed), and push gemsmith-6.0.0.gem to RubyGems
|
174
|
+
rake release # Create tag v6.0.0 and build and push gemsmith-6.0.0.gem to Rubygems
|
148
175
|
rake rubocop # Run RuboCop
|
149
176
|
rake rubocop:auto_correct # Auto-correct RuboCop offenses
|
150
177
|
rake spec # Run RSpec code examples
|
151
178
|
|
179
|
+
Run `bundle exec rake` to run everything (includes all specs and code quality checks).
|
180
|
+
|
152
181
|
## Upgrades
|
153
182
|
|
154
|
-
For those upgrading from Gemsmith 5.
|
183
|
+
For those upgrading from Gemsmith 5.6.0 please be aware of the following changes:
|
155
184
|
|
156
|
-
-
|
157
|
-
|
158
|
-
|
185
|
+
- Move your `~/.gemsmith/settings.yml` settings to the new `~/.gemsmithrc` file. Refer to the Setup documentation
|
186
|
+
mentioned above for details.
|
187
|
+
- The `--cli/-c` create option has been replaced with the `--bin/-b` create option.
|
188
|
+
- The `--code-climate` create option shortcut is now `-C` instead of `-c`.
|
189
|
+
- [Tocer](https://github.com/bkuhlmann/tocer) has replaced [DocToc](https://github.com/thlorenz/doctoc) as a pure Ruby
|
190
|
+
implementation for generating README table of contents and removing the dependency on NPM.
|
191
|
+
- The `rake readme:toc` task has been replaced with `rake doc`.
|
192
|
+
- Using Rake to build or publish a gem will fail if uncommitted Git changes are detected helping to prevent you
|
193
|
+
from publishing a gem with missing changes.
|
159
194
|
|
160
195
|
# Tests
|
161
196
|
|
@@ -202,8 +237,8 @@ To create a certificate for your gems, run the following:
|
|
202
237
|
gem cert --build you@example.com
|
203
238
|
chmod 600 gem-*.pem
|
204
239
|
|
205
|
-
The resulting
|
206
|
-
|
240
|
+
The resulting `*.pem` key files can be referenced via the `:private_key:` and `:public_key:` keys within the
|
241
|
+
`~/.gemsmithrc` file.
|
207
242
|
|
208
243
|
To learn more about gem certificates, read the following:
|
209
244
|
|
@@ -213,9 +248,10 @@ To learn more about gem certificates, read the following:
|
|
213
248
|
|
214
249
|
# Promotion
|
215
250
|
|
216
|
-
Once your gem is released, you might
|
251
|
+
Once your gem is released, you might want to let the world know about your awesomeness. Here are several resources:
|
217
252
|
|
218
253
|
- [How to Spread the Word About Your Code](https://hacks.mozilla.org/2013/05/how-to-spread-the-word-about-your-code)
|
254
|
+
- [Ruby Green News](http://greenruby.org)
|
219
255
|
- [Ruby Toolbox](https://www.ruby-toolbox.com)
|
220
256
|
- [RubyFlow](http://www.rubyflow.com)
|
221
257
|
- [The Ruby Show](http://rubyshow.com)
|
data/lib/gemsmith.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Gemsmith
|
2
|
+
module Aids
|
3
|
+
# Parses a raw string into a valid gem and/or class name which can be used to construct gem skeletons
|
4
|
+
# and related Ruby objects.
|
5
|
+
class Gem
|
6
|
+
def initialize string = "unknown", util: Thor::Util
|
7
|
+
@string = string
|
8
|
+
@util = util
|
9
|
+
end
|
10
|
+
|
11
|
+
def name
|
12
|
+
@name ||= util.snake_case(string).tr(" ", "_").tr "-", "_"
|
13
|
+
end
|
14
|
+
|
15
|
+
def klass
|
16
|
+
@klass ||= util.camel_case name
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :string, :util
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "open3"
|
2
|
+
|
3
|
+
module Gemsmith
|
4
|
+
module Aids
|
5
|
+
# A convenience aid to the Gem::Specification object.
|
6
|
+
class Spec
|
7
|
+
def initialize specification: ::Gem::Specification, shell: Open3
|
8
|
+
@specification = specification
|
9
|
+
@shell = shell
|
10
|
+
end
|
11
|
+
|
12
|
+
def editor
|
13
|
+
ENV["EDITOR"]
|
14
|
+
end
|
15
|
+
|
16
|
+
def open spec = nil
|
17
|
+
return unless spec
|
18
|
+
shell.capture2 editor, spec.full_gem_path
|
19
|
+
end
|
20
|
+
|
21
|
+
def read spec = nil
|
22
|
+
return unless spec
|
23
|
+
return if spec.homepage.nil? || spec.homepage.empty?
|
24
|
+
|
25
|
+
shell.capture2 "open", spec.homepage
|
26
|
+
end
|
27
|
+
|
28
|
+
def find name, version
|
29
|
+
specification.find_by_name name, version
|
30
|
+
end
|
31
|
+
|
32
|
+
def find_all name
|
33
|
+
specification.find_all_by_name name
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
attr_reader :specification, :shell
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/gemsmith/cli.rb
CHANGED
@@ -2,8 +2,9 @@ require "yaml"
|
|
2
2
|
require "thor"
|
3
3
|
require "thor/actions"
|
4
4
|
require "thor_plus/actions"
|
5
|
-
require "gemsmith/
|
6
|
-
require "gemsmith/
|
5
|
+
require "gemsmith/aids/gem"
|
6
|
+
require "gemsmith/aids/git"
|
7
|
+
require "gemsmith/aids/spec"
|
7
8
|
require "gemsmith/skeletons/base_skeleton"
|
8
9
|
require "gemsmith/skeletons/bundler_skeleton"
|
9
10
|
require "gemsmith/skeletons/cli_skeleton"
|
@@ -11,19 +12,21 @@ require "gemsmith/skeletons/documentation_skeleton"
|
|
11
12
|
require "gemsmith/skeletons/gem_skeleton"
|
12
13
|
require "gemsmith/skeletons/git_skeleton"
|
13
14
|
require "gemsmith/skeletons/guard_skeleton"
|
15
|
+
require "gemsmith/skeletons/pry_skeleton"
|
14
16
|
require "gemsmith/skeletons/rails_skeleton"
|
15
17
|
require "gemsmith/skeletons/rake_skeleton"
|
16
18
|
require "gemsmith/skeletons/rspec_skeleton"
|
17
19
|
require "gemsmith/skeletons/rubocop_skeleton"
|
18
20
|
require "gemsmith/skeletons/ruby_skeleton"
|
19
21
|
require "gemsmith/skeletons/travis_skeleton"
|
22
|
+
require "gemsmith/cli_helpers"
|
23
|
+
require "gemsmith/configuration"
|
20
24
|
|
21
25
|
module Gemsmith
|
22
26
|
# The Command Line Interface (CLI) for the gem.
|
23
27
|
class CLI < Thor
|
24
28
|
include Thor::Actions
|
25
29
|
include ThorPlus::Actions
|
26
|
-
include CLIOptions
|
27
30
|
include CLIHelpers
|
28
31
|
|
29
32
|
package_name Gemsmith::Identity.version_label
|
@@ -44,6 +47,7 @@ module Gemsmith
|
|
44
47
|
Skeletons::RspecSkeleton,
|
45
48
|
Skeletons::RubocopSkeleton,
|
46
49
|
Skeletons::GuardSkeleton,
|
50
|
+
Skeletons::PrySkeleton,
|
47
51
|
Skeletons::TravisSkeleton,
|
48
52
|
Skeletons::BundlerSkeleton,
|
49
53
|
Skeletons::GitSkeleton
|
@@ -53,29 +57,29 @@ module Gemsmith
|
|
53
57
|
# Initialize.
|
54
58
|
def initialize args = [], options = {}, config = {}
|
55
59
|
super args, options, config
|
56
|
-
@
|
57
|
-
@
|
58
|
-
@template_options = {}
|
60
|
+
@configuration = Configuration.new
|
61
|
+
@spec_aid = Aids::Spec.new
|
59
62
|
end
|
60
63
|
|
61
64
|
desc "-c, [create=CREATE]", "Create new gem."
|
62
65
|
map %w(-c --create) => :create
|
63
|
-
method_option :
|
66
|
+
method_option :cli, aliases: "-c", desc: "Add CLI support.", type: :boolean, default: false
|
64
67
|
method_option :rails, aliases: "-r", desc: "Add Rails support.", type: :boolean, default: false
|
65
68
|
method_option :security, aliases: "-S", desc: "Add security support.", type: :boolean, default: true
|
66
69
|
method_option :pry, aliases: "-p", desc: "Add Pry support.", type: :boolean, default: true
|
67
70
|
method_option :guard, aliases: "-g", desc: "Add Guard support.", type: :boolean, default: true
|
68
71
|
method_option :rspec, aliases: "-s", desc: "Add RSpec support.", type: :boolean, default: true
|
69
72
|
method_option :rubocop, aliases: "-R", desc: "Add Rubocop support.", type: :boolean, default: true
|
70
|
-
method_option :code_climate, aliases: "-
|
73
|
+
method_option :code_climate, aliases: "-C", desc: "Add Code Climate support.", type: :boolean, default: true
|
71
74
|
method_option :gemnasium, aliases: "-G", desc: "Add Gemnasium support.", type: :boolean, default: true
|
72
75
|
method_option :travis, aliases: "-t", desc: "Add Travis CI support.", type: :boolean, default: true
|
76
|
+
method_option :patreon, aliases: "-P", desc: "Add Patreon support.", type: :boolean, default: true
|
73
77
|
def create name
|
74
78
|
say
|
75
79
|
info "Creating gem..."
|
76
80
|
|
77
|
-
|
78
|
-
self.class.skeletons.each { |skeleton| skeleton.create self }
|
81
|
+
setup_configuration name, options
|
82
|
+
self.class.skeletons.each { |skeleton| skeleton.create self, configuration: configuration }
|
79
83
|
|
80
84
|
info "Gem created."
|
81
85
|
say
|
@@ -96,7 +100,8 @@ module Gemsmith
|
|
96
100
|
desc "-e, [--edit]", "Edit #{Gemsmith::Identity.label} settings in default editor."
|
97
101
|
map %w(-e --edit) => :edit
|
98
102
|
def edit
|
99
|
-
|
103
|
+
info "Editing: #{configuration.file_path}..."
|
104
|
+
`#{spec_aid.editor} #{configuration.file_path}`
|
100
105
|
end
|
101
106
|
|
102
107
|
desc "-v, [--version]", "Show #{Gemsmith::Identity.label} version."
|
@@ -110,5 +115,15 @@ module Gemsmith
|
|
110
115
|
def help task = nil
|
111
116
|
say && super
|
112
117
|
end
|
118
|
+
|
119
|
+
private
|
120
|
+
|
121
|
+
attr_reader :configuration, :spec_aid
|
122
|
+
|
123
|
+
def setup_configuration name, options
|
124
|
+
gem = Aids::Gem.new name
|
125
|
+
@configuration = Configuration.new gem_name: gem.name, gem_class: gem.klass
|
126
|
+
options.each { |key, value| configuration.public_send "create_#{key}=", value }
|
127
|
+
end
|
113
128
|
end
|
114
129
|
end
|
data/lib/gemsmith/cli_helpers.rb
CHANGED
@@ -1,97 +1,48 @@
|
|
1
1
|
module Gemsmith
|
2
|
-
# Command Line Interface (CLI) helpers
|
3
|
-
# in order to not clutter up the main CLI object.
|
2
|
+
# Command Line Interface (CLI) helpers for the CLI class.
|
4
3
|
module CLIHelpers
|
5
|
-
|
6
|
-
|
7
|
-
def editor
|
8
|
-
ENV["EDITOR"]
|
4
|
+
def gem_name
|
5
|
+
configuration.gem_name
|
9
6
|
end
|
10
7
|
|
11
|
-
|
12
|
-
|
13
|
-
# * +name+ - Optional. The gem name. Default: nil
|
14
|
-
def gem_name name = nil
|
15
|
-
@gem_name ||= Thor::Util.snake_case name
|
8
|
+
def gem_class
|
9
|
+
configuration.gem_class
|
16
10
|
end
|
17
11
|
|
18
|
-
|
19
|
-
|
20
|
-
# * +name+ - Optional. The gem class. Default: nil
|
21
|
-
def gem_class name = nil
|
22
|
-
@gem_class ||= Thor::Util.camel_case name
|
23
|
-
end
|
24
|
-
|
25
|
-
# Answers all gem template options.
|
26
|
-
def template_options
|
27
|
-
@template_options
|
12
|
+
def rails_version
|
13
|
+
configuration.rails_version
|
28
14
|
end
|
29
15
|
|
30
16
|
module_function
|
31
17
|
|
32
|
-
# Converts hash keys from strings to symbols (if any).
|
33
|
-
# ===== Parameters
|
34
|
-
# * +options+ - Optional. The hash to convert. Default: {}
|
35
|
-
def enforce_symbol_keys options = {}
|
36
|
-
options.each.with_object({}) { |(key, value), hash| hash[key.to_sym] = value }
|
37
|
-
end
|
38
|
-
|
39
|
-
# Prints currently installed gem name and version information.
|
40
|
-
# ===== Parameters
|
41
|
-
# * +gems+ - Required. The array of gem names (i.e. gem specifications).
|
42
18
|
def print_gems gems
|
43
|
-
say "Multiple versions found
|
44
|
-
gems.each.with_index
|
45
|
-
|
46
|
-
end
|
19
|
+
say "Multiple versions found:\n\n"
|
20
|
+
gems.each.with_index { |spec, index| say "#{index + 1}. #{spec.name} #{spec.version.version}" }
|
21
|
+
say "q. Quit.\n\n"
|
47
22
|
end
|
48
23
|
|
49
|
-
# Picks a gem specification for processing.
|
50
|
-
# ===== Parameters
|
51
|
-
# * +gems+ - Required. The array of gem specifications.
|
52
|
-
# * +name+ - Required. The gem name to search for.
|
53
24
|
def pick_gem gems, name
|
54
|
-
|
25
|
+
answer = ask "Enter selection:"
|
26
|
+
return if answer == "q"
|
55
27
|
|
56
|
-
|
57
|
-
|
58
|
-
if (1..gems.size).include?(result.to_i)
|
59
|
-
Gem::Specification.find_by_name name, gems[result.to_i - 1].version.version
|
28
|
+
if (1..gems.size).include?(answer.to_i)
|
29
|
+
spec_aid.find name, gems[answer.to_i - 1].version.version
|
60
30
|
else
|
61
|
-
error "Invalid option: #{
|
62
|
-
nil
|
31
|
+
error "Invalid option: #{answer}"
|
63
32
|
end
|
64
33
|
end
|
65
34
|
|
66
|
-
|
67
|
-
|
68
|
-
# * +spec+ - Required. The gem specification.
|
69
|
-
def open_gem spec
|
70
|
-
`#{editor} #{spec.full_gem_path}` if spec
|
71
|
-
end
|
72
|
-
|
73
|
-
# Opens selected gem within default browser.
|
74
|
-
# ===== Parameters
|
75
|
-
# * +spec+ - Required. The gem specification.
|
76
|
-
def read_gem spec
|
77
|
-
`open #{spec.homepage}` if spec
|
78
|
-
end
|
79
|
-
|
80
|
-
# Processes a gem for given name and command.
|
81
|
-
# ===== Parameters
|
82
|
-
# * +name+ - Required. The gem name.
|
83
|
-
# * +command+ - Required. The command to process the gem.
|
84
|
-
def process_gem name, command
|
85
|
-
specs = Gem::Specification.find_all_by_name name
|
35
|
+
def process_gem name, method
|
36
|
+
specs = spec_aid.find_all name
|
86
37
|
|
87
38
|
case
|
88
39
|
when specs.size == 1
|
89
|
-
send
|
40
|
+
spec_aid.send method, specs.first
|
90
41
|
when specs.size > 1
|
91
42
|
print_gems specs
|
92
|
-
send
|
43
|
+
spec_aid.send method, pick_gem(specs, name)
|
93
44
|
else
|
94
|
-
|
45
|
+
error "Unable to find gem: #{name}."
|
95
46
|
end
|
96
47
|
end
|
97
48
|
end
|