rubysmith 0.16.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/LICENSE.adoc +207 -155
  4. data/README.adoc +340 -94
  5. data/lib/rubysmith/builder.rb +1 -2
  6. data/lib/rubysmith/builders/bundler.rb +7 -11
  7. data/lib/rubysmith/builders/circle_ci.rb +8 -2
  8. data/lib/rubysmith/builders/console.rb +8 -2
  9. data/lib/rubysmith/builders/core.rb +7 -3
  10. data/lib/rubysmith/builders/documentation/{change.rb → citation.rb} +8 -8
  11. data/lib/rubysmith/builders/documentation/license.rb +9 -4
  12. data/lib/rubysmith/builders/documentation/readme.rb +12 -18
  13. data/lib/rubysmith/builders/documentation/{contribution.rb → version.rb} +10 -5
  14. data/lib/rubysmith/builders/git/commit.rb +3 -1
  15. data/lib/rubysmith/builders/git/setup.rb +2 -1
  16. data/lib/rubysmith/builders/git_hub.rb +8 -3
  17. data/lib/rubysmith/builders/guard.rb +9 -3
  18. data/lib/rubysmith/builders/rake.rb +8 -3
  19. data/lib/rubysmith/builders/reek.rb +7 -2
  20. data/lib/rubysmith/builders/rspec/context.rb +8 -2
  21. data/lib/rubysmith/builders/rspec/helper.rb +8 -2
  22. data/lib/rubysmith/builders/rubocop.rb +34 -0
  23. data/lib/rubysmith/builders/setup.rb +8 -2
  24. data/lib/rubysmith/cli/actions/build.rb +10 -12
  25. data/lib/rubysmith/cli/actions/config.rb +4 -2
  26. data/lib/rubysmith/cli/actions/publish.rb +21 -0
  27. data/lib/rubysmith/cli/parser.rb +31 -0
  28. data/lib/rubysmith/cli/parsers/build.rb +80 -45
  29. data/lib/rubysmith/cli/parsers/core.rb +14 -10
  30. data/lib/rubysmith/cli/shell.rb +22 -15
  31. data/lib/rubysmith/configuration/content.rb +170 -0
  32. data/lib/rubysmith/configuration/defaults.yml +88 -0
  33. data/lib/rubysmith/configuration/enhancers/current_time.rb +24 -0
  34. data/lib/rubysmith/configuration/enhancers/git_email.rb +31 -0
  35. data/lib/rubysmith/configuration/enhancers/git_hub_user.rb +31 -0
  36. data/lib/rubysmith/configuration/enhancers/git_user.rb +33 -0
  37. data/lib/rubysmith/configuration/loader.rb +48 -0
  38. data/lib/rubysmith/container.rb +1 -1
  39. data/lib/rubysmith/extensions/bundler.rb +30 -0
  40. data/lib/rubysmith/extensions/milestoner.rb +35 -0
  41. data/lib/rubysmith/extensions/pragmater.rb +35 -0
  42. data/lib/rubysmith/extensions/rubocop.rb +29 -0
  43. data/lib/rubysmith/extensions/tocer.rb +37 -0
  44. data/lib/rubysmith/identity.rb +1 -1
  45. data/lib/rubysmith/templates/%project_name%/.github/ISSUE_TEMPLATE.md.erb +1 -4
  46. data/lib/rubysmith/templates/%project_name%/.rubocop.yml.erb +2 -0
  47. data/lib/rubysmith/templates/%project_name%/CITATION.cff.erb +16 -0
  48. data/lib/rubysmith/templates/%project_name%/Gemfile.erb +12 -9
  49. data/lib/rubysmith/templates/%project_name%/LICENSE-hippocratic.adoc.erb +214 -0
  50. data/lib/rubysmith/templates/%project_name%/LICENSE-hippocratic.md.erb +214 -0
  51. data/lib/rubysmith/templates/%project_name%/README.adoc.erb +20 -21
  52. data/lib/rubysmith/templates/%project_name%/README.md.erb +20 -21
  53. data/lib/rubysmith/templates/%project_name%/VERSIONS.adoc.erb +5 -0
  54. data/lib/rubysmith/templates/%project_name%/VERSIONS.md.erb +5 -0
  55. data/lib/rubysmith/templates/%project_name%/bin/rubocop.erb +0 -1
  56. data.tar.gz.sig +0 -0
  57. metadata +54 -38
  58. metadata.gz.sig +3 -2
  59. data/lib/rubysmith/builders/documentation/conduct.rb +0 -32
  60. data/lib/rubysmith/builders/pragma.rb +0 -32
  61. data/lib/rubysmith/builders/rubocop/formatter.rb +0 -31
  62. data/lib/rubysmith/builders/rubocop/setup.rb +0 -31
  63. data/lib/rubysmith/cli/configuration/content.rb +0 -97
  64. data/lib/rubysmith/cli/configuration/defaults.yml +0 -46
  65. data/lib/rubysmith/cli/configuration/enhancers/current_time.rb +0 -26
  66. data/lib/rubysmith/cli/configuration/enhancers/git_hub_user.rb +0 -33
  67. data/lib/rubysmith/cli/configuration/enhancers/version.rb +0 -26
  68. data/lib/rubysmith/cli/configuration/loader.rb +0 -46
  69. data/lib/rubysmith/cli/parsers/assembler.rb +0 -32
  70. data/lib/rubysmith/cli/parsers.rb +0 -11
  71. data/lib/rubysmith/templates/%project_name%/CHANGES.adoc.erb +0 -5
  72. data/lib/rubysmith/templates/%project_name%/CHANGES.md.erb +0 -5
  73. data/lib/rubysmith/templates/%project_name%/CODE_OF_CONDUCT.adoc.erb +0 -114
  74. data/lib/rubysmith/templates/%project_name%/CODE_OF_CONDUCT.md.erb +0 -115
  75. data/lib/rubysmith/templates/%project_name%/CONTRIBUTING.adoc.erb +0 -22
  76. data/lib/rubysmith/templates/%project_name%/CONTRIBUTING.md.erb +0 -22
@@ -1,9 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "refinements/structs"
4
+
3
5
  module Rubysmith
4
6
  module Builders
5
7
  # Builds project skeleton console for object inspection and exploration.
6
8
  class Console
9
+ using Refinements::Structs
10
+
7
11
  def self.call(...) = new(...).call
8
12
 
9
13
  def initialize configuration, builder: Builder
@@ -12,11 +16,13 @@ module Rubysmith
12
16
  end
13
17
 
14
18
  def call
15
- return unless configuration.build_console
19
+ return configuration unless configuration.build_console
16
20
 
17
- builder.call(configuration.with(template_path: "%project_name%/bin/console.erb"))
21
+ builder.call(configuration.merge(template_path: "%project_name%/bin/console.erb"))
18
22
  .render
19
23
  .permit 0o755
24
+
25
+ configuration
20
26
  end
21
27
 
22
28
  private
@@ -1,9 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "refinements/structs"
4
+
3
5
  module Rubysmith
4
6
  module Builders
5
7
  # Builds project skeleton core structure and minimum file support.
6
8
  class Core
9
+ using Refinements::Structs
10
+
7
11
  def self.call(...) = new(...).call
8
12
 
9
13
  def initialize configuration, builder: Builder
@@ -12,14 +16,14 @@ module Rubysmith
12
16
  end
13
17
 
14
18
  def call
15
- builder.call(configuration.with(template_path: "%project_name%/lib/%project_path%.rb.erb"))
19
+ builder.call(configuration.merge(template_path: "%project_name%/lib/%project_path%.rb.erb"))
16
20
  .render
17
21
  .replace(" require", "require")
18
22
  .replace(/ (?=(Zeit|\.tap|\.setup))/, "")
19
23
  .replace("\n \n", "\n\n")
20
24
 
21
- builder.call(configuration.with(template_path: "%project_name%/.ruby-version.erb")).render
22
- nil
25
+ builder.call(configuration.merge(template_path: "%project_name%/.ruby-version.erb")).render
26
+ configuration
23
27
  end
24
28
 
25
29
  private
@@ -1,12 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "tocer"
3
+ require "refinements/structs"
4
4
 
5
5
  module Rubysmith
6
6
  module Builders
7
7
  module Documentation
8
- # Builds project skeleton CHANGES documentation.
9
- class Change
8
+ # Builds project skeleton citation documentation.
9
+ class Citation
10
+ using Refinements::Structs
11
+
10
12
  def self.call(...) = new(...).call
11
13
 
12
14
  def initialize configuration, builder: Builder
@@ -15,17 +17,15 @@ module Rubysmith
15
17
  end
16
18
 
17
19
  def call
18
- return unless configuration.build_changes
20
+ return configuration unless configuration.build_citation
19
21
 
20
- builder.call(configuration.with(template_path: "%project_name%/CHANGES.#{kind}.erb"))
21
- .render
22
+ builder.call(configuration.merge(template_path: "%project_name%/CITATION.cff.erb")).render
23
+ configuration
22
24
  end
23
25
 
24
26
  private
25
27
 
26
28
  attr_reader :configuration, :builder
27
-
28
- def kind = configuration.documentation_format || "md"
29
29
  end
30
30
  end
31
31
  end
@@ -1,12 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "tocer"
4
+ require "refinements/structs"
4
5
 
5
6
  module Rubysmith
6
7
  module Builders
7
8
  module Documentation
8
9
  # Builds project skeleton LICENSE documentation.
9
10
  class License
11
+ using Refinements::Structs
12
+
10
13
  def self.call(...) = new(...).call
11
14
 
12
15
  def initialize configuration, builder: Builder
@@ -15,21 +18,23 @@ module Rubysmith
15
18
  end
16
19
 
17
20
  def call
18
- return unless configuration.build_license
21
+ return configuration unless configuration.build_license
19
22
 
20
- configuration.with(template_path: "%project_name%/LICENSE-#{license}.#{kind}.erb")
23
+ configuration.merge(template_path: "%project_name%/LICENSE-#{license}.#{kind}.erb")
21
24
  .then do |updated_configuration|
22
25
  builder.call(updated_configuration).render.rename "LICENSE.#{kind}"
23
26
  end
27
+
28
+ configuration
24
29
  end
25
30
 
26
31
  private
27
32
 
28
33
  attr_reader :configuration, :builder
29
34
 
30
- def kind = configuration.documentation_format || "md"
35
+ def kind = configuration.documentation_format
31
36
 
32
- def license = configuration.documentation_license || "mit"
37
+ def license = configuration.license_name
33
38
  end
34
39
  end
35
40
  end
@@ -1,43 +1,37 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "tocer"
4
+ require "refinements/structs"
4
5
 
5
6
  module Rubysmith
6
7
  module Builders
7
8
  module Documentation
8
9
  # Builds project skeleton README documentation.
9
10
  class Readme
11
+ using Refinements::Structs
12
+
10
13
  def self.call(...) = new(...).call
11
14
 
12
- def initialize configuration, builder: Builder, tocer: Tocer::Writer.new
15
+ def initialize configuration, builder: Builder
13
16
  @configuration = configuration
14
17
  @builder = builder
15
- @tocer = tocer
16
18
  end
17
19
 
18
20
  def call
19
- return unless configuration.build_readme
21
+ return configuration unless configuration.build_readme
22
+
23
+ builder.call(configuration.merge(template_path: "%project_name%/README.#{kind}.erb"))
24
+ .render
25
+ .replace(/\n{2,}/, "\n\n")
20
26
 
21
- private_methods.sort.grep(/render_/).each { |method| __send__ method }
27
+ configuration
22
28
  end
23
29
 
24
30
  private
25
31
 
26
- attr_reader :configuration, :builder, :tocer
27
-
28
- def render_content
29
- builder.call(configuration.with(template_path: "%project_name%/README.#{kind}.erb"))
30
- .render
31
- .replace("\n\n\n", "\n\n")
32
- end
33
-
34
- def render_table_of_contents
35
- configuration.project_root
36
- .join("README.md")
37
- .then { |path| tocer.call path if path.exist? }
38
- end
32
+ attr_reader :configuration, :builder
39
33
 
40
- def kind = configuration.documentation_format || "md"
34
+ def kind = configuration.documentation_format
41
35
  end
42
36
  end
43
37
  end
@@ -1,12 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "tocer"
4
+ require "refinements/structs"
4
5
 
5
6
  module Rubysmith
6
7
  module Builders
7
8
  module Documentation
8
- # Builds project skeleton CONTRIBUTING documentation.
9
- class Contribution
9
+ # Builds project skeleton version history.
10
+ class Version
11
+ using Refinements::Structs
12
+
10
13
  def self.call(...) = new(...).call
11
14
 
12
15
  def initialize configuration, builder: Builder
@@ -15,17 +18,19 @@ module Rubysmith
15
18
  end
16
19
 
17
20
  def call
18
- return unless configuration.build_contributions
21
+ return configuration unless configuration.build_versions
19
22
 
20
- builder.call(configuration.with(template_path: "%project_name%/CONTRIBUTING.#{kind}.erb"))
23
+ builder.call(configuration.merge(template_path: "%project_name%/VERSIONS.#{kind}.erb"))
21
24
  .render
25
+
26
+ configuration
22
27
  end
23
28
 
24
29
  private
25
30
 
26
31
  attr_reader :configuration, :builder
27
32
 
28
- def kind = configuration.documentation_format || "md"
33
+ def kind = configuration.documentation_format
29
34
  end
30
35
  end
31
36
  end
@@ -13,7 +13,7 @@ module Rubysmith
13
13
  end
14
14
 
15
15
  def call
16
- return unless configuration.build_git
16
+ return configuration unless configuration.build_git
17
17
 
18
18
  builder.call(configuration)
19
19
  .run("git add .", chdir: project_name)
@@ -21,6 +21,8 @@ module Rubysmith
21
21
  %(git commit --all --message "Added project skeleton" --message "#{body}"),
22
22
  chdir: project_name
23
23
  )
24
+
25
+ configuration
24
26
  end
25
27
 
26
28
  private
@@ -13,9 +13,10 @@ module Rubysmith
13
13
  end
14
14
 
15
15
  def call
16
- return unless configuration.build_git
16
+ return configuration unless configuration.build_git
17
17
 
18
18
  builder.call(configuration).run("git init", chdir: configuration.project_name)
19
+ configuration
19
20
  end
20
21
 
21
22
  private
@@ -1,9 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "refinements/structs"
4
+
3
5
  module Rubysmith
4
6
  module Builders
5
7
  # Builds project skeleton GitHub templates.
6
8
  class GitHub
9
+ using Refinements::Structs
10
+
7
11
  def self.call(...) = new(...).call
8
12
 
9
13
  def initialize configuration, builder: Builder
@@ -12,10 +16,11 @@ module Rubysmith
12
16
  end
13
17
 
14
18
  def call
15
- return unless configuration.build_git_hub
19
+ return configuration unless configuration.build_git_hub
16
20
 
17
21
  builder.call(with_issue_template).render
18
22
  builder.call(with_pull_request_template).render
23
+ configuration
19
24
  end
20
25
 
21
26
  private
@@ -23,11 +28,11 @@ module Rubysmith
23
28
  attr_reader :configuration, :builder
24
29
 
25
30
  def with_issue_template
26
- configuration.with template_path: "%project_name%/.github/ISSUE_TEMPLATE.md.erb"
31
+ configuration.merge template_path: "%project_name%/.github/ISSUE_TEMPLATE.md.erb"
27
32
  end
28
33
 
29
34
  def with_pull_request_template
30
- configuration.with template_path: "%project_name%/.github/PULL_REQUEST_TEMPLATE.md.erb"
35
+ configuration.merge template_path: "%project_name%/.github/PULL_REQUEST_TEMPLATE.md.erb"
31
36
  end
32
37
  end
33
38
  end
@@ -1,9 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "refinements/structs"
4
+
3
5
  module Rubysmith
4
6
  module Builders
5
7
  # Builds project skeleton Guard support for a red, green, refactor loop.
6
8
  class Guard
9
+ using Refinements::Structs
10
+
7
11
  def self.call(...) = new(...).call
8
12
 
9
13
  def initialize configuration, builder: Builder
@@ -12,12 +16,14 @@ module Rubysmith
12
16
  end
13
17
 
14
18
  def call
15
- return unless configuration.build_guard
19
+ return configuration unless configuration.build_guard
16
20
 
17
- builder.call(configuration.with(template_path: "%project_name%/bin/guard.erb"))
21
+ builder.call(configuration.merge(template_path: "%project_name%/bin/guard.erb"))
18
22
  .render
19
23
  .permit 0o755
20
- builder.call(configuration.with(template_path: "%project_name%/Guardfile.erb")).render
24
+
25
+ builder.call(configuration.merge(template_path: "%project_name%/Guardfile.erb")).render
26
+ configuration
21
27
  end
22
28
 
23
29
  private
@@ -1,9 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "refinements/structs"
4
+
3
5
  module Rubysmith
4
6
  module Builders
5
7
  # Builds project skeleton Rake support.
6
8
  class Rake
9
+ using Refinements::Structs
10
+
7
11
  def self.call(...) = new(...).call
8
12
 
9
13
  def initialize configuration, builder: Builder
@@ -12,16 +16,17 @@ module Rubysmith
12
16
  end
13
17
 
14
18
  def call
15
- return unless configuration.build_rake
19
+ return configuration unless configuration.build_rake
16
20
 
17
- builder.call(configuration.with(template_path: "%project_name%/Rakefile.erb"))
21
+ builder.call(configuration.merge(template_path: "%project_name%/Rakefile.erb"))
18
22
  .render
19
23
  .replace(/\[\s+/, "[")
20
24
  .replace(/\s+\]/, "]")
21
25
  .replace(" ", "")
22
26
  .replace(/\n+(?=require)/, "\n")
23
27
  .replace(/\n{2,}/, "\n\n")
24
- nil
28
+
29
+ configuration
25
30
  end
26
31
 
27
32
  private
@@ -1,9 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "refinements/structs"
4
+
3
5
  module Rubysmith
4
6
  module Builders
5
7
  # Builds project skeleton Reek code quality support.
6
8
  class Reek
9
+ using Refinements::Structs
10
+
7
11
  def self.call(...) = new(...).call
8
12
 
9
13
  def initialize configuration, builder: Builder
@@ -12,9 +16,10 @@ module Rubysmith
12
16
  end
13
17
 
14
18
  def call
15
- return unless configuration.build_reek
19
+ return configuration unless configuration.build_reek
16
20
 
17
- builder.call(configuration.with(template_path: "%project_name%/.reek.yml.erb")).render
21
+ builder.call(configuration.merge(template_path: "%project_name%/.reek.yml.erb")).render
22
+ configuration
18
23
  end
19
24
 
20
25
  private
@@ -1,10 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "refinements/structs"
4
+
3
5
  module Rubysmith
4
6
  module Builders
5
7
  module RSpec
6
8
  # Builds RSpec shared context for temporary directories.
7
9
  class Context
10
+ using Refinements::Structs
11
+
8
12
  def self.call(...) = new(...).call
9
13
 
10
14
  def initialize configuration, builder: Builder
@@ -13,13 +17,15 @@ module Rubysmith
13
17
  end
14
18
 
15
19
  def call
16
- return unless configuration.build_rspec
20
+ return configuration unless configuration.build_rspec
17
21
 
18
22
  template = "%project_name%/spec/support/shared_contexts/temp_dir.rb.erb"
19
- configuration.with(template_path: template)
23
+ configuration.merge(template_path: template)
20
24
  .then { |updated_configuration| builder.call updated_configuration }
21
25
  .render
22
26
  .replace(/\n\s+\n\s+/, "\n ")
27
+
28
+ configuration
23
29
  end
24
30
 
25
31
  private
@@ -1,10 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "refinements/structs"
4
+
3
5
  module Rubysmith
4
6
  module Builders
5
7
  module RSpec
6
8
  # Builds RSpec spec helper for project skeleton.
7
9
  class Helper
10
+ using Refinements::Structs
11
+
8
12
  def self.call(...) = new(...).call
9
13
 
10
14
  def initialize configuration, builder: Builder
@@ -13,12 +17,14 @@ module Rubysmith
13
17
  end
14
18
 
15
19
  def call
16
- return unless configuration.build_rspec
20
+ return configuration unless configuration.build_rspec
17
21
 
18
- builder.call(configuration.with(template_path: "%project_name%/spec/spec_helper.rb.erb"))
22
+ builder.call(configuration.merge(template_path: "%project_name%/spec/spec_helper.rb.erb"))
19
23
  .render
20
24
  .replace(/\n{3,}/, "\n\n")
21
25
  .replace(/\n\s{2}(?=(require|Simple|using|Pathname|Dir))/, "\n")
26
+
27
+ configuration
22
28
  end
23
29
 
24
30
  private
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+
5
+ module Rubysmith
6
+ module Builders
7
+ # Builds project skeleton with RuboCop code quality support.
8
+ class Rubocop
9
+ using Refinements::Structs
10
+
11
+ def self.call(...) = new(...).call
12
+
13
+ def initialize configuration, builder: Builder
14
+ @configuration = configuration
15
+ @builder = builder
16
+ end
17
+
18
+ def call
19
+ return configuration unless configuration.build_rubocop
20
+
21
+ builder.call(configuration.merge(template_path: "%project_name%/bin/rubocop.erb"))
22
+ .render
23
+ .permit 0o755
24
+
25
+ builder.call(configuration.merge(template_path: "%project_name%/.rubocop.yml.erb")).render
26
+ configuration
27
+ end
28
+
29
+ private
30
+
31
+ attr_reader :configuration, :builder
32
+ end
33
+ end
34
+ end
@@ -1,9 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "refinements/structs"
4
+
3
5
  module Rubysmith
4
6
  module Builders
5
7
  # Builds project skeleton setup script.
6
8
  class Setup
9
+ using Refinements::Structs
10
+
7
11
  def self.call(...) = new(...).call
8
12
 
9
13
  def initialize configuration, builder: Builder
@@ -12,11 +16,13 @@ module Rubysmith
12
16
  end
13
17
 
14
18
  def call
15
- return unless configuration.build_setup
19
+ return configuration unless configuration.build_setup
16
20
 
17
- builder.call(configuration.with(template_path: "%project_name%/bin/setup.erb"))
21
+ builder.call(configuration.merge(template_path: "%project_name%/bin/setup.erb"))
18
22
  .render
19
23
  .permit 0o755
24
+
25
+ configuration
20
26
  end
21
27
 
22
28
  private
@@ -9,10 +9,9 @@ module Rubysmith
9
9
  BUILDERS = [
10
10
  Builders::Core,
11
11
  Builders::Documentation::Readme,
12
- Builders::Documentation::Change,
13
- Builders::Documentation::Conduct,
14
- Builders::Documentation::Contribution,
12
+ Builders::Documentation::Citation,
15
13
  Builders::Documentation::License,
14
+ Builders::Documentation::Version,
16
15
  Builders::Git::Setup,
17
16
  Builders::Bundler,
18
17
  Builders::Rake,
@@ -24,24 +23,23 @@ module Rubysmith
24
23
  Builders::Reek,
25
24
  Builders::RSpec::Context,
26
25
  Builders::RSpec::Helper,
27
- Builders::Pragma,
28
- Builders::Rubocop::Setup,
29
- Builders::Rubocop::Formatter,
26
+ Builders::Rubocop,
27
+ Extensions::Bundler,
28
+ Extensions::Pragmater,
29
+ Extensions::Tocer,
30
+ Extensions::Rubocop,
30
31
  Builders::Git::Commit
31
32
  ].freeze
32
33
 
33
- def initialize builders: BUILDERS, container: Container
34
+ def initialize builders: BUILDERS
34
35
  @builders = builders
35
- @container = container
36
36
  end
37
37
 
38
- def call = builders.each { |builder| builder.call configuration }
38
+ def call(configuration) = builders.each { |builder| builder.call configuration }
39
39
 
40
40
  private
41
41
 
42
- attr_reader :builders, :container
43
-
44
- def configuration = container[__method__]
42
+ attr_reader :configuration, :builders
45
43
  end
46
44
  end
47
45
  end
@@ -5,7 +5,7 @@ module Rubysmith
5
5
  module Actions
6
6
  # Handles the config action.
7
7
  class Config
8
- def initialize client: CLI::Configuration::Loader::CLIENT, container: Container
8
+ def initialize client: Configuration::Loader::CLIENT, container: Container
9
9
  @client = client
10
10
  @container = container
11
11
  end
@@ -14,7 +14,7 @@ module Rubysmith
14
14
  case selection
15
15
  when :edit then edit
16
16
  when :view then view
17
- else fail StandardError, "Invalid configuration selection: #{selection}."
17
+ else logger.error { "Invalid configuration selection: #{selection}." }
18
18
  end
19
19
  end
20
20
 
@@ -27,6 +27,8 @@ module Rubysmith
27
27
  def view = kernel.system("cat #{client.current}")
28
28
 
29
29
  def kernel = container[__method__]
30
+
31
+ def logger = container[__method__]
30
32
  end
31
33
  end
32
34
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rubysmith
4
+ module CLI
5
+ module Actions
6
+ # Handles parsing of Command Line Interface (CLI) publish options.
7
+ class Publish
8
+ def initialize extension: Extensions::Milestoner, container: Container
9
+ @extension = extension
10
+ @container = container
11
+ end
12
+
13
+ def call(configuration) = extension.call(configuration)
14
+
15
+ private
16
+
17
+ attr_reader :extension, :container
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "optparse"
4
+
5
+ module Rubysmith
6
+ module CLI
7
+ # Assembles and parses all Command Line Interface (CLI) options.
8
+ class Parser
9
+ CLIENT = OptionParser.new nil, 40, " "
10
+ SECTIONS = [Parsers::Core, Parsers::Build].freeze # Order is important.
11
+
12
+ def initialize sections: SECTIONS, client: CLIENT, container: Container
13
+ @sections = sections
14
+ @client = client
15
+ @configuration = container[:configuration].dup
16
+ end
17
+
18
+ def call arguments = []
19
+ sections.each { |section| section.call configuration, client: }
20
+ client.parse arguments
21
+ configuration.freeze
22
+ end
23
+
24
+ def to_s = client.to_s
25
+
26
+ private
27
+
28
+ attr_reader :sections, :client, :configuration
29
+ end
30
+ end
31
+ end