gemsmith 5.6.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -0,0 +1,189 @@
|
|
1
|
+
module Gemsmith
|
2
|
+
# Default configuration for gem with support for custom settings.
|
3
|
+
class Configuration
|
4
|
+
attr_reader :gem_name, :gem_class, :file_path
|
5
|
+
attr_writer :gem_platform, :gem_home_url, :gem_license, :gem_private_key, :gem_public_key, :author_name,
|
6
|
+
:author_email, :author_url, :organization_name, :organization_email, :organization_url,
|
7
|
+
:ruby_version, :rails_version, :create_cli, :create_rails, :create_security, :create_pry,
|
8
|
+
:create_guard, :create_rspec, :create_rubocop, :create_code_climate, :create_gemnasium,
|
9
|
+
:create_travis, :create_patreon, :github_user, :year
|
10
|
+
|
11
|
+
def initialize gem_name: "unknown",
|
12
|
+
gem_class: "Unknown",
|
13
|
+
git: Aids::Git,
|
14
|
+
file_path: File.join(ENV["HOME"], Identity.file_name)
|
15
|
+
|
16
|
+
@gem_name = gem_name
|
17
|
+
@gem_class = gem_class
|
18
|
+
@file_path = file_path
|
19
|
+
@git = git
|
20
|
+
@settings = load_settings
|
21
|
+
end
|
22
|
+
|
23
|
+
def gem_platform
|
24
|
+
@gem_platform || settings_group(:gem).fetch(:platform, "Gem::Platform::RUBY")
|
25
|
+
end
|
26
|
+
|
27
|
+
def gem_home_url
|
28
|
+
@gem_home_url || settings_group(:gem).fetch(:home_url, github_gem_url)
|
29
|
+
end
|
30
|
+
|
31
|
+
def gem_license
|
32
|
+
@gem_license || settings_group(:gem).fetch(:license, "MIT")
|
33
|
+
end
|
34
|
+
|
35
|
+
def gem_private_key
|
36
|
+
@gem_private_key || settings_group(:gem).fetch(:private_key, "~/.ssh/gem-private.pem")
|
37
|
+
end
|
38
|
+
|
39
|
+
def gem_public_key
|
40
|
+
@gem_public_key || settings_group(:gem).fetch(:public_key, "~/.ssh/gem-public.pem")
|
41
|
+
end
|
42
|
+
|
43
|
+
def author_name
|
44
|
+
@author_name || settings_group(:author).fetch(:name, git.config_value("user.name"))
|
45
|
+
end
|
46
|
+
|
47
|
+
def author_email
|
48
|
+
@author_email || settings_group(:author).fetch(:email, git.config_value("user.email"))
|
49
|
+
end
|
50
|
+
|
51
|
+
def author_url
|
52
|
+
@author_url || settings_group(:author).fetch(:url, "")
|
53
|
+
end
|
54
|
+
|
55
|
+
def organization_name
|
56
|
+
@organization_name || settings_group(:organization).fetch(:name, "")
|
57
|
+
end
|
58
|
+
|
59
|
+
def organization_url
|
60
|
+
@organization_url || settings_group(:organization).fetch(:url, "")
|
61
|
+
end
|
62
|
+
|
63
|
+
def ruby_version
|
64
|
+
@ruby_version || settings_group(:versions).fetch(:ruby, RUBY_VERSION)
|
65
|
+
end
|
66
|
+
|
67
|
+
def rails_version
|
68
|
+
@rails_version || settings_group(:versions).fetch(:rails, "4.2")
|
69
|
+
end
|
70
|
+
|
71
|
+
def create_cli?
|
72
|
+
parse_boolean @create_cli, :create, :cli, false
|
73
|
+
end
|
74
|
+
|
75
|
+
def create_rails?
|
76
|
+
parse_boolean @create_rails, :create, :rails, false
|
77
|
+
end
|
78
|
+
|
79
|
+
def create_security?
|
80
|
+
parse_boolean @create_security, :create, :security, true
|
81
|
+
end
|
82
|
+
|
83
|
+
def create_pry?
|
84
|
+
parse_boolean @create_pry, :create, :pry, true
|
85
|
+
end
|
86
|
+
|
87
|
+
def create_guard?
|
88
|
+
parse_boolean @create_guard, :create, :guard, true
|
89
|
+
end
|
90
|
+
|
91
|
+
def create_rspec?
|
92
|
+
parse_boolean @create_rspec, :create, :rspec, true
|
93
|
+
end
|
94
|
+
|
95
|
+
def create_rubocop?
|
96
|
+
parse_boolean @create_rubocop, :create, :rubocop, true
|
97
|
+
end
|
98
|
+
|
99
|
+
def create_code_climate?
|
100
|
+
parse_boolean @create_code_climate, :create, :code_climate, true
|
101
|
+
end
|
102
|
+
|
103
|
+
def create_gemnasium?
|
104
|
+
parse_boolean @create_gemnasium, :create, :gemnasium, true
|
105
|
+
end
|
106
|
+
|
107
|
+
def create_travis?
|
108
|
+
parse_boolean @create_travis, :create, :travis, true
|
109
|
+
end
|
110
|
+
|
111
|
+
def create_patreon?
|
112
|
+
parse_boolean @create_patreon, :create, :patreon, true
|
113
|
+
end
|
114
|
+
|
115
|
+
def github_user
|
116
|
+
@github_user || settings.fetch(:github_user, git.config_value("github.user"))
|
117
|
+
end
|
118
|
+
|
119
|
+
def year
|
120
|
+
@year || settings.fetch(:year, Time.now.year)
|
121
|
+
end
|
122
|
+
|
123
|
+
def to_h
|
124
|
+
{
|
125
|
+
year: year,
|
126
|
+
github_user: github_user,
|
127
|
+
gem: {
|
128
|
+
name: gem_name,
|
129
|
+
class: gem_class,
|
130
|
+
platform: gem_platform,
|
131
|
+
home_url: gem_home_url,
|
132
|
+
license: gem_license,
|
133
|
+
private_key: gem_private_key,
|
134
|
+
public_key: gem_public_key
|
135
|
+
},
|
136
|
+
author: {
|
137
|
+
name: author_name,
|
138
|
+
email: author_email,
|
139
|
+
url: author_url
|
140
|
+
},
|
141
|
+
organization: {
|
142
|
+
name: organization_name,
|
143
|
+
url: organization_url
|
144
|
+
},
|
145
|
+
versions: {
|
146
|
+
ruby: ruby_version,
|
147
|
+
rails: rails_version
|
148
|
+
},
|
149
|
+
create: {
|
150
|
+
cli: create_cli?,
|
151
|
+
rails: create_rails?,
|
152
|
+
security: create_security?,
|
153
|
+
pry: create_pry?,
|
154
|
+
guard: create_guard?,
|
155
|
+
rspec: create_rspec?,
|
156
|
+
rubocop: create_rubocop?,
|
157
|
+
code_climate: create_code_climate?,
|
158
|
+
gemnasium: create_gemnasium?,
|
159
|
+
travis: create_travis?,
|
160
|
+
patreon: create_patreon?
|
161
|
+
}
|
162
|
+
}
|
163
|
+
end
|
164
|
+
|
165
|
+
private
|
166
|
+
|
167
|
+
attr_reader :gem_parser, :git, :settings
|
168
|
+
|
169
|
+
def load_settings
|
170
|
+
return {} unless File.exist?(file_path)
|
171
|
+
yaml = YAML.load_file file_path
|
172
|
+
yaml.is_a?(Hash) ? yaml : {}
|
173
|
+
end
|
174
|
+
|
175
|
+
def settings_group key
|
176
|
+
settings.fetch key, {}
|
177
|
+
end
|
178
|
+
|
179
|
+
def parse_boolean variable, group_key, item_key, default_value
|
180
|
+
return variable if [true, false].include?(variable)
|
181
|
+
settings_group(group_key).fetch item_key, default_value
|
182
|
+
end
|
183
|
+
|
184
|
+
def github_gem_url
|
185
|
+
return "" if github_user.nil?
|
186
|
+
"https://github.com/#{github_user}/#{gem_name}"
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
data/lib/gemsmith/identity.rb
CHANGED
data/lib/gemsmith/rake/build.rb
CHANGED
@@ -1,38 +1,36 @@
|
|
1
1
|
require "bundler/ui/shell"
|
2
|
+
require "tocer"
|
2
3
|
|
3
4
|
module Gemsmith
|
4
5
|
module Rake
|
5
6
|
# Provides gem build functionality. Meant to be wrapped in Rake tasks.
|
6
7
|
class Build
|
7
|
-
def initialize shell: Bundler::UI::Shell
|
8
|
-
@
|
8
|
+
def initialize tocer: Tocer::Writer, shell: Bundler::UI::Shell, kernel: Kernel
|
9
|
+
@tocer = tocer
|
10
|
+
@shell = shell.new
|
9
11
|
@kernel = kernel
|
10
12
|
end
|
11
13
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
shell.error error_message
|
17
|
-
kernel.exit 1
|
18
|
-
end
|
14
|
+
def doc
|
15
|
+
readme = File.join Dir.pwd, "README.md"
|
16
|
+
tocer.new(readme).write
|
17
|
+
shell.confirm "Updated gem documentation."
|
19
18
|
end
|
20
19
|
|
21
|
-
def clean
|
20
|
+
def clean
|
22
21
|
FileUtils.rm_rf "pkg"
|
23
|
-
shell.
|
22
|
+
shell.confirm "Cleaned gem artifacts."
|
24
23
|
end
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
def validate
|
26
|
+
return if `git status --porcelain`.empty?
|
27
|
+
shell.error "Build failed: Gem has uncommitted changes."
|
28
|
+
kernel.exit 1
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
url = "https://github.com/thlorenz/doctoc"
|
32
|
-
command = "npm install --global doctoc"
|
31
|
+
private
|
33
32
|
|
34
|
-
|
35
|
-
end
|
33
|
+
attr_reader :tocer, :shell, :kernel
|
36
34
|
end
|
37
35
|
end
|
38
36
|
end
|
data/lib/gemsmith/rake/tasks.rb
CHANGED
@@ -16,23 +16,25 @@ module Gemsmith
|
|
16
16
|
build = Gemsmith::Rake::Build.new
|
17
17
|
release = Gemsmith::Rake::Release.new
|
18
18
|
|
19
|
-
::Rake::Task[:build].enhance [:clean,
|
19
|
+
::Rake::Task[:build].enhance [:clean, :doc, :validate]
|
20
20
|
::Rake::Task[:release].enhance { ::Rake::Task[:clean].invoke }
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
build.table_of_contents
|
26
|
-
end
|
22
|
+
desc "Update README (table of contents)"
|
23
|
+
task :doc do
|
24
|
+
build.doc
|
27
25
|
end
|
28
26
|
|
29
|
-
desc "Clean gem artifacts
|
27
|
+
desc "Clean gem artifacts"
|
30
28
|
task :clean do
|
31
|
-
build.clean
|
29
|
+
build.clean
|
30
|
+
end
|
31
|
+
|
32
|
+
task :validate do
|
33
|
+
build.validate
|
32
34
|
end
|
33
35
|
|
34
36
|
desc "Build, tag #{release.version_label} (signed), and push #{release.gem_file_name} to RubyGems"
|
35
|
-
task publish: [:
|
37
|
+
task publish: [:build, "release:guard_clean"] do
|
36
38
|
release.publish
|
37
39
|
::Rake::Task["release:rubygem_push"].invoke
|
38
40
|
end
|
@@ -2,25 +2,22 @@ module Gemsmith
|
|
2
2
|
module Skeletons
|
3
3
|
# Abstract class from which all skeletons inherit from.
|
4
4
|
class BaseSkeleton
|
5
|
-
def initialize cli
|
5
|
+
def initialize cli, configuration: Configuration.new
|
6
6
|
@cli = cli
|
7
|
+
@configuration = configuration
|
7
8
|
end
|
8
9
|
|
9
|
-
def self.create cli
|
10
|
-
new(cli).create
|
11
|
-
end
|
12
|
-
|
13
|
-
def enabled?
|
14
|
-
true
|
10
|
+
def self.create cli, configuration: Configuration.new
|
11
|
+
new(cli, configuration: configuration).create
|
15
12
|
end
|
16
13
|
|
17
14
|
def create
|
18
15
|
fail NotImplementedError, "The method, #create, is not implemented yet."
|
19
16
|
end
|
20
17
|
|
21
|
-
|
18
|
+
protected
|
22
19
|
|
23
|
-
attr_reader :cli
|
20
|
+
attr_reader :cli, :configuration
|
24
21
|
|
25
22
|
def lib_root
|
26
23
|
"%gem_name%/lib"
|
@@ -3,7 +3,7 @@ module Gemsmith
|
|
3
3
|
# Configures Bundler support.
|
4
4
|
class BundlerSkeleton < BaseSkeleton
|
5
5
|
def create
|
6
|
-
Dir.chdir(File.join(cli.destination_root,
|
6
|
+
Dir.chdir(File.join(cli.destination_root, configuration.gem_name)) do
|
7
7
|
cli.info "Installing gem dependencies..."
|
8
8
|
`bundle install`
|
9
9
|
end
|
@@ -2,15 +2,11 @@ module Gemsmith
|
|
2
2
|
module Skeletons
|
3
3
|
# Configures Command Line Interface (CLI) support.
|
4
4
|
class CLISkeleton < BaseSkeleton
|
5
|
-
def enabled?
|
6
|
-
cli.template_options.key?(:bin) && cli.template_options[:bin]
|
7
|
-
end
|
8
|
-
|
9
5
|
def create
|
10
|
-
return unless
|
6
|
+
return unless configuration.create_cli?
|
11
7
|
|
12
|
-
cli.template "%gem_name%/bin/%gem_name%.tt",
|
13
|
-
cli.template "%gem_name%/lib/%gem_name%/cli.rb.tt",
|
8
|
+
cli.template "%gem_name%/bin/%gem_name%.tt", configuration.to_h
|
9
|
+
cli.template "%gem_name%/lib/%gem_name%/cli.rb.tt", configuration.to_h
|
14
10
|
end
|
15
11
|
end
|
16
12
|
end
|
@@ -1,13 +1,25 @@
|
|
1
|
+
require "tocer"
|
2
|
+
|
1
3
|
module Gemsmith
|
2
4
|
module Skeletons
|
3
5
|
# Configures documentation support.
|
4
6
|
class DocumentationSkeleton < BaseSkeleton
|
7
|
+
def create_files
|
8
|
+
cli.template "%gem_name%/README.md.tt", configuration.to_h
|
9
|
+
cli.template "%gem_name%/CONTRIBUTING.md.tt", configuration.to_h
|
10
|
+
cli.template "%gem_name%/CODE_OF_CONDUCT.md.tt", configuration.to_h
|
11
|
+
cli.template "%gem_name%/LICENSE.md.tt", configuration.to_h
|
12
|
+
cli.template "%gem_name%/CHANGELOG.md.tt", configuration.to_h
|
13
|
+
end
|
14
|
+
|
15
|
+
def update_readme
|
16
|
+
file = File.join cli.destination_root, configuration.gem_name, "README.md"
|
17
|
+
Tocer::Writer.new(file).write
|
18
|
+
end
|
19
|
+
|
5
20
|
def create
|
6
|
-
|
7
|
-
|
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
|
21
|
+
create_files
|
22
|
+
update_readme
|
11
23
|
end
|
12
24
|
end
|
13
25
|
end
|
@@ -3,10 +3,10 @@ module Gemsmith
|
|
3
3
|
# Configures default gem support.
|
4
4
|
class GemSkeleton < BaseSkeleton
|
5
5
|
def create
|
6
|
-
cli.template "%gem_name%/Gemfile.tt",
|
7
|
-
cli.template "%gem_name%/%gem_name%.gemspec.tt",
|
8
|
-
cli.template "#{lib_root}/%gem_name%.rb.tt",
|
9
|
-
cli.template "#{lib_root}/%gem_name%/identity.rb.tt",
|
6
|
+
cli.template "%gem_name%/Gemfile.tt", configuration.to_h
|
7
|
+
cli.template "%gem_name%/%gem_name%.gemspec.tt", configuration.to_h
|
8
|
+
cli.template "#{lib_root}/%gem_name%.rb.tt", configuration.to_h
|
9
|
+
cli.template "#{lib_root}/%gem_name%/identity.rb.tt", configuration.to_h
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -3,11 +3,11 @@ module Gemsmith
|
|
3
3
|
# Configures Git support.
|
4
4
|
class GitSkeleton < BaseSkeleton
|
5
5
|
def create_ignore_file
|
6
|
-
cli.template "%gem_name%/.gitignore.tt",
|
6
|
+
cli.template "%gem_name%/.gitignore.tt", configuration.to_h
|
7
7
|
end
|
8
8
|
|
9
9
|
def create_repository
|
10
|
-
Dir.chdir(File.join(cli.destination_root,
|
10
|
+
Dir.chdir(File.join(cli.destination_root, configuration.gem_name)) do
|
11
11
|
`git init`
|
12
12
|
`git add .`
|
13
13
|
`git commit --all --no-verify --message "Added Gemsmith skeleton."`
|
@@ -2,13 +2,9 @@ module Gemsmith
|
|
2
2
|
module Skeletons
|
3
3
|
# Configures Guard support.
|
4
4
|
class GuardSkeleton < BaseSkeleton
|
5
|
-
def enabled?
|
6
|
-
cli.template_options.key?(:guard) && cli.template_options[:guard]
|
7
|
-
end
|
8
|
-
|
9
5
|
def create
|
10
|
-
return unless
|
11
|
-
cli.template "%gem_name%/Guardfile.tt",
|
6
|
+
return unless configuration.create_guard?
|
7
|
+
cli.template "%gem_name%/Guardfile.tt", configuration.to_h
|
12
8
|
end
|
13
9
|
end
|
14
10
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Gemsmith
|
2
|
+
module Skeletons
|
3
|
+
# Configures Pry debugging support.
|
4
|
+
class PrySkeleton < BaseSkeleton
|
5
|
+
def create
|
6
|
+
return unless configuration.create_pry?
|
7
|
+
cli.template "%gem_name%/spec/support/extensions/pry.rb.tt", configuration.to_h
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|