gemsmith 5.3.0 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) 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 +68 -29
  5. data/lib/gemsmith/cli.rb +25 -11
  6. data/lib/gemsmith/cli_helpers.rb +3 -1
  7. data/lib/gemsmith/cli_options.rb +6 -4
  8. data/lib/gemsmith/identity.rb +2 -1
  9. data/lib/gemsmith/kit.rb +1 -1
  10. data/lib/gemsmith/rake/build.rb +38 -0
  11. data/lib/gemsmith/rake/release.rb +62 -0
  12. data/lib/gemsmith/rake/setup.rb +2 -0
  13. data/lib/gemsmith/rake/tasks.rb +43 -0
  14. data/lib/gemsmith/skeletons/base_skeleton.rb +9 -14
  15. data/lib/gemsmith/skeletons/bundler_skeleton.rb +4 -3
  16. data/lib/gemsmith/skeletons/cli_skeleton.rb +10 -3
  17. data/lib/gemsmith/skeletons/documentation_skeleton.rb +7 -6
  18. data/lib/gemsmith/skeletons/gem_skeleton.rb +13 -0
  19. data/lib/gemsmith/skeletons/git_skeleton.rb +9 -3
  20. data/lib/gemsmith/skeletons/guard_skeleton.rb +8 -2
  21. data/lib/gemsmith/skeletons/rails_skeleton.rb +30 -17
  22. data/lib/gemsmith/skeletons/rake_skeleton.rb +35 -0
  23. data/lib/gemsmith/skeletons/rspec_skeleton.rb +15 -7
  24. data/lib/gemsmith/skeletons/rubocop_skeleton.rb +17 -0
  25. data/lib/gemsmith/skeletons/ruby_skeleton.rb +10 -0
  26. data/lib/gemsmith/skeletons/travis_skeleton.rb +8 -2
  27. data/lib/gemsmith/tasks/rspec.rake +6 -0
  28. data/lib/gemsmith/tasks/rubocop.rake +6 -0
  29. data/lib/gemsmith/templates/%gem_name%/%gem_name%.gemspec.tt +4 -1
  30. data/lib/gemsmith/templates/%gem_name%/.rubocop.yml.tt +18 -0
  31. data/lib/gemsmith/templates/%gem_name%/.travis.yml.tt +1 -1
  32. data/lib/gemsmith/templates/%gem_name%/Guardfile.tt +12 -21
  33. data/lib/gemsmith/templates/%gem_name%/README.md.tt +5 -5
  34. data/lib/gemsmith/templates/%gem_name%/Rakefile.tt +2 -1
  35. data/lib/gemsmith/templates/%gem_name%/lib/%gem_name%/cli.rb.tt +2 -1
  36. data/lib/gemsmith/templates/%gem_name%/lib/%gem_name%/engine.rb.tt +6 -0
  37. data/lib/gemsmith/templates/%gem_name%/lib/%gem_name%/identity.rb.tt +1 -0
  38. data/lib/gemsmith/templates/%gem_name%/lib/%gem_name%/tasks/rspec.rake.tt +6 -0
  39. data/lib/gemsmith/templates/%gem_name%/lib/%gem_name%/tasks/rubocop.rake.tt +6 -0
  40. data/lib/gemsmith/templates/%gem_name%/lib/generators/%gem_name%/install/install_generator.rb.tt +3 -2
  41. data/lib/gemsmith/templates/%gem_name%/lib/generators/%gem_name%/upgrade/upgrade_generator.rb.tt +3 -2
  42. data/lib/gemsmith/templates/%gem_name%/spec/spec_helper.rb.tt +8 -0
  43. data/lib/gemsmith/templates/%gem_name%/spec/support/kit/stderr.rb.tt +1 -1
  44. data/lib/gemsmith/templates/%gem_name%/spec/support/kit/stdout.rb.tt +1 -1
  45. data/lib/gemsmith/templates/%gem_name%/spec/support/kit/temp_dir.rb.tt +1 -0
  46. metadata +31 -6
  47. metadata.gz.sig +0 -0
  48. data/lib/gemsmith/skeletons/default_skeleton.rb +0 -20
  49. data/lib/gemsmith/templates/%gem_name%/.coveralls.yml.tt +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e6492cee97fb77e9c3e7200512a746c31d04d0a
4
- data.tar.gz: db448eb8883cbeac936da5a443bfa625f623695e
3
+ metadata.gz: 1805ddbb3db7c0fefc5439520bc56b19d025d5fe
4
+ data.tar.gz: 0edc5d98121b4acc88d85dd1ae6c7d50dbb9be72
5
5
  SHA512:
6
- metadata.gz: cdabea344ce173819a595e8b4d5685cb0e6a336ca5a415b1ee13a2e8013c4ad0a100fdc35ff8ab29fa4d1ec61fe70736d8273ab03f29af2d457d85566b6e228d
7
- data.tar.gz: d035b0e6c5729477081a3664ebd393ab7eced5363c1c37bdb1e988555299d53030164f24c62ed1bcb26f7d42f34b23d55ed1b042eadb91985aa1a638a1b0405f
6
+ metadata.gz: 0fdd84fddfda3796bd2864437f7178f37b2f735f07770b801933a654319a5ce39df457fd56e261c5b0b737b7512488920b1b3aa3879bf022060f9a43f32abd81
7
+ data.tar.gz: d039120a68cc02dc413ca0a66d57f30730e65c230876114791d7ddc77882cabe0483310172e382bd5862144856c4ef39d1d0e27653019bbaa2029b070b977835
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -1,11 +1,10 @@
1
1
  # Gemsmith
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/gemsmith.png)](http://badge.fury.io/rb/gemsmith)
4
- [![Code Climate GPA](https://codeclimate.com/github/bkuhlmann/gemsmith.png)](https://codeclimate.com/github/bkuhlmann/gemsmith)
5
- [![Code Climate Coverage](https://codeclimate.com/github/bkuhlmann/gemsmith/coverage.png)](https://codeclimate.com/github/bkuhlmann/gemsmith)
6
- [![Gemnasium Status](https://gemnasium.com/bkuhlmann/gemsmith.png)](https://gemnasium.com/bkuhlmann/gemsmith)
7
- [![Travis CI Status](https://secure.travis-ci.org/bkuhlmann/gemsmith.png)](http://travis-ci.org/bkuhlmann/gemsmith)
8
- [![Gittip](http://img.shields.io/gittip/bkuhlmann.svg)](https://www.gittip.com/bkuhlmann)
3
+ [![Gem Version](https://badge.fury.io/rb/gemsmith.svg)](http://badge.fury.io/rb/gemsmith)
4
+ [![Code Climate GPA](https://codeclimate.com/github/bkuhlmann/gemsmith.svg)](https://codeclimate.com/github/bkuhlmann/gemsmith)
5
+ [![Code Climate Coverage](https://codeclimate.com/github/bkuhlmann/gemsmith/coverage.svg)](https://codeclimate.com/github/bkuhlmann/gemsmith)
6
+ [![Gemnasium Status](https://gemnasium.com/bkuhlmann/gemsmith.svg)](https://gemnasium.com/bkuhlmann/gemsmith)
7
+ [![Travis CI Status](https://secure.travis-ci.org/bkuhlmann/gemsmith.svg)](http://travis-ci.org/bkuhlmann/gemsmith)
9
8
 
10
9
  Gemsmith allows you to easily craft new gems via the command line with custom settings (if desired).
11
10
 
@@ -17,10 +16,13 @@ Gemsmith allows you to easily craft new gems via the command line with custom se
17
16
  - [Requirements](#requirements)
18
17
  - [Setup](#setup)
19
18
  - [Usage](#usage)
19
+ - [Command Line Interface (CLI)](#command-line-interface-cli)
20
+ - [Rake](#rake)
21
+ - [Upgrades](#upgrades)
20
22
  - [Tests](#tests)
21
23
  - [Security](#security)
22
- - [Best Practices](#best-practices)
23
- - [Documentation](#documentation)
24
+ - [Git Signing Key](#git-signing-key)
25
+ - [Gem Certificates](#gem-certificates)
24
26
  - [Promotion](#promotion)
25
27
  - [Versioning](#versioning)
26
28
  - [Code of Conduct](#code-of-conduct)
@@ -38,6 +40,7 @@ Gemsmith allows you to easily craft new gems via the command line with custom se
38
40
  - Supports [Thor](https://github.com/wycats/thor) command line functionality.
39
41
  - Supports [Ruby on Rails](http://rubyonrails.org).
40
42
  - Supports [RSpec](http://rspec.info).
43
+ - Supports [Rubocop](https://github.com/bbatsov/rubocop).
41
44
  - Supports [Pry](http://pryrepl.org).
42
45
  - Supports [Guard](https://github.com/guard/guard).
43
46
  - Supports [Code Climate](https://codeclimate.com).
@@ -99,6 +102,8 @@ If no options are configured, then the defaults are as follows:
99
102
 
100
103
  # Usage
101
104
 
105
+ ## Command Line Interface (CLI)
106
+
102
107
  From the command line, type: gemsmith help
103
108
 
104
109
  gemsmith -c, [create=CREATE] # Create new gem.
@@ -120,6 +125,8 @@ For more gem creation options, type: gemsmith help create
120
125
  # Default: true
121
126
  -s, [--rspec], [--no-rspec] # Add RSpec support.
122
127
  # Default: true
128
+ -R, [--rubocop], [--no-rubocop] # Add Rubocop support.
129
+ # Default: true
123
130
  -c, [--code-climate], [--no-code-climate] # Add Code Climate support.
124
131
  # Default: true
125
132
  -G, [--gemnasium], [--no-gemnasium] # Add Gemnasium support.
@@ -127,20 +134,68 @@ For more gem creation options, type: gemsmith help create
127
134
  -t, [--travis], [--no-travis] # Add Travis CI support.
128
135
  # Default: true
129
136
 
137
+ ## Rake
138
+
130
139
  Once a gem skeleton has been created, the following tasks are available within the project via Bundler (i.e. rake -T):
131
140
 
132
- rake build # Build example-0.1.0.gem into the pkg directory
133
- rake install # Build and install example-0.1.0.gem into system gems
134
- rake release # Create tag v2.3.0 and build and push example-0.1.0.gem to Rubygems
141
+ rake build # Build gemsmith-5.4.0.gem into the pkg directory
142
+ rake clean # Clean gem artifacts
143
+ rake install # Build and install gemsmith-5.4.0.gem into system gems
144
+ rake install:local # Build and install gemsmith-5.4.0.gem into system gems without network access
145
+ rake publish # Build, tag v5.4.0 (signed), and push gemsmith-5.4.0.gem to RubyGems
146
+ rake readme:toc # Update README Table of Contents
147
+ rake release # Create tag v5.4.0 and build and push gemsmith-5.4.0.gem to Rubygems
148
+ rake rubocop # Run RuboCop
149
+ rake rubocop:auto_correct # Auto-correct RuboCop offenses
150
+ rake spec # Run RSpec code examples
151
+
152
+ ## Upgrades
153
+
154
+ For those upgrading from Gemsmith 5.3.0 and wanting to use the new Rake tasks, do the following:
155
+
156
+ - Edit your `gemspec` and add the following dependency: `spec.add_development_dependency "gemsmith"`.
157
+ - Edit your `Rakefile` and remove the Bundler requirement `require "bundler/gem_tasks"` and replace it with
158
+ the Gemsmith tasks: `require "gemsmith/rake/setup"`. Don't worry, this includes the Bundler tasks too.
135
159
 
136
160
  # Tests
137
161
 
138
162
  To test, run:
139
163
 
140
- bundle exec rspec spec
164
+ bundle exec rake
141
165
 
142
166
  # Security
143
167
 
168
+ ## Git Signing Key
169
+
170
+ To sign your Git tags, start by installing and configuring [GPG](https://www.gnupg.org):
171
+
172
+ brew install gpg
173
+ gpg --gen-key
174
+
175
+ When setting up your GPG key, here is an example of safe defaults:
176
+
177
+ - Key kind: RSA and RSA (default)
178
+ - Key size: 4096
179
+ - Key validity: 0
180
+ - Real Name: `<your name>`
181
+ - Email: `<your email>`
182
+ - Passphrase: `<your passphrase>`
183
+
184
+ To obtain your key, run the following and take the part after the forward slash:
185
+
186
+ gpg --list-keys | grep pub
187
+
188
+ Add your key to your global Git configuration in the `[user]` section. Example:
189
+
190
+ [user]
191
+ signingkey = <your GPG key>
192
+
193
+ Now, when publishing your gems with Gemsmith (i.e. `bundle exec rake publish`), signing of your Git tag will happen
194
+ automatically. Should you not want to sign your tags, use `bundle exec rake release` which is the same as
195
+ `bundle exec rake publish` except the Git tag is not signed.
196
+
197
+ ## Gem Certificates
198
+
144
199
  To create a certificate for your gems, run the following:
145
200
 
146
201
  cd ~/.ssh
@@ -156,22 +211,6 @@ To learn more about gem certificates, read the following:
156
211
  - [A Practical Guide to Using Signed Ruby Gems - Part 1: Bundler](http://blog.meldium.com/home/2013/3/3/signed-rubygems-part)
157
212
  - [A Practical Guide to Using Signed Ruby Gems - Part 2: Heroku](http://blog.meldium.com/home/2013/3/6/signed-gems-on-heroku)
158
213
 
159
- # Best Practices
160
-
161
- 0. [Semantic Versioning](http://semver.org)
162
- 0. [Best Practices While Cutting Gems](http://rubysource.com/crafting-rubies-best-practices-while-cutting-gems).
163
- 0. [Ruby on Rails Gem Packaging](http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices).
164
- 0. [Gem Activation and You: Part I](http://erik.hollensbe.org/2013/05/11/gem-activation-and-you)
165
- 0. [Gem Activation and You: Part II](http://erik.hollensbe.org/2013/05/15/gem-activation-and-you-part-2-bundler-and-binstubs)
166
- 0. [Why You Should Use a BSD Style License](http://www.freebsd.org/doc/en/articles/bsdl-gpl/article.html).
167
- 0. Add -w to the RUBYOPT environment variable when testing. [Details](http://avdi.org/devblog/2011/06/23/how-ruby-helps-you-fix-your-broken-code).
168
-
169
- # Documentation
170
-
171
- In order to make your gem easier to use and adopt by others, good documentation is always a plus. Consider submitting
172
- your gem to RubyDocs[http://rubydoc.info] once your gem is released and available for use. RubyDocs supports both
173
- RDoc and YARD formats.
174
-
175
214
  # Promotion
176
215
 
177
216
  Once your gem is released, you might like to let the world know about the new awesomeness. Here are several resources:
@@ -180,7 +219,7 @@ Once your gem is released, you might like to let the world know about the new aw
180
219
  - [Ruby Toolbox](https://www.ruby-toolbox.com)
181
220
  - [RubyFlow](http://www.rubyflow.com)
182
221
  - [The Ruby Show](http://rubyshow.com)
183
- - [Ruby 5](http://ruby5.envylabs.com)
222
+ - [Ruby 5](https://ruby5.codeschool.com)
184
223
 
185
224
  # Versioning
186
225
 
@@ -7,15 +7,19 @@ require "gemsmith/cli_helpers"
7
7
  require "gemsmith/skeletons/base_skeleton"
8
8
  require "gemsmith/skeletons/bundler_skeleton"
9
9
  require "gemsmith/skeletons/cli_skeleton"
10
- require "gemsmith/skeletons/default_skeleton"
11
10
  require "gemsmith/skeletons/documentation_skeleton"
11
+ require "gemsmith/skeletons/gem_skeleton"
12
12
  require "gemsmith/skeletons/git_skeleton"
13
13
  require "gemsmith/skeletons/guard_skeleton"
14
14
  require "gemsmith/skeletons/rails_skeleton"
15
+ require "gemsmith/skeletons/rake_skeleton"
15
16
  require "gemsmith/skeletons/rspec_skeleton"
17
+ require "gemsmith/skeletons/rubocop_skeleton"
18
+ require "gemsmith/skeletons/ruby_skeleton"
16
19
  require "gemsmith/skeletons/travis_skeleton"
17
20
 
18
21
  module Gemsmith
22
+ # The Command Line Interface (CLI) for the gem.
19
23
  class CLI < Thor
20
24
  include Thor::Actions
21
25
  include ThorPlus::Actions
@@ -29,6 +33,23 @@ module Gemsmith
29
33
  File.expand_path File.join(File.dirname(__FILE__), "templates")
30
34
  end
31
35
 
36
+ def self.skeletons
37
+ [
38
+ Skeletons::GemSkeleton,
39
+ Skeletons::DocumentationSkeleton,
40
+ Skeletons::RakeSkeleton,
41
+ Skeletons::CLISkeleton,
42
+ Skeletons::RubySkeleton,
43
+ Skeletons::RailsSkeleton,
44
+ Skeletons::RspecSkeleton,
45
+ Skeletons::RubocopSkeleton,
46
+ Skeletons::GuardSkeleton,
47
+ Skeletons::TravisSkeleton,
48
+ Skeletons::BundlerSkeleton,
49
+ Skeletons::GitSkeleton
50
+ ]
51
+ end
52
+
32
53
  # Initialize.
33
54
  def initialize args = [], options = {}, config = {}
34
55
  super args, options, config
@@ -45,6 +66,7 @@ module Gemsmith
45
66
  method_option :pry, aliases: "-p", desc: "Add Pry support.", type: :boolean, default: true
46
67
  method_option :guard, aliases: "-g", desc: "Add Guard support.", type: :boolean, default: true
47
68
  method_option :rspec, aliases: "-s", desc: "Add RSpec support.", type: :boolean, default: true
69
+ method_option :rubocop, aliases: "-R", desc: "Add Rubocop support.", type: :boolean, default: true
48
70
  method_option :code_climate, aliases: "-c", desc: "Add Code Climate support.", type: :boolean, default: true
49
71
  method_option :gemnasium, aliases: "-G", desc: "Add Gemnasium support.", type: :boolean, default: true
50
72
  method_option :travis, aliases: "-t", desc: "Add Travis CI support.", type: :boolean, default: true
@@ -53,15 +75,7 @@ module Gemsmith
53
75
  info "Creating gem..."
54
76
 
55
77
  initialize_template_options name, options
56
- Skeletons::DefaultSkeleton.run self
57
- Skeletons::DocumentationSkeleton.run self
58
- Skeletons::CLISkeleton.run(self) if template_options[:bin]
59
- Skeletons::RailsSkeleton.run(self) if template_options[:rails]
60
- Skeletons::RspecSkeleton.run(self) if template_options[:rspec]
61
- Skeletons::GuardSkeleton.run(self) if template_options[:guard]
62
- Skeletons::TravisSkeleton.run(self) if template_options[:travis]
63
- Skeletons::BundlerSkeleton.run self
64
- Skeletons::GitSkeleton.run self
78
+ self.class.skeletons.each { |skeleton| skeleton.create self }
65
79
 
66
80
  info "Gem created."
67
81
  say
@@ -94,7 +108,7 @@ module Gemsmith
94
108
  desc "-h, [--help=HELP]", "Show this message or get help for a command."
95
109
  map %w(-h --help) => :help
96
110
  def help task = nil
97
- say and super
111
+ say && super
98
112
  end
99
113
  end
100
114
  end
@@ -1,4 +1,6 @@
1
1
  module Gemsmith
2
+ # Command Line Interface (CLI) helpers that aid the CLI class. These are extracted to a module
3
+ # in order to not clutter up the main CLI object.
2
4
  module CLIHelpers
3
5
  # Answers default editor.
4
6
  # NOTE: This will be replaced by the Thor+ gem in the future.
@@ -51,7 +53,7 @@ module Gemsmith
51
53
  def pick_gem gems, name
52
54
  result = ask "Please pick one (or type 'q' to quit):"
53
55
 
54
- return if result == 'q' # Exit early.
56
+ return if result == "q" # Exit early.
55
57
 
56
58
  if (1..gems.size).include?(result.to_i)
57
59
  Gem::Specification.find_by_name name, gems[result.to_i - 1].version.version
@@ -1,4 +1,5 @@
1
1
  module Gemsmith
2
+ # Provides Command Line Interface (CLI) settings initialization with safe defaults.
2
3
  module CLIOptions
3
4
  module_function
4
5
 
@@ -36,6 +37,7 @@ module Gemsmith
36
37
  pry: default_boolean(:pry, true),
37
38
  guard: default_boolean(:guard, true),
38
39
  rspec: default_boolean(:rspec, true),
40
+ rubocop: default_boolean(:rubocop, true),
39
41
  code_climate: default_boolean(:code_climate, true),
40
42
  gemnasium: default_boolean(:gemnasium, true),
41
43
  travis: default_boolean(:travis, true)
@@ -59,11 +61,11 @@ module Gemsmith
59
61
  end
60
62
 
61
63
  def author_name
62
- @settings[:author_name] || Gemsmith::Kit.git_config_value("user.name") || "TODO: Add full name here."
64
+ @settings[:author_name] || Gemsmith::Kit.git_config_value("user.name") || "TODO: Add full name."
63
65
  end
64
66
 
65
67
  def author_email
66
- @settings[:author_email] || Gemsmith::Kit.git_config_value("user.email") || "TODO: Add email address here."
68
+ @settings[:author_email] || Gemsmith::Kit.git_config_value("user.email") || "TODO: Add email address."
67
69
  end
68
70
 
69
71
  def author_url
@@ -87,7 +89,7 @@ module Gemsmith
87
89
  end
88
90
 
89
91
  def ruby_version
90
- @settings[:ruby_version] || "2.2.2"
92
+ @settings[:ruby_version] || "2.2.3"
91
93
  end
92
94
 
93
95
  def rails_version
@@ -95,7 +97,7 @@ module Gemsmith
95
97
  end
96
98
 
97
99
  def default_boolean key, value = false
98
- @settings.has_key?(key) ? @settings[key] : value
100
+ @settings.key?(key) ? @settings[key] : value
99
101
  end
100
102
  end
101
103
  end
@@ -1,4 +1,5 @@
1
1
  module Gemsmith
2
+ # The canonical source of gem information.
2
3
  module Identity
3
4
  def self.name
4
5
  "gemsmith"
@@ -9,7 +10,7 @@ module Gemsmith
9
10
  end
10
11
 
11
12
  def self.version
12
- "5.3.0"
13
+ "5.4.0"
13
14
  end
14
15
 
15
16
  def self.label_version
@@ -9,4 +9,4 @@ module Gemsmith
9
9
  value.nil? || value.empty? ? nil : value
10
10
  end
11
11
  end
12
- end
12
+ end
@@ -0,0 +1,38 @@
1
+ require "bundler/ui/shell"
2
+
3
+ module Gemsmith
4
+ module Rake
5
+ # Enhances gem publishing with build functionality. Meant to be wrapped in Rake tasks.
6
+ class Build
7
+ def initialize shell: Bundler::UI::Shell.new, kernel: Kernel
8
+ @shell = shell
9
+ @kernel = kernel
10
+ end
11
+
12
+ def table_of_contents
13
+ if kernel.system("command -v doctoc > /dev/null")
14
+ kernel.system %(doctoc --title "# Table of Contents" README.md)
15
+ else
16
+ shell.error error_message
17
+ kernel.exit 1
18
+ end
19
+ end
20
+
21
+ def clean!
22
+ FileUtils.rm_rf "pkg"
23
+ shell.info "Gem artifacts cleaned."
24
+ end
25
+
26
+ private
27
+
28
+ attr_reader :shell, :kernel
29
+
30
+ def error_message
31
+ url = "https://github.com/thlorenz/doctoc"
32
+ command = "npm install --global doctoc"
33
+
34
+ "Unable to update README Table of Contents, please install DocToc (#{url}): #{command}."
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,62 @@
1
+ require "bundler/ui/shell"
2
+
3
+ module Gemsmith
4
+ module Rake
5
+ # Enhances gem publishing with release functionality. Meant to be wrapped in Rake tasks.
6
+ class Release
7
+ def initialize gem_spec_path = Dir.glob("#{Dir.pwd}/*.gemspec").first,
8
+ shell: Bundler::UI::Shell.new,
9
+ kernel: Kernel
10
+
11
+ @gem_spec_path = gem_spec_path
12
+ @shell = shell
13
+ @kernel = kernel
14
+
15
+ @gem_spec = load_gem_spec
16
+ end
17
+
18
+ def name
19
+ gem_spec.name
20
+ end
21
+
22
+ def version
23
+ gem_spec.version.version
24
+ end
25
+
26
+ def version_formatted
27
+ "v#{version}"
28
+ end
29
+
30
+ def package_file_name
31
+ "#{name}-#{version}.gem"
32
+ end
33
+
34
+ def tag
35
+ shell.error(%(Tag #{version_formatted} exists!)) && return if tagged?
36
+
37
+ return if kernel.system %(git tag --sign --annotate "#{version_formatted}" --message "Version #{version}.")
38
+
39
+ kernel.system "git tag -d #{version_formatted}"
40
+ shell.error %(Removed "#{version_formatted}" due to errors.)
41
+ end
42
+
43
+ def push
44
+ kernel.system "git push --tags"
45
+ end
46
+
47
+ private
48
+
49
+ attr_reader :gem_spec_path, :gem_spec, :shell, :kernel
50
+
51
+ def load_gem_spec
52
+ Bundler.load_gemspec gem_spec_path.to_s
53
+ rescue Errno::ENOENT
54
+ shell.error "Invalid gemspec file path: #{gem_spec_path}."
55
+ end
56
+
57
+ def tagged?
58
+ kernel.system %(git show #{version_formatted})
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,2 @@
1
+ require "gemsmith/rake/tasks"
2
+ Gemsmith::Rake::Tasks.setup
@@ -0,0 +1,43 @@
1
+ require "bundler/gem_tasks"
2
+ require "gemsmith/rake/build"
3
+ require "gemsmith/rake/release"
4
+
5
+ module Gemsmith
6
+ module Rake
7
+ # Provides Rake tasks for use in all gems built by this gem.
8
+ class Tasks
9
+ include ::Rake::DSL
10
+
11
+ def self.setup
12
+ new.install
13
+ end
14
+
15
+ def install
16
+ build = Gemsmith::Rake::Build.new
17
+ release = Gemsmith::Rake::Release.new
18
+
19
+ ::Rake::Task[:build].enhance [:clean, "readme:toc"]
20
+ ::Rake::Task[:release].enhance { ::Rake::Task[:clean].invoke }
21
+
22
+ namespace :readme do
23
+ desc "Update README Table of Contents."
24
+ task :toc do
25
+ build.table_of_contents
26
+ end
27
+ end
28
+
29
+ desc "Clean gem artifacts."
30
+ task :clean do
31
+ build.clean!
32
+ end
33
+
34
+ desc "Build, tag #{release.version_formatted} (signed), and push #{release.package_file_name} to RubyGems"
35
+ task publish: [:clean, :build, "release:guard_clean"] do
36
+ release.tag
37
+ release.push
38
+ ::Rake::Task["release:rubygem_push"].invoke
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,32 +1,27 @@
1
1
  module Gemsmith
2
2
  module Skeletons
3
+ # Abstract class from which all skeletons inherit from.
3
4
  class BaseSkeleton
4
5
  def initialize cli
5
6
  @cli = cli
6
7
  end
7
8
 
8
- def self.run cli
9
- self.new(cli).create
9
+ def self.create cli
10
+ new(cli).create
10
11
  end
11
12
 
12
- def create
13
- public_methods.each { |method| public_send(method) if method =~ /^create_.+$/ }
14
- end
15
-
16
- def respond_to? name, include_private = false
17
- @cli.respond_to?(name, include_private) || super(name, include_private)
13
+ def enabled?
14
+ true
18
15
  end
19
16
 
20
- def method_missing name, *args, &block
21
- if respond_to?(name)
22
- @cli.public_send name, *args, &block
23
- else
24
- super name, *args, &block
25
- end
17
+ def create
18
+ fail NotImplementedError, "The method, #create, is not implemented yet."
26
19
  end
27
20
 
28
21
  private
29
22
 
23
+ attr_reader :cli
24
+
30
25
  def lib_root
31
26
  "%gem_name%/lib"
32
27
  end
@@ -1,9 +1,10 @@
1
1
  module Gemsmith
2
2
  module Skeletons
3
+ # Configures Bundler support.
3
4
  class BundlerSkeleton < BaseSkeleton
4
- def create_gemfile_lock
5
- Dir.chdir(File.join(destination_root, gem_name)) do
6
- info "Installing gem dependencies..."
5
+ def create
6
+ Dir.chdir(File.join(cli.destination_root, cli.gem_name)) do
7
+ cli.info "Installing gem dependencies..."
7
8
  `bundle install`
8
9
  end
9
10
  end
@@ -1,9 +1,16 @@
1
1
  module Gemsmith
2
2
  module Skeletons
3
+ # Configures Command Line Interface (CLI) support.
3
4
  class CLISkeleton < BaseSkeleton
4
- def create_files
5
- template "%gem_name%/bin/%gem_name%.tt", template_options
6
- template "%gem_name%/lib/%gem_name%/cli.rb.tt", template_options
5
+ def enabled?
6
+ cli.template_options.key?(:bin) && cli.template_options[:bin]
7
+ end
8
+
9
+ def create
10
+ return unless enabled?
11
+
12
+ cli.template "%gem_name%/bin/%gem_name%.tt", cli.template_options
13
+ cli.template "%gem_name%/lib/%gem_name%/cli.rb.tt", cli.template_options
7
14
  end
8
15
  end
9
16
  end
@@ -1,12 +1,13 @@
1
1
  module Gemsmith
2
2
  module Skeletons
3
+ # Configures documentation support.
3
4
  class DocumentationSkeleton < BaseSkeleton
4
- def create_files
5
- template "%gem_name%/README.md.tt", template_options
6
- template "%gem_name%/CONTRIBUTING.md.tt", template_options
7
- template "%gem_name%/CODE_OF_CONDUCT.md.tt", template_options
8
- template "%gem_name%/LICENSE.md.tt", template_options
9
- template "%gem_name%/CHANGELOG.md.tt", template_options
5
+ def create
6
+ cli.template "%gem_name%/README.md.tt", cli.template_options
7
+ cli.template "%gem_name%/CONTRIBUTING.md.tt", cli.template_options
8
+ cli.template "%gem_name%/CODE_OF_CONDUCT.md.tt", cli.template_options
9
+ cli.template "%gem_name%/LICENSE.md.tt", cli.template_options
10
+ cli.template "%gem_name%/CHANGELOG.md.tt", cli.template_options
10
11
  end
11
12
  end
12
13
  end
@@ -0,0 +1,13 @@
1
+ module Gemsmith
2
+ module Skeletons
3
+ # Configures default gem support.
4
+ class GemSkeleton < BaseSkeleton
5
+ def create
6
+ cli.template "%gem_name%/Gemfile.tt", cli.template_options
7
+ cli.template "%gem_name%/%gem_name%.gemspec.tt", cli.template_options
8
+ cli.template "#{lib_root}/%gem_name%.rb.tt", cli.template_options
9
+ cli.template "#{lib_root}/%gem_name%/identity.rb.tt", cli.template_options
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,17 +1,23 @@
1
1
  module Gemsmith
2
2
  module Skeletons
3
+ # Configures Git support.
3
4
  class GitSkeleton < BaseSkeleton
4
- def create_files
5
- template "%gem_name%/Gemfile.tt", template_options
5
+ def create_ignore_file
6
+ cli.template "%gem_name%/.gitignore.tt", cli.template_options
6
7
  end
7
8
 
8
9
  def create_repository
9
- Dir.chdir(File.join(destination_root, gem_name)) do
10
+ Dir.chdir(File.join(cli.destination_root, cli.gem_name)) do
10
11
  `git init`
11
12
  `git add .`
12
13
  `git commit --all --no-verify --message "Added Gemsmith skeleton."`
13
14
  end
14
15
  end
16
+
17
+ def create
18
+ create_ignore_file
19
+ create_repository
20
+ end
15
21
  end
16
22
  end
17
23
  end
@@ -1,8 +1,14 @@
1
1
  module Gemsmith
2
2
  module Skeletons
3
+ # Configures Guard support.
3
4
  class GuardSkeleton < BaseSkeleton
4
- def create_files
5
- template "%gem_name%/Guardfile.tt", template_options
5
+ def enabled?
6
+ cli.template_options.key?(:guard) && cli.template_options[:guard]
7
+ end
8
+
9
+ def create
10
+ return unless enabled?
11
+ cli.template "%gem_name%/Guardfile.tt", cli.template_options
6
12
  end
7
13
  end
8
14
  end
@@ -1,35 +1,48 @@
1
1
  module Gemsmith
2
2
  module Skeletons
3
+ # Configures Ruby on Rails support.
3
4
  class RailsSkeleton < BaseSkeleton
5
+ def enabled?
6
+ cli.template_options.key?(:rails) && cli.template_options[:rails]
7
+ end
8
+
4
9
  def create_engine
5
- gem_name = template_options.fetch :gem_name
6
- system "rails plugin new #{gem_name} #{engine_options}"
7
- remove_file "#{gem_name}/MIT-LICENSE", template_options
8
- remove_file "#{gem_name}/README.rdoc", template_options
10
+ cli.template "#{lib_root}/%gem_name%/engine.rb.tt", cli.template_options
11
+
12
+ gem_name = cli.template_options.fetch :gem_name
13
+ system "rails plugin new --skip #{gem_name} #{engine_options}"
14
+
15
+ cli.remove_file "#{gem_name}/app/helpers/#{gem_name}/application_helper.rb", cli.template_options
16
+ cli.remove_file "#{gem_name}/lib/#{gem_name}/version.rb", cli.template_options
17
+ cli.remove_file "#{gem_name}/MIT-LICENSE", cli.template_options
18
+ cli.remove_file "#{gem_name}/README.rdoc", cli.template_options
9
19
  end
10
20
 
11
21
  def create_generator_files
12
- empty_directory "#{generator_root}/templates"
13
- template "#{generator_root}/install/install_generator.rb.tt", template_options
14
- template "#{generator_root}/install/USAGE.tt", template_options
15
- template "#{generator_root}/upgrade/upgrade_generator.rb.tt", template_options
16
- template "#{generator_root}/upgrade/USAGE.tt", template_options
22
+ cli.empty_directory "#{generator_root}/templates"
23
+ cli.template "#{generator_root}/install/install_generator.rb.tt", cli.template_options
24
+ cli.template "#{generator_root}/install/USAGE.tt", cli.template_options
25
+ cli.template "#{generator_root}/upgrade/upgrade_generator.rb.tt", cli.template_options
26
+ cli.template "#{generator_root}/upgrade/USAGE.tt", cli.template_options
17
27
  end
18
28
 
19
29
  def create_travis_gemfiles
20
- if template_options[:travis]
21
- template "%gem_name%/gemfiles/rails-4.1.x.gemfile.tt", template_options
22
- end
30
+ return unless cli.template_options[:travis]
31
+ cli.template "%gem_name%/gemfiles/rails-4.1.x.gemfile.tt", cli.template_options
23
32
  end
24
33
 
25
- private
34
+ def create
35
+ return unless enabled?
26
36
 
27
- def engine_options
28
- "--skip --skip-bundle --skip-test-unit --skip-keeps --mountable --dummy-path=spec/dummy"
37
+ create_engine
38
+ create_generator_files
39
+ create_travis_gemfiles
29
40
  end
30
41
 
31
- def lib_gem_root
32
- "#{lib_root}/%gem_name%"
42
+ private
43
+
44
+ def engine_options
45
+ "--skip-bundle --skip-test-unit --skip-keeps --skip-git --mountable --dummy-path=spec/dummy"
33
46
  end
34
47
 
35
48
  def generator_root
@@ -0,0 +1,35 @@
1
+ module Gemsmith
2
+ module Skeletons
3
+ # Configures Rake support.
4
+ class RakeSkeleton < BaseSkeleton
5
+ def self.allowed_options
6
+ {
7
+ rspec: "spec",
8
+ rubocop: "rubocop"
9
+ }
10
+ end
11
+
12
+ def create
13
+ cli.template "%gem_name%/Rakefile.tt", cli.template_options
14
+ configure_rakefile
15
+ end
16
+
17
+ private
18
+
19
+ def allowed_options?
20
+ cli.template_options.keys.any? { |key| self.class.allowed_options.keys.include? key }
21
+ end
22
+
23
+ def default_tasks
24
+ cli.template_options.each.with_object([]) do |(key, _), tasks|
25
+ tasks.push self.class.allowed_options[key]
26
+ end
27
+ end
28
+
29
+ def configure_rakefile
30
+ return unless allowed_options?
31
+ cli.append_to_file "%gem_name%/Rakefile", "\ntask default: %w(#{default_tasks.compact.join(' ')})\n"
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,13 +1,21 @@
1
1
  module Gemsmith
2
2
  module Skeletons
3
+ # Configures RSpec support.
3
4
  class RspecSkeleton < BaseSkeleton
4
- def create_files
5
- template "#{rspec_root}/spec_helper.rb.tt", template_options
6
- template "#{rspec_root}/%gem_name%_spec.rb.tt", template_options
7
- template "#{rspec_root}/support/kit/default_config.rb.tt", template_options
8
- template "#{rspec_root}/support/kit/stderr.rb.tt", template_options
9
- template "#{rspec_root}/support/kit/stdout.rb.tt", template_options
10
- template "#{rspec_root}/support/kit/temp_dir.rb.tt", template_options
5
+ def enabled?
6
+ cli.template_options.key?(:rspec) && cli.template_options[:rspec]
7
+ end
8
+
9
+ def create
10
+ return unless enabled?
11
+
12
+ cli.template "%gem_name%/lib/%gem_name%/tasks/rspec.rake.tt", cli.template_options
13
+ cli.template "#{rspec_root}/spec_helper.rb.tt", cli.template_options
14
+ cli.template "#{rspec_root}/%gem_name%_spec.rb.tt", cli.template_options
15
+ cli.template "#{rspec_root}/support/kit/default_config.rb.tt", cli.template_options
16
+ cli.template "#{rspec_root}/support/kit/stderr.rb.tt", cli.template_options
17
+ cli.template "#{rspec_root}/support/kit/stdout.rb.tt", cli.template_options
18
+ cli.template "#{rspec_root}/support/kit/temp_dir.rb.tt", cli.template_options
11
19
  end
12
20
 
13
21
  private
@@ -0,0 +1,17 @@
1
+ module Gemsmith
2
+ module Skeletons
3
+ # Configures Rubocop support.
4
+ class RubocopSkeleton < BaseSkeleton
5
+ def enabled?
6
+ cli.template_options.key?(:rubocop) && cli.template_options[:rubocop]
7
+ end
8
+
9
+ def create
10
+ return unless enabled?
11
+
12
+ cli.template "%gem_name%/.rubocop.yml.tt", cli.template_options
13
+ cli.template "%gem_name%/lib/%gem_name%/tasks/rubocop.rake.tt", cli.template_options
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,10 @@
1
+ module Gemsmith
2
+ module Skeletons
3
+ # Configures Ruby support.
4
+ class RubySkeleton < BaseSkeleton
5
+ def create
6
+ cli.template "%gem_name%/.ruby-version.tt", cli.template_options
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,8 +1,14 @@
1
1
  module Gemsmith
2
2
  module Skeletons
3
+ # Configures Travis CI support.
3
4
  class TravisSkeleton < BaseSkeleton
4
- def create_files
5
- template "%gem_name%/.travis.yml.tt", template_options
5
+ def enabled?
6
+ cli.template_options.key?(:travis) && cli.template_options[:travis]
7
+ end
8
+
9
+ def create
10
+ return unless enabled?
11
+ cli.template "%gem_name%/.travis.yml.tt", cli.template_options
6
12
  end
7
13
  end
8
14
  end
@@ -0,0 +1,6 @@
1
+ begin
2
+ require "rspec/core/rake_task"
3
+ RSpec::Core::RakeTask.new(:spec)
4
+ rescue LoadError => error
5
+ puts error.message
6
+ end
@@ -0,0 +1,6 @@
1
+ begin
2
+ require "rubocop/rake_task"
3
+ RuboCop::RakeTask.new
4
+ rescue LoadError => error
5
+ puts error.message
6
+ end
@@ -22,7 +22,6 @@ Gem::Specification.new do |spec|
22
22
  end
23
23
  <%- end -%>
24
24
 
25
- spec.required_ruby_version = "~> <%= config[:ruby_version] %>"
26
25
  <%- if config[:bin] -%>
27
26
  spec.add_dependency "thor"
28
27
  spec.add_dependency "thor_plus"
@@ -33,6 +32,7 @@ Gem::Specification.new do |spec|
33
32
  <%- if config[:travis] -%>
34
33
  spec.add_development_dependency "rake"
35
34
  <%- end -%>
35
+ spec.add_development_dependency "gemsmith"
36
36
  <%- if config[:pry] -%>
37
37
  spec.add_development_dependency "pry"
38
38
  spec.add_development_dependency "pry-byebug"
@@ -54,6 +54,9 @@ Gem::Specification.new do |spec|
54
54
  spec.add_development_dependency "terminal-notifier"
55
55
  spec.add_development_dependency "terminal-notifier-guard"
56
56
  <%- end -%>
57
+ <%- if config[:rubocop] -%>
58
+ spec.add_development_dependency "rubocop"
59
+ <%- end -%>
57
60
  <%- if config[:code_climate] -%>
58
61
  spec.add_development_dependency "codeclimate-test-reporter"
59
62
  <%- end -%>
@@ -0,0 +1,18 @@
1
+ <%- if config[:rails] -%>
2
+ AllCops:
3
+ Exclude:
4
+ - "spec/dummy/**/*"
5
+ - "bin/rails"
6
+ <%- end -%>
7
+ Style/CaseIndentation:
8
+ IndentOneStep: true
9
+ Style/MethodDefParentheses:
10
+ EnforcedStyle: require_no_parentheses
11
+ Style/SingleLineBlockParams:
12
+ Enabled: false
13
+ Style/SpaceInsideHashLiteralBraces:
14
+ EnforcedStyle: no_space
15
+ Style/StringLiterals:
16
+ EnforcedStyle: double_quotes
17
+ Metrics/LineLength:
18
+ Max: 120
@@ -6,4 +6,4 @@ rvm:
6
6
  gemfile:
7
7
  - gemfiles/rails-4.1.x.gemfile
8
8
  <%- end -%>
9
- script: bundle exec rspec spec
9
+ script: bundle exec rake
@@ -1,30 +1,21 @@
1
1
  guard :rspec, cmd: "bundle exec rspec" do
2
2
  watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
- watch('spec/spec_helper.rb') { "spec" }
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch("spec/spec_helper.rb") { "spec" }
5
5
  <%- if config[:rails] -%>
6
6
 
7
7
  # Rails
8
- watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
9
- watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
10
- watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
11
- watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
12
- watch('config/routes.rb') { "spec/routing" }
13
- watch('app/controllers/application_controller.rb') { "spec/controllers" }
14
- watch('spec/rails_helper.rb') { "spec" }
8
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
9
+ watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
10
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m|
11
+ ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb"]
12
+ end
13
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
+ watch("config/routes.rb") { "spec/routing" }
15
+ watch("app/controllers/application_controller.rb") { "spec/controllers" }
16
+ watch("spec/rails_helper.rb") { "spec" }
15
17
 
16
18
  # Capybara
17
- watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
19
+ watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
18
20
  <%- end -%>
19
21
  end
20
-
21
- <%- if config[:rails] -%>
22
- guard "livereload" do
23
- watch(%r{app/views/.+\.(erb|haml|slim)$})
24
- watch(%r{app/helpers/.+\.rb})
25
- watch(%r{public/.+\.(css|js|html)})
26
- watch(%r{config/locales/.+\.yml})
27
- # Rails Assets Pipeline
28
- watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html|png|jpg))).*}) { |m| "/assets/#{m[3]}" }
29
- end
30
- <%- end -%>
@@ -1,15 +1,15 @@
1
1
  # <%= config[:gem_class] %>
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/<%= config[:gem_name] %>.png)](http://badge.fury.io/rb/<%= config[:gem_name] %>)
3
+ [![Gem Version](https://badge.fury.io/rb/<%= config[:gem_name] %>.svg)](http://badge.fury.io/rb/<%= config[:gem_name] %>)
4
4
  <%- if config[:code_climate] -%>
5
- [![Code Climate GPA](https://codeclimate.com/github/<%= config[:github_user] %>/<%= config[:gem_name] %>.png)](https://codeclimate.com/github/<%= config[:github_user] %>/<%= config[:gem_name] %>)
6
- [![Code Climate Coverage](https://codeclimate.com/github/<%= config[:github_user] %>/<%= config[:gem_name] %>/coverage.png)](https://codeclimate.com/github/<%= config[:github_user] %>/<%= config[:gem_name] %>)
5
+ [![Code Climate GPA](https://codeclimate.com/github/<%= config[:github_user] %>/<%= config[:gem_name] %>.svg)](https://codeclimate.com/github/<%= config[:github_user] %>/<%= config[:gem_name] %>)
6
+ [![Code Climate Coverage](https://codeclimate.com/github/<%= config[:github_user] %>/<%= config[:gem_name] %>/coverage.svg)](https://codeclimate.com/github/<%= config[:github_user] %>/<%= config[:gem_name] %>)
7
7
  <%- end -%>
8
8
  <%- if config[:gemnasium] -%>
9
- [![Gemnasium Status](https://gemnasium.com/<%= config[:github_user] %>/<%= config[:gem_name] %>.png)](https://gemnasium.com/<%= config[:github_user] %>/<%= config[:gem_name] %>)
9
+ [![Gemnasium Status](https://gemnasium.com/<%= config[:github_user] %>/<%= config[:gem_name] %>.svg)](https://gemnasium.com/<%= config[:github_user] %>/<%= config[:gem_name] %>)
10
10
  <%- end -%>
11
11
  <%- if config[:travis] -%>
12
- [![Travis CI Status](https://secure.travis-ci.org/<%= config[:github_user] %>/<%= config[:gem_name] %>.png)](http://travis-ci.org/<%= config[:github_user] %>/<%= config[:gem_name] %>)
12
+ [![Travis CI Status](https://secure.travis-ci.org/<%= config[:github_user] %>/<%= config[:gem_name] %>.svg)](http://travis-ci.org/<%= config[:github_user] %>/<%= config[:gem_name] %>)
13
13
  <%- end -%>
14
14
 
15
15
  <!-- START doctoc - For use by DocToc (https://github.com/thlorenz/doctoc), autogenerates the table of contents -->
@@ -1 +1,2 @@
1
- require "bundler/gem_tasks"
1
+ require "gemsmith/rake/setup"
2
+ Dir.glob("lib/<%= config[:gem_name] %>/tasks/*.rake").each { |file| load file }
@@ -4,6 +4,7 @@ require "thor/actions"
4
4
  require "thor_plus/actions"
5
5
 
6
6
  module <%= config[:gem_class] %>
7
+ # The Command Line Interface (CLI) for the gem.
7
8
  class CLI < Thor
8
9
  include Thor::Actions
9
10
  include ThorPlus::Actions
@@ -24,7 +25,7 @@ module <%= config[:gem_class] %>
24
25
  desc "-h, [--help=HELP]", "Show this message or get help for a command."
25
26
  map %w(-h --help) => :help
26
27
  def help task = nil
27
- say and super
28
+ say && super
28
29
  end
29
30
  end
30
31
  end
@@ -0,0 +1,6 @@
1
+ module <%= config[:gem_class] %>
2
+ # Defines and registers the Rails engine.
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace <%= config[:gem_class] %>
5
+ end
6
+ end
@@ -1,4 +1,5 @@
1
1
  module <%= config[:gem_class] %>
2
+ # The canonical source of gem information.
2
3
  module Identity
3
4
  def self.name
4
5
  "<%= config[:gem_name] %>"
@@ -0,0 +1,6 @@
1
+ begin
2
+ require "rspec/core/rake_task"
3
+ RSpec::Core::RakeTask.new(:spec)
4
+ rescue LoadError => error
5
+ puts error.message
6
+ end
@@ -0,0 +1,6 @@
1
+ begin
2
+ require "rubocop/rake_task"
3
+ RuboCop::RakeTask.new
4
+ rescue LoadError => error
5
+ puts error.message
6
+ end
@@ -1,10 +1,11 @@
1
1
  module <%= config[:gem_class] %>
2
+ # Generator for installing new files.
2
3
  class InstallGenerator < Rails::Generators::Base
3
- source_root File.join(File.dirname(__FILE__), "..", "templates")
4
+ source_root File.join(File.dirname(__FILE__), "..", "templates")
4
5
 
5
6
  desc "Installs additional <%= config[:gem_class] %> resources."
6
7
  def install
7
- # TODO - Add install code here.
8
+ # TODO: Add install code.
8
9
  end
9
10
  end
10
11
  end
@@ -1,10 +1,11 @@
1
1
  module <%= config[:gem_class] %>
2
+ # Generator for updating existing files.
2
3
  class UpgradeGenerator < Rails::Generators::Base
3
- source_root File.join(File.dirname(__FILE__), "..", "templates")
4
+ source_root File.join(File.dirname(__FILE__), "..", "templates")
4
5
 
5
6
  desc "Upgrades previously installed <%= config[:gem_class] %> resources."
6
7
  def upgrade
7
- # TODO - Add upgrade code here.
8
+ # TODO: Add upgrade code.
8
9
  end
9
10
  end
10
11
  end
@@ -1,9 +1,17 @@
1
1
  require "bundler/setup"
2
+
2
3
  <%- if config[:code_climate] -%>
3
4
  if ENV["CODECLIMATE_REPO_TOKEN"]
4
5
  require "codeclimate-test-reporter"
5
6
  CodeClimate::TestReporter.start
6
7
  end
8
+
9
+ <%- end -%>
10
+ <%- if config[:rails] -%>
11
+ ENV["RAILS_ENV"] ||= "test"
12
+ require File.expand_path "../dummy/config/environment", __FILE__
13
+ ENV["RAILS_ROOT"] ||= File.dirname(__FILE__) + "/dummy"
14
+
7
15
  <%- end -%>
8
16
  require "<%= config[:gem_name] %>"
9
17
  <%- if config[:pry] -%>
@@ -1,7 +1,7 @@
1
1
  if ENV["SUPPRESS_STDERR"] == "enabled"
2
2
  RSpec.configure do |config|
3
3
  stderr_original = $stderr
4
- config.before(:suite) { $stderr = File.new "/dev/null", 'w' }
4
+ config.before(:suite) { $stderr = File.new "/dev/null", "w" }
5
5
  config.after(:suite) { $stderr = stderr_original }
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  if ENV["SUPPRESS_STDOUT"] == "enabled"
2
2
  RSpec.configure do |config|
3
3
  stdout_original = $stdout
4
- config.before(:suite) { $stdout = File.new "/dev/null", 'w' }
4
+ config.before(:suite) { $stdout = File.new "/dev/null", "w" }
5
5
  config.after(:suite) { $stdout = stdout_original }
6
6
  end
7
7
  end
@@ -2,6 +2,7 @@ require "rspec/core/shared_context"
2
2
 
3
3
  module RSpec
4
4
  module Kit
5
+ # Adds temp directory support to specs enabled with the :temp_dir metadata key.
5
6
  module TempDirContext
6
7
  extend RSpec::Core::SharedContext
7
8
  let(:temp_dir) { File.expand_path "../../../../tmp/rspec", __FILE__ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemsmith
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.3.0
4
+ version: 5.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -30,7 +30,7 @@ cert_chain:
30
30
  aSif+qBc6oHD7EQWPF5cZkzkIURuwNwPBngZGxIKaMAgRhjGFXzUMAaq++r59cS9
31
31
  xTfQ4k6fglKEgpnLAXiKdo2c8Ym+X4rIKFfedQ==
32
32
  -----END CERTIFICATE-----
33
- date: 2015-08-03 00:00:00.000000000 Z
33
+ date: 2015-08-31 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: thor
@@ -242,6 +242,20 @@ dependencies:
242
242
  - - ">="
243
243
  - !ruby/object:Gem::Version
244
244
  version: '0'
245
+ - !ruby/object:Gem::Dependency
246
+ name: rubocop
247
+ requirement: !ruby/object:Gem::Requirement
248
+ requirements:
249
+ - - ">="
250
+ - !ruby/object:Gem::Version
251
+ version: '0'
252
+ type: :development
253
+ prerelease: false
254
+ version_requirements: !ruby/object:Gem::Requirement
255
+ requirements:
256
+ - - ">="
257
+ - !ruby/object:Gem::Version
258
+ version: '0'
245
259
  - !ruby/object:Gem::Dependency
246
260
  name: codeclimate-test-reporter
247
261
  requirement: !ruby/object:Gem::Requirement
@@ -256,8 +270,7 @@ dependencies:
256
270
  - - ">="
257
271
  - !ruby/object:Gem::Version
258
272
  version: '0'
259
- description: 'Ruby gem skeleton generation for the professional gemsmith. Includes
260
- custom settings, binary, Ruby on Rails, and RSpec support. '
273
+ description: Ruby gem skeleton generation for the professional gemsmith.
261
274
  email:
262
275
  - brooke@alchemists.io
263
276
  executables:
@@ -276,19 +289,28 @@ files:
276
289
  - lib/gemsmith/cli_options.rb
277
290
  - lib/gemsmith/identity.rb
278
291
  - lib/gemsmith/kit.rb
292
+ - lib/gemsmith/rake/build.rb
293
+ - lib/gemsmith/rake/release.rb
294
+ - lib/gemsmith/rake/setup.rb
295
+ - lib/gemsmith/rake/tasks.rb
279
296
  - lib/gemsmith/skeletons/base_skeleton.rb
280
297
  - lib/gemsmith/skeletons/bundler_skeleton.rb
281
298
  - lib/gemsmith/skeletons/cli_skeleton.rb
282
- - lib/gemsmith/skeletons/default_skeleton.rb
283
299
  - lib/gemsmith/skeletons/documentation_skeleton.rb
300
+ - lib/gemsmith/skeletons/gem_skeleton.rb
284
301
  - lib/gemsmith/skeletons/git_skeleton.rb
285
302
  - lib/gemsmith/skeletons/guard_skeleton.rb
286
303
  - lib/gemsmith/skeletons/rails_skeleton.rb
304
+ - lib/gemsmith/skeletons/rake_skeleton.rb
287
305
  - lib/gemsmith/skeletons/rspec_skeleton.rb
306
+ - lib/gemsmith/skeletons/rubocop_skeleton.rb
307
+ - lib/gemsmith/skeletons/ruby_skeleton.rb
288
308
  - lib/gemsmith/skeletons/travis_skeleton.rb
309
+ - lib/gemsmith/tasks/rspec.rake
310
+ - lib/gemsmith/tasks/rubocop.rake
289
311
  - lib/gemsmith/templates/%gem_name%/%gem_name%.gemspec.tt
290
- - lib/gemsmith/templates/%gem_name%/.coveralls.yml.tt
291
312
  - lib/gemsmith/templates/%gem_name%/.gitignore.tt
313
+ - lib/gemsmith/templates/%gem_name%/.rubocop.yml.tt
292
314
  - lib/gemsmith/templates/%gem_name%/.ruby-version.tt
293
315
  - lib/gemsmith/templates/%gem_name%/.travis.yml.tt
294
316
  - lib/gemsmith/templates/%gem_name%/CHANGELOG.md.tt
@@ -303,7 +325,10 @@ files:
303
325
  - lib/gemsmith/templates/%gem_name%/gemfiles/rails-4.1.x.gemfile.tt
304
326
  - lib/gemsmith/templates/%gem_name%/lib/%gem_name%.rb.tt
305
327
  - lib/gemsmith/templates/%gem_name%/lib/%gem_name%/cli.rb.tt
328
+ - lib/gemsmith/templates/%gem_name%/lib/%gem_name%/engine.rb.tt
306
329
  - lib/gemsmith/templates/%gem_name%/lib/%gem_name%/identity.rb.tt
330
+ - lib/gemsmith/templates/%gem_name%/lib/%gem_name%/tasks/rspec.rake.tt
331
+ - lib/gemsmith/templates/%gem_name%/lib/%gem_name%/tasks/rubocop.rake.tt
307
332
  - lib/gemsmith/templates/%gem_name%/lib/generators/%gem_name%/install/USAGE.tt
308
333
  - lib/gemsmith/templates/%gem_name%/lib/generators/%gem_name%/install/install_generator.rb.tt
309
334
  - lib/gemsmith/templates/%gem_name%/lib/generators/%gem_name%/upgrade/USAGE.tt
metadata.gz.sig CHANGED
Binary file
@@ -1,20 +0,0 @@
1
- module Gemsmith
2
- module Skeletons
3
- class DefaultSkeleton < BaseSkeleton
4
- def create_default_files
5
- template "%gem_name%/Rakefile.tt", template_options
6
- template "%gem_name%/%gem_name%.gemspec.tt", template_options
7
- template "#{lib_root}/%gem_name%.rb.tt", template_options
8
- template "#{lib_root}/%gem_name%/identity.rb.tt", template_options
9
- end
10
-
11
- def create_ruby_files
12
- template "%gem_name%/.ruby-version.tt", template_options
13
- end
14
-
15
- def create_git_files
16
- template "%gem_name%/.gitignore.tt", template_options
17
- end
18
- end
19
- end
20
- end
@@ -1,3 +0,0 @@
1
- <%- if config[:travis] -%>
2
- service_name: travis-ci
3
- <%- end -%>