rubysmith 4.9.0 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.adoc +91 -117
  4. data/lib/rubysmith/builders/core.rb +0 -1
  5. data/lib/rubysmith/cli/actions/amazing_print.rb +25 -0
  6. data/lib/rubysmith/cli/actions/caliber.rb +25 -0
  7. data/lib/rubysmith/cli/actions/circle_ci.rb +25 -0
  8. data/lib/rubysmith/cli/actions/citation.rb +25 -0
  9. data/lib/rubysmith/cli/actions/community.rb +25 -0
  10. data/lib/rubysmith/cli/actions/conduct.rb +25 -0
  11. data/lib/rubysmith/cli/actions/console.rb +25 -0
  12. data/lib/rubysmith/cli/actions/contributions.rb +25 -0
  13. data/lib/rubysmith/cli/actions/debug.rb +25 -0
  14. data/lib/rubysmith/cli/actions/funding.rb +25 -0
  15. data/lib/rubysmith/cli/actions/git.rb +25 -0
  16. data/lib/rubysmith/cli/actions/git_hub.rb +25 -0
  17. data/lib/rubysmith/cli/actions/git_hub_ci.rb +25 -0
  18. data/lib/rubysmith/cli/actions/git_lint.rb +25 -0
  19. data/lib/rubysmith/cli/actions/guard.rb +25 -0
  20. data/lib/rubysmith/cli/actions/license.rb +25 -0
  21. data/lib/rubysmith/cli/actions/maximum.rb +25 -0
  22. data/lib/rubysmith/cli/actions/minimum.rb +25 -0
  23. data/lib/rubysmith/cli/actions/name.rb +23 -0
  24. data/lib/rubysmith/cli/actions/publish.rb +16 -4
  25. data/lib/rubysmith/cli/actions/rake.rb +25 -0
  26. data/lib/rubysmith/cli/actions/readme.rb +25 -0
  27. data/lib/rubysmith/cli/actions/reek.rb +25 -0
  28. data/lib/rubysmith/cli/actions/refinements.rb +25 -0
  29. data/lib/rubysmith/cli/actions/rspec.rb +25 -0
  30. data/lib/rubysmith/cli/actions/security.rb +25 -0
  31. data/lib/rubysmith/cli/actions/setup.rb +25 -0
  32. data/lib/rubysmith/cli/actions/simple_cov.rb +25 -0
  33. data/lib/rubysmith/cli/actions/versions.rb +25 -0
  34. data/lib/rubysmith/cli/actions/yard.rb +25 -0
  35. data/lib/rubysmith/cli/actions/zeitwerk.rb +25 -0
  36. data/lib/rubysmith/cli/{actions → commands}/build.rb +45 -7
  37. data/lib/rubysmith/cli/shell.rb +20 -18
  38. data/lib/rubysmith/configuration/contract.rb +78 -0
  39. data/lib/rubysmith/configuration/defaults.yml +52 -73
  40. data/lib/rubysmith/configuration/{content.rb → model.rb} +8 -22
  41. data/lib/rubysmith/configuration/transformers/current_time.rb +18 -0
  42. data/lib/rubysmith/configuration/transformers/git_email.rb +19 -0
  43. data/lib/rubysmith/configuration/transformers/git_hub_user.rb +19 -0
  44. data/lib/rubysmith/configuration/transformers/git_user.rb +24 -0
  45. data/lib/rubysmith/configuration/transformers/target_root.rb +18 -0
  46. data/lib/rubysmith/configuration/transformers/template_root.rb +22 -0
  47. data/lib/rubysmith/container.rb +21 -3
  48. data/lib/rubysmith/extensions/milestoner.rb +1 -1
  49. data/lib/rubysmith/extensions/pragmater.rb +8 -8
  50. data/lib/rubysmith/extensions/tocer.rb +8 -8
  51. data/lib/rubysmith/pathway.rb +1 -0
  52. data/lib/rubysmith/templates/%project_name%/Gemfile.erb +4 -4
  53. data/rubysmith.gemspec +16 -13
  54. data.tar.gz.sig +0 -0
  55. metadata +112 -46
  56. metadata.gz.sig +0 -0
  57. data/lib/rubysmith/cli/actions/config.rb +0 -33
  58. data/lib/rubysmith/cli/actions/container.rb +0 -20
  59. data/lib/rubysmith/cli/actions/import.rb +0 -11
  60. data/lib/rubysmith/cli/parser.rb +0 -35
  61. data/lib/rubysmith/cli/parsers/build.rb +0 -307
  62. data/lib/rubysmith/cli/parsers/core.rb +0 -72
  63. data/lib/rubysmith/configuration/enhancers/container.rb +0 -20
  64. data/lib/rubysmith/configuration/enhancers/current_time.rb +0 -14
  65. data/lib/rubysmith/configuration/enhancers/git_email.rb +0 -21
  66. data/lib/rubysmith/configuration/enhancers/git_hub_user.rb +0 -21
  67. data/lib/rubysmith/configuration/enhancers/git_user.rb +0 -25
  68. data/lib/rubysmith/configuration/enhancers/template_root.rb +0 -12
  69. data/lib/rubysmith/configuration/loader.rb +0 -44
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+ require "sod"
5
+
6
+ module Rubysmith
7
+ module CLI
8
+ module Actions
9
+ # Stores Guard flag.
10
+ class Guard < Sod::Action
11
+ include Import[:input]
12
+
13
+ using ::Refinements::Structs
14
+
15
+ description "Add Guard gem."
16
+
17
+ on "--[no-]guard"
18
+
19
+ default { Container[:configuration].build_guard }
20
+
21
+ def call(value = default) = input.merge!(build_guard: value)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+ require "sod"
5
+
6
+ module Rubysmith
7
+ module CLI
8
+ module Actions
9
+ # Stores license flag.
10
+ class License < Sod::Action
11
+ include Import[:input]
12
+
13
+ using ::Refinements::Structs
14
+
15
+ description "Add license documentation."
16
+
17
+ on "--[no-]license"
18
+
19
+ default { Container[:configuration].build_license }
20
+
21
+ def call(value = default) = input.merge!(build_license: value)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+ require "sod"
5
+
6
+ module Rubysmith
7
+ module CLI
8
+ module Actions
9
+ # Forces maximum configuration.
10
+ class Maximum < Sod::Action
11
+ include Import[:input]
12
+
13
+ using ::Refinements::Structs
14
+
15
+ description "Use maximum options."
16
+
17
+ on "--max"
18
+
19
+ default { Container[:configuration].build_maximum }
20
+
21
+ def call(*) = input.merge!(input.maximize)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+ require "sod"
5
+
6
+ module Rubysmith
7
+ module CLI
8
+ module Actions
9
+ # Forces minimum configuration.
10
+ class Minimum < Sod::Action
11
+ include Import[:input]
12
+
13
+ using ::Refinements::Structs
14
+
15
+ description "Use minimum options."
16
+
17
+ on "--min"
18
+
19
+ default { Container[:configuration].build_minimum }
20
+
21
+ def call(*) = input.merge!(input.minimize)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+ require "sod"
5
+
6
+ module Rubysmith
7
+ module CLI
8
+ module Actions
9
+ # Stores project (build) name.
10
+ class Name < Sod::Action
11
+ include Import[:input]
12
+
13
+ using ::Refinements::Structs
14
+
15
+ description "Set project name."
16
+
17
+ on %w[-n --name], argument: "NAME"
18
+
19
+ def call(name) = input.merge!(project_name: name)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,15 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "refinements/structs"
4
+ require "sod"
5
+
3
6
  module Rubysmith
4
7
  module CLI
5
8
  module Actions
6
- # Handles parsing of Command Line Interface (CLI) publish options.
7
- class Publish
8
- def initialize extension: Extensions::Milestoner
9
+ # Publishes project.
10
+ class Publish < Sod::Action
11
+ include Import[:configuration]
12
+
13
+ using ::Refinements::Structs
14
+
15
+ description "Publish project."
16
+
17
+ on %w[-p --publish], argument: "VERSION"
18
+
19
+ def initialize(extension: Extensions::Milestoner, **)
20
+ super(**)
9
21
  @extension = extension
10
22
  end
11
23
 
12
- def call(configuration) = extension.call(configuration)
24
+ def call(version) = extension.call configuration.merge(project_version: version)
13
25
 
14
26
  private
15
27
 
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+ require "sod"
5
+
6
+ module Rubysmith
7
+ module CLI
8
+ module Actions
9
+ # Stores Rake flag.
10
+ class Rake < Sod::Action
11
+ include Import[:input]
12
+
13
+ using ::Refinements::Structs
14
+
15
+ description "Add Rake gem."
16
+
17
+ on "--[no-]rake"
18
+
19
+ default { Container[:configuration].build_rake }
20
+
21
+ def call(value = default) = input.merge!(build_rake: value)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+ require "sod"
5
+
6
+ module Rubysmith
7
+ module CLI
8
+ module Actions
9
+ # Stores readme flag.
10
+ class Readme < Sod::Action
11
+ include Import[:input]
12
+
13
+ using ::Refinements::Structs
14
+
15
+ description "Add readme documentation."
16
+
17
+ on "--[no-]readme"
18
+
19
+ default { Container[:configuration].build_readme }
20
+
21
+ def call(value = default) = input.merge!(build_readme: value)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+ require "sod"
5
+
6
+ module Rubysmith
7
+ module CLI
8
+ module Actions
9
+ # Stores Reek flag.
10
+ class Reek < Sod::Action
11
+ include Import[:input]
12
+
13
+ using ::Refinements::Structs
14
+
15
+ description "Add Reek gem."
16
+
17
+ on "--[no-]reek"
18
+
19
+ default { Container[:configuration].build_reek }
20
+
21
+ def call(value = default) = input.merge!(build_reek: value)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+ require "sod"
5
+
6
+ module Rubysmith
7
+ module CLI
8
+ module Actions
9
+ # Stores Refinements flag.
10
+ class Refinements < Sod::Action
11
+ include Import[:input]
12
+
13
+ using ::Refinements::Structs
14
+
15
+ description "Add Refinements gem."
16
+
17
+ on "--[no-]refinements"
18
+
19
+ default { Container[:configuration].build_refinements }
20
+
21
+ def call(value = default) = input.merge!(build_refinements: value)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+ require "sod"
5
+
6
+ module Rubysmith
7
+ module CLI
8
+ module Actions
9
+ # Stores RSpec flag.
10
+ class RSpec < Sod::Action
11
+ include Import[:input]
12
+
13
+ using ::Refinements::Structs
14
+
15
+ description "Add RSpec gem."
16
+
17
+ on "--[no-]rspec"
18
+
19
+ default { Container[:configuration].build_rspec }
20
+
21
+ def call(value = default) = input.merge!(build_rspec: value)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+ require "sod"
5
+
6
+ module Rubysmith
7
+ module CLI
8
+ module Actions
9
+ # Stores security flag.
10
+ class Security < Sod::Action
11
+ include Import[:input]
12
+
13
+ using ::Refinements::Structs
14
+
15
+ description "Add security."
16
+
17
+ on "--[no-]security"
18
+
19
+ default { Container[:configuration].build_security }
20
+
21
+ def call(value = default) = input.merge!(build_security: value)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+ require "sod"
5
+
6
+ module Rubysmith
7
+ module CLI
8
+ module Actions
9
+ # Stores setup flag.
10
+ class Setup < Sod::Action
11
+ include Import[:input]
12
+
13
+ using ::Refinements::Structs
14
+
15
+ description "Add setup script."
16
+
17
+ on "--[no-]setup"
18
+
19
+ default { Container[:configuration].build_setup }
20
+
21
+ def call(value = default) = input.merge!(build_setup: value)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+ require "sod"
5
+
6
+ module Rubysmith
7
+ module CLI
8
+ module Actions
9
+ # Stores SimpleCov flag.
10
+ class SimpleCov < Sod::Action
11
+ include Import[:input]
12
+
13
+ using ::Refinements::Structs
14
+
15
+ description "Add SimpleCov gem."
16
+
17
+ on "--[no-]simple_cov"
18
+
19
+ default { Container[:configuration].build_simple_cov }
20
+
21
+ def call(value = default) = input.merge!(build_simple_cov: value)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+ require "sod"
5
+
6
+ module Rubysmith
7
+ module CLI
8
+ module Actions
9
+ # Stores versions flag.
10
+ class Versions < Sod::Action
11
+ include Import[:input]
12
+
13
+ using ::Refinements::Structs
14
+
15
+ description "Add version history."
16
+
17
+ on "--[no-]versions"
18
+
19
+ default { Container[:configuration].build_versions }
20
+
21
+ def call(value = default) = input.merge!(build_versions: value)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+ require "sod"
5
+
6
+ module Rubysmith
7
+ module CLI
8
+ module Actions
9
+ # Stores Yard flag.
10
+ class Yard < Sod::Action
11
+ include Import[:input]
12
+
13
+ using ::Refinements::Structs
14
+
15
+ description "Add Yard gem."
16
+
17
+ on "--[no-]yard"
18
+
19
+ default { Container[:configuration].build_yard }
20
+
21
+ def call(value = default) = input.merge!(build_yard: value)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/structs"
4
+ require "sod"
5
+
6
+ module Rubysmith
7
+ module CLI
8
+ module Actions
9
+ # Stores Zeitwerk flag.
10
+ class Zeitwerk < Sod::Action
11
+ include Import[:input]
12
+
13
+ using ::Refinements::Structs
14
+
15
+ description "Add Zeitwerk gem."
16
+
17
+ on "--[no-]zeitwerk"
18
+
19
+ default { Container[:configuration].build_zeitwerk }
20
+
21
+ def call(value = default) = input.merge!(build_zeitwerk: value)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,11 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "refinements/structs"
4
+ require "sod"
5
+
3
6
  module Rubysmith
4
7
  module CLI
5
- module Actions
6
- # Handles the build action.
7
- class Build
8
- include Rubysmith::Import[:logger]
8
+ module Commands
9
+ # Stores table of contents root path.
10
+ class Build < Sod::Command
11
+ include Import[:input, :kernel, :logger]
9
12
 
10
13
  # Order is important.
11
14
  # rubocop:todo Metrics/CollectionLiteralLength
@@ -40,14 +43,49 @@ module Rubysmith
40
43
  ].freeze
41
44
  # rubocop:enable Metrics/CollectionLiteralLength
42
45
 
46
+ handle "build"
47
+
48
+ description "Build new project."
49
+
50
+ on Actions::Name
51
+ on Actions::AmazingPrint
52
+ on Actions::Caliber
53
+ on Actions::Console
54
+ on Actions::Contributions
55
+ on Actions::CircleCI
56
+ on Actions::Citation
57
+ on Actions::Community
58
+ on Actions::Conduct
59
+ on Actions::Debug
60
+ on Actions::Funding
61
+ on Actions::Git
62
+ on Actions::GitHub
63
+ on Actions::GitHubCI
64
+ on Actions::GitLint
65
+ on Actions::Guard
66
+ on Actions::License
67
+ on Actions::Maximum
68
+ on Actions::Minimum
69
+ on Actions::Rake
70
+ on Actions::Readme
71
+ on Actions::Reek
72
+ on Actions::Refinements
73
+ on Actions::RSpec
74
+ on Actions::Security
75
+ on Actions::Setup
76
+ on Actions::SimpleCov
77
+ on Actions::Versions
78
+ on Actions::Yard
79
+ on Actions::Zeitwerk
80
+
43
81
  def initialize(builders: BUILDERS, **)
44
82
  super(**)
45
83
  @builders = builders
46
84
  end
47
85
 
48
- def call configuration
49
- log_info "Building project skeleton: #{configuration.project_name}..."
50
- builders.each { |builder| builder.call configuration }
86
+ def call
87
+ log_info "Building project skeleton: #{input.project_name}..."
88
+ builders.each { |builder| builder.call input }
51
89
  log_info "Project skeleton complete!"
52
90
  end
53
91
 
@@ -1,38 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "core"
4
- require "milestoner"
3
+ require "sod"
5
4
 
6
5
  module Rubysmith
7
6
  module CLI
8
7
  # The main Command Line Interface (CLI) object.
9
8
  class Shell
10
- include Actions::Import[:config, :build, :kernel, :logger, :publish, :specification]
9
+ include Import[:defaults_path, :xdg_config, :specification]
11
10
 
12
- def initialize(parser: Parser.new, **)
11
+ def initialize(context: Sod::Context, dsl: Sod, **)
13
12
  super(**)
14
- @parser = parser
13
+ @context = context
14
+ @dsl = dsl
15
15
  end
16
16
 
17
- def call arguments = Core::EMPTY_ARRAY
18
- act_on parser.call(arguments)
19
- rescue OptionParser::ParseError, Milestoner::Error => error
20
- logger.error { error.message }
21
- end
17
+ def call(...) = cli.call(...)
22
18
 
23
19
  private
24
20
 
25
- attr_reader :parser
21
+ attr_reader :context, :dsl
22
+
23
+ def cli
24
+ context = build_context
26
25
 
27
- def act_on configuration
28
- case configuration
29
- in action_config: Symbol => action then config.call action
30
- in action_build: true then build.call configuration
31
- in action_publish: true then publish.call configuration
32
- in action_version: true then kernel.puts specification.labeled_version
33
- else kernel.puts parser.to_s
26
+ dsl.new :rubysmith, banner: specification.banner do
27
+ on(Sod::Prefabs::Commands::Config, context:)
28
+ on Commands::Build
29
+ on Actions::Publish
30
+ on(Sod::Prefabs::Actions::Version, context:)
31
+ on Sod::Prefabs::Actions::Help, self
34
32
  end
35
33
  end
34
+
35
+ def build_context
36
+ context[defaults_path:, xdg_config:, version_label: specification.labeled_version]
37
+ end
36
38
  end
37
39
  end
38
40
  end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/schema"
4
+ require "etcher"
5
+
6
+ Dry::Schema.load_extensions :monads
7
+
8
+ module Rubysmith
9
+ module Configuration
10
+ Contract = Dry::Schema.Params do
11
+ optional(:author_email).filled :string
12
+ optional(:author_family_name).filled :string
13
+ optional(:author_given_name).filled :string
14
+ optional(:author_url).filled :string
15
+ required(:build_amazing_print).filled :bool
16
+ required(:build_caliber).filled :bool
17
+ required(:build_circle_ci).filled :bool
18
+ required(:build_citation).filled :bool
19
+ required(:build_cli).filled :bool
20
+ required(:build_community).filled :bool
21
+ required(:build_conduct).filled :bool
22
+ required(:build_console).filled :bool
23
+ required(:build_contributions).filled :bool
24
+ required(:build_debug).filled :bool
25
+ required(:build_funding).filled :bool
26
+ required(:build_git).filled :bool
27
+ required(:build_git_hub).filled :bool
28
+ required(:build_git_hub_ci).filled :bool
29
+ required(:build_git_lint).filled :bool
30
+ required(:build_guard).filled :bool
31
+ required(:build_license).filled :bool
32
+ required(:build_maximum).filled :bool
33
+ required(:build_minimum).filled :bool
34
+ required(:build_rake).filled :bool
35
+ required(:build_readme).filled :bool
36
+ required(:build_reek).filled :bool
37
+ required(:build_refinements).filled :bool
38
+ required(:build_rspec).filled :bool
39
+ required(:build_security).filled :bool
40
+ required(:build_setup).filled :bool
41
+ required(:build_simple_cov).filled :bool
42
+ required(:build_versions).filled :bool
43
+ required(:build_yard).filled :bool
44
+ required(:build_zeitwerk).filled :bool
45
+ optional(:citation_affiliation).filled :string
46
+ optional(:citation_message).filled :string
47
+ optional(:citation_orcid).filled :string
48
+ required(:documentation_format).filled :string
49
+ required(:extensions_milestoner_documentation_format).filled :string
50
+ required(:extensions_milestoner_prefixes).array :string
51
+ required(:extensions_pragmater_comments).array :string
52
+ required(:extensions_pragmater_patterns).array :string
53
+ required(:extensions_tocer_label).filled :string
54
+ required(:extensions_tocer_patterns).array :string
55
+ optional(:git_hub_user).filled :string
56
+ required(:license_label).filled :string
57
+ required(:license_name).filled :string
58
+ required(:license_version).filled :string
59
+ optional(:now).filled :time
60
+ optional(:project_name).filled :string
61
+ optional(:project_url_community).filled :string
62
+ optional(:project_url_conduct).filled :string
63
+ optional(:project_url_contributions).filled :string
64
+ optional(:project_url_download).filled :string
65
+ optional(:project_url_funding).filled :string
66
+ optional(:project_url_home).filled :string
67
+ optional(:project_url_issues).filled :string
68
+ optional(:project_url_license).filled :string
69
+ optional(:project_url_security).filled :string
70
+ optional(:project_url_source).filled :string
71
+ optional(:project_url_versions).filled :string
72
+ required(:project_version).filled :string
73
+ required(:target_root).filled Etcher::Types::Pathname
74
+ optional(:template_path).filled Etcher::Types::Pathname
75
+ required(:template_roots).array Etcher::Types::Pathname
76
+ end
77
+ end
78
+ end