gemsmith 15.5.0 → 16.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/LICENSE.adoc +207 -155
  4. data/README.adoc +177 -189
  5. data/exe/gemsmith +6 -0
  6. data/gemsmith.gemspec +41 -0
  7. data/lib/gemsmith/builders/bundler.rb +34 -0
  8. data/lib/gemsmith/builders/cli.rb +86 -0
  9. data/lib/gemsmith/builders/git/commit.rb +46 -0
  10. data/lib/gemsmith/builders/git/ignore.rb +37 -0
  11. data/lib/gemsmith/builders/rspec/helper.rb +47 -0
  12. data/lib/gemsmith/builders/specification.rb +35 -0
  13. data/lib/gemsmith/cli/actions/build.rb +53 -0
  14. data/lib/gemsmith/cli/actions/config.rb +35 -0
  15. data/lib/gemsmith/cli/actions/edit.rb +38 -0
  16. data/lib/gemsmith/cli/actions/install.rb +36 -0
  17. data/lib/gemsmith/cli/actions/publish.rb +36 -0
  18. data/lib/gemsmith/cli/actions/view.rb +38 -0
  19. data/lib/gemsmith/cli/parser.rb +33 -0
  20. data/lib/gemsmith/cli/parsers/build.rb +54 -0
  21. data/lib/gemsmith/cli/parsers/core.rb +94 -0
  22. data/lib/gemsmith/cli/shell.rb +66 -0
  23. data/lib/gemsmith/configuration/enhancers/template_root.rb +20 -0
  24. data/lib/gemsmith/configuration/loader.rb +50 -0
  25. data/lib/gemsmith/container.rb +21 -0
  26. data/lib/gemsmith/gems/finder.rb +21 -0
  27. data/lib/gemsmith/gems/loader.rb +21 -0
  28. data/lib/gemsmith/gems/picker.rb +43 -0
  29. data/lib/gemsmith/gems/presenter.rb +50 -0
  30. data/lib/gemsmith/templates/%project_name%/%project_name%.gemspec.erb +49 -0
  31. data/lib/gemsmith/templates/%project_name%/exe/%project_name%.erb +5 -0
  32. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/actions/config.rb.erb +35 -0
  33. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/parser.rb.erb +31 -0
  34. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/parsers/core.rb.erb +54 -0
  35. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/shell.rb.erb +38 -0
  36. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/configuration/content.rb.erb +18 -0
  37. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/configuration/defaults.yml.erb +0 -0
  38. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/configuration/loader.rb.erb +33 -0
  39. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/container.rb.erb +35 -0
  40. data/lib/gemsmith/templates/{%gem_name%/lib/%gem_path%/identity.rb.tt → %project_name%/lib/%project_path%/identity.rb.erb} +1 -1
  41. data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/actions/config_spec.rb.erb +24 -0
  42. data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/parser_spec.rb.erb +25 -0
  43. data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/parsers/core_spec.rb.erb +53 -0
  44. data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/shell_spec.rb.erb +43 -0
  45. data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/configuration/content_spec.rb.erb +15 -0
  46. data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/configuration/loader_spec.rb.erb +29 -0
  47. data/lib/gemsmith/templates/%project_name%/spec/support/shared_contexts/application_container.rb.erb +22 -0
  48. data/lib/gemsmith/templates/%project_name%/spec/support/shared_examples/a_parser.rb.erb +7 -0
  49. data/lib/gemsmith/tools/cleaner.rb +29 -0
  50. data/lib/gemsmith/tools/editor.rb +30 -0
  51. data/lib/gemsmith/tools/installer.rb +39 -0
  52. data/lib/gemsmith/tools/packager.rb +33 -0
  53. data/lib/gemsmith/tools/publisher.rb +34 -0
  54. data/lib/gemsmith/tools/pusher.rb +36 -0
  55. data/lib/gemsmith/tools/validator.rb +28 -0
  56. data/lib/gemsmith/tools/versioner.rb +43 -0
  57. data/lib/gemsmith/tools/viewer.rb +28 -0
  58. data/lib/gemsmith.rb +5 -3
  59. data.tar.gz.sig +0 -0
  60. metadata +87 -115
  61. metadata.gz.sig +0 -0
  62. data/bin/gemsmith +0 -9
  63. data/lib/gemsmith/authenticators/basic.rb +0 -28
  64. data/lib/gemsmith/authenticators/ruby_gems.rb +0 -41
  65. data/lib/gemsmith/cli.rb +0 -259
  66. data/lib/gemsmith/credentials.rb +0 -82
  67. data/lib/gemsmith/errors/base.rb +0 -9
  68. data/lib/gemsmith/errors/requirement_conversion.rb +0 -9
  69. data/lib/gemsmith/errors/requirement_operator.rb +0 -9
  70. data/lib/gemsmith/errors/specification.rb +0 -9
  71. data/lib/gemsmith/gem/inspector.rb +0 -30
  72. data/lib/gemsmith/gem/module_formatter.rb +0 -50
  73. data/lib/gemsmith/gem/requirement.rb +0 -55
  74. data/lib/gemsmith/gem/specification.rb +0 -74
  75. data/lib/gemsmith/generators/base.rb +0 -46
  76. data/lib/gemsmith/generators/bundler.rb +0 -19
  77. data/lib/gemsmith/generators/bundler_audit.rb +0 -15
  78. data/lib/gemsmith/generators/circle_ci.rb +0 -14
  79. data/lib/gemsmith/generators/cli.rb +0 -17
  80. data/lib/gemsmith/generators/documentation.rb +0 -36
  81. data/lib/gemsmith/generators/engine.rb +0 -77
  82. data/lib/gemsmith/generators/gem.rb +0 -29
  83. data/lib/gemsmith/generators/git.rb +0 -45
  84. data/lib/gemsmith/generators/git_hub.rb +0 -15
  85. data/lib/gemsmith/generators/git_lint.rb +0 -14
  86. data/lib/gemsmith/generators/guard.rb +0 -14
  87. data/lib/gemsmith/generators/pragma.rb +0 -49
  88. data/lib/gemsmith/generators/rake.rb +0 -76
  89. data/lib/gemsmith/generators/reek.rb +0 -17
  90. data/lib/gemsmith/generators/rspec.rb +0 -39
  91. data/lib/gemsmith/generators/rubocop.rb +0 -18
  92. data/lib/gemsmith/generators/ruby.rb +0 -12
  93. data/lib/gemsmith/helpers/cli.rb +0 -59
  94. data/lib/gemsmith/helpers/template.rb +0 -30
  95. data/lib/gemsmith/identity.rb +0 -12
  96. data/lib/gemsmith/rake/builder.rb +0 -57
  97. data/lib/gemsmith/rake/publisher.rb +0 -100
  98. data/lib/gemsmith/rake/setup.rb +0 -4
  99. data/lib/gemsmith/rake/tasks.rb +0 -83
  100. data/lib/gemsmith/templates/%gem_name%/%gem_name%.gemspec.tt +0 -44
  101. data/lib/gemsmith/templates/%gem_name%/.circleci/config.yml.tt +0 -31
  102. data/lib/gemsmith/templates/%gem_name%/.github/ISSUE_TEMPLATE.md.tt +0 -14
  103. data/lib/gemsmith/templates/%gem_name%/.github/PULL_REQUEST_TEMPLATE.md.tt +0 -11
  104. data/lib/gemsmith/templates/%gem_name%/.gitignore.tt +0 -6
  105. data/lib/gemsmith/templates/%gem_name%/.reek.yml.tt +0 -6
  106. data/lib/gemsmith/templates/%gem_name%/.rubocop.yml.tt +0 -15
  107. data/lib/gemsmith/templates/%gem_name%/.ruby-version.tt +0 -1
  108. data/lib/gemsmith/templates/%gem_name%/CHANGES.md.tt +0 -3
  109. data/lib/gemsmith/templates/%gem_name%/CODE_OF_CONDUCT.md.tt +0 -66
  110. data/lib/gemsmith/templates/%gem_name%/CONTRIBUTING.md.tt +0 -22
  111. data/lib/gemsmith/templates/%gem_name%/Gemfile.tt +0 -47
  112. data/lib/gemsmith/templates/%gem_name%/Guardfile.tt +0 -21
  113. data/lib/gemsmith/templates/%gem_name%/LICENSE.md.tt +0 -20
  114. data/lib/gemsmith/templates/%gem_name%/README.md.tt +0 -93
  115. data/lib/gemsmith/templates/%gem_name%/Rakefile.tt +0 -12
  116. data/lib/gemsmith/templates/%gem_name%/bin/%gem_name%.tt +0 -8
  117. data/lib/gemsmith/templates/%gem_name%/bin/console.tt +0 -10
  118. data/lib/gemsmith/templates/%gem_name%/bin/setup.tt +0 -8
  119. data/lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt +0 -61
  120. data/lib/gemsmith/templates/%gem_name%/lib/%gem_path%/engine.rb.tt +0 -6
  121. data/lib/gemsmith/templates/%gem_name%/lib/%gem_path%.rb.tt +0 -7
  122. data/lib/gemsmith/templates/%gem_name%/lib/generators/%gem_path%/install/USAGE.tt +0 -8
  123. data/lib/gemsmith/templates/%gem_name%/lib/generators/%gem_path%/install/install_generator.rb.tt +0 -12
  124. data/lib/gemsmith/templates/%gem_name%/lib/generators/%gem_path%/upgrade/USAGE.tt +0 -8
  125. data/lib/gemsmith/templates/%gem_name%/lib/generators/%gem_path%/upgrade/upgrade_generator.rb.tt +0 -10
  126. data/lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt +0 -81
  127. data/lib/gemsmith/templates/%gem_name%/spec/rails_helper.rb.tt +0 -14
  128. data/lib/gemsmith/templates/%gem_name%/spec/spec_helper.rb.tt +0 -37
  129. data/lib/gemsmith/templates/%gem_name%/spec/support/shared_contexts/temp_dir.rb.tt +0 -9
data/README.adoc CHANGED
@@ -11,56 +11,27 @@ image::https://img.shields.io/badge/code_style-alchemists-brightgreen.svg[Alchem
11
11
  [link=https://circleci.com/gh/bkuhlmann/gemsmith]
12
12
  image::https://circleci.com/gh/bkuhlmann/gemsmith.svg?style=svg[Circle CI Status]
13
13
 
14
- A command line interface for smithing Ruby gems.
14
+ Gemsmith is a command line interface for smithing Ruby gems. Perfect for when you need a
15
+ professional and robust tool beyond link:https://bundler.io[Bundler]'s basic gem skeletons. While
16
+ Bundler is great for creating your first gem, you'll quickly outgrow Bundler when creating and
17
+ maintaining multiple gems. This is where Gemsmith can increase your productivity by providing much
18
+ of the tooling you need from the start with the ability to customize as desired.
15
19
 
16
20
  toc::[]
17
21
 
18
22
  == Features
19
23
 
20
- * Builds a gem skeleton with enhanced Bundler functionality.
21
- * Uses link:https://www.alchemists.io/projects/refinements[Refinements] Ruby core library enhancements.
22
- * Uses link:https://www.alchemists.io/projects/versionaire[Versionaire] for semantic versioning.
23
- * Uses link:https://www.alchemists.io/projects/runcom[Runcom] for resource configuration management.
24
- * Uses link:https://www.alchemists.io/projects/milestoner[Milestoner] for consistent project/gem versioning.
25
- * Uses link:https://www.alchemists.io/projects/pragmater[Pragmater] for Ruby source pragma directives.
26
- * Uses link:https://www.alchemists.io/projects/tocer[Tocer] for README table of contents generation.
27
- * Supports link:https://github.com/rubysec/bundler-audit[Bundler Audit].
28
- * Supports link:https://circleci.com[Circle CI].
29
- * Supports link:https://git-scm.com[Git]
30
- * Supports link:https://www.alchemists.io/projects/git-lint[Git Lint].
31
- * Supports link:https://github.com[GitHub].
32
- * Supports link:https://github.com/guard/guard[Guard].
33
- * Supports link:http://pryrepl.org[Pry].
34
- * Supports link:https://github.com/troessner/reek[Reek].
35
- * Supports link:https://rspec.info[RSpec].
36
- * Supports link:https://github.com/rubocop-hq/rubocop[Rubocop].
37
- * Supports link:https://github.com/rubocop-hq/rubocop-rspec[Rubocop RSpec].
38
- * Supports link:https://rubyonrails.org[Ruby on Rails].
39
- * Supports link:https://guides.rubygems.org/security[RubyGems Security].
40
- * Supports link:https://github.com/simplecov-ruby/simplecov[SimpleCov].
41
- * Supports link:https://github.com/erikhuda/thor[Thor].
42
- * Supports common settings and a structured layout for building gems.
43
- * Supports publishing to public or private gem servers.
44
- * Provides common documentation:
45
- ** README
46
- ** CHANGES
47
- ** CONTRIBUTING
48
- ** CODE OF CONDUCT
49
- ** LICENSE
50
- * Aids in viewing source code of semantically versioned gems within your favorite editor.
51
- * Aids in viewing documentation of semantically versioned within your default browser.
52
-
53
- == Screencasts
54
-
55
- [link=https://www.alchemists.io/screencasts/gemsmith]
56
- image::https://www.alchemists.io/images/screencasts/gemsmith/cover.svg[Screencast,600,240,role=focal_point]
24
+ * Supports all features provided by link:https://www.alchemists.io/projects/rubysmith[Rubysmith]
25
+ which is used for smithing Ruby projects.
26
+ * Supports basic gem skeletons or more advanced Command Line Interface (CLI) skeletons.
27
+ * Supports gem building, installing for local development, and publishing.
28
+ * Supports the editing and viewing of installed gems.
57
29
 
58
30
  == Requirements
59
31
 
60
32
  . A UNIX-based system.
61
33
  . link:https://www.ruby-lang.org[Ruby].
62
34
  . link:https://rubygems.org[RubyGems].
63
- . link:https://github.com/bundler/bundler[Bundler].
64
35
 
65
36
  == Setup
66
37
 
@@ -78,74 +49,151 @@ gem install gemsmith
78
49
  From the command line, type: `gemsmith --help`
79
50
 
80
51
  ....
81
- gemsmith -c, [--config] # Manage gem configuration.
82
- gemsmith -g, [--generate=GEM] # Generate new gem.
83
- gemsmith -h, [--help=COMMAND] # Show this message or get help for a command.
84
- gemsmith -o, [--open=GEM] # Open a gem in default editor.
85
- gemsmith -r, [--read=GEM] # Open a gem in default browser.
86
- gemsmith -v, [--version] # Show gem version.
52
+ USAGE:
53
+ -b, --build NAME [options] Build new project.
54
+ -c, --config ACTION Manage gem configuration: edit or view.
55
+ --edit GEM Edit installed gem in default editor.
56
+ -h, --help Show this message.
57
+ -i, --install [NAME] Install gem for local development.
58
+ -p, --publish [NAME] Publish gem to remote gem server.
59
+ -v, --version Show gem version.
60
+ --view GEM View installed gem in default browser.
61
+
62
+ BUILD OPTIONS:
63
+ --[no-]amazing_print Add Amazing Print gem. Default: true.
64
+ --[no-]bundler-leak Add Bundler Leak gem. Default: true.
65
+ --[no-]circle_ci Add Circle CI configuration and badge. Default: false.
66
+ --[no-]citation Add citation documentation. Default: true.
67
+ --[no-]community Add community documentation. Default: false.
68
+ --[no-]conduct Add code of conduct documentation. Default: true.
69
+ --[no-]console Add console script. Default: true.
70
+ --[no-]contributions Add contributions documentation. Default: true.
71
+ --[no-]dead_end Add Dead End gem. Default: true.
72
+ --[no-]debug Add Debug gem. Default: true.
73
+ --[no-]git Add Git. Default: true.
74
+ --[no-]git_hub Add GitHub templates. Default: false.
75
+ --[no-]git-lint Add Git Lint gem. Default: true.
76
+ --[no-]guard Add Guard gem. Default: true.
77
+ --[no-]license Add license documentation. Default: true.
78
+ --max Use maximum/enabled options. Default: false.
79
+ --min Use minimum/disabled options. Default: false.
80
+ --[no-]rake Add Rake gem. Default: true.
81
+ --[no-]readme Add readme documentation. Default: true.
82
+ --[no-]reek Add Reek gem. Default: true.
83
+ --[no-]refinements Add Refinements gem. Default: true.
84
+ --[no-]rspec Add RSpec gem. Default: true.
85
+ --[no-]rubocop Add RuboCop gems. Default: true.
86
+ --[no-]security Add security. Default: true.
87
+ --[no-]setup Add setup script. Default: true.
88
+ --[no-]simple_cov Add SimpleCov gem. Default: true.
89
+ --[no-]versions Add version history. Default: true.
90
+ --[no-]yard Add Yard gem. Default: false.
91
+ --[no-]zeitwerk Add Zeitwerk gem. Default: true.
92
+ --[no-]cli Add command line interface. Default: false.
87
93
  ....
88
94
 
89
- For more gem generation options, type: `gemsmith --help --generate`
95
+ === Build
90
96
 
91
- ....
92
- [--bundler-audit], [--no-bundler-audit] # Add Bundler Audit support.
93
- # Default: true
94
- [--circle-ci], [--no-circle-ci] # Add Circle CI support.
95
- [--cli], [--no-cli] # Add CLI support.
96
- [--engine], [--no-engine] # Add Rails Engine support.
97
- [--git-lint], [--no-git-lint] # Add Git Lint support.
98
- # Default: true
99
- [--git-hub], [--no-git-hub] # Add GitHub support.
100
- [--guard], [--no-guard] # Add Guard support.
101
- # Default: true
102
- [--pry], [--no-pry] # Add Pry support.
103
- # Default: true
104
- [--reek], [--no-reek] # Add Reek support.
105
- # Default: true
106
- [--rspec], [--no-rspec] # Add RSpec support.
107
- # Default: true
108
- [--rubocop], [--no-rubocop] # Add Rubocop support.
109
- # Default: true
110
- [--simple-cov], [--no-simple-cov] # Add SimpleCov support.
111
- # Default: true
112
- [--security], [--no-security] # Add security support.
113
- ....
97
+ The core functionality of this gem centers around the `--build` command and associated flags. The
98
+ build options allow you to further customize the kind of gem you want to build. Most build options
99
+ are enabled by default. For detailed documentation on all supported flags, see the
100
+ link:https://www.alchemists.io/projects/rubysmith/#_build[Rubysmith] documentation.
114
101
 
115
- === Rake
102
+ The build option, which is unique to Gemsmith, is the `--cli` option. This allows you to build a gem
103
+ which has a Command Line Interface (CLI). There are multiple ways a CLI can be built in Ruby but
104
+ Gemsmith takes an approach which builds upon Ruby's native `OptionParser` with help from
105
+ link:https://dry-rb.org/gems/dry-container[Dry Container]. All of this culminates in a design that
106
+ is mix of Objected Oriented + Functional Programming design. Building a gem with CLI support is a
107
+ simple as running:
116
108
 
117
- Once a gem skeleton has been created, the following tasks are available (i.e. `bundle exec rake
118
- -T`):
109
+ [source,bash]
110
+ ----
111
+ gemsmith --build demo --cli
112
+ ----
113
+
114
+ The above will give you a new gem with CLI support which includes working specs. It's the same
115
+ design used to build this Gemsmith gem. You'll have both a `configuration` and `CLI` namespace for
116
+ configuring your gem and adding additional CLI support. Out of the box, the CLI gem generated for
117
+ you supports the following options:
119
118
 
120
119
  ....
121
- rake build # Build example-0.1.0.gem package
122
- rake bundle:audit # Updates the ruby-advisory-db then runs bundle-audit
123
- rake clean # Clean gem artifacts
124
- rake code_quality # Run code quality checks
125
- rake git_lint # Run Git Lint
126
- rake install # Install example-0.1.0.gem package
127
- rake publish # Build, tag as 0.1.0 (unsigned), and push example-0.1.0.gem to RubyGems
128
- rake reek # Check for code smells
129
- rake rubocop # Run RuboCop
130
- rake rubocop:auto_correct # Auto-correct RuboCop offenses
131
- rake spec # Run RSpec code examples
132
- rake toc[label,includes] # Add/Update Table of Contents (README)
120
+ -c, --config ACTION Manage gem configuration: edit or view.
121
+ -h, --help Show this message.
122
+ -v, --version Show gem version.
133
123
  ....
134
124
 
135
- _NOTE: Some tasks might differ depending on what options you enabled/disabled during gem
136
- generation._
125
+ From here you can add whatever you wish to make an awesome CLI gem for others to enjoy.
137
126
 
138
- When building/testing your gem locally, a typical workflow is:
127
+ === Install
139
128
 
140
- . `bundle exec rake install`
141
- . Test your gem locally.
142
- . Repeat until satisfied.
129
+ After you've designed, implemented, and built your gem, you'll want to test it out within your local
130
+ environment by installing it. You can do this by running:
143
131
 
144
- When satified with your gem, builds are green, and ready to publish, run:
132
+ [source,bash]
133
+ ----
134
+ # Implicit
135
+ gemsmith --install
145
136
 
146
- ....
147
- bundle exec rake publish
148
- ....
137
+ # Explicit
138
+ gemsmith --install demo
139
+ ----
140
+
141
+ Gemsmith can be used to install any gem, in fact. Doesn't matter if the gem was built by Gemsmith,
142
+ Bundler, or some other tool. As long as your gem has a `*.gemspec` file, Gemsmith will be able to
143
+ install it.
144
+
145
+ === Publish
146
+
147
+ Once you've built your gem; installed it locally; and thoroughly tested it, you'll want to publish
148
+ your gem so anyone in the world can make use of it. You can do this by running the following:
149
+
150
+ [source,bash]
151
+ ----
152
+ # Implicit
153
+ gemsmith --publish
154
+
155
+ # Explicit
156
+ gemsmith --publish demo
157
+ ----
158
+
159
+ Security is important and turned on by default which requires a GPG key for signing your Git tags
160
+ along with link:https://guides.rubygems.org/setting-up-multifactor-authentication[RubyGems
161
+ Multi-Factor Authentication] enabled. Even better, if you are using
162
+ link:https://www.alchemists.io/articles/universal_2nd_factor[Universal Second Factor
163
+ Authentication], Gemsmith supports this by default and will automatically attempt to use your
164
+ YubiKey which makes publishing gems, securely, a breeze.
165
+
166
+ As when installing or publishing a gem, Gemsmith can be used for existing gems which were not built
167
+ by Gemsmith too. As long as your gem has a `*.gemspec` file, Gemsmith will be able to publish it.
168
+
169
+ === Edit
170
+
171
+ Gemsmith can be used to edit existing gems on your local system. You can do this by running:
172
+
173
+ [source,bash]
174
+ ----
175
+ gemsmith --edit <name of gem>
176
+ ----
177
+
178
+ If multiple versions of the same gem are detected, you'll be prompted to pick which gem you want to
179
+ edit. Otherwise, the gem will immediately be opened within your default editor (or whatever you
180
+ have set in your `EDITOR` environment variable).
181
+
182
+ Editing a local gem is a great way to learn from others or quickly debug issues.
183
+
184
+ === View
185
+
186
+ Gemsmith can be used to view existing gem documentation. You can do this by running:
187
+
188
+ [source,bash]
189
+ ----
190
+ gemsmith --view <name of gem>
191
+ ----
192
+
193
+ If multiple versions of the same gem are detected, you'll be prompted to pick which gem you want to
194
+ view. Otherwise, the gem will immediately be opened within your default browser.
195
+
196
+ Viewing a gem is a great way to learn more about the gem and documentation in general.
149
197
 
150
198
  === Configuration
151
199
 
@@ -155,82 +203,42 @@ This gem can be configured via a global configuration:
155
203
  $HOME/.config/gemsmith/configuration.yml
156
204
  ....
157
205
 
158
- It can also be configured via link:https://www.alchemists.io/projects/xdg[XDG] environment variables.
206
+ It can also be configured via link:https://www.alchemists.io/projects/xdg[XDG] environment
207
+ variables.
159
208
 
160
- The default configuration is as follows:
209
+ The default configuration is everything provided in the
210
+ link:https://www.alchemists.io/projects/rubysmith/#_configuration[Rubysmith] with the addition of
211
+ the following:
161
212
 
162
213
  [source,yaml]
163
214
  ----
164
- :year: <current year>
165
- :github_user: "<Git config GitHub user>"
166
- :gem:
167
- :label: "Undefined"
168
- :name: "undefined"
169
- :path: "undefined"
170
- :class: "Undefined"
171
- :platform: "Gem::Platform::RUBY"
172
- :url: "https://github.com/<author>/<gem name>"
173
- :license: "MIT"
174
- :author:
175
- :name: "<Git config user name>"
176
- :email: "<Git config user email>"
177
- :url: ""
178
- :organization:
179
- :name: ""
180
- :url: ""
181
- :versions:
182
- :ruby: "<current Ruby version>"
183
- :rails: "5.1"
184
- :generate:
185
- :bundler_audit: true
186
- :circle_ci: false
215
+ :build:
187
216
  :cli: false
188
- :engine: false
189
- :git_lint: true
190
- :git_hub: true
191
- :guard: true
192
- :pry: true
193
- :reek: true
194
- :rspec: true
195
- :rubocop: true
196
- :simple_cov: true
197
- :security: false
198
- :publish:
199
- :sign: false
200
217
  ----
201
218
 
202
- Feel free to take this default configuration, modify, and save as your own custom
203
- `configuration.yml`.
204
-
205
- === Existing Gems
219
+ Feel free to take the combined Rubysmith + Gemsmith configuration, modify, and save as your own
220
+ custom `configuration.yml`.
206
221
 
207
- If you have gems that were not originally crafted by Gemsmith, you can add Gemsmith support to them
208
- by modifying the following files:
222
+ === Workflows
209
223
 
210
- Add the following to your gem's `.gemspec` file:
224
+ When building/testing your gem locally, a typical workflow is:
211
225
 
212
- [source,ruby]
213
- ----
214
- spec.add_development_dependency "gemsmith"
226
+ [source,bash]
215
227
  ----
228
+ # Build
229
+ gemsmith --build demo
216
230
 
217
- Replace or add a modified version of the following to your gem's `Rakefile`:
231
+ # Design, Implement and Test.
232
+ cd demo
233
+ bundle exec rake
218
234
 
219
- [source,ruby]
220
- ----
221
- # frozen_string_literal: true
235
+ # Install
236
+ gemsmith --install
222
237
 
223
- begin
224
- require "gemsmith/rake/setup"
225
- rescue LoadError => error
226
- puts error.message
227
- end
238
+ # Publish
239
+ gemsmith --publish
228
240
  ----
229
241
 
230
- _NOTE: Ensure `require "bundler/gem_tasks"` is removed as Gemsmith replaces Bundler functionality._
231
-
232
- With those changes, you can leverage the benefits of Gemsmith within your existing gem.
233
-
234
242
  == Security
235
243
 
236
244
  === Git Signing Key
@@ -267,8 +275,7 @@ Add your key to your global Git configuration in the `[user]` section. Example:
267
275
  ....
268
276
 
269
277
  Now, when publishing your gems with Gemsmith (i.e. `bundle exec rake publish`), signing of your Git
270
- tag will happen automatically. You will be prompted for the GPG Passphrase each time but that is to
271
- be expected.
278
+ tag will happen automatically.
272
279
 
273
280
  === Gem Certificates
274
281
 
@@ -293,12 +300,12 @@ By default, the following Rake task will publish your gem to link:https://rubyge
293
300
 
294
301
  [source,bash]
295
302
  ----
296
- bundle exec rake publish
303
+ gemsmith --publish
297
304
  ----
298
305
 
299
- You can change this behavior by adding metadata to your gemspec that will allow the Rake tasks,
300
- mentioned above, to publish your gem to an alternate/private gem server instead. This can be done by
301
- updating your gem specification and RubyGems credentials.
306
+ You can change this behavior by adding metadata to your gemspec that will allow Gemsmith to publish
307
+ your gem to an alternate/private gem server instead. This can be done by updating your gem
308
+ specification and RubyGems credentials.
302
309
 
303
310
  === Gem Specification Metadata
304
311
 
@@ -334,7 +341,7 @@ Example:
334
341
  [source,yaml]
335
342
  ----
336
343
  :rubygems_api_key: 2a0b460650e67d9b85a60e183defa376
337
- :example_key: "Basic dXNlcjpwYXNzd29yZA=="
344
+ :some_custom_key: "Basic dXNlcjpwYXNzd29yZA=="
338
345
  ----
339
346
 
340
347
  Should you need to delete a credential (due to a bad login/password for example), you can open the
@@ -346,20 +353,14 @@ publish of your gem, you'll be prompted for the missing credentials.
346
353
  Once your gem is released, let the world know about your accomplishment by posting an update to
347
354
  these sites:
348
355
 
349
- * link:http://www.rubyflow.com[RubyFlow]
356
+ * link:https://rubyflow.com[RubyFlow]
357
+ * link:https://rubyradar.dev[Ruby Radar]
350
358
  * link:https://ruby.libhunt.com[Ruby Library Hunt]
351
- * link:http://rubydaily.org[RubyDaily]
359
+ * link:https://rubydaily.org[RubyDaily]
352
360
  * link:https://awesome-ruby.com[Awesome Ruby]
353
361
  * link:https://www.ruby-toolbox.com[Ruby Toolbox]
354
362
  * link:https://www.ruby-lang.org/en/community[Ruby Community]
355
363
 
356
- == Troubleshooting
357
-
358
- When running `bundle exec rake install` or `bundle exec rake publish` with modified, staged, or
359
- uncommitted Git changes, the rake task will throw an error to this effect. When this occurs, it is
360
- recommended that you commit your changes or link:https://git-scm.com/docs/git-stash[stash] them
361
- before proceeding.
362
-
363
364
  == Development
364
365
 
365
366
  To contribute, run:
@@ -387,30 +388,17 @@ To test, run:
387
388
  bundle exec rake
388
389
  ----
389
390
 
390
- == Versioning
391
-
392
- Read link:https://semver.org[Semantic Versioning] for details. Briefly, it means:
393
-
394
- * Major (X.y.z) - Incremented for any backwards incompatible public API changes.
395
- * Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
396
- * Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
397
-
398
- == Code of Conduct
399
-
400
- Please note that this project is released with a link:CODE_OF_CONDUCT.adoc[CODE OF CONDUCT]. By
401
- participating in this project you agree to abide by its terms.
402
-
403
- == Contributions
391
+ == link:https://www.alchemists.io/policies/license[License]
404
392
 
405
- Read link:CONTRIBUTING.adoc[CONTRIBUTING] for details.
393
+ == link:https://www.alchemists.io/policies/security[Security]
406
394
 
407
- == License
395
+ == link:https://www.alchemists.io/policies/code_of_conduct[Code of Conduct]
408
396
 
409
- Read link:LICENSE.adoc[LICENSE] for details.
397
+ == link:https://www.alchemists.io/policies/contributions[Contributions]
410
398
 
411
- == History
399
+ == link:https://www.alchemists.io/projects/gemsmith/versions[Versions]
412
400
 
413
- Read link:CHANGES.adoc[CHANGES] for details.
401
+ == link:https://www.alchemists.io/community[Community]
414
402
 
415
403
  == Credits
416
404
 
data/exe/gemsmith ADDED
@@ -0,0 +1,6 @@
1
+ #! /usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "gemsmith"
5
+
6
+ Gemsmith::CLI::Shell.new.call ARGV
data/gemsmith.gemspec ADDED
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "gemsmith"
5
+ spec.version = "16.0.0"
6
+ spec.platform = Gem::Platform::RUBY
7
+ spec.authors = ["Brooke Kuhlmann"]
8
+ spec.email = ["brooke@alchemists.io"]
9
+ spec.homepage = "https://www.alchemists.io/projects/gemsmith"
10
+ spec.summary = "A command line interface for smithing Ruby gems."
11
+ spec.license = "Hippocratic-3.0"
12
+
13
+ spec.metadata = {
14
+ "bug_tracker_uri" => "https://github.com/bkuhlmann/gemsmith/issues",
15
+ "changelog_uri" => "https://www.alchemists.io/projects/gemsmith/versions",
16
+ "documentation_uri" => "https://www.alchemists.io/projects/gemsmith",
17
+ "label" => "Gemsmith",
18
+ "rubygems_mfa_required" => "true",
19
+ "source_code_uri" => "https://github.com/bkuhlmann/gemsmith"
20
+ }
21
+
22
+ spec.signing_key = Gem.default_key_path
23
+ spec.cert_chain = [Gem.default_cert_path]
24
+
25
+ spec.required_ruby_version = "~> 3.1"
26
+ spec.add_dependency "dry-container", "~> 0.9"
27
+ spec.add_dependency "dry-monads", "~> 1.4"
28
+ spec.add_dependency "milestoner", "~> 13.0"
29
+ spec.add_dependency "pastel", "~> 0.8"
30
+ spec.add_dependency "refinements", "~> 9.1"
31
+ spec.add_dependency "rubysmith", "~> 1.2"
32
+ spec.add_dependency "runcom", "~> 8.0"
33
+ spec.add_dependency "versionaire", "~> 10.0"
34
+ spec.add_dependency "zeitwerk", "~> 2.5"
35
+
36
+ spec.bindir = "exe"
37
+ spec.executables << "gemsmith"
38
+ spec.extra_rdoc_files = Dir["README*", "LICENSE*"]
39
+ spec.files = Dir.glob ["*.gemspec", "lib/**/*"], File::FNM_DOTMATCH
40
+ spec.require_paths = ["lib"]
41
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+
5
+ module Gemsmith
6
+ module Builders
7
+ # Builds project skeleton with Gemfile configuration.
8
+ class Bundler
9
+ using Refinements::Structs
10
+
11
+ def self.call(...) = new(...).call
12
+
13
+ def initialize configuration, builder: Rubysmith::Builder
14
+ @configuration = configuration
15
+ @builder = builder
16
+ end
17
+
18
+ def call
19
+ builder.call(configuration.merge(template_path: "%project_name%/Gemfile.erb"))
20
+ .insert_after("source", "\ngemspec\n")
21
+ .replace(/spec\n\n\Z/m, "spec\n")
22
+ .replace(/.+refinements.+/, "")
23
+ .replace(/.+zeitwerk.+/, "")
24
+ .replace("\n\n\n\n", "\n")
25
+
26
+ configuration
27
+ end
28
+
29
+ private
30
+
31
+ attr_reader :configuration, :builder
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+
5
+ module Gemsmith
6
+ module Builders
7
+ # Builds project skeleton CLI templates.
8
+ class CLI
9
+ using Refinements::Structs
10
+
11
+ def self.call(...) = new(...).call
12
+
13
+ def initialize configuration, builder: Rubysmith::Builder
14
+ @configuration = configuration
15
+ @builder = builder
16
+ end
17
+
18
+ def call
19
+ return configuration unless configuration.build_cli
20
+
21
+ render
22
+ configuration
23
+ end
24
+
25
+ private
26
+
27
+ attr_reader :configuration, :builder
28
+
29
+ def render = private_methods.sort.grep(/render_/).each { |method| __send__ method }
30
+
31
+ def render_exe
32
+ builder.call(configuration.merge(template_path: "%project_name%/exe/%project_name%.erb"))
33
+ .render
34
+ .permit 0o755
35
+ end
36
+
37
+ def render_core
38
+ content = configuration.merge template_path: "%project_name%/lib/%project_path%.rb.erb"
39
+
40
+ builder.call(content)
41
+ .insert_after(/push_dir/, %( loader.inflector.inflect "cli" => "CLI"\n))
42
+ .replace("Zeitwerk::Loader.for_gem.setup", <<~CONTENT.strip)
43
+ Zeitwerk::Loader.for_gem.then do |loader|
44
+ loader.inflector.inflect "cli" => "CLI"
45
+ loader.setup
46
+ end
47
+ CONTENT
48
+ end
49
+
50
+ def render_library
51
+ [
52
+ "%project_name%/lib/%project_path%/cli/actions/config.rb.erb",
53
+ "%project_name%/lib/%project_path%/cli/parser.rb.erb",
54
+ "%project_name%/lib/%project_path%/cli/parsers/core.rb.erb",
55
+ "%project_name%/lib/%project_path%/cli/shell.rb.erb",
56
+ "%project_name%/lib/%project_path%/configuration/content.rb.erb",
57
+ "%project_name%/lib/%project_path%/configuration/defaults.yml.erb",
58
+ "%project_name%/lib/%project_path%/configuration/loader.rb.erb",
59
+ "%project_name%/lib/%project_path%/container.rb.erb"
60
+ ].each { |path| builder.call(configuration.merge(template_path: path)).render }
61
+ end
62
+
63
+ def render_specs
64
+ return unless configuration.build_rspec
65
+
66
+ [
67
+ "%project_name%/spec/lib/%project_path%/cli/actions/config_spec.rb.erb",
68
+ "%project_name%/spec/lib/%project_path%/cli/parser_spec.rb.erb",
69
+ "%project_name%/spec/lib/%project_path%/cli/parsers/core_spec.rb.erb",
70
+ "%project_name%/spec/lib/%project_path%/cli/shell_spec.rb.erb",
71
+ "%project_name%/spec/lib/%project_path%/configuration/content_spec.rb.erb",
72
+ "%project_name%/spec/lib/%project_path%/configuration/loader_spec.rb.erb"
73
+ ].each { |path| builder.call(configuration.merge(template_path: path)).render }
74
+ end
75
+
76
+ def render_rspec_support
77
+ return unless configuration.build_rspec
78
+
79
+ [
80
+ "%project_name%/spec/support/shared_contexts/application_container.rb.erb",
81
+ "%project_name%/spec/support/shared_examples/a_parser.rb.erb"
82
+ ].each { |path| builder.call(configuration.merge(template_path: path)).render }
83
+ end
84
+ end
85
+ end
86
+ end