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.
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
metadata.gz.sig CHANGED
Binary file
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Gemsmith
4
- module Aids
5
- # A thin wrapper to Git.
6
- class Git
7
- def self.config_value key
8
- `git config #{key}`.chomp
9
- end
10
- end
11
- end
12
- end
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "open3"
4
-
5
- module Gemsmith
6
- module Aids
7
- # A convenience aid to the Gem::Specification object.
8
- # DEPRECATED: Will be removed in the next major release. Use `GemSpec` instead.
9
- class Spec
10
- def initialize specification: ::Gem::Specification, shell: Open3
11
- @specification = specification
12
- @shell = shell
13
- end
14
-
15
- def editor
16
- ENV["EDITOR"]
17
- end
18
-
19
- def open spec = nil
20
- return unless spec
21
- shell.capture2 editor, spec.full_gem_path
22
- spec.full_gem_path
23
- end
24
-
25
- def read spec = nil
26
- return unless spec
27
- return if spec.homepage.nil? || spec.homepage.empty?
28
-
29
- shell.capture2 "open", spec.homepage
30
- spec.homepage
31
- end
32
-
33
- def find name, version
34
- specification.find_by_name name, version
35
- end
36
-
37
- def find_all name
38
- specification.find_all_by_name name
39
- end
40
-
41
- private
42
-
43
- attr_reader :specification, :shell
44
- end
45
- end
46
- end
@@ -1,200 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "refinements/string_extensions"
4
-
5
- module Gemsmith
6
- # Default configuration for gem with support for custom settings.
7
- class Configuration
8
- using Refinements::StringExtensions
9
-
10
- attr_reader :gem_name, :gem_class, :file_path
11
- attr_writer :gem_platform, :gem_home_url, :gem_license, :gem_private_key, :gem_public_key, :author_name,
12
- :author_email, :author_url, :organization_name, :organization_email, :organization_url,
13
- :ruby_version, :rails_version, :create_cli, :create_rails, :create_security, :create_pry,
14
- :create_guard, :create_rspec, :create_rubocop, :create_git_hub, :create_code_climate,
15
- :create_gemnasium, :create_travis, :create_patreon, :github_user, :year
16
-
17
- def initialize gem_name: "unknown",
18
- gem_class: "Unknown",
19
- git: Aids::Git,
20
- file_path: File.join(ENV["HOME"], Identity.file_name)
21
-
22
- @gem_name = gem_name.snakecase
23
- @gem_class = gem_class.camelcase
24
- @file_path = file_path
25
- @git = git
26
- @settings = load_settings
27
- end
28
-
29
- def gem_platform
30
- @gem_platform || settings_group(:gem).fetch(:platform, "Gem::Platform::RUBY")
31
- end
32
-
33
- def gem_home_url
34
- @gem_home_url || settings_group(:gem).fetch(:home_url, github_gem_url)
35
- end
36
-
37
- def gem_license
38
- @gem_license || settings_group(:gem).fetch(:license, "MIT")
39
- end
40
-
41
- def gem_private_key
42
- @gem_private_key || settings_group(:gem).fetch(:private_key, "~/.ssh/gem-private.pem")
43
- end
44
-
45
- def gem_public_key
46
- @gem_public_key || settings_group(:gem).fetch(:public_key, "~/.ssh/gem-public.pem")
47
- end
48
-
49
- def author_name
50
- @author_name || settings_group(:author).fetch(:name, git.config_value("user.name"))
51
- end
52
-
53
- def author_email
54
- @author_email || settings_group(:author).fetch(:email, git.config_value("user.email"))
55
- end
56
-
57
- def author_url
58
- @author_url || settings_group(:author).fetch(:url, "")
59
- end
60
-
61
- def organization_name
62
- @organization_name || settings_group(:organization).fetch(:name, "")
63
- end
64
-
65
- def organization_url
66
- @organization_url || settings_group(:organization).fetch(:url, "")
67
- end
68
-
69
- def ruby_version
70
- @ruby_version || settings_group(:versions).fetch(:ruby, RUBY_VERSION)
71
- end
72
-
73
- def rails_version
74
- @rails_version || settings_group(:versions).fetch(:rails, "4.2")
75
- end
76
-
77
- def create_cli?
78
- parse_boolean @create_cli, :create, :cli, false
79
- end
80
-
81
- def create_rails?
82
- parse_boolean @create_rails, :create, :rails, false
83
- end
84
-
85
- def create_security?
86
- parse_boolean @create_security, :create, :security, true
87
- end
88
-
89
- def create_pry?
90
- parse_boolean @create_pry, :create, :pry, true
91
- end
92
-
93
- def create_guard?
94
- parse_boolean @create_guard, :create, :guard, true
95
- end
96
-
97
- def create_rspec?
98
- parse_boolean @create_rspec, :create, :rspec, true
99
- end
100
-
101
- def create_git_hub?
102
- parse_boolean @create_git_hub, :create, :git_hub, false
103
- end
104
-
105
- def create_rubocop?
106
- parse_boolean @create_rubocop, :create, :rubocop, true
107
- end
108
-
109
- def create_code_climate?
110
- parse_boolean @create_code_climate, :create, :code_climate, true
111
- end
112
-
113
- def create_gemnasium?
114
- parse_boolean @create_gemnasium, :create, :gemnasium, true
115
- end
116
-
117
- def create_travis?
118
- parse_boolean @create_travis, :create, :travis, true
119
- end
120
-
121
- def create_patreon?
122
- parse_boolean @create_patreon, :create, :patreon, true
123
- end
124
-
125
- def github_user
126
- @github_user || settings.fetch(:github_user, git.config_value("github.user"))
127
- end
128
-
129
- def year
130
- @year || settings.fetch(:year, Time.now.year)
131
- end
132
-
133
- def to_h
134
- {
135
- year: year,
136
- github_user: github_user,
137
- gem: {
138
- name: gem_name,
139
- class: gem_class,
140
- platform: gem_platform,
141
- home_url: gem_home_url,
142
- license: gem_license,
143
- private_key: gem_private_key,
144
- public_key: gem_public_key
145
- },
146
- author: {
147
- name: author_name,
148
- email: author_email,
149
- url: author_url
150
- },
151
- organization: {
152
- name: organization_name,
153
- url: organization_url
154
- },
155
- versions: {
156
- ruby: ruby_version,
157
- rails: rails_version
158
- },
159
- create: {
160
- cli: create_cli?,
161
- rails: create_rails?,
162
- security: create_security?,
163
- pry: create_pry?,
164
- guard: create_guard?,
165
- rspec: create_rspec?,
166
- rubocop: create_rubocop?,
167
- git_hub: create_git_hub?,
168
- code_climate: create_code_climate?,
169
- gemnasium: create_gemnasium?,
170
- travis: create_travis?,
171
- patreon: create_patreon?
172
- }
173
- }
174
- end
175
-
176
- private
177
-
178
- attr_reader :gem_parser, :git, :settings
179
-
180
- def load_settings
181
- return {} unless File.exist?(file_path)
182
- yaml = YAML.load_file file_path
183
- yaml.is_a?(Hash) ? yaml : {}
184
- end
185
-
186
- def settings_group key
187
- settings.fetch key, {}
188
- end
189
-
190
- def parse_boolean variable, group_key, item_key, default_value
191
- return variable if [true, false].include?(variable)
192
- settings_group(group_key).fetch item_key, default_value
193
- end
194
-
195
- def github_gem_url
196
- return "" if github_user.nil?
197
- "https://github.com/#{github_user}/#{gem_name}"
198
- end
199
- end
200
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/ui/shell"
4
- require "tocer"
5
-
6
- module Gemsmith
7
- module Rake
8
- # Provides gem build functionality. Meant to be wrapped in Rake tasks.
9
- class Build
10
- def initialize tocer: Tocer::Writer, shell: Bundler::UI::Shell, kernel: Kernel
11
- @tocer = tocer
12
- @shell = shell.new
13
- @kernel = kernel
14
- end
15
-
16
- def doc
17
- readme = File.join Dir.pwd, "README.md"
18
- tocer.new(readme).write
19
- shell.confirm "Updated gem documentation."
20
- end
21
-
22
- def clean
23
- FileUtils.rm_rf "pkg"
24
- shell.confirm "Cleaned gem artifacts."
25
- end
26
-
27
- def validate
28
- return if `git status --porcelain`.empty?
29
- shell.error "Build failed: Gem has uncommitted changes."
30
- kernel.exit 1
31
- end
32
-
33
- private
34
-
35
- attr_reader :tocer, :shell, :kernel
36
- end
37
- end
38
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Gemsmith
4
- module Skeletons
5
- # Abstract class from which all skeletons inherit from.
6
- class BaseSkeleton
7
- def initialize cli, configuration: Configuration.new
8
- @cli = cli
9
- @configuration = configuration
10
- end
11
-
12
- def self.create cli, configuration: Configuration.new
13
- new(cli, configuration: configuration).create
14
- end
15
-
16
- def create
17
- fail NotImplementedError, "The method, #create, is not implemented yet."
18
- end
19
-
20
- protected
21
-
22
- attr_reader :cli, :configuration
23
-
24
- def lib_root
25
- "%gem_name%/lib"
26
- end
27
- end
28
- end
29
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Gemsmith
4
- module Skeletons
5
- # Configures Bundler support.
6
- class BundlerSkeleton < BaseSkeleton
7
- def create
8
- Dir.chdir(File.join(cli.destination_root, configuration.gem_name)) do
9
- cli.info "Installing gem dependencies..."
10
- `bundle install`
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Gemsmith
4
- module Skeletons
5
- # Configures Command Line Interface (CLI) support.
6
- class CLISkeleton < BaseSkeleton
7
- def create
8
- return unless configuration.create_cli?
9
-
10
- cli.template "%gem_name%/bin/%gem_name%.tt", configuration.to_h
11
- cli.template "%gem_name%/lib/%gem_name%/cli.rb.tt", configuration.to_h
12
- cli.chmod "#{configuration.gem_name}/bin/#{configuration.gem_name}", 0755
13
- end
14
- end
15
- end
16
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "tocer"
4
-
5
- module Gemsmith
6
- module Skeletons
7
- # Configures documentation support.
8
- class DocumentationSkeleton < BaseSkeleton
9
- def create_files
10
- cli.template "%gem_name%/README.md.tt", configuration.to_h
11
- cli.template "%gem_name%/CONTRIBUTING.md.tt", configuration.to_h
12
- cli.template "%gem_name%/CODE_OF_CONDUCT.md.tt", configuration.to_h
13
- cli.template "%gem_name%/LICENSE.md.tt", configuration.to_h
14
- cli.template "%gem_name%/CHANGELOG.md.tt", configuration.to_h
15
- end
16
-
17
- def update_readme
18
- file = File.join cli.destination_root, configuration.gem_name, "README.md"
19
- Tocer::Writer.new(file).write
20
- end
21
-
22
- def create
23
- create_files
24
- update_readme
25
- end
26
- end
27
- end
28
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Gemsmith
4
- module Skeletons
5
- # Configures default gem support.
6
- class GemSkeleton < BaseSkeleton
7
- def create
8
- cli.template "%gem_name%/bin/setup.tt", configuration.to_h
9
- cli.template "%gem_name%/Gemfile.tt", configuration.to_h
10
- cli.template "%gem_name%/%gem_name%.gemspec.tt", configuration.to_h
11
- cli.template "#{lib_root}/%gem_name%.rb.tt", configuration.to_h
12
- cli.template "#{lib_root}/%gem_name%/identity.rb.tt", configuration.to_h
13
- cli.chmod "#{configuration.gem_name}/bin/setup", 0755
14
- end
15
- end
16
- end
17
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Gemsmith
4
- module Skeletons
5
- # Configures GitHub support.
6
- class GitHubSkeleton < BaseSkeleton
7
- def create
8
- return unless configuration.create_git_hub?
9
- cli.template "%gem_name%/.github/ISSUE_TEMPLATE.md.tt", configuration.to_h
10
- cli.template "%gem_name%/.github/PULL_REQUEST_TEMPLATE.md.tt", configuration.to_h
11
- end
12
- end
13
- end
14
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Gemsmith
4
- module Skeletons
5
- # Configures Guard support.
6
- class GuardSkeleton < BaseSkeleton
7
- def create
8
- return unless configuration.create_guard?
9
- cli.template "%gem_name%/Guardfile.tt", configuration.to_h
10
- end
11
- end
12
- end
13
- end