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
@@ -4,25 +4,25 @@ module Rubysmith
4
4
  module Builders
5
5
  # Builds project skeleton Guard support for a red, green, refactor loop.
6
6
  class Guard
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_guard
15
+ return unless configuration.build_guard
18
16
 
19
- builder.call(realm.with(template_path: "%project_name%/bin/guard.erb")).render.permit 0o755
20
- builder.call(realm.with(template_path: "%project_name%/Guardfile.erb")).render
17
+ builder.call(configuration.with(template_path: "%project_name%/bin/guard.erb"))
18
+ .render
19
+ .permit 0o755
20
+ builder.call(configuration.with(template_path: "%project_name%/Guardfile.erb")).render
21
21
  end
22
22
 
23
23
  private
24
24
 
25
- attr_reader :realm, :builder
25
+ attr_reader :configuration, :builder
26
26
  end
27
27
  end
28
28
  end
@@ -6,30 +6,25 @@ module Rubysmith
6
6
  module Builders
7
7
  # Builds project skeleton pragmas so all Ruby strings are frozen by default.
8
8
  class Pragma
9
- def self.call realm
10
- new(realm).call
11
- end
9
+ def self.call(...) = new(...).call
12
10
 
13
- def initialize realm, client: Pragmater::Runner
14
- @realm = realm
11
+ def initialize configuration, client: Pragmater::Runner
12
+ @configuration = configuration
15
13
  @client = client
16
14
  end
17
15
 
18
- def call
19
- client.for(**attributes).call
20
- nil
21
- end
16
+ def call = client.for(**attributes).call && nil
22
17
 
23
18
  private
24
19
 
25
- attr_reader :realm, :client
20
+ attr_reader :configuration, :client
26
21
 
27
22
  def attributes
28
23
  {
29
24
  action: :insert,
30
- root_dir: realm.project_root,
31
- comments: realm.builders_pragmater_comments,
32
- includes: realm.builders_pragmater_includes
25
+ root_dir: configuration.project_root,
26
+ comments: configuration.builders_pragmater_comments,
27
+ includes: configuration.builders_pragmater_includes
33
28
  }
34
29
  end
35
30
  end
@@ -4,17 +4,17 @@ module Rubysmith
4
4
  module Builders
5
5
  # Builds project skeleton Rake support.
6
6
  class Rake
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%/Rakefile.erb"))
15
+ return unless configuration.build_rake
16
+
17
+ builder.call(configuration.with(template_path: "%project_name%/Rakefile.erb"))
18
18
  .render
19
19
  .replace(/\[\s+/, "[")
20
20
  .replace(/\s+\]/, "]")
@@ -26,7 +26,7 @@ module Rubysmith
26
26
 
27
27
  private
28
28
 
29
- attr_reader :realm, :builder
29
+ attr_reader :configuration, :builder
30
30
  end
31
31
  end
32
32
  end
@@ -4,24 +4,22 @@ module Rubysmith
4
4
  module Builders
5
5
  # Builds project skeleton Reek code quality support.
6
6
  class Reek
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_reek
15
+ return unless configuration.build_reek
18
16
 
19
- builder.call(realm.with(template_path: "%project_name%/.reek.yml.erb")).render
17
+ builder.call(configuration.with(template_path: "%project_name%/.reek.yml.erb")).render
20
18
  end
21
19
 
22
20
  private
23
21
 
24
- attr_reader :realm, :builder
22
+ attr_reader :configuration, :builder
25
23
  end
26
24
  end
27
25
  end
@@ -5,27 +5,26 @@ module Rubysmith
5
5
  module RSpec
6
6
  # Builds RSpec shared context for temporary directories.
7
7
  class Context
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_rspec
16
+ return unless configuration.build_rspec
19
17
 
20
- realm.with(template_path: "%project_name%/spec/support/shared_contexts/temp_dir.rb.erb")
21
- .then { |new_realm| builder.call new_realm }
22
- .render
23
- .replace(/\n\s+\n\s+/, "\n ")
18
+ template = "%project_name%/spec/support/shared_contexts/temp_dir.rb.erb"
19
+ configuration.with(template_path: template)
20
+ .then { |updated_configuration| builder.call updated_configuration }
21
+ .render
22
+ .replace(/\n\s+\n\s+/, "\n ")
24
23
  end
25
24
 
26
25
  private
27
26
 
28
- attr_reader :realm, :builder
27
+ attr_reader :configuration, :builder
29
28
  end
30
29
  end
31
30
  end
@@ -5,19 +5,17 @@ module Rubysmith
5
5
  module RSpec
6
6
  # Builds RSpec spec helper for project skeleton.
7
7
  class Helper
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_rspec
16
+ return unless configuration.build_rspec
19
17
 
20
- builder.call(realm.with(template_path: "%project_name%/spec/spec_helper.rb.erb"))
18
+ builder.call(configuration.with(template_path: "%project_name%/spec/spec_helper.rb.erb"))
21
19
  .render
22
20
  .replace(/\n{3,}/, "\n\n")
23
21
  .replace(/\n\s{2}(?=(require|Simple|using|Pathname|Dir))/, "\n")
@@ -25,7 +23,7 @@ module Rubysmith
25
23
 
26
24
  private
27
25
 
28
- attr_reader :realm, :builder
26
+ attr_reader :configuration, :builder
29
27
  end
30
28
  end
31
29
  end
@@ -10,23 +10,21 @@ module Rubysmith
10
10
  class Formatter
11
11
  using Refinements::IOs
12
12
 
13
- def self.call realm
14
- new(realm).call
15
- end
13
+ def self.call(...) = new(...).call
16
14
 
17
- def initialize realm, client: RuboCop::CLI.new
18
- @realm = realm
15
+ def initialize configuration, client: RuboCop::CLI.new
16
+ @configuration = configuration
19
17
  @client = client
20
18
  end
21
19
 
22
20
  def call
23
- STDOUT.squelch { client.run ["--auto-correct", realm.project_root.to_s] }
21
+ STDOUT.squelch { client.run ["--auto-correct", configuration.project_root.to_s] }
24
22
  nil
25
23
  end
26
24
 
27
25
  private
28
26
 
29
- attr_reader :realm, :client
27
+ attr_reader :configuration, :client
30
28
  end
31
29
  end
32
30
  end
@@ -5,28 +5,26 @@ module Rubysmith
5
5
  module Rubocop
6
6
  # Builds project skeleton for Rubocop code quality support.
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_rubocop
16
+ return unless configuration.build_rubocop
19
17
 
20
- builder.call(realm.with(template_path: "%project_name%/bin/rubocop.erb"))
18
+ builder.call(configuration.with(template_path: "%project_name%/bin/rubocop.erb"))
21
19
  .render
22
20
  .permit 0o755
23
21
 
24
- builder.call(realm.with(template_path: "%project_name%/.rubocop.yml.erb")).render
22
+ builder.call(configuration.with(template_path: "%project_name%/.rubocop.yml.erb")).render
25
23
  end
26
24
 
27
25
  private
28
26
 
29
- attr_reader :realm, :builder
27
+ attr_reader :configuration, :builder
30
28
  end
31
29
  end
32
30
  end
@@ -4,24 +4,24 @@ module Rubysmith
4
4
  module Builders
5
5
  # Builds project skeleton setup script.
6
6
  class Setup
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_setup
15
+ return unless configuration.build_setup
18
16
 
19
- builder.call(realm.with(template_path: "%project_name%/bin/setup.erb")).render.permit 0o755
17
+ builder.call(configuration.with(template_path: "%project_name%/bin/setup.erb"))
18
+ .render
19
+ .permit 0o755
20
20
  end
21
21
 
22
22
  private
23
23
 
24
- attr_reader :realm, :builder
24
+ attr_reader :configuration, :builder
25
25
  end
26
26
  end
27
27
  end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+ require "refinements/strings"
5
+
6
+ module Rubysmith
7
+ module CLI
8
+ module Configuration
9
+ # Defines the common configuration content for use throughout the gem.
10
+ Content = Struct.new(
11
+ :config,
12
+ :template_root,
13
+ :template_path,
14
+ :build_root,
15
+ :project_name,
16
+ :author_name,
17
+ :author_email,
18
+ :author_url,
19
+ :now,
20
+ :documentation_format,
21
+ :documentation_license,
22
+ :build_minimum,
23
+ :build_amazing_print,
24
+ :build_bundler_leak,
25
+ :build_console,
26
+ :build_documentation,
27
+ :build_git,
28
+ :build_git_lint,
29
+ :build_guard,
30
+ :build_pry,
31
+ :build_rake,
32
+ :build_reek,
33
+ :build_refinements,
34
+ :build_rspec,
35
+ :build_rubocop,
36
+ :build_setup,
37
+ :build_simple_cov,
38
+ :build_zeitwerk,
39
+ :builders_pragmater_comments,
40
+ :builders_pragmater_includes,
41
+ :version,
42
+ :help,
43
+ keyword_init: true
44
+ ) do
45
+ using Refinements::Strings
46
+
47
+ def initialize *arguments
48
+ super
49
+
50
+ self[:template_root] ||= Pathname(__dir__).join("../../templates").expand_path
51
+ self[:build_root] ||= Pathname.pwd
52
+ freeze
53
+ end
54
+
55
+ def with(attributes) = self.class.new(to_h.merge(attributes))
56
+
57
+ def project_label = project_name.titleize
58
+
59
+ def project_class = project_name.camelcase
60
+
61
+ def project_root = build_root.join(project_name)
62
+
63
+ def project_path = project_name.snakecase
64
+
65
+ def to_pathway
66
+ Pathway[start_root: template_root, start_path: template_path, end_root: build_root]
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -9,7 +9,6 @@
9
9
  :license: "mit"
10
10
  :build:
11
11
  :amazing_print: true
12
- :bundler_audit: true
13
12
  :bundler_leak: true
14
13
  :console: true
15
14
  :documentation: true
@@ -18,13 +17,14 @@
18
17
  :guard: true
19
18
  :minimum: false
20
19
  :pry: true
20
+ :rake: true
21
21
  :reek: true
22
22
  :refinements: true
23
23
  :rspec: true
24
24
  :rubocop: true
25
- :ruby_critic: true
26
25
  :setup: true
27
26
  :simple_cov: true
27
+ :zeitwerk: true
28
28
  :builders:
29
29
  :pragmater:
30
30
  :comments:
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+ require "refinements/hashes"
5
+ require "refinements/structs"
6
+ require "runcom"
7
+ require "yaml"
8
+
9
+ module Rubysmith
10
+ module CLI
11
+ module Configuration
12
+ # Represents the fully assembled Command Line Interface (CLI) configuration.
13
+ class Loader
14
+ using Refinements::Hashes
15
+ using Refinements::Structs
16
+
17
+ DEFAULTS = YAML.load_file(Pathname(__dir__).join("defaults.yml")).freeze
18
+ CLIENT = Runcom::Config.new "#{Identity::NAME}/configuration.yml", defaults: DEFAULTS
19
+
20
+ def self.call = new.call
21
+
22
+ def initialize content: Content.new, client: CLIENT
23
+ @content = content
24
+ @client = client
25
+ end
26
+
27
+ def call = content.merge(**client.to_h.flatten_keys)
28
+
29
+ private
30
+
31
+ attr_reader :content, :client
32
+ end
33
+ end
34
+ end
35
+ end