rubysmith 0.9.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.adoc +13 -11
  4. data/bin/rubysmith +0 -1
  5. data/lib/rubysmith/builder.rb +15 -27
  6. data/lib/rubysmith/builders/bundler.rb +7 -9
  7. data/lib/rubysmith/builders/console.rb +6 -8
  8. data/lib/rubysmith/builders/core.rb +9 -8
  9. data/lib/rubysmith/builders/documentation.rb +16 -21
  10. data/lib/rubysmith/builders/git/commit.rb +7 -11
  11. data/lib/rubysmith/builders/git/setup.rb +6 -8
  12. data/lib/rubysmith/builders/guard.rb +9 -9
  13. data/lib/rubysmith/builders/pragma.rb +8 -13
  14. data/lib/rubysmith/builders/rake.rb +7 -7
  15. data/lib/rubysmith/builders/reek.rb +6 -8
  16. data/lib/rubysmith/builders/rspec/context.rb +10 -11
  17. data/lib/rubysmith/builders/rspec/helper.rb +6 -8
  18. data/lib/rubysmith/builders/rubocop/formatter.rb +5 -7
  19. data/lib/rubysmith/builders/rubocop/setup.rb +7 -9
  20. data/lib/rubysmith/builders/setup.rb +8 -8
  21. data/lib/rubysmith/cli/configuration/content.rb +71 -0
  22. data/lib/rubysmith/cli/{defaults.yml → configuration/defaults.yml} +2 -2
  23. data/lib/rubysmith/cli/configuration/loader.rb +35 -0
  24. data/lib/rubysmith/cli/parsers/assembler.rb +10 -15
  25. data/lib/rubysmith/cli/parsers/build.rb +16 -19
  26. data/lib/rubysmith/cli/parsers/core.rb +5 -9
  27. data/lib/rubysmith/cli/parsers.rb +11 -0
  28. data/lib/rubysmith/cli/processors/build.rb +10 -12
  29. data/lib/rubysmith/cli/processors/config.rb +3 -7
  30. data/lib/rubysmith/cli/shell.rb +9 -17
  31. data/lib/rubysmith/identity.rb +2 -2
  32. data/lib/rubysmith/pathway.rb +3 -9
  33. data/lib/rubysmith/renderers/erb.rb +7 -9
  34. data/lib/rubysmith/renderers/namespace.rb +2 -4
  35. data/lib/rubysmith/templates/%project_name%/.rubocop.yml.erb +5 -5
  36. data/lib/rubysmith/templates/%project_name%/CHANGES.adoc.erb +1 -1
  37. data/lib/rubysmith/templates/%project_name%/CHANGES.md.erb +1 -1
  38. data/lib/rubysmith/templates/%project_name%/CODE_OF_CONDUCT.adoc.erb +2 -2
  39. data/lib/rubysmith/templates/%project_name%/CODE_OF_CONDUCT.md.erb +1 -1
  40. data/lib/rubysmith/templates/%project_name%/Gemfile.erb +25 -26
  41. data/lib/rubysmith/templates/%project_name%/LICENSE-apache.adoc.erb +1 -1
  42. data/lib/rubysmith/templates/%project_name%/LICENSE-apache.md.erb +1 -1
  43. data/lib/rubysmith/templates/%project_name%/LICENSE-mit.adoc.erb +1 -1
  44. data/lib/rubysmith/templates/%project_name%/LICENSE-mit.md.erb +1 -1
  45. data/lib/rubysmith/templates/%project_name%/README.adoc.erb +5 -5
  46. data/lib/rubysmith/templates/%project_name%/README.md.erb +5 -5
  47. data/lib/rubysmith/templates/%project_name%/Rakefile.erb +11 -23
  48. data/lib/rubysmith/templates/%project_name%/bin/console.erb +1 -1
  49. data/lib/rubysmith/templates/%project_name%/lib/%project_path%.rb.erb +13 -0
  50. data/lib/rubysmith/templates/%project_name%/spec/spec_helper.rb.erb +8 -3
  51. data/lib/rubysmith/templates/%project_name%/spec/support/shared_contexts/temp_dir.rb.erb +3 -3
  52. data/lib/rubysmith.rb +9 -30
  53. data.tar.gz.sig +0 -0
  54. metadata +34 -21
  55. metadata.gz.sig +0 -0
  56. data/lib/rubysmith/builders/ruby_critic.rb +0 -27
  57. data/lib/rubysmith/cli/configuration.rb +0 -30
  58. data/lib/rubysmith/realm.rb +0 -74
  59. data/lib/rubysmith/templates/%project_name%/.rubycritic.yml.erb +0 -3
  60. data/lib/rubysmith/templates/%project_name%/lib/%project_name%.rb.erb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35f0eea5be27d1e8a8e05430c6b99d80bfa02bbeabbc6e1148f4c7b388280a26
4
- data.tar.gz: ebce4666b017291222012d583ce61266cd15674bf6248199e6cff1700484d4fd
3
+ metadata.gz: 628bf912ecce44ded950cf18f54d54a3a8ca13430ccc300f7db53062da718716
4
+ data.tar.gz: cbefec98da88d0e1b6198789805eeed82ea6b5238bee41ca9341c7d6114ed84c
5
5
  SHA512:
6
- metadata.gz: be592ad7f91f4589ba1aac09b26a7ff875edbc36974559abdae1410e0e41342f08dd5ff24c6517ff63eb87af30491a86115c165c161a39bb3b6453f315230a13
7
- data.tar.gz: d245861a8bf50f49541dd9f0aae53007681905eebff6d561ac3a7a9d0fc70ccfa495233fa2f0764cb44313e8f2d0569130ef007e2d63468d587c455e9c3a8035
6
+ metadata.gz: 4b7bb2b58f60f60057c12e9f9358d720a10fe4825eefcefb8231d4998647c1d44523a550a05a2938b8d16536954ba2cb6f9fa3a4d5a484a0536f24420cb51991
7
+ data.tar.gz: 315a9e28cd8231629bb17fce77051f0fb42b86c25d1fb04245437333b20171c5b5dc40b1e3cbca33cce6c611761fea3ec31493a6dad2e34c56982a598e66785d
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -15,8 +15,11 @@ Rubysmith is a command line interface for smithing Ruby projects.
15
15
 
16
16
  This gem is useful in situations in which you need something more sophisticated than a
17
17
  link:https://bundler.io/guides/bundler_in_a_single_file_ruby_script.html[Bundler Inline] script but
18
- less complicated than a Ruby Gem as provided by
19
- link:https://www.alchemists.io/projects/gemsmith[Gemsmith].
18
+ less complicated than a link:https://www.alchemists.io/projects/gemsmith[Gemsmith] gem. Rubysmith is
19
+ the foundation of Gemsmith and provides a lot of the same functionality as Gemsmith but solely
20
+ tailored for pure Ruby projects. Again, this is a great tool for spiking quick Ruby implementations,
21
+ sharing code snippets with others, or building full blown Ruby projects for collaboration with
22
+ others.
20
23
 
21
24
  toc::[]
22
25
 
@@ -26,12 +29,12 @@ toc::[]
26
29
  * Uses link:https://www.alchemists.io/projects/runcom[Runcom] for resource configuration management.
27
30
  * Uses link:https://www.alchemists.io/projects/pragmater[Pragmater] for Ruby source pragma directives.
28
31
  * Supports link:https://github.com/amazing-print/amazing_print[Amazing Print].
29
- * Supports link:https://github.com/rubysec/bundler-audit[Bundler Audit].
30
32
  * Supports link:https://github.com/rubymem/bundler-leak[Bundler Leak].
31
33
  * Supports link:https://git-scm.com[Git].
32
34
  * Supports link:https://www.alchemists.io/projects/git-lint[Git Lint].
33
35
  * Supports link:https://github.com/guard/guard[Guard].
34
36
  * Supports link:http://pryrepl.org[Pry].
37
+ * Supports link:https://github.com/ruby/rake[Rake].
35
38
  * Supports link:https://github.com/troessner/reek[Reek].
36
39
  * Supports link:https://www.alchemists.io/projects/refinements[Refinements].
37
40
  * Supports link:https://rspec.info[RSpec].
@@ -39,7 +42,6 @@ toc::[]
39
42
  * Supports link:https://docs.rubocop.org/rubocop-performance[Rubocop Performance].
40
43
  * Supports link:https://github.com/rubocop-hq/rubocop-rake[Rubocop Rake].
41
44
  * Supports link:https://github.com/rubocop-hq/rubocop-rspec[Rubocop RSpec].
42
- * Supports link:https://github.com/whitesmith/RubyCritic[RubyCritic].
43
45
  * Supports link:https://github.com/simplecov-ruby/simplecov[SimpleCov].
44
46
  * Supports common settings and a structured layout for building projects.
45
47
  * Provides common documentation:
@@ -79,28 +81,28 @@ From the command line, type: `rubysmith --help`
79
81
  ....
80
82
  USAGE:
81
83
  -b, --build NAME [options] Build new project.
82
- -v, --version Show gem version.
83
- -h, --help Show this message.
84
84
  -c, --config ACTION Manage gem configuration: edit or view.
85
+ -h, --help Show this message.
86
+ -v, --version Show gem version.
85
87
 
86
88
  BUILD OPTIONS:
87
89
  --[no-]amazing_print Add Amazing Print.
88
- --[no-]bundler-audit Add Bundler Audit.
89
90
  --[no-]bundler-leak Add Bundler Leak.
90
91
  --[no-]console Add console script.
91
92
  --[no-]documentation Add documentation.
92
93
  --[no-]git Add Git.
93
94
  --[no-]git-lint Add Git Lint.
94
95
  --[no-]guard Add Guard.
96
+ --min Use minimum/no options.
95
97
  --[no-]pry Add Pry.
98
+ --[no-]rake Add Rake.
96
99
  --[no-]reek Add Reek.
97
100
  --[no-]refinements Add Refinements.
98
101
  --[no-]rspec Add RSpec.
99
102
  --[no-]rubocop Add Rubocop.
100
- --[no-]ruby_critic Add RubyCritic.
101
103
  --[no-]setup Add setup script.
102
104
  --[no-]simple_cov Add SimpleCov.
103
- --min Use minimum/no options.
105
+ --[no-]zeitwerk Add Zeitwerk.
104
106
  ....
105
107
 
106
108
  === Building
@@ -161,7 +163,6 @@ The default configuration is as follows:
161
163
  :license: "mit"
162
164
  :build:
163
165
  :amazing_print: true
164
- :bundler_audit: true
165
166
  :bundler_leak: true
166
167
  :console: true
167
168
  :documentation: true
@@ -170,13 +171,14 @@ The default configuration is as follows:
170
171
  :guard: true
171
172
  :minimum: false
172
173
  :pry: true
174
+ :rake: true
173
175
  :reek: true
174
176
  :refinements: true
175
177
  :rspec: true
176
178
  :rubocop: true
177
- :ruby_critic: true
178
179
  :setup: true
179
180
  :simple_cov: true
181
+ :zeitwerk: true
180
182
  :builders:
181
183
  :pragmater:
182
184
  :comments:
data/bin/rubysmith CHANGED
@@ -2,7 +2,6 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "rubysmith"
5
- require "rubysmith/cli/shell"
6
5
 
7
6
  Process.setproctitle Rubysmith::Identity::VERSION_LABEL
8
7
  Rubysmith::CLI::Shell.new.call ARGV
@@ -6,7 +6,7 @@ require "logger"
6
6
 
7
7
  module Rubysmith
8
8
  # :reek:TooManyMethods
9
- # rubocop:disable Metrics/ClassLength
9
+ # Provides common functionality necessary for all builders.
10
10
  class Builder
11
11
  using Refinements::Pathnames
12
12
 
@@ -19,12 +19,10 @@ module Rubysmith
19
19
  logger: LOGGER
20
20
  }.freeze
21
21
 
22
- def self.call realm, helpers: HELPERS
23
- new realm, helpers: helpers
24
- end
22
+ def self.call(...) = new(...)
25
23
 
26
- def initialize realm, helpers: HELPERS
27
- @realm = realm
24
+ def initialize configuration, helpers: HELPERS
25
+ @configuration = configuration
28
26
  @helpers = helpers
29
27
  end
30
28
 
@@ -102,7 +100,7 @@ module Rubysmith
102
100
 
103
101
  private
104
102
 
105
- attr_reader :realm, :helpers
103
+ attr_reader :configuration, :helpers
106
104
 
107
105
  def execute *command
108
106
  kernel.capture2e(*command).then do |result, status|
@@ -110,33 +108,23 @@ module Rubysmith
110
108
  end
111
109
  end
112
110
 
113
- def inserter
114
- helpers.fetch __method__
115
- end
111
+ def inserter = helpers.fetch(__method__)
116
112
 
117
- def renderer
118
- helpers.fetch(__method__).new realm
119
- end
113
+ def renderer = helpers.fetch(__method__).new(configuration)
120
114
 
121
- def kernel
122
- helpers.fetch __method__
123
- end
115
+ def kernel = helpers.fetch(__method__)
124
116
 
125
- def logger
126
- helpers.fetch __method__
127
- end
117
+ def logger = helpers.fetch(__method__)
128
118
 
129
- def relative_build_path
130
- build_path.relative_path_from realm.build_root
131
- end
119
+ def relative_build_path = build_path.relative_path_from(configuration.build_root)
132
120
 
133
121
  def build_path
134
- pathway.end_path.gsub("%project_name%", realm.project_name).sub(".erb", "")
122
+ pathway.end_path
123
+ .gsub("%project_name%", configuration.project_name)
124
+ .sub("%project_path%", configuration.project_path)
125
+ .sub ".erb", ""
135
126
  end
136
127
 
137
- def pathway
138
- realm.to_pathway
139
- end
128
+ def pathway = configuration.to_pathway
140
129
  end
141
- # rubocop:enable Metrics/ClassLength
142
130
  end
@@ -10,33 +10,31 @@ module Rubysmith
10
10
  class Bundler
11
11
  using Refinements::Pathnames
12
12
 
13
- def self.call realm, builder: Builder
14
- new(realm, builder: builder).call
15
- end
13
+ def self.call(...) = new(...).call
16
14
 
17
- def initialize realm, builder: Builder, client: ::Bundler::CLI
18
- @realm = realm
15
+ def initialize configuration, builder: Builder, client: ::Bundler::CLI
16
+ @configuration = configuration
19
17
  @builder = builder
20
18
  @client = client
21
19
  end
22
20
 
23
21
  def call
24
- builder.call(realm.with(template_path: "%project_name%/Gemfile.erb"))
22
+ builder.call(configuration.with(template_path: "%project_name%/Gemfile.erb"))
25
23
  .render
26
24
  .replace(/\n\s+group/, "\n\ngroup")
27
25
  .replace(/\n\s+gem/, "\n gem")
28
- .replace(/ (?=.+refinements)/, "")
26
+ .replace(/ (?=.+(refinements|zeitwerk))/, "")
29
27
  .replace(/(\n+|\s+)end/, "\nend")
30
28
  .replace(/\n\ngroup :(code_quality|test|tools) do\nend/, "")
31
29
  .replace(/org"\n+/, "org\"\n\n")
32
30
 
33
- realm.project_root.change_dir { client.start %w[install --quiet] }
31
+ configuration.project_root.change_dir { client.start %w[install --quiet] }
34
32
  nil
35
33
  end
36
34
 
37
35
  private
38
36
 
39
- attr_reader :realm, :builder, :client
37
+ attr_reader :configuration, :builder, :client
40
38
  end
41
39
  end
42
40
  end
@@ -4,26 +4,24 @@ module Rubysmith
4
4
  module Builders
5
5
  # Builds project skeleton console for object inspection and exploration.
6
6
  class Console
7
- def self.call realm, builder: Builder
8
- new(realm, builder: builder).call
9
- end
7
+ def self.call(...) = new(...).call
10
8
 
11
- def initialize realm, builder: Builder
12
- @realm = realm
9
+ def initialize configuration, builder: Builder
10
+ @configuration = configuration
13
11
  @builder = builder
14
12
  end
15
13
 
16
14
  def call
17
- return unless realm.build_console
15
+ return unless configuration.build_console
18
16
 
19
- builder.call(realm.with(template_path: "%project_name%/bin/console.erb"))
17
+ builder.call(configuration.with(template_path: "%project_name%/bin/console.erb"))
20
18
  .render
21
19
  .permit 0o755
22
20
  end
23
21
 
24
22
  private
25
23
 
26
- attr_reader :realm, :builder
24
+ attr_reader :configuration, :builder
27
25
  end
28
26
  end
29
27
  end
@@ -4,24 +4,25 @@ module Rubysmith
4
4
  module Builders
5
5
  # Builds project skeleton core structure and minimum file support.
6
6
  class Core
7
- def self.call realm, builder: Builder
8
- new(realm, builder: builder).call
9
- end
7
+ def self.call(...) = new(...).call
10
8
 
11
- def initialize realm, builder: Builder
12
- @realm = realm
9
+ def initialize configuration, builder: Builder
10
+ @configuration = configuration
13
11
  @builder = builder
14
12
  end
15
13
 
16
14
  def call
17
- builder.call(realm.with(template_path: "%project_name%/lib/%project_name%.rb.erb")).render
18
- builder.call(realm.with(template_path: "%project_name%/.ruby-version.erb")).render
15
+ builder.call(configuration.with(template_path: "%project_name%/lib/%project_path%.rb.erb"))
16
+ .render
17
+ .replace(/ (?!(module|end))/, "")
18
+
19
+ builder.call(configuration.with(template_path: "%project_name%/.ruby-version.erb")).render
19
20
  nil
20
21
  end
21
22
 
22
23
  private
23
24
 
24
- attr_reader :realm, :builder
25
+ attr_reader :configuration, :builder
25
26
  end
26
27
  end
27
28
  end
@@ -4,59 +4,54 @@ module Rubysmith
4
4
  module Builders
5
5
  # Builds project skeleton documentation.
6
6
  class Documentation
7
- def self.call realm, builder: Builder
8
- new(realm, builder: builder).call
9
- end
7
+ def self.call(...) = new(...).call
10
8
 
11
- def initialize realm, builder: Builder
12
- @realm = realm
9
+ def initialize configuration, builder: Builder
10
+ @configuration = configuration
13
11
  @builder = builder
14
12
  end
15
13
 
16
14
  def call
17
- return unless realm.build_documentation
15
+ return unless configuration.build_documentation
18
16
 
19
17
  private_methods.sort.grep(/render_/).each { |method| __send__ method }
20
18
  end
21
19
 
22
20
  private
23
21
 
24
- attr_reader :realm, :builder
22
+ attr_reader :configuration, :builder
25
23
 
26
24
  def render_changes
27
- builder.call(realm.with(template_path: "%project_name%/CHANGES.#{kind}.erb"))
25
+ builder.call(configuration.with(template_path: "%project_name%/CHANGES.#{kind}.erb"))
28
26
  .render
29
27
  end
30
28
 
31
29
  def render_conduct
32
- builder.call(realm.with(template_path: "%project_name%/CODE_OF_CONDUCT.#{kind}.erb"))
33
- .render
30
+ configuration.with(template_path: "%project_name%/CODE_OF_CONDUCT.#{kind}.erb")
31
+ .then { |updated_configuration| builder.call(updated_configuration).render }
34
32
  end
35
33
 
36
34
  def render_contributions
37
- builder.call(realm.with(template_path: "%project_name%/CONTRIBUTING.#{kind}.erb"))
35
+ builder.call(configuration.with(template_path: "%project_name%/CONTRIBUTING.#{kind}.erb"))
38
36
  .render
39
37
  end
40
38
 
41
39
  def render_license
42
- builder.call(realm.with(template_path: "%project_name%/LICENSE-#{license}.#{kind}.erb"))
43
- .render
44
- .rename "LICENSE.#{kind}"
40
+ configuration.with(template_path: "%project_name%/LICENSE-#{license}.#{kind}.erb")
41
+ .then do |updated_configuration|
42
+ builder.call(updated_configuration).render.rename "LICENSE.#{kind}"
43
+ end
45
44
  end
46
45
 
47
46
  def render_readme
48
- builder.call(realm.with(template_path: "%project_name%/README.#{kind}.erb"))
47
+ builder.call(configuration.with(template_path: "%project_name%/README.#{kind}.erb"))
49
48
  .render
50
49
  .replace("\n\n\n", "\n\n")
51
50
  end
52
51
 
53
- def kind
54
- realm.documentation_format || "md"
55
- end
52
+ def kind = configuration.documentation_format || "md"
56
53
 
57
- def license
58
- realm.documentation_license || "mit"
59
- end
54
+ def license = configuration.documentation_license || "mit"
60
55
  end
61
56
  end
62
57
  end
@@ -5,19 +5,17 @@ module Rubysmith
5
5
  module Git
6
6
  # Builds project skeleton initial Git commit message.
7
7
  class Commit
8
- def self.call realm, builder: Builder
9
- new(realm, builder: builder).call
10
- end
8
+ def self.call(...) = new(...).call
11
9
 
12
- def initialize realm, builder: Builder
13
- @realm = realm
10
+ def initialize configuration, builder: Builder
11
+ @configuration = configuration
14
12
  @builder = builder
15
13
  end
16
14
 
17
15
  def call
18
- return unless realm.build_git
16
+ return unless configuration.build_git
19
17
 
20
- builder.call(realm)
18
+ builder.call(configuration)
21
19
  .run("git add .", chdir: project_name)
22
20
  .run(
23
21
  %(git commit --all --message "Added project skeleton" --message "#{body}"),
@@ -27,7 +25,7 @@ module Rubysmith
27
25
 
28
26
  private
29
27
 
30
- attr_reader :realm, :builder
28
+ attr_reader :configuration, :builder
31
29
 
32
30
  def body
33
31
  <<~CONTENT
@@ -36,9 +34,7 @@ module Rubysmith
36
34
  CONTENT
37
35
  end
38
36
 
39
- def project_name
40
- realm.project_name
41
- end
37
+ def project_name = configuration.project_name
42
38
  end
43
39
  end
44
40
  end
@@ -5,24 +5,22 @@ module Rubysmith
5
5
  module Git
6
6
  # Initializes project skeleton as a Git repository.
7
7
  class Setup
8
- def self.call realm, builder: Builder
9
- new(realm, builder: builder).call
10
- end
8
+ def self.call(...) = new(...).call
11
9
 
12
- def initialize realm, builder: Builder
13
- @realm = realm
10
+ def initialize configuration, builder: Builder
11
+ @configuration = configuration
14
12
  @builder = builder
15
13
  end
16
14
 
17
15
  def call
18
- return unless realm.build_git
16
+ return unless configuration.build_git
19
17
 
20
- builder.call(realm).run("git init", chdir: realm.project_name)
18
+ builder.call(configuration).run("git init", chdir: configuration.project_name)
21
19
  end
22
20
 
23
21
  private
24
22
 
25
- attr_reader :realm, :builder
23
+ attr_reader :configuration, :builder
26
24
  end
27
25
  end
28
26
  end