gemsmith 7.7.0 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) 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 +114 -118
  5. data/bin/gemsmith +2 -1
  6. data/lib/gemsmith/cli.rb +195 -99
  7. data/lib/gemsmith/cli_helpers.rb +8 -19
  8. data/lib/gemsmith/credentials.rb +2 -2
  9. data/lib/gemsmith/gem/inspector.rb +30 -0
  10. data/lib/gemsmith/gem/module_formatter.rb +51 -0
  11. data/lib/gemsmith/gem/requirement.rb +2 -0
  12. data/lib/gemsmith/{aids/gem_spec.rb → gem/specification.rb} +19 -26
  13. data/lib/gemsmith/generators/base.rb +33 -0
  14. data/lib/gemsmith/generators/bundler.rb +15 -0
  15. data/lib/gemsmith/generators/cli.rb +17 -0
  16. data/lib/gemsmith/generators/code_climate.rb +14 -0
  17. data/lib/gemsmith/generators/documentation.rb +28 -0
  18. data/lib/gemsmith/generators/gem.rb +17 -0
  19. data/lib/gemsmith/{skeletons/git_skeleton.rb → generators/git.rb} +13 -7
  20. data/lib/gemsmith/generators/git_hub.rb +14 -0
  21. data/lib/gemsmith/generators/guard.rb +13 -0
  22. data/lib/gemsmith/generators/pragma.rb +40 -0
  23. data/lib/gemsmith/generators/rails.rb +85 -0
  24. data/lib/gemsmith/generators/rake.rb +40 -0
  25. data/lib/gemsmith/generators/reek.rb +13 -0
  26. data/lib/gemsmith/generators/rspec.rb +23 -0
  27. data/lib/gemsmith/generators/rubocop.rb +16 -0
  28. data/lib/gemsmith/{skeletons/ruby_skeleton.rb → generators/ruby.rb} +5 -5
  29. data/lib/gemsmith/generators/scss_lint.rb +13 -0
  30. data/lib/gemsmith/generators/travis.rb +13 -0
  31. data/lib/gemsmith/git.rb +19 -0
  32. data/lib/gemsmith/identity.rb +1 -1
  33. data/lib/gemsmith/rake/builder.rb +65 -0
  34. data/lib/gemsmith/rake/{release.rb → publisher.rb} +14 -5
  35. data/lib/gemsmith/rake/tasks.rb +32 -20
  36. data/lib/gemsmith/template_helper.rb +28 -0
  37. data/lib/gemsmith/templates/%gem_name%/%gem_name%.gemspec.tt +30 -28
  38. data/lib/gemsmith/templates/%gem_name%/.codeclimate.yml.tt +36 -0
  39. data/lib/gemsmith/templates/%gem_name%/.rubocop.yml.tt +9 -1
  40. data/lib/gemsmith/templates/%gem_name%/.travis.yml.tt +4 -1
  41. data/lib/gemsmith/templates/%gem_name%/{CHANGELOG.md.tt → CHANGES.md.tt} +0 -0
  42. data/lib/gemsmith/templates/%gem_name%/Guardfile.tt +1 -1
  43. data/lib/gemsmith/templates/%gem_name%/README.md.tt +20 -18
  44. data/lib/gemsmith/templates/%gem_name%/Rakefile.tt +6 -1
  45. data/lib/gemsmith/templates/%gem_name%/bin/%gem_name%.tt +4 -4
  46. data/lib/gemsmith/templates/%gem_name%/bin/setup.tt +1 -1
  47. data/lib/gemsmith/templates/%gem_name%/lib/%gem_path%.rb.tt +4 -0
  48. data/lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt +54 -0
  49. data/lib/gemsmith/templates/%gem_name%/lib/{%gem_name% → %gem_path%}/engine.rb.tt +2 -4
  50. data/lib/gemsmith/templates/%gem_name%/lib/{%gem_name% → %gem_path%}/identity.rb.tt +3 -5
  51. data/lib/gemsmith/templates/%gem_name%/lib/generators/{%gem_name% → %gem_path%}/install/USAGE.tt +0 -0
  52. data/lib/gemsmith/templates/%gem_name%/lib/generators/{%gem_name% → %gem_path%}/install/install_generator.rb.tt +2 -5
  53. data/lib/gemsmith/templates/%gem_name%/lib/generators/{%gem_name% → %gem_path%}/upgrade/USAGE.tt +0 -0
  54. data/lib/gemsmith/templates/%gem_name%/lib/generators/{%gem_name% → %gem_path%}/upgrade/upgrade_generator.rb.tt +2 -5
  55. data/lib/gemsmith/templates/%gem_name%/lib/tasks/reek.rake.tt +6 -0
  56. data/lib/gemsmith/templates/%gem_name%/lib/tasks/scss_lint.rake.tt +6 -0
  57. data/lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt +83 -0
  58. data/lib/gemsmith/templates/%gem_name%/spec/rails_helper.rb.tt +14 -0
  59. data/lib/gemsmith/templates/%gem_name%/spec/spec_helper.rb.tt +29 -16
  60. data/lib/gemsmith/templates/%gem_name%/spec/support/shared_contexts/temp_dir.rb.tt +9 -0
  61. data/lib/tasks/reek.rake +8 -0
  62. data/lib/tasks/rspec.rake +2 -0
  63. data/lib/tasks/rubocop.rake +2 -0
  64. metadata +138 -149
  65. metadata.gz.sig +0 -0
  66. data/lib/gemsmith/aids/git.rb +0 -12
  67. data/lib/gemsmith/aids/spec.rb +0 -46
  68. data/lib/gemsmith/configuration.rb +0 -200
  69. data/lib/gemsmith/rake/build.rb +0 -38
  70. data/lib/gemsmith/skeletons/base_skeleton.rb +0 -29
  71. data/lib/gemsmith/skeletons/bundler_skeleton.rb +0 -15
  72. data/lib/gemsmith/skeletons/cli_skeleton.rb +0 -16
  73. data/lib/gemsmith/skeletons/documentation_skeleton.rb +0 -28
  74. data/lib/gemsmith/skeletons/gem_skeleton.rb +0 -17
  75. data/lib/gemsmith/skeletons/git_hub_skeleton.rb +0 -14
  76. data/lib/gemsmith/skeletons/guard_skeleton.rb +0 -13
  77. data/lib/gemsmith/skeletons/pry_skeleton.rb +0 -13
  78. data/lib/gemsmith/skeletons/rails_skeleton.rb +0 -61
  79. data/lib/gemsmith/skeletons/rake_skeleton.rb +0 -37
  80. data/lib/gemsmith/skeletons/rspec_skeleton.rb +0 -26
  81. data/lib/gemsmith/skeletons/rubocop_skeleton.rb +0 -15
  82. data/lib/gemsmith/skeletons/travis_skeleton.rb +0 -13
  83. data/lib/gemsmith/templates/%gem_name%/lib/%gem_name%.rb.tt +0 -6
  84. data/lib/gemsmith/templates/%gem_name%/lib/%gem_name%/cli.rb.tt +0 -40
  85. data/lib/gemsmith/templates/%gem_name%/lib/tasks/console.rake.tt +0 -7
  86. data/lib/gemsmith/templates/%gem_name%/spec/lib/%gem_name%/%gem_name%_spec.rb.tt +0 -7
  87. data/lib/gemsmith/templates/%gem_name%/spec/support/extensions/pry.rb.tt +0 -5
  88. data/lib/gemsmith/templates/%gem_name%/spec/support/kit/default_config.rb.tt +0 -18
  89. data/lib/gemsmith/templates/%gem_name%/spec/support/kit/stderr.rb.tt +0 -9
  90. data/lib/gemsmith/templates/%gem_name%/spec/support/kit/stdout.rb.tt +0 -9
  91. data/lib/gemsmith/templates/%gem_name%/spec/support/kit/temp_dir.rb.tt +0 -25
  92. data/lib/tasks/console.rake +0 -7
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Gemsmith
4
- module Skeletons
5
- # Configures Pry debugging support.
6
- class PrySkeleton < BaseSkeleton
7
- def create
8
- return unless configuration.create_pry?
9
- cli.template "%gem_name%/spec/support/extensions/pry.rb.tt", configuration.to_h
10
- end
11
- end
12
- end
13
- end
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Gemsmith
4
- module Skeletons
5
- # Configures Ruby on Rails support.
6
- class RailsSkeleton < BaseSkeleton
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
- gem_name = configuration.gem_name
19
-
20
- cli.template "#{lib_root}/%gem_name%/engine.rb.tt", configuration.to_h
21
- cli.run "rails plugin new --skip #{gem_name} #{engine_options}"
22
- cli.remove_file "#{gem_name}/app/helpers/#{gem_name}/application_helper.rb", configuration.to_h
23
- cli.remove_file "#{gem_name}/lib/#{gem_name}/version.rb", configuration.to_h
24
- cli.remove_file "#{gem_name}/MIT-LICENSE", configuration.to_h
25
- cli.remove_file "#{gem_name}/README.rdoc", configuration.to_h
26
- end
27
-
28
- def create_generator_files
29
- cli.empty_directory "#{generator_root}/templates"
30
- cli.template "#{generator_root}/install/install_generator.rb.tt", configuration.to_h
31
- cli.template "#{generator_root}/install/USAGE.tt", configuration.to_h
32
- cli.template "#{generator_root}/upgrade/upgrade_generator.rb.tt", configuration.to_h
33
- cli.template "#{generator_root}/upgrade/USAGE.tt", configuration.to_h
34
- end
35
-
36
- def create_travis_gemfiles
37
- return unless configuration.create_travis?
38
- cli.template "%gem_name%/gemfiles/rails-%rails_version%.x.gemfile.tt", configuration.to_h
39
- end
40
-
41
- def create
42
- return unless configuration.create_rails?
43
-
44
- install_rails
45
- create_engine
46
- create_generator_files
47
- create_travis_gemfiles
48
- end
49
-
50
- private
51
-
52
- def engine_options
53
- "--skip-bundle --skip-test-unit --skip-keeps --skip-git --mountable --dummy-path=spec/dummy"
54
- end
55
-
56
- def generator_root
57
- "#{lib_root}/generators/%gem_name%"
58
- end
59
- end
60
- end
61
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Gemsmith
4
- module Skeletons
5
- # Configures Rake support.
6
- class RakeSkeleton < BaseSkeleton
7
- def create_console_task
8
- cli.template "%gem_name%/lib/tasks/console.rake.tt", configuration.to_h
9
- end
10
-
11
- def create
12
- create_console_task
13
- cli.template "%gem_name%/Rakefile.tt", configuration.to_h
14
- configure_rakefile
15
- end
16
-
17
- private
18
-
19
- def rspec_task
20
- "spec" if configuration.create_rspec?
21
- end
22
-
23
- def rubocop_task
24
- "rubocop" if configuration.create_rubocop?
25
- end
26
-
27
- def default_tasks
28
- [rspec_task, rubocop_task].compact
29
- end
30
-
31
- def configure_rakefile
32
- return if default_tasks.empty?
33
- cli.append_to_file "%gem_name%/Rakefile", %(\ntask default: %w[#{default_tasks.join(" ")}]\n)
34
- end
35
- end
36
- end
37
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Gemsmith
4
- module Skeletons
5
- # Configures RSpec support.
6
- class RspecSkeleton < BaseSkeleton
7
- def create
8
- return unless configuration.create_rspec?
9
-
10
- cli.template "%gem_name%/lib/tasks/rspec.rake.tt", configuration.to_h
11
- cli.template "#{rspec_root}/spec_helper.rb.tt", configuration.to_h
12
- cli.template "#{rspec_root}/lib/%gem_name%/%gem_name%_spec.rb.tt", configuration.to_h
13
- cli.template "#{rspec_root}/support/kit/default_config.rb.tt", configuration.to_h
14
- cli.template "#{rspec_root}/support/kit/stderr.rb.tt", configuration.to_h
15
- cli.template "#{rspec_root}/support/kit/stdout.rb.tt", configuration.to_h
16
- cli.template "#{rspec_root}/support/kit/temp_dir.rb.tt", configuration.to_h
17
- end
18
-
19
- private
20
-
21
- def rspec_root
22
- "%gem_name%/spec"
23
- end
24
- end
25
- end
26
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Gemsmith
4
- module Skeletons
5
- # Configures Rubocop support.
6
- class RubocopSkeleton < BaseSkeleton
7
- def create
8
- return unless configuration.create_rubocop?
9
-
10
- cli.template "%gem_name%/.rubocop.yml.tt", configuration.to_h
11
- cli.template "%gem_name%/lib/tasks/rubocop.rake.tt", configuration.to_h
12
- end
13
- end
14
- end
15
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Gemsmith
4
- module Skeletons
5
- # Configures Travis CI support.
6
- class TravisSkeleton < BaseSkeleton
7
- def create
8
- return unless configuration.create_travis?
9
- cli.template "%gem_name%/.travis.yml.tt", configuration.to_h
10
- end
11
- end
12
- end
13
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "<%= config.dig(:gem, :name) %>/identity"
4
- <%- if config.dig(:create, :rails) -%>
5
- require "<%= config.dig(:gem, :name) %>/engine"
6
- <%- end -%>
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "yaml"
4
- require "thor"
5
- require "thor/actions"
6
- require "thor_plus/actions"
7
-
8
- module <%= config.dig(:gem, :class) %>
9
- # The Command Line Interface (CLI) for the gem.
10
- class CLI < Thor
11
- include Thor::Actions
12
- include ThorPlus::Actions
13
-
14
- package_name <%= config.dig(:gem, :class) %>::Identity.version_label
15
-
16
- def initialize args = [], options = {}, config = {}
17
- super args, options, config
18
- end
19
- <%- if config.dig(:create, :cli) -%>
20
-
21
- desc "-e, [--edit]", "Edit gem settings in default editor."
22
- map %w[-e --edit] => :edit
23
- def edit
24
- `#{editor} $HOME/#{<%= config.dig(:gem, :class) %>::Identity.file_name}`
25
- end
26
- <%- end -%>
27
-
28
- desc "-v, [--version]", "Show gem version."
29
- map %w[-v --version] => :version
30
- def version
31
- say <%= config.dig(:gem, :class) %>::Identity.version_label
32
- end
33
-
34
- desc "-h, [--help=HELP]", "Show this message or get help for a command."
35
- map %w[-h --help] => :help
36
- def help task = nil
37
- say and super
38
- end
39
- end
40
- end
@@ -1,7 +0,0 @@
1
- desc "Open IRB console for gem development environment"
2
- task :console do
3
- require "irb"
4
- require "<%= config.dig(:gem, :name) %>"
5
- ARGV.clear
6
- IRB.start
7
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- RSpec.describe "<%= config.dig(:gem, :class) %>" do
6
- it "should be tested"
7
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "pry"
4
- require "pry-byebug"
5
- require "pry-state"
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.configure do |config|
4
- config.order = "random"
5
- config.filter_run focus: true
6
- config.disable_monkey_patching!
7
- config.run_all_when_everything_filtered = true
8
- config.example_status_persistence_file_path = "./tmp/rspec-status.txt"
9
-
10
- config.mock_with :rspec do |mocks|
11
- mocks.verify_partial_doubles = true
12
- end
13
-
14
- config.expect_with :rspec do |expectations|
15
- expectations.syntax = :expect
16
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
17
- end
18
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if ENV["SUPPRESS_STDERR"] == "enabled"
4
- RSpec.configure do |config|
5
- stderr_original = $stderr
6
- config.before(:suite) { $stderr = File.new "/dev/null", "w" }
7
- config.after(:suite) { $stderr = stderr_original }
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if ENV["SUPPRESS_STDOUT"] == "enabled"
4
- RSpec.configure do |config|
5
- stdout_original = $stdout
6
- config.before(:suite) { $stdout = File.new "/dev/null", "w" }
7
- config.after(:suite) { $stdout = stdout_original }
8
- end
9
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rspec/core/shared_context"
4
-
5
- module RSpec
6
- module Kit
7
- # Adds temp directory support to specs enabled with the :temp_dir metadata key.
8
- module TempDirContext
9
- extend RSpec::Core::SharedContext
10
- let(:temp_dir) { File.expand_path "../../../../tmp/rspec", __FILE__ }
11
- end
12
- end
13
- end
14
-
15
- RSpec.configure do |config|
16
- config.include RSpec::Kit::TempDirContext
17
-
18
- config.before do |example|
19
- FileUtils.mkdir_p(temp_dir) if example.metadata[:temp_dir]
20
- end
21
-
22
- config.after do |example|
23
- FileUtils.rm_rf(temp_dir) if example.metadata[:temp_dir]
24
- end
25
- end
@@ -1,7 +0,0 @@
1
- desc "Open IRB console for gem development environment"
2
- task :console do
3
- require "irb"
4
- require "gemsmith"
5
- ARGV.clear
6
- IRB.start
7
- end