gemsmith 15.4.0 → 16.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/LICENSE.adoc +207 -155
  4. data/README.adoc +179 -196
  5. data/exe/gemsmith +6 -0
  6. data/gemsmith.gemspec +40 -0
  7. data/lib/gemsmith/builders/bundler.rb +34 -0
  8. data/lib/gemsmith/builders/cli.rb +86 -0
  9. data/lib/gemsmith/builders/documentation/readme.rb +37 -0
  10. data/lib/gemsmith/builders/git/commit.rb +46 -0
  11. data/lib/gemsmith/builders/git/ignore.rb +37 -0
  12. data/lib/gemsmith/builders/rspec/helper.rb +47 -0
  13. data/lib/gemsmith/builders/specification.rb +35 -0
  14. data/lib/gemsmith/cli/actions/build.rb +54 -0
  15. data/lib/gemsmith/cli/actions/config.rb +35 -0
  16. data/lib/gemsmith/cli/actions/edit.rb +39 -0
  17. data/lib/gemsmith/cli/actions/install.rb +37 -0
  18. data/lib/gemsmith/cli/actions/publish.rb +37 -0
  19. data/lib/gemsmith/cli/actions/view.rb +39 -0
  20. data/lib/gemsmith/cli/parser.rb +33 -0
  21. data/lib/gemsmith/cli/parsers/build.rb +54 -0
  22. data/lib/gemsmith/cli/parsers/core.rb +94 -0
  23. data/lib/gemsmith/cli/shell.rb +66 -0
  24. data/lib/gemsmith/configuration/enhancers/template_root.rb +20 -0
  25. data/lib/gemsmith/configuration/loader.rb +50 -0
  26. data/lib/gemsmith/container.rb +22 -0
  27. data/lib/gemsmith/gems/finder.rb +23 -0
  28. data/lib/gemsmith/gems/loader.rb +23 -0
  29. data/lib/gemsmith/gems/picker.rb +45 -0
  30. data/lib/gemsmith/gems/presenter.rb +52 -0
  31. data/lib/gemsmith/templates/%project_name%/%project_name%.gemspec.erb +50 -0
  32. data/lib/gemsmith/templates/%project_name%/exe/%project_name%.erb +5 -0
  33. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/actions/config.rb.erb +35 -0
  34. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/parser.rb.erb +31 -0
  35. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/parsers/core.rb.erb +59 -0
  36. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/shell.rb.erb +40 -0
  37. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/configuration/content.rb.erb +18 -0
  38. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/configuration/defaults.yml.erb +0 -0
  39. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/configuration/loader.rb.erb +33 -0
  40. data/lib/gemsmith/templates/%project_name%/lib/%project_path%/container.rb.erb +37 -0
  41. data/lib/gemsmith/templates/{%gem_name%/lib/%gem_path%/identity.rb.tt → %project_name%/lib/%project_path%/identity.rb.erb} +1 -1
  42. data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/actions/config_spec.rb.erb +24 -0
  43. data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/parser_spec.rb.erb +25 -0
  44. data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/parsers/core_spec.rb.erb +53 -0
  45. data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/shell_spec.rb.erb +43 -0
  46. data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/configuration/content_spec.rb.erb +15 -0
  47. data/lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/configuration/loader_spec.rb.erb +29 -0
  48. data/lib/gemsmith/templates/%project_name%/spec/support/shared_contexts/application_container.rb.erb +22 -0
  49. data/lib/gemsmith/templates/%project_name%/spec/support/shared_examples/a_parser.rb.erb +7 -0
  50. data/lib/gemsmith/tools/cleaner.rb +29 -0
  51. data/lib/gemsmith/tools/editor.rb +30 -0
  52. data/lib/gemsmith/tools/installer.rb +39 -0
  53. data/lib/gemsmith/tools/packager.rb +33 -0
  54. data/lib/gemsmith/tools/publisher.rb +34 -0
  55. data/lib/gemsmith/tools/pusher.rb +36 -0
  56. data/lib/gemsmith/tools/validator.rb +28 -0
  57. data/lib/gemsmith/tools/versioner.rb +43 -0
  58. data/lib/gemsmith/tools/viewer.rb +28 -0
  59. data/lib/gemsmith.rb +11 -32
  60. data.tar.gz.sig +0 -0
  61. metadata +101 -100
  62. metadata.gz.sig +0 -0
  63. data/bin/gemsmith +0 -9
  64. data/lib/gemsmith/authenticators/basic.rb +0 -28
  65. data/lib/gemsmith/authenticators/ruby_gems.rb +0 -41
  66. data/lib/gemsmith/cli.rb +0 -259
  67. data/lib/gemsmith/credentials.rb +0 -82
  68. data/lib/gemsmith/errors/base.rb +0 -9
  69. data/lib/gemsmith/errors/requirement_conversion.rb +0 -9
  70. data/lib/gemsmith/errors/requirement_operator.rb +0 -9
  71. data/lib/gemsmith/errors/specification.rb +0 -9
  72. data/lib/gemsmith/gem/inspector.rb +0 -30
  73. data/lib/gemsmith/gem/module_formatter.rb +0 -50
  74. data/lib/gemsmith/gem/requirement.rb +0 -55
  75. data/lib/gemsmith/gem/specification.rb +0 -74
  76. data/lib/gemsmith/generators/base.rb +0 -46
  77. data/lib/gemsmith/generators/bundler.rb +0 -19
  78. data/lib/gemsmith/generators/bundler_audit.rb +0 -15
  79. data/lib/gemsmith/generators/circle_ci.rb +0 -14
  80. data/lib/gemsmith/generators/cli.rb +0 -17
  81. data/lib/gemsmith/generators/documentation.rb +0 -36
  82. data/lib/gemsmith/generators/engine.rb +0 -77
  83. data/lib/gemsmith/generators/gem.rb +0 -29
  84. data/lib/gemsmith/generators/git.rb +0 -45
  85. data/lib/gemsmith/generators/git_hub.rb +0 -15
  86. data/lib/gemsmith/generators/git_lint.rb +0 -14
  87. data/lib/gemsmith/generators/guard.rb +0 -14
  88. data/lib/gemsmith/generators/pragma.rb +0 -49
  89. data/lib/gemsmith/generators/rake.rb +0 -81
  90. data/lib/gemsmith/generators/reek.rb +0 -17
  91. data/lib/gemsmith/generators/rspec.rb +0 -39
  92. data/lib/gemsmith/generators/rubocop.rb +0 -18
  93. data/lib/gemsmith/generators/ruby.rb +0 -12
  94. data/lib/gemsmith/helpers/cli.rb +0 -59
  95. data/lib/gemsmith/helpers/template.rb +0 -30
  96. data/lib/gemsmith/identity.rb +0 -12
  97. data/lib/gemsmith/rake/builder.rb +0 -57
  98. data/lib/gemsmith/rake/publisher.rb +0 -87
  99. data/lib/gemsmith/rake/setup.rb +0 -4
  100. data/lib/gemsmith/rake/tasks.rb +0 -83
  101. data/lib/gemsmith/templates/%gem_name%/%gem_name%.gemspec.tt +0 -44
  102. data/lib/gemsmith/templates/%gem_name%/.circleci/config.yml.tt +0 -31
  103. data/lib/gemsmith/templates/%gem_name%/.github/ISSUE_TEMPLATE.md.tt +0 -14
  104. data/lib/gemsmith/templates/%gem_name%/.github/PULL_REQUEST_TEMPLATE.md.tt +0 -11
  105. data/lib/gemsmith/templates/%gem_name%/.gitignore.tt +0 -6
  106. data/lib/gemsmith/templates/%gem_name%/.reek.yml.tt +0 -6
  107. data/lib/gemsmith/templates/%gem_name%/.rubocop.yml.tt +0 -15
  108. data/lib/gemsmith/templates/%gem_name%/.ruby-version.tt +0 -1
  109. data/lib/gemsmith/templates/%gem_name%/CHANGES.md.tt +0 -3
  110. data/lib/gemsmith/templates/%gem_name%/CODE_OF_CONDUCT.md.tt +0 -66
  111. data/lib/gemsmith/templates/%gem_name%/CONTRIBUTING.md.tt +0 -22
  112. data/lib/gemsmith/templates/%gem_name%/Gemfile.tt +0 -47
  113. data/lib/gemsmith/templates/%gem_name%/Guardfile.tt +0 -21
  114. data/lib/gemsmith/templates/%gem_name%/LICENSE.md.tt +0 -20
  115. data/lib/gemsmith/templates/%gem_name%/README.md.tt +0 -93
  116. data/lib/gemsmith/templates/%gem_name%/Rakefile.tt +0 -12
  117. data/lib/gemsmith/templates/%gem_name%/bin/%gem_name%.tt +0 -8
  118. data/lib/gemsmith/templates/%gem_name%/bin/console.tt +0 -10
  119. data/lib/gemsmith/templates/%gem_name%/bin/setup.tt +0 -8
  120. data/lib/gemsmith/templates/%gem_name%/lib/%gem_path%/cli.rb.tt +0 -61
  121. data/lib/gemsmith/templates/%gem_name%/lib/%gem_path%/engine.rb.tt +0 -6
  122. data/lib/gemsmith/templates/%gem_name%/lib/%gem_path%.rb.tt +0 -7
  123. data/lib/gemsmith/templates/%gem_name%/lib/generators/%gem_path%/install/USAGE.tt +0 -8
  124. data/lib/gemsmith/templates/%gem_name%/lib/generators/%gem_path%/install/install_generator.rb.tt +0 -12
  125. data/lib/gemsmith/templates/%gem_name%/lib/generators/%gem_path%/upgrade/USAGE.tt +0 -8
  126. data/lib/gemsmith/templates/%gem_name%/lib/generators/%gem_path%/upgrade/upgrade_generator.rb.tt +0 -10
  127. data/lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt +0 -81
  128. data/lib/gemsmith/templates/%gem_name%/spec/rails_helper.rb.tt +0 -14
  129. data/lib/gemsmith/templates/%gem_name%/spec/spec_helper.rb.tt +0 -37
  130. data/lib/gemsmith/templates/%gem_name%/spec/support/shared_contexts/temp_dir.rb.tt +0 -9
data/README.adoc CHANGED
@@ -4,63 +4,27 @@
4
4
 
5
5
  = Gemsmith
6
6
 
7
- [link=http://badge.fury.io/rb/gemsmith]
8
- image::https://badge.fury.io/rb/gemsmith.svg[Gem Version]
9
- [link=https://www.alchemists.io/projects/code_quality]
10
- image::https://img.shields.io/badge/code_style-alchemists-brightgreen.svg[Alchemists Style Guide]
11
- [link=https://circleci.com/gh/bkuhlmann/gemsmith]
12
- image::https://circleci.com/gh/bkuhlmann/gemsmith.svg?style=svg[Circle CI Status]
13
-
14
- A command line interface for smithing Ruby gems.
7
+ Gemsmith is a command line interface for smithing Ruby gems. Perfect for when you need a
8
+ professional and robust tool beyond link:https://bundler.io[Bundler]'s basic gem skeletons. While
9
+ Bundler is great for creating your first gem, you'll quickly outgrow Bundler when creating and
10
+ maintaining multiple gems. This is where Gemsmith can increase your productivity by providing much
11
+ of the tooling you need from the start with the ability to customize as desired.
15
12
 
16
13
  toc::[]
17
14
 
18
15
  == Features
19
16
 
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]
17
+ * Supports all features provided by link:https://www.alchemists.io/projects/rubysmith[Rubysmith]
18
+ which is used for smithing Ruby projects.
19
+ * Supports basic gem skeletons or more advanced Command Line Interface (CLI) skeletons.
20
+ * Supports gem building, installing for local development, and publishing.
21
+ * Supports the editing and viewing of installed gems.
57
22
 
58
23
  == Requirements
59
24
 
60
25
  . A UNIX-based system.
61
26
  . link:https://www.ruby-lang.org[Ruby].
62
27
  . link:https://rubygems.org[RubyGems].
63
- . link:https://github.com/bundler/bundler[Bundler].
64
28
 
65
29
  == Setup
66
30
 
@@ -78,74 +42,153 @@ gem install gemsmith
78
42
  From the command line, type: `gemsmith --help`
79
43
 
80
44
  ....
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.
45
+ USAGE:
46
+ -b, --build NAME [options] Build new project.
47
+ -c, --config ACTION Manage gem configuration: edit or view.
48
+ --edit GEM Edit installed gem in default editor.
49
+ -h, --help Show this message.
50
+ -i, --install [NAME] Install gem for local development.
51
+ -p, --publish [NAME] Publish gem to remote gem server.
52
+ -v, --version Show gem version.
53
+ --view GEM View installed gem in default browser.
54
+
55
+ BUILD OPTIONS:
56
+ --[no-]amazing_print Add Amazing Print gem. Default: true.
57
+ --[no-]bundler-leak Add Bundler Leak gem. Default: true.
58
+ --[no-]circle_ci Add Circle CI configuration and badge. Default: false.
59
+ --[no-]citation Add citation documentation. Default: true.
60
+ --[no-]community Add community documentation. Default: false.
61
+ --[no-]conduct Add code of conduct documentation. Default: true.
62
+ --[no-]console Add console script. Default: true.
63
+ --[no-]contributions Add contributions documentation. Default: true.
64
+ --[no-]dead_end Add Dead End gem. Default: true.
65
+ --[no-]debug Add Debug gem. Default: true.
66
+ --[no-]git Add Git. Default: true.
67
+ --[no-]git_hub Add GitHub templates. Default: false.
68
+ --[no-]git-lint Add Git Lint gem. Default: true.
69
+ --[no-]guard Add Guard gem. Default: true.
70
+ --[no-]license Add license documentation. Default: true.
71
+ --max Use maximum/enabled options. Default: false.
72
+ --min Use minimum/disabled options. Default: false.
73
+ --[no-]rake Add Rake gem. Default: true.
74
+ --[no-]readme Add readme documentation. Default: true.
75
+ --[no-]reek Add Reek gem. Default: true.
76
+ --[no-]refinements Add Refinements gem. Default: true.
77
+ --[no-]rspec Add RSpec gem. Default: true.
78
+ --[no-]rubocop Add RuboCop gems. Default: true.
79
+ --[no-]security Add security. Default: true.
80
+ --[no-]setup Add setup script. Default: true.
81
+ --[no-]simple_cov Add SimpleCov gem. Default: true.
82
+ --[no-]versions Add version history. Default: true.
83
+ --[no-]yard Add Yard gem. Default: false.
84
+ --[no-]zeitwerk Add Zeitwerk gem. Default: true.
85
+ --[no-]cli Add command line interface. Default: false.
87
86
  ....
88
87
 
89
- For more gem generation options, type: `gemsmith --help --generate`
88
+ === Build
90
89
 
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
- ....
90
+ The core functionality of this gem centers around the `--build` command and associated flags. The
91
+ build options allow you to further customize the kind of gem you want to build. Most build options
92
+ are enabled by default. For detailed documentation on all supported flags, see the
93
+ link:https://www.alchemists.io/projects/rubysmith/#_build[Rubysmith] documentation.
94
+
95
+ The build option, which is unique to Gemsmith, is the `--cli` option. This allows you to build a gem
96
+ which has a Command Line Interface (CLI). There are multiple ways a CLI can be built in Ruby but
97
+ Gemsmith takes an approach which builds upon Ruby's native `OptionParser` with help from
98
+ link:https://dry-rb.org/gems/dry-container[Dry Container]. All of this culminates in a design that
99
+ is mix of Objected Oriented + Functional Programming design. Building a gem with CLI support is a
100
+ simple as running:
114
101
 
115
- === Rake
102
+ [source,bash]
103
+ ----
104
+ gemsmith --build demo --cli
105
+ ----
116
106
 
117
- Once a gem skeleton has been created, the following tasks are available (i.e. `bundle exec rake
118
- -T`):
107
+ The above will give you a new gem with CLI support which includes working specs. It's the same
108
+ design used to build this Gemsmith gem. You'll have both a `configuration` and `CLI` namespace for
109
+ configuring your gem and adding additional CLI support. Out of the box, the CLI gem generated for
110
+ you supports the following options:
119
111
 
120
112
  ....
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)
113
+ -c, --config ACTION Manage gem configuration: edit or view.
114
+ -h, --help Show this message.
115
+ -v, --version Show gem version.
133
116
  ....
134
117
 
135
- _NOTE: Some tasks might differ depending on what options you enabled/disabled during gem
136
- generation._
118
+ From here you can add whatever you wish to make an awesome CLI gem for others to enjoy.
137
119
 
138
- When building/testing your gem locally, a typical workflow is:
120
+ === Install
139
121
 
140
- . `bundle exec rake install`
141
- . Test your gem locally.
142
- . Repeat until satisfied.
122
+ After you've designed, implemented, and built your gem, you'll want to test it out within your local
123
+ environment by installing it. You can do this by running:
143
124
 
144
- When satified with your gem, builds are green, and ready to publish, run:
125
+ [source,bash]
126
+ ----
127
+ # Implicit
128
+ gemsmith --install
145
129
 
146
- ....
147
- bundle exec rake publish
148
- ....
130
+ # Explicit
131
+ gemsmith --install demo
132
+ ----
133
+
134
+ Gemsmith can be used to install any gem, in fact. Doesn't matter if the gem was built by Gemsmith,
135
+ Bundler, or some other tool. As long as your gem has a `*.gemspec` file, Gemsmith will be able to
136
+ install it.
137
+
138
+ === Publish
139
+
140
+ Once you've built your gem; installed it locally; and thoroughly tested it, you'll want to publish
141
+ your gem so anyone in the world can make use of it. You can do this by running the following:
142
+
143
+ [source,bash]
144
+ ----
145
+ # Implicit
146
+ gemsmith --publish
147
+
148
+ # Explicit
149
+ gemsmith --publish demo
150
+ ----
151
+
152
+ Security is important which requires a GPG key for signing your Git tags and
153
+ link:https://www.alchemists.io/articles/ruby_gems_multi_factor_authentication/[RubyGems Multi-Factor
154
+ Authentication] for publishing to RubyGems. Both of which are enabled by default. You'll want to
155
+ read through the linked article which delves into how Gemsmith automatically makes use of your
156
+ YubiKey to authenticate with RubyGems. Spending the time to set this up will allow Gemsmith to use
157
+ of your YubiKey for effortless and secure publishing of new versions of your gems so I highly
158
+ recommend doing this.
159
+
160
+ As with installing a gem, Gemsmith can be used to publish existing gems which were not built by
161
+ Gemsmith too. As long as your gem has a `*.gemspec` file with a valid version, Gemsmith will be able
162
+ to publish it.
163
+
164
+ === Edit
165
+
166
+ Gemsmith can be used to edit existing gems on your local system. You can do this by running:
167
+
168
+ [source,bash]
169
+ ----
170
+ gemsmith --edit <name of gem>
171
+ ----
172
+
173
+ If multiple versions of the same gem are detected, you'll be prompted to pick which gem you want to
174
+ edit. Otherwise, the gem will immediately be opened within your default editor (or whatever you
175
+ have set in your `EDITOR` environment variable).
176
+
177
+ Editing a local gem is a great way to learn from others or quickly debug issues.
178
+
179
+ === View
180
+
181
+ Gemsmith can be used to view existing gem documentation. You can do this by running:
182
+
183
+ [source,bash]
184
+ ----
185
+ gemsmith --view <name of gem>
186
+ ----
187
+
188
+ If multiple versions of the same gem are detected, you'll be prompted to pick which gem you want to
189
+ view. Otherwise, the gem will immediately be opened within your default browser.
190
+
191
+ Viewing a gem is a great way to learn more about the gem and documentation in general.
149
192
 
150
193
  === Configuration
151
194
 
@@ -155,82 +198,42 @@ This gem can be configured via a global configuration:
155
198
  $HOME/.config/gemsmith/configuration.yml
156
199
  ....
157
200
 
158
- It can also be configured via link:https://www.alchemists.io/projects/xdg[XDG] environment variables.
201
+ It can also be configured via link:https://www.alchemists.io/projects/xdg[XDG] environment
202
+ variables.
159
203
 
160
- The default configuration is as follows:
204
+ The default configuration is everything provided in the
205
+ link:https://www.alchemists.io/projects/rubysmith/#_configuration[Rubysmith] with the addition of
206
+ the following:
161
207
 
162
208
  [source,yaml]
163
209
  ----
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
210
+ :build:
187
211
  :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
212
  ----
201
213
 
202
- Feel free to take this default configuration, modify, and save as your own custom
203
- `configuration.yml`.
204
-
205
- === Existing Gems
214
+ Feel free to take the combined Rubysmith + Gemsmith configuration, modify, and save as your own
215
+ custom `configuration.yml`.
206
216
 
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:
217
+ === Workflows
209
218
 
210
- Add the following to your gem's `.gemspec` file:
219
+ When building/testing your gem locally, a typical workflow is:
211
220
 
212
- [source,ruby]
213
- ----
214
- spec.add_development_dependency "gemsmith"
221
+ [source,bash]
215
222
  ----
223
+ # Build
224
+ gemsmith --build demo
216
225
 
217
- Replace or add a modified version of the following to your gem's `Rakefile`:
226
+ # Design, Implement and Test.
227
+ cd demo
228
+ bundle exec rake
218
229
 
219
- [source,ruby]
220
- ----
221
- # frozen_string_literal: true
230
+ # Install
231
+ gemsmith --install
222
232
 
223
- begin
224
- require "gemsmith/rake/setup"
225
- rescue LoadError => error
226
- puts error.message
227
- end
233
+ # Publish
234
+ gemsmith --publish
228
235
  ----
229
236
 
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
237
  == Security
235
238
 
236
239
  === Git Signing Key
@@ -267,8 +270,7 @@ Add your key to your global Git configuration in the `[user]` section. Example:
267
270
  ....
268
271
 
269
272
  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.
273
+ tag will happen automatically.
272
274
 
273
275
  === Gem Certificates
274
276
 
@@ -293,12 +295,12 @@ By default, the following Rake task will publish your gem to link:https://rubyge
293
295
 
294
296
  [source,bash]
295
297
  ----
296
- bundle exec rake publish
298
+ gemsmith --publish
297
299
  ----
298
300
 
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.
301
+ You can change this behavior by adding metadata to your gemspec that will allow Gemsmith to publish
302
+ your gem to an alternate/private gem server instead. This can be done by updating your gem
303
+ specification and RubyGems credentials.
302
304
 
303
305
  === Gem Specification Metadata
304
306
 
@@ -334,7 +336,7 @@ Example:
334
336
  [source,yaml]
335
337
  ----
336
338
  :rubygems_api_key: 2a0b460650e67d9b85a60e183defa376
337
- :example_key: "Basic dXNlcjpwYXNzd29yZA=="
339
+ :some_custom_key: "Basic dXNlcjpwYXNzd29yZA=="
338
340
  ----
339
341
 
340
342
  Should you need to delete a credential (due to a bad login/password for example), you can open the
@@ -346,20 +348,14 @@ publish of your gem, you'll be prompted for the missing credentials.
346
348
  Once your gem is released, let the world know about your accomplishment by posting an update to
347
349
  these sites:
348
350
 
349
- * link:http://www.rubyflow.com[RubyFlow]
351
+ * link:https://rubyflow.com[RubyFlow]
352
+ * link:https://rubyradar.dev[Ruby Radar]
350
353
  * link:https://ruby.libhunt.com[Ruby Library Hunt]
351
- * link:http://rubydaily.org[RubyDaily]
354
+ * link:https://rubydaily.org[RubyDaily]
352
355
  * link:https://awesome-ruby.com[Awesome Ruby]
353
356
  * link:https://www.ruby-toolbox.com[Ruby Toolbox]
354
357
  * link:https://www.ruby-lang.org/en/community[Ruby Community]
355
358
 
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
359
  == Development
364
360
 
365
361
  To contribute, run:
@@ -387,30 +383,17 @@ To test, run:
387
383
  bundle exec rake
388
384
  ----
389
385
 
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
386
+ == link:https://www.alchemists.io/policies/license[License]
404
387
 
405
- Read link:CONTRIBUTING.adoc[CONTRIBUTING] for details.
388
+ == link:https://www.alchemists.io/policies/security[Security]
406
389
 
407
- == License
390
+ == link:https://www.alchemists.io/policies/code_of_conduct[Code of Conduct]
408
391
 
409
- Read link:LICENSE.adoc[LICENSE] for details.
392
+ == link:https://www.alchemists.io/policies/contributions[Contributions]
410
393
 
411
- == History
394
+ == link:https://www.alchemists.io/projects/gemsmith/versions[Versions]
412
395
 
413
- Read link:CHANGES.adoc[CHANGES] for details.
396
+ == link:https://www.alchemists.io/community[Community]
414
397
 
415
398
  == Credits
416
399
 
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,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "gemsmith"
5
+ spec.version = "16.2.0"
6
+ spec.authors = ["Brooke Kuhlmann"]
7
+ spec.email = ["brooke@alchemists.io"]
8
+ spec.homepage = "https://www.alchemists.io/projects/gemsmith"
9
+ spec.summary = "A command line interface for smithing Ruby gems."
10
+ spec.license = "Hippocratic-3.0"
11
+
12
+ spec.metadata = {
13
+ "bug_tracker_uri" => "https://github.com/bkuhlmann/gemsmith/issues",
14
+ "changelog_uri" => "https://www.alchemists.io/projects/gemsmith/versions",
15
+ "documentation_uri" => "https://www.alchemists.io/projects/gemsmith",
16
+ "label" => "Gemsmith",
17
+ "rubygems_mfa_required" => "true",
18
+ "source_code_uri" => "https://github.com/bkuhlmann/gemsmith"
19
+ }
20
+
21
+ spec.signing_key = Gem.default_key_path
22
+ spec.cert_chain = [Gem.default_cert_path]
23
+
24
+ spec.required_ruby_version = "~> 3.1"
25
+ spec.add_dependency "dry-container", "~> 0.9"
26
+ spec.add_dependency "dry-monads", "~> 1.4"
27
+ spec.add_dependency "milestoner", "~> 13.0"
28
+ spec.add_dependency "pastel", "~> 0.8"
29
+ spec.add_dependency "refinements", "~> 9.1"
30
+ spec.add_dependency "rubysmith", "~> 1.3"
31
+ spec.add_dependency "runcom", "~> 8.2"
32
+ spec.add_dependency "spek", "~> 0.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
+ 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