gemsmith 7.7.0 → 8.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 +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
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Gemsmith
|
|
4
|
+
module Generators
|
|
5
|
+
# Generates Guard support.
|
|
6
|
+
class Guard < Base
|
|
7
|
+
def run
|
|
8
|
+
return unless configuration.dig(:generate, :guard)
|
|
9
|
+
cli.template "%gem_name%/Guardfile.tt", configuration
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "pragmater"
|
|
4
|
+
require "pathname"
|
|
5
|
+
|
|
6
|
+
module Gemsmith
|
|
7
|
+
module Generators
|
|
8
|
+
# Formats pragma comments in source files.
|
|
9
|
+
class Pragma < Base
|
|
10
|
+
def self.comments
|
|
11
|
+
["# frozen_string_literal: true"]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# rubocop:disable Metrics/MethodLength
|
|
15
|
+
def whitelist
|
|
16
|
+
%W[
|
|
17
|
+
Gemfile
|
|
18
|
+
Guardfile
|
|
19
|
+
Rakefile
|
|
20
|
+
config.ru
|
|
21
|
+
bin/#{configuration.dig :gem, :name}
|
|
22
|
+
bin/rails
|
|
23
|
+
.gemspec
|
|
24
|
+
.rake
|
|
25
|
+
.rb
|
|
26
|
+
]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def run
|
|
30
|
+
whitelisted_files.each { |file| Pragmater::Writer.new(file, self.class.comments).add }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def whitelisted_files
|
|
36
|
+
Pathname.glob(%(#{cli.destination_root}/**/*{#{whitelist.join ","}})).select(&:file?)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Gemsmith
|
|
4
|
+
module Generators
|
|
5
|
+
# Generates Ruby on Rails support.
|
|
6
|
+
class Rails < Base
|
|
7
|
+
def rails?
|
|
8
|
+
cli.run "command -v rails > /dev/null"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def install_rails
|
|
12
|
+
return if rails?
|
|
13
|
+
return unless cli.yes?("Ruby on Rails is not installed. Would you like to install it (y/n)?")
|
|
14
|
+
cli.run "gem install rails"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def create_engine
|
|
18
|
+
cli.template "#{lib_root}/%gem_path%/engine.rb.tt", configuration
|
|
19
|
+
cli.run "rails plugin new --skip #{configuration.dig :gem, :name} #{engine_options}"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create_generator_files
|
|
23
|
+
cli.empty_directory "#{generator_root}/templates"
|
|
24
|
+
cli.template "#{generator_root}/install/install_generator.rb.tt", configuration
|
|
25
|
+
cli.template "#{generator_root}/install/USAGE.tt", configuration
|
|
26
|
+
cli.template "#{generator_root}/upgrade/upgrade_generator.rb.tt", configuration
|
|
27
|
+
cli.template "#{generator_root}/upgrade/USAGE.tt", configuration
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def create_travis_gemfiles
|
|
31
|
+
return unless configuration.dig(:generate, :travis)
|
|
32
|
+
cli.template "%gem_name%/gemfiles/rails-%rails_version%.x.gemfile.tt", configuration
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def add_comments
|
|
36
|
+
file = "%gem_name%/app/controllers/%gem_path%/application_controller.rb"
|
|
37
|
+
comment = "#{indentation}# The application controller.\n"
|
|
38
|
+
cli.insert_into_file file, comment, before: /.+class.+/
|
|
39
|
+
|
|
40
|
+
file = "%gem_name%/app/mailers/%gem_path%/application_mailer.rb"
|
|
41
|
+
comment = "#{indentation}# The application mailer.\n"
|
|
42
|
+
cli.insert_into_file file, comment, before: /.+class.+/
|
|
43
|
+
|
|
44
|
+
file = "%gem_name%/app/models/%gem_path%/application_record.rb"
|
|
45
|
+
comment = "#{indentation}# The application record.\n"
|
|
46
|
+
cli.insert_into_file file, comment, before: /.+class.+/
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def remove_files
|
|
50
|
+
gem_name = configuration.dig :gem, :name
|
|
51
|
+
gem_path = configuration.dig :gem, :path
|
|
52
|
+
|
|
53
|
+
cli.remove_file "#{gem_name}/app/helpers/#{gem_path}/application_helper.rb", configuration
|
|
54
|
+
cli.remove_file "#{gem_name}/lib/#{gem_path}/version.rb", configuration
|
|
55
|
+
cli.remove_file "#{gem_name}/MIT-LICENSE", configuration
|
|
56
|
+
cli.remove_file "#{gem_name}/README.rdoc", configuration
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def run
|
|
60
|
+
return unless configuration.dig(:generate, :rails)
|
|
61
|
+
|
|
62
|
+
install_rails
|
|
63
|
+
create_engine
|
|
64
|
+
create_generator_files
|
|
65
|
+
create_travis_gemfiles
|
|
66
|
+
add_comments
|
|
67
|
+
remove_files
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
private
|
|
71
|
+
|
|
72
|
+
def engine_options
|
|
73
|
+
"--skip-bundle --skip-test --skip-keeps --skip-git --mountable --dummy-path=spec/dummy"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def generator_root
|
|
77
|
+
"#{lib_root}/generators/%gem_path%"
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def indentation
|
|
81
|
+
" " * (configuration.dig(:gem, :path).scan("/").size + 1)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Gemsmith
|
|
4
|
+
module Generators
|
|
5
|
+
# Generates Rake support.
|
|
6
|
+
class Rake < Base
|
|
7
|
+
def run
|
|
8
|
+
cli.template "%gem_name%/Rakefile.tt", configuration
|
|
9
|
+
configure_rakefile
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def rspec_task
|
|
15
|
+
"spec" if configuration.dig(:generate, :rspec)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def reek_task
|
|
19
|
+
"reek" if configuration.dig(:generate, :reek)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def rubocop_task
|
|
23
|
+
"rubocop" if configuration.dig(:generate, :rubocop)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def scss_lint_task
|
|
27
|
+
"scss_lint" if configuration.dig(:generate, :scss_lint)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def default_tasks
|
|
31
|
+
[rspec_task, reek_task, rubocop_task, scss_lint_task].compact
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def configure_rakefile
|
|
35
|
+
return if default_tasks.empty?
|
|
36
|
+
cli.append_to_file "%gem_name%/Rakefile", %(\ntask default: %w[#{default_tasks.join(" ")}]\n)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Gemsmith
|
|
4
|
+
module Generators
|
|
5
|
+
# Generates Reek support.
|
|
6
|
+
class Reek < Base
|
|
7
|
+
def run
|
|
8
|
+
return unless configuration.dig(:generate, :reek)
|
|
9
|
+
cli.template "%gem_name%/lib/tasks/reek.rake.tt", configuration
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Gemsmith
|
|
4
|
+
module Generators
|
|
5
|
+
# Generates RSpec support.
|
|
6
|
+
class Rspec < Base
|
|
7
|
+
def run
|
|
8
|
+
return unless configuration.dig(:generate, :rspec)
|
|
9
|
+
|
|
10
|
+
cli.template "%gem_name%/lib/tasks/rspec.rake.tt", configuration
|
|
11
|
+
cli.template "#{rspec_root}/spec_helper.rb.tt", configuration
|
|
12
|
+
cli.template("#{rspec_root}/rails_helper.rb.tt", configuration) if configuration.dig(:generate, :rails)
|
|
13
|
+
cli.template "#{rspec_root}/support/shared_contexts/temp_dir.rb.tt", configuration
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def rspec_root
|
|
19
|
+
"%gem_name%/spec"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Gemsmith
|
|
4
|
+
module Generators
|
|
5
|
+
# Generates Rubocop support.
|
|
6
|
+
class Rubocop < Base
|
|
7
|
+
def run
|
|
8
|
+
return unless configuration.dig(:generate, :rubocop)
|
|
9
|
+
|
|
10
|
+
cli.template "%gem_name%/.rubocop.yml.tt", configuration
|
|
11
|
+
cli.template "%gem_name%/lib/tasks/rubocop.rake.tt", configuration
|
|
12
|
+
cli.run "rubocop --auto-correct > /dev/null"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Gemsmith
|
|
4
|
-
module
|
|
5
|
-
#
|
|
6
|
-
class
|
|
7
|
-
def
|
|
8
|
-
cli.template "%gem_name%/.ruby-version.tt", configuration
|
|
4
|
+
module Generators
|
|
5
|
+
# Generates Ruby support.
|
|
6
|
+
class Ruby < Base
|
|
7
|
+
def run
|
|
8
|
+
cli.template "%gem_name%/.ruby-version.tt", configuration
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Gemsmith
|
|
4
|
+
module Generators
|
|
5
|
+
# Generates SCSS Lint support.
|
|
6
|
+
class SCSSLint < Base
|
|
7
|
+
def run
|
|
8
|
+
return unless configuration.dig(:generate, :scss_lint)
|
|
9
|
+
cli.template "%gem_name%/lib/tasks/scss_lint.rake.tt", configuration
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Gemsmith
|
|
4
|
+
module Generators
|
|
5
|
+
# Generates Travis CI support.
|
|
6
|
+
class Travis < Base
|
|
7
|
+
def run
|
|
8
|
+
return unless configuration.dig(:generate, :travis)
|
|
9
|
+
cli.template "%gem_name%/.travis.yml.tt", configuration
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
data/lib/gemsmith/git.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Gemsmith
|
|
4
|
+
# A thin wrapper to Git.
|
|
5
|
+
class Git
|
|
6
|
+
def self.config_value key
|
|
7
|
+
`git config #{key}`.chomp
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.github_user
|
|
11
|
+
config_value "github.user"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.github_url project
|
|
15
|
+
return "" if github_user.empty?
|
|
16
|
+
"https://github.com/#{github_user}/#{project}"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/gemsmith/identity.rb
CHANGED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "bundler/ui/shell"
|
|
4
|
+
require "fileutils"
|
|
5
|
+
require "tocer"
|
|
6
|
+
|
|
7
|
+
module Gemsmith
|
|
8
|
+
module Rake
|
|
9
|
+
# Provides gem build functionality. Meant to be wrapped in Rake tasks.
|
|
10
|
+
class Builder
|
|
11
|
+
def initialize tocer: Tocer::Writer, shell: Bundler::UI::Shell.new, kernel: Kernel
|
|
12
|
+
@tocer = tocer
|
|
13
|
+
@shell = shell
|
|
14
|
+
@kernel = kernel
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def doc
|
|
18
|
+
readme = File.join Dir.pwd, "README.md"
|
|
19
|
+
tocer.new(readme).write
|
|
20
|
+
shell.confirm "Updated gem documentation."
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def clean
|
|
24
|
+
FileUtils.rm_rf "pkg"
|
|
25
|
+
shell.confirm "Cleaned gem artifacts."
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def validate
|
|
29
|
+
return if `git status --porcelain`.empty?
|
|
30
|
+
shell.error "Build failed: Gem has uncommitted changes."
|
|
31
|
+
kernel.exit 1
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def build gem_spec
|
|
35
|
+
path = package_path gem_spec
|
|
36
|
+
|
|
37
|
+
if kernel.system("gem build #{gem_spec.name}.gemspec")
|
|
38
|
+
FileUtils.mkdir_p "pkg"
|
|
39
|
+
FileUtils.mv gem_spec.package_file_name, path
|
|
40
|
+
shell.confirm "Built: #{path}."
|
|
41
|
+
else
|
|
42
|
+
shell.error "Unable to build: #{path}."
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def install gem_spec
|
|
47
|
+
gem_name = "#{gem_spec.name} #{gem_spec.version_number}"
|
|
48
|
+
|
|
49
|
+
if kernel.system("gem install #{package_path gem_spec}")
|
|
50
|
+
shell.confirm "Installed: #{gem_name}."
|
|
51
|
+
else
|
|
52
|
+
shell.error "Unable to install: #{gem_name}."
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
|
|
58
|
+
attr_reader :tocer, :shell, :kernel
|
|
59
|
+
|
|
60
|
+
def package_path gem_spec
|
|
61
|
+
File.join "pkg", gem_spec.package_file_name
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -2,22 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
require "milestoner"
|
|
4
4
|
require "gemsmith/credentials"
|
|
5
|
+
require "gemsmith/git"
|
|
6
|
+
require "gemsmith/identity"
|
|
5
7
|
|
|
6
8
|
module Gemsmith
|
|
7
9
|
module Rake
|
|
8
10
|
# Provides gem release functionality. Meant to be wrapped in Rake tasks.
|
|
9
|
-
class
|
|
11
|
+
class Publisher
|
|
10
12
|
def self.gem_spec_path
|
|
11
13
|
String Dir["#{Dir.pwd}/*.gemspec"].first
|
|
12
14
|
end
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
# rubocop:disable Metrics/ParameterLists
|
|
17
|
+
def initialize gem_spec: Gemsmith::Gem::Specification.new(self.class.gem_spec_path),
|
|
18
|
+
gem_config: {},
|
|
15
19
|
credentials: Gemsmith::Credentials,
|
|
16
20
|
publisher: Milestoner::Publisher.new,
|
|
17
21
|
shell: Bundler::UI::Shell.new,
|
|
18
22
|
kernel: Kernel
|
|
19
23
|
|
|
20
24
|
@gem_spec = gem_spec
|
|
25
|
+
@gem_config = gem_config
|
|
21
26
|
@credentials = credentials
|
|
22
27
|
@publisher = publisher
|
|
23
28
|
@shell = shell
|
|
@@ -33,16 +38,20 @@ module Gemsmith
|
|
|
33
38
|
process_push status
|
|
34
39
|
end
|
|
35
40
|
|
|
36
|
-
def publish
|
|
37
|
-
publisher.publish gem_spec.version_number, sign:
|
|
41
|
+
def publish
|
|
42
|
+
publisher.publish gem_spec.version_number, sign: signed?
|
|
38
43
|
push
|
|
39
44
|
rescue Milestoner::Errors::Base => error
|
|
40
45
|
shell.error error.message
|
|
41
46
|
end
|
|
42
47
|
|
|
48
|
+
def signed?
|
|
49
|
+
gem_config.dig :publish, :sign
|
|
50
|
+
end
|
|
51
|
+
|
|
43
52
|
private
|
|
44
53
|
|
|
45
|
-
attr_reader :gem_spec, :credentials, :publisher, :shell, :kernel
|
|
54
|
+
attr_reader :gem_spec, :gem_config, :credentials, :publisher, :shell, :kernel
|
|
46
55
|
|
|
47
56
|
def translate_key key
|
|
48
57
|
key == credentials.default_key ? :rubygems : key
|
data/lib/gemsmith/rake/tasks.rb
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
4
|
-
require "gemsmith/aids/gem_spec"
|
|
3
|
+
require "gemsmith/gem/specification"
|
|
5
4
|
require "gemsmith/errors/base"
|
|
6
5
|
require "gemsmith/errors/specification"
|
|
7
|
-
require "gemsmith/rake/
|
|
8
|
-
require "gemsmith/rake/
|
|
6
|
+
require "gemsmith/rake/builder"
|
|
7
|
+
require "gemsmith/rake/publisher"
|
|
9
8
|
|
|
10
9
|
module Gemsmith
|
|
11
10
|
module Rake
|
|
@@ -13,48 +12,61 @@ module Gemsmith
|
|
|
13
12
|
class Tasks
|
|
14
13
|
include ::Rake::DSL
|
|
15
14
|
|
|
15
|
+
def self.default_gem_spec
|
|
16
|
+
Dir.glob("#{Dir.pwd}/*.gemspec").first
|
|
17
|
+
end
|
|
18
|
+
|
|
16
19
|
def self.setup
|
|
17
20
|
new.install
|
|
18
21
|
end
|
|
19
22
|
|
|
20
|
-
def initialize
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
@
|
|
23
|
+
def initialize gem_spec: Gem::Specification.new(self.class.default_gem_spec),
|
|
24
|
+
builder: Rake::Builder.new,
|
|
25
|
+
publisher: Rake::Publisher.new
|
|
26
|
+
@gem_spec = gem_spec
|
|
27
|
+
@builder = builder
|
|
28
|
+
@publisher = publisher
|
|
24
29
|
end
|
|
25
30
|
|
|
26
31
|
def install
|
|
27
|
-
::Rake::Task[:build].enhance [:clean, :doc, :validate]
|
|
28
|
-
::Rake::Task[:release].clear
|
|
29
|
-
|
|
30
32
|
desc "Update README (table of contents)"
|
|
31
33
|
task :doc do
|
|
32
|
-
|
|
34
|
+
builder.doc
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
desc "Clean gem artifacts"
|
|
36
38
|
task :clean do
|
|
37
|
-
|
|
39
|
+
builder.clean
|
|
38
40
|
end
|
|
39
41
|
|
|
40
42
|
task :validate do
|
|
41
|
-
|
|
43
|
+
builder.validate
|
|
42
44
|
end
|
|
43
45
|
|
|
44
|
-
desc "Build
|
|
45
|
-
task
|
|
46
|
-
|
|
46
|
+
desc "Build #{gem_spec.package_file_name} package"
|
|
47
|
+
task build: [:clean, :doc, :validate] do
|
|
48
|
+
builder.build gem_spec
|
|
47
49
|
end
|
|
48
50
|
|
|
49
|
-
desc "
|
|
51
|
+
desc "Install #{gem_spec.package_file_name} package"
|
|
52
|
+
task install: :build do
|
|
53
|
+
builder.install gem_spec
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
desc "Build, tag as #{gem_spec.version_label} (#{signed_label}), " \
|
|
57
|
+
"and push #{gem_spec.package_file_name} to RubyGems"
|
|
50
58
|
task publish: :build do
|
|
51
|
-
|
|
59
|
+
publisher.publish
|
|
52
60
|
end
|
|
53
61
|
end
|
|
54
62
|
|
|
55
63
|
private
|
|
56
64
|
|
|
57
|
-
attr_reader :gem_spec, :
|
|
65
|
+
attr_reader :gem_spec, :builder, :publisher
|
|
66
|
+
|
|
67
|
+
def signed_label
|
|
68
|
+
publisher.signed? ? "signed" : "unsigned"
|
|
69
|
+
end
|
|
58
70
|
end
|
|
59
71
|
end
|
|
60
72
|
end
|