loading
Generated 2025-10-11T17:15:06+00:00

All Files ( 100.0% covered at 49.52 hits/line )

89 files in total.
1253 relevant lines, 1253 lines covered and 0 lines missed. ( 100.0% )
93 total branches, 93 branches covered and 0 branches missed. ( 100.0% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line Branch Coverage Branches Covered branches Missed branches
lib/rubysmith.rb 100.00 % 25 9 9 0 1.56 100.00 % 0 0 0
lib/rubysmith/builder.rb 100.00 % 139 79 79 0 76.73 100.00 % 4 4 0
lib/rubysmith/builders/abstract.rb 100.00 % 24 11 11 0 90.73 100.00 % 0 0 0
lib/rubysmith/builders/bundler.rb 100.00 % 25 8 8 0 6.75 100.00 % 0 0 0
lib/rubysmith/builders/caliber.rb 100.00 % 24 11 11 0 3.73 100.00 % 2 2 0
lib/rubysmith/builders/circle_ci.rb 100.00 % 22 9 9 0 2.78 100.00 % 2 2 0
lib/rubysmith/builders/console.rb 100.00 % 22 9 9 0 3.44 100.00 % 2 2 0
lib/rubysmith/builders/core.rb 100.00 % 42 20 20 0 5.45 100.00 % 2 2 0
lib/rubysmith/builders/dev_container/compose.rb 100.00 % 22 11 11 0 2.45 100.00 % 2 2 0
lib/rubysmith/builders/dev_container/configuration.rb 100.00 % 22 11 11 0 3.18 100.00 % 2 2 0
lib/rubysmith/builders/dev_container/dockerfile.rb 100.00 % 22 10 10 0 2.30 100.00 % 2 2 0
lib/rubysmith/builders/docker/build.rb 100.00 % 24 10 10 0 2.60 100.00 % 2 2 0
lib/rubysmith/builders/docker/compose.rb 100.00 % 21 10 10 0 2.30 100.00 % 2 2 0
lib/rubysmith/builders/docker/console.rb 100.00 % 24 10 10 0 2.60 100.00 % 2 2 0
lib/rubysmith/builders/docker/entrypoint.rb 100.00 % 24 10 10 0 2.60 100.00 % 2 2 0
lib/rubysmith/builders/docker/file.rb 100.00 % 21 10 10 0 4.40 100.00 % 2 2 0
lib/rubysmith/builders/docker/ignore.rb 100.00 % 21 10 10 0 2.30 100.00 % 2 2 0
lib/rubysmith/builders/documentation/citation.rb 100.00 % 21 10 10 0 2.60 100.00 % 2 2 0
lib/rubysmith/builders/documentation/license.rb 100.00 % 31 14 14 0 5.86 100.00 % 2 2 0
lib/rubysmith/builders/documentation/readme.rb 100.00 % 29 12 12 0 2.83 100.00 % 2 2 0
lib/rubysmith/builders/documentation/version.rb 100.00 % 27 13 13 0 2.69 100.00 % 2 2 0
lib/rubysmith/builders/git/commit.rb 100.00 % 34 13 13 0 2.23 100.00 % 2 2 0
lib/rubysmith/builders/git/ignore.rb 100.00 % 24 10 10 0 2.30 100.00 % 2 2 0
lib/rubysmith/builders/git/safe.rb 100.00 % 21 10 10 0 2.30 100.00 % 2 2 0
lib/rubysmith/builders/git/setup.rb 100.00 % 17 8 8 0 2.63 100.00 % 2 2 0
lib/rubysmith/builders/git_hub/ci.rb 100.00 % 27 13 13 0 2.85 100.00 % 2 2 0
lib/rubysmith/builders/git_hub/funding.rb 100.00 % 23 11 11 0 3.18 100.00 % 2 2 0
lib/rubysmith/builders/git_hub/template.rb 100.00 % 37 19 19 0 3.84 100.00 % 2 2 0
lib/rubysmith/builders/init.rb 100.00 % 18 9 9 0 2.11 100.00 % 0 0 0
lib/rubysmith/builders/rake/binstub.rb 100.00 % 24 10 10 0 2.60 100.00 % 2 2 0
lib/rubysmith/builders/rake/configuration.rb 100.00 % 29 10 10 0 3.80 100.00 % 2 2 0
lib/rubysmith/builders/reek.rb 100.00 % 19 9 9 0 2.44 100.00 % 2 2 0
lib/rubysmith/builders/rspec/binstub.rb 100.00 % 24 10 10 0 2.60 100.00 % 2 2 0
lib/rubysmith/builders/rspec/context.rb 100.00 % 26 12 12 0 2.58 100.00 % 2 2 0
lib/rubysmith/builders/rspec/helper.rb 100.00 % 26 10 10 0 5.30 100.00 % 2 2 0
lib/rubysmith/builders/setup.rb 100.00 % 22 9 9 0 3.44 100.00 % 2 2 0
lib/rubysmith/builders/version.rb 100.00 % 19 8 8 0 3.00 100.00 % 0 0 0
lib/rubysmith/cli/actions/amazing_print.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/bootsnap.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/caliber.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/circle_ci.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/citation.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/community.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/conduct.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/console.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/contributions.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/dcoo.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/debug.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/dev_container.rb 100.00 % 27 13 13 0 2.92 100.00 % 0 0 0
lib/rubysmith/cli/actions/docker.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/funding.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/git.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/git_hub.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/git_hub_ci.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/git_lint.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/irb_kit.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/license.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/maximum.rb 100.00 % 25 12 12 0 1.83 100.00 % 0 0 0
lib/rubysmith/cli/actions/minimum.rb 100.00 % 25 12 12 0 1.83 100.00 % 0 0 0
lib/rubysmith/cli/actions/monads.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/name.rb 100.00 % 20 9 9 0 1.00 100.00 % 0 0 0
lib/rubysmith/cli/actions/rake.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/readme.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/reek.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/refinements.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/rspec.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/rtc.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/security.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/setup.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/simple_cov.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/versions.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/actions/zeitwerk.rb 100.00 % 22 10 10 0 2.10 100.00 % 0 0 0
lib/rubysmith/cli/commands/build.rb 100.00 % 114 55 55 0 4.58 100.00 % 0 0 0
lib/rubysmith/cli/shell.rb 100.00 % 39 21 21 0 3.86 100.00 % 0 0 0
lib/rubysmith/configuration/contract.rb 100.00 % 83 76 76 0 1.00 100.00 % 0 0 0
lib/rubysmith/configuration/model.rb 100.00 % 162 49 49 0 545.16 100.00 % 0 0 0
lib/rubysmith/configuration/transformers/git_email.rb 100.00 % 32 17 17 0 112.65 100.00 % 4 4 0
lib/rubysmith/configuration/transformers/git_hub_user.rb 100.00 % 32 17 17 0 68.29 100.00 % 4 4 0
lib/rubysmith/configuration/transformers/git_user.rb 100.00 % 36 18 18 0 127.39 100.00 % 4 4 0
lib/rubysmith/configuration/transformers/template_root.rb 100.00 % 33 16 16 0 120.31 100.00 % 0 0 0
lib/rubysmith/dependencies.rb 100.00 % 7 3 3 0 1.00 100.00 % 0 0 0
lib/rubysmith/extensions/bundler.rb 100.00 % 48 27 27 0 4.37 100.00 % 0 0 0
lib/rubysmith/extensions/pragmater.rb 100.00 % 50 17 17 0 3.59 100.00 % 0 0 0
lib/rubysmith/extensions/rubocop.rb 100.00 % 40 22 22 0 3.82 100.00 % 0 0 0
lib/rubysmith/extensions/tocer.rb 100.00 % 35 19 19 0 3.53 100.00 % 2 2 0
lib/rubysmith/pathway.rb 100.00 % 32 16 16 0 977.75 100.00 % 4 4 0
lib/rubysmith/renderers/erb.rb 100.00 % 35 17 17 0 54.24 100.00 % 2 2 0
lib/rubysmith/renderers/namespace.rb 100.00 % 45 22 22 0 52.14 100.00 % 2 2 0
lib/rubysmith/text/inserter.rb 100.00 % 31 17 17 0 33.59 100.00 % 5 5 0

lib/rubysmith.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "zeitwerk"
  3. 1 Zeitwerk::Loader.new.then do |loader|
  4. 1 loader.inflector.inflect "cli" => "CLI",
  5. "ci" => "CI",
  6. "circle_ci" => "CircleCI",
  7. "dcoo" => "DCOO",
  8. "erb" => "ERB",
  9. "git_hub_ci" => "GitHubCI",
  10. "irb_kit" => "IRBKit",
  11. "rspec" => "RSpec",
  12. "rtc" => "RTC"
  13. 1 loader.tag = File.basename __FILE__, ".rb"
  14. 1 loader.push_dir __dir__
  15. 1 loader.setup
  16. end
  17. # Main namespace.
  18. 1 module Rubysmith
  19. 1 def self.loader registry = Zeitwerk::Registry
  20. 6 @loader ||= registry.loaders.each.find { |loader| loader.tag == File.basename(__FILE__, ".rb") }
  21. end
  22. end

lib/rubysmith/builder.rb

100.0% lines covered

100.0% branches covered

79 relevant lines. 79 lines covered and 0 lines missed.
4 total branches, 4 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "open3"
  3. 1 require "refinements/pathname"
  4. 1 module Rubysmith
  5. # :reek:DataClump
  6. # Provides common functionality necessary for all builders.
  7. 1 class Builder
  8. 1 include Dependencies[:logger]
  9. 1 using Refinements::Pathname
  10. 1 HELPERS = {inserter: Text::Inserter, renderer: Renderers::ERB, executor: Open3}.freeze
  11. 1 def initialize(settings, helpers: HELPERS, **)
  12. 313 @settings = settings
  13. 313 @helpers = helpers
  14. 313 super(**)
  15. end
  16. 1 def append content
  17. 12 log_debug "Appending content to: #{relative_build_path}"
  18. 24 build_path.rewrite { |body| body + content }
  19. 12 self
  20. end
  21. 1 def check
  22. 8 build_path.then do |path|
  23. 8 then: 1 else: 7 path.exist? ? logger.abort("Path exists: #{path}.") : log_debug("Checked: #{path}.")
  24. end
  25. end
  26. 1 def delete
  27. 3 log_info "Deleting: #{relative_build_path}"
  28. 3 build_path.delete
  29. 3 self
  30. end
  31. 1 def insert_after pattern, content
  32. 28 log_debug "Inserting content after pattern in: #{relative_build_path}"
  33. 28 build_path.write inserter.new(build_path.readlines, :after).call(content, pattern).join
  34. 28 self
  35. end
  36. 1 def insert_before pattern, content
  37. 20 log_debug "Inserting content before pattern in: #{relative_build_path}"
  38. 20 build_path.write inserter.new(build_path.readlines, :before).call(content, pattern).join
  39. 20 self
  40. end
  41. 1 def make_path
  42. 8 log_info "Making: #{relative_build_path}"
  43. 8 build_path.mkpath
  44. 8 self
  45. end
  46. 1 def permit mode
  47. 48 log_debug "Changing permissions for: #{relative_build_path}"
  48. 48 build_path.chmod mode
  49. 48 self
  50. end
  51. 1 def prepend content
  52. 3 log_debug "Prepending content to: #{relative_build_path}"
  53. 6 build_path.rewrite { |body| content + body }
  54. 3 self
  55. end
  56. 1 def rename name
  57. 20 log_debug "Renaming: #{build_path.basename} to #{name}"
  58. 20 build_path.rename build_path.parent.join(name)
  59. 20 self
  60. end
  61. 1 def render
  62. 270 log_info "Rendering: #{relative_build_path}"
  63. 270 pathway.start_path.read.then do |content|
  64. 270 build_path.make_ancestors.write renderer.call(content)
  65. end
  66. 270 self
  67. end
  68. 1 def replace pattern, content
  69. 300 log_debug "Replacing content for patterns in: #{relative_build_path}"
  70. 600 build_path.rewrite { |body| body.gsub pattern, content }
  71. 300 self
  72. end
  73. 1 def run *command
  74. 18 log_info "Running: #{command}"
  75. 18 execute(*command)
  76. 16 self
  77. rescue StandardError => error
  78. 2 log_error error and self
  79. end
  80. 1 def touch
  81. 4 log_info "Touching: #{relative_build_path}"
  82. 4 build_path.touch_deep
  83. 4 self
  84. end
  85. 1 private
  86. 1 attr_reader :settings, :helpers
  87. 1 def execute *command
  88. 18 executor.capture2e(*command).then do |result, status|
  89. 16 else: 14 then: 2 log_error result unless status.success?
  90. end
  91. end
  92. 1 def inserter = helpers.fetch(__method__)
  93. 1 def renderer = helpers.fetch(__method__).new(settings)
  94. 1 def executor = helpers.fetch(__method__)
  95. 1 def relative_build_path = build_path.relative_path_from(settings.target_root)
  96. 1 def build_path
  97. 1508 pathway.end_path
  98. .gsub("%project_name%", settings.project_name)
  99. .sub("%project_path%", settings.project_path)
  100. .sub ".erb", ""
  101. end
  102. 1 def pathway = settings.pathway
  103. 304 def log_info(message) = logger.info { message }
  104. 439 def log_debug(message) = logger.debug { message }
  105. 5 def log_error(message) = logger.error { message }
  106. end
  107. end

lib/rubysmith/builders/abstract.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module Rubysmith
  3. 1 module Builders
  4. # Provides default implementation from which builders can inherit from.
  5. 1 class Abstract
  6. 1 include Dependencies[:settings, :logger]
  7. 1 def initialize(builder: Builder, **)
  8. 628 @builder = -> settings { builder.new settings, logger: }
  9. 361 super(**)
  10. end
  11. 1 def call
  12. 1 fail NoMethodError,
  13. "`#{self.class}##{__method__} #{method(__method__).parameters}` must be implemented."
  14. end
  15. 1 protected
  16. 1 attr_reader :builder
  17. end
  18. end
  19. end

lib/rubysmith/builders/bundler.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. # Builds Bundler Gemfile configuration for project skeleton.
  6. 1 class Bundler < Abstract
  7. 1 using Refinements::Struct
  8. 1 def call
  9. 24 builder.call(settings.with(template_path: "%project_name%/Gemfile.erb"))
  10. .render
  11. .replace(/\n\s+group/, "\n\ngroup")
  12. .replace(/\n\s+gem/, "\n gem")
  13. .replace(/ (?=.+(bootsnap|dry-monads|refinements|zeitwerk))/, "")
  14. .replace(/(\n+|\s+)end/, "\nend")
  15. .replace(/\n\ngroup :(quality|development|test|tools) do\nend/, "")
  16. .insert_after(/source.+"\n/, "\n")
  17. 24 true
  18. end
  19. end
  20. end
  21. end

lib/rubysmith/builders/caliber.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. # Builds project skeleton with Caliber style support.
  6. 1 class Caliber < Abstract
  7. 1 using Refinements::Struct
  8. 1 def call
  9. 11 else: 6 then: 5 return false unless settings.build_caliber
  10. 6 builder.call(settings.with(template_path: "%project_name%/bin/rubocop.erb"))
  11. .render
  12. .permit 0o755
  13. 6 path = "%project_name%/.config/rubocop/config.yml.erb"
  14. 6 builder.call(settings.with(template_path: path)).render
  15. 6 true
  16. end
  17. end
  18. end
  19. end

lib/rubysmith/builders/circle_ci.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. # Builds project skeleton Circle CI configuration.
  6. 1 class CircleCI < Abstract
  7. 1 using Refinements::Struct
  8. 1 def call
  9. 9 else: 5 then: 4 return false unless settings.build_circle_ci
  10. 5 builder.call(settings.with(template_path: "%project_name%/.circleci/config.yml.erb"))
  11. .render
  12. .replace(/\n\n\Z/, "\n")
  13. 5 true
  14. end
  15. end
  16. end
  17. end

lib/rubysmith/builders/console.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. # Builds project skeleton console for object inspection and exploration.
  6. 1 class Console < Abstract
  7. 1 using Refinements::Struct
  8. 1 def call
  9. 11 else: 7 then: 4 return false unless settings.build_console
  10. 7 builder.call(settings.with(template_path: "%project_name%/bin/console.erb"))
  11. .render
  12. .permit 0o755
  13. 7 true
  14. end
  15. end
  16. end
  17. end

lib/rubysmith/builders/core.rb

100.0% lines covered

100.0% branches covered

20 relevant lines. 20 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/string"
  3. 1 require "refinements/struct"
  4. 1 module Rubysmith
  5. 1 module Builders
  6. # Builds project skeleton core structure and minimum file support.
  7. 1 class Core < Abstract
  8. 1 using Refinements::String
  9. 1 using Refinements::Struct
  10. 1 def call
  11. 16 render_implementation
  12. 16 render_specification
  13. 16 true
  14. end
  15. 1 private
  16. 1 def render_implementation
  17. 16 builder.call(settings.with(template_path: "%project_name%/lib/%project_path%.rb.erb"))
  18. .render
  19. .replace(" require", "require")
  20. .replace(/ (?=(Zeit|loader|end))/, "")
  21. .replace("\n \n", "\n\n")
  22. .insert_before("module #{module_name}", "#{indentation}# Main namespace.\n")
  23. end
  24. 1 def render_specification
  25. 16 else: 8 then: 8 return unless settings.build_zeitwerk
  26. 8 path = "%project_name%/spec/lib/%project_path%_spec.rb.erb"
  27. 8 builder.call(settings.with(template_path: path)).render
  28. end
  29. 1 def indentation = ::Core::EMPTY_STRING.indent settings.project_levels
  30. 1 def module_name = settings.project_class
  31. end
  32. end
  33. end

lib/rubysmith/builders/dev_container/compose.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module DevContainer
  6. # Builds Docker Compose configuration for container.
  7. 1 class Compose < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 8 else: 4 then: 4 return false unless settings.build_devcontainer
  11. 4 path = "%project_name%/.devcontainer/compose.yaml.erb"
  12. 4 builder.call(settings.with(template_path: path)).render
  13. 4 true
  14. end
  15. end
  16. end
  17. end
  18. end

lib/rubysmith/builders/dev_container/configuration.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module DevContainer
  6. # Builds container configuration.
  7. 1 class Configuration < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 10 else: 6 then: 4 return false unless settings.build_devcontainer
  11. 6 path = "%project_name%/.devcontainer/devcontainer.json.erb"
  12. 6 builder.call(settings.with(template_path: path)).render
  13. 6 true
  14. end
  15. end
  16. end
  17. end
  18. end

lib/rubysmith/builders/dev_container/dockerfile.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module DevContainer
  6. # Builds Dockerfile for container.
  7. 1 class Dockerfile < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 8 else: 4 then: 4 return false unless settings.build_devcontainer
  11. 4 builder.call(settings.with(template_path: "%project_name%/.devcontainer/Dockerfile.erb"))
  12. .render
  13. 4 true
  14. end
  15. end
  16. end
  17. end
  18. end

lib/rubysmith/builders/docker/build.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module Docker
  6. # Builds Docker build script.
  7. 1 class Build < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 9 else: 5 then: 4 return false unless settings.build_docker
  11. 5 builder.call(settings.with(template_path: "%project_name%/bin/docker/build.erb"))
  12. .render
  13. .permit 0o755
  14. 5 true
  15. end
  16. end
  17. end
  18. end
  19. end

lib/rubysmith/builders/docker/compose.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module Docker
  6. # Builds Docker compose configuration.
  7. 1 class Compose < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 8 else: 4 then: 4 return false unless settings.build_docker
  11. 4 builder.call(settings.with(template_path: "%project_name%/compose.yml.erb")).render
  12. 4 true
  13. end
  14. end
  15. end
  16. end
  17. end

lib/rubysmith/builders/docker/console.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module Docker
  6. # Builds Docker console script.
  7. 1 class Console < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 9 else: 5 then: 4 return false unless settings.build_docker
  11. 5 builder.call(settings.with(template_path: "%project_name%/bin/docker/console.erb"))
  12. .render
  13. .permit 0o755
  14. 5 true
  15. end
  16. end
  17. end
  18. end
  19. end

lib/rubysmith/builders/docker/entrypoint.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module Docker
  6. # Builds Docker entrypoint script.
  7. 1 class Entrypoint < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 9 else: 5 then: 4 return false unless settings.build_docker
  11. 5 builder.call(settings.with(template_path: "%project_name%/bin/docker/entrypoint.erb"))
  12. .render
  13. .permit 0o755
  14. 5 true
  15. end
  16. end
  17. end
  18. end
  19. end

lib/rubysmith/builders/docker/file.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module Docker
  6. # Builds Dockerfile configuration.
  7. 1 class File < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 15 else: 11 then: 4 return false unless settings.build_docker
  11. 11 builder.call(settings.with(template_path: "%project_name%/Dockerfile.erb")).render
  12. 11 true
  13. end
  14. end
  15. end
  16. end
  17. end

lib/rubysmith/builders/docker/ignore.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module Docker
  6. # Builds Docker ignore configuration.
  7. 1 class Ignore < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 8 else: 4 then: 4 return false unless settings.build_docker
  11. 4 builder.call(settings.with(template_path: "%project_name%/.dockerignore.erb")).render
  12. 4 true
  13. end
  14. end
  15. end
  16. end
  17. end

lib/rubysmith/builders/documentation/citation.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module Documentation
  6. # Builds project skeleton citation documentation.
  7. 1 class Citation < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 9 else: 5 then: 4 return false unless settings.build_citation
  11. 5 builder.call(settings.with(template_path: "%project_name%/CITATION.cff.erb")).render
  12. 5 true
  13. end
  14. end
  15. end
  16. end
  17. end

lib/rubysmith/builders/documentation/license.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module Documentation
  6. # Builds project skeleton LICENSE documentation.
  7. 1 class License < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 21 else: 17 then: 4 return false unless settings.build_license
  11. 17 settings.with(template_path: "%project_name%/LICENSE-#{license}.#{kind}.erb")
  12. .then do |updated_settings|
  13. 17 builder.call(updated_settings).render.rename "LICENSE.#{kind}"
  14. end
  15. 17 true
  16. end
  17. 1 private
  18. 1 def kind = settings.documentation_format
  19. 1 def license = settings.license_name
  20. end
  21. end
  22. end
  23. end

lib/rubysmith/builders/documentation/readme.rb

100.0% lines covered

100.0% branches covered

12 relevant lines. 12 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module Documentation
  6. # Builds project skeleton README documentation.
  7. 1 class Readme < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 11 else: 7 then: 4 return false unless settings.build_readme
  11. 7 builder.call(settings.with(template_path: "%project_name%/README.#{kind}.erb"))
  12. .render
  13. .replace(/\n{2,}/, "\n\n")
  14. .replace("\n \n", "\n")
  15. 7 true
  16. end
  17. 1 protected
  18. 1 def kind = settings.documentation_format
  19. end
  20. end
  21. end
  22. end

lib/rubysmith/builders/documentation/version.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 require "tocer"
  4. 1 module Rubysmith
  5. 1 module Builders
  6. 1 module Documentation
  7. # Builds project skeleton version history.
  8. 1 class Version < Abstract
  9. 1 using Refinements::Struct
  10. 1 def call
  11. 11 else: 7 then: 4 return false unless settings.build_versions
  12. 7 builder.call(settings.with(template_path: "%project_name%/VERSIONS.#{kind}.erb")).render
  13. 7 true
  14. end
  15. 1 private
  16. 1 def kind = settings.documentation_format
  17. end
  18. end
  19. end
  20. end

lib/rubysmith/builders/git/commit.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module Rubysmith
  3. 1 module Builders
  4. 1 module Git
  5. # Builds project skeleton initial Git commit message.
  6. 1 class Commit < Abstract
  7. 1 include Dependencies[:specification]
  8. 1 def call
  9. 8 else: 4 then: 4 return false unless settings.build_git
  10. 4 builder.call(settings)
  11. .run("git add .", chdir: project_name)
  12. .run(
  13. %(git commit --all --message "Added project skeleton" --message "#{body}"),
  14. chdir: project_name
  15. )
  16. 4 true
  17. end
  18. 1 private
  19. 1 def body
  20. 4 "Generated with link:#{specification.homepage_url}[#{specification.label}] " \
  21. "#{specification.version}."
  22. end
  23. 1 def project_name = settings.project_name
  24. end
  25. end
  26. end
  27. end

lib/rubysmith/builders/git/ignore.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module Git
  6. # Builds Git repository directory and file ignore configuration.
  7. 1 class Ignore < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 8 else: 4 then: 4 return false unless settings.build_git
  11. 4 builder.call(settings.with(template_path: "%project_name%/.gitignore.erb"))
  12. .render
  13. .replace(" ", "")
  14. 4 true
  15. end
  16. end
  17. end
  18. end
  19. end

lib/rubysmith/builders/git/safe.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module Git
  6. # Initializes project skeleton with Git Safe support.
  7. 1 class Safe < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 8 else: 4 then: 4 return false unless settings.build_git
  11. 4 builder.call(settings.with(template_path: "%project_name%/.git/safe")).make_path
  12. 4 true
  13. end
  14. end
  15. end
  16. end
  17. end

lib/rubysmith/builders/git/setup.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module Rubysmith
  3. 1 module Builders
  4. 1 module Git
  5. # Initializes project skeleton as a Git repository.
  6. 1 class Setup < Abstract
  7. 1 def call
  8. 8 else: 4 then: 4 return false unless settings.build_git
  9. 4 builder.call(settings).run("git init", chdir: settings.project_name)
  10. 4 true
  11. end
  12. end
  13. end
  14. end
  15. end

lib/rubysmith/builders/git_hub/ci.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module GitHub
  6. # Builds project skeleton GitHub CI template.
  7. 1 class CI < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 10 else: 6 then: 4 return false unless settings.build_git_hub_ci
  11. 6 builder.call(with_template).render.replace(/\n\n\Z/, "\n")
  12. 6 true
  13. end
  14. 1 private
  15. 1 def with_template
  16. 6 settings.with template_path: "%project_name%/.github/workflows/ci.yml.erb"
  17. end
  18. end
  19. end
  20. end
  21. end

lib/rubysmith/builders/git_hub/funding.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module GitHub
  6. # Builds project skeleton GitHub funding template.
  7. 1 class Funding < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 13 else: 5 then: 8 return false unless settings.build_git_hub && settings.build_funding
  11. 5 settings.with(template_path: "%project_name%/.github/FUNDING.yml.erb")
  12. 5 .then { |updated_configuration| builder.call(updated_configuration).render }
  13. 5 true
  14. end
  15. end
  16. end
  17. end
  18. end

lib/rubysmith/builders/git_hub/template.rb

100.0% lines covered

100.0% branches covered

19 relevant lines. 19 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module GitHub
  6. # Builds project skeleton GitHub templates.
  7. 1 class Template < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 13 else: 7 then: 6 return false unless settings.build_git_hub
  11. 7 builder.call(with_issue).render
  12. 7 builder.call(with_pull_request).render
  13. 7 builder.call(with_configuration).render
  14. 7 true
  15. end
  16. 1 private
  17. 1 def with_issue
  18. 7 settings.with template_path: "%project_name%/.github/ISSUE_TEMPLATE/issue.md.erb"
  19. end
  20. 1 def with_pull_request
  21. 7 settings.with template_path: "%project_name%/.github/PULL_REQUEST_TEMPLATE.md.erb"
  22. end
  23. 1 def with_configuration
  24. 7 settings.with template_path: "%project_name%/.github/ISSUE_TEMPLATE/config.yml.erb"
  25. end
  26. end
  27. end
  28. end
  29. end

lib/rubysmith/builders/init.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "pathname"
  3. 1 require "refinements/struct"
  4. 1 module Rubysmith
  5. 1 module Builders
  6. # Initializes building of project by checking for existence first.
  7. 1 class Init < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 6 builder.call(settings.with(template_path: "%project_name%")).check
  11. 6 true
  12. end
  13. end
  14. end
  15. end

lib/rubysmith/builders/rake/binstub.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module Rake
  6. # Builds project skeleton Rake binstub.
  7. 1 class Binstub < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 9 else: 5 then: 4 return false unless settings.build_rake
  11. 5 builder.call(settings.with(template_path: "%project_name%/bin/rake.erb"))
  12. .render
  13. .permit 0o755
  14. 5 true
  15. end
  16. end
  17. end
  18. end
  19. end

lib/rubysmith/builders/rake/configuration.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module Rake
  6. # Builds project skeleton Rake file configuration.
  7. 1 class Configuration < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 13 else: 9 then: 4 return false unless settings.build_rake
  11. 9 builder.call(settings.with(template_path: "%project_name%/Rakefile.erb"))
  12. .render
  13. .replace(/\[\s+/, "[")
  14. .replace(/\s+\]/, "]")
  15. .replace(" ", "")
  16. .replace("task.options", " task.options")
  17. .replace(/\n+(?=require)/, "\n")
  18. .replace(/\n{2,}/, "\n\n")
  19. 9 true
  20. end
  21. end
  22. end
  23. end
  24. end

lib/rubysmith/builders/reek.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. # Builds project skeleton Reek code quality support.
  6. 1 class Reek < Abstract
  7. 1 using Refinements::Struct
  8. 1 def call
  9. 8 else: 4 then: 4 return false unless settings.build_reek
  10. 4 builder.call(settings.with(template_path: "%project_name%/.reek.yml.erb")).render
  11. 4 true
  12. end
  13. end
  14. end
  15. end

lib/rubysmith/builders/rspec/binstub.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module RSpec
  6. # Builds RSpec binstub for project skeleton.
  7. 1 class Binstub < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 9 else: 5 then: 4 return false unless settings.build_rspec
  11. 5 builder.call(settings.with(template_path: "%project_name%/bin/rspec.erb"))
  12. .render
  13. .permit 0o755
  14. 5 true
  15. end
  16. end
  17. end
  18. end
  19. end

lib/rubysmith/builders/rspec/context.rb

100.0% lines covered

100.0% branches covered

12 relevant lines. 12 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module RSpec
  6. # Builds RSpec shared context for temporary directories.
  7. 1 class Context < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 8 else: 4 then: 4 return false unless settings.build_rspec
  11. 4 template = "%project_name%/spec/support/shared_contexts/temp_dir.rb.erb"
  12. 4 settings.with(template_path: template)
  13. 4 .then { |updated_configuration| builder.call updated_configuration }
  14. .render
  15. .replace(/\n\s+\n\s+/, "\n ")
  16. 4 true
  17. end
  18. end
  19. end
  20. end
  21. end

lib/rubysmith/builders/rspec/helper.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. 1 module RSpec
  6. # Builds RSpec spec helper for project skeleton.
  7. 1 class Helper < Abstract
  8. 1 using Refinements::Struct
  9. 1 def call
  10. 18 else: 14 then: 4 return false unless settings.build_rspec
  11. 14 builder.call(settings.with(template_path: "%project_name%/spec/spec_helper.rb.erb"))
  12. .render
  13. .replace(/\A\n/, "")
  14. .replace("\n\n\n", "\n\n")
  15. .replace("\n \n", "\n")
  16. 14 true
  17. end
  18. end
  19. end
  20. end
  21. end

lib/rubysmith/builders/setup.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. # Builds project skeleton setup script.
  6. 1 class Setup < Abstract
  7. 1 using Refinements::Struct
  8. 1 def call
  9. 11 else: 7 then: 4 return false unless settings.build_setup
  10. 7 builder.call(settings.with(template_path: "%project_name%/bin/setup.erb"))
  11. .render
  12. .permit 0o755
  13. 7 true
  14. end
  15. end
  16. end
  17. end

lib/rubysmith/builders/version.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 module Rubysmith
  4. 1 module Builders
  5. # Builds project skeleton Ruby version file.
  6. 1 class Version < Abstract
  7. 1 using Refinements::Struct
  8. 1 def call
  9. 9 builder.call(settings.with(template_path: "%project_name%/.ruby-version.erb"))
  10. .render
  11. .append("\n")
  12. 9 true
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/amazing_print.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores Amazing Print flag.
  7. 1 class AmazingPrint < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add Amazing Print gem."
  10. 1 on "--[no-]amazing_print"
  11. 12 default { Container[:settings].build_amazing_print }
  12. 1 def call(boolean) = settings.build_amazing_print = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/bootsnap.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores Bootsnap flag.
  7. 1 class Bootsnap < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add Bootsnap gem."
  10. 1 on "--[no-]bootsnap"
  11. 12 default { Container[:settings].build_bootsnap }
  12. 1 def call(boolean) = settings.build_bootsnap = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/caliber.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores Caliber flag.
  7. 1 class Caliber < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add Caliber gem."
  10. 1 on "--[no-]caliber"
  11. 12 default { Container[:settings].build_caliber }
  12. 1 def call(boolean) = settings.build_caliber = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/circle_ci.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores Circle CI flag.
  7. 1 class CircleCI < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add Circle CI support."
  10. 1 on "--[no-]circle_ci"
  11. 12 default { Container[:settings].build_circle_ci }
  12. 1 def call(boolean) = settings.build_circle_ci = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/citation.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores citation flag.
  7. 1 class Citation < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add citation documentation."
  10. 1 on "--[no-]citation"
  11. 12 default { Container[:settings].build_citation }
  12. 1 def call(boolean) = settings.build_citation = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/community.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores community flag.
  7. 1 class Community < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add community documentation."
  10. 1 on "--[no-]community"
  11. 12 default { Container[:settings].build_community }
  12. 1 def call(boolean) = settings.build_community = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/conduct.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores conduct flag.
  7. 1 class Conduct < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add code of conduct documentation."
  10. 1 on "--[no-]conduct"
  11. 12 default { Container[:settings].build_conduct }
  12. 1 def call(boolean) = settings.build_conduct = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/console.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores console flag.
  7. 1 class Console < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add console script."
  10. 1 on "--[no-]console"
  11. 12 default { Container[:settings].build_console }
  12. 1 def call(boolean) = settings.build_console = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/contributions.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores contributions flag.
  7. 1 class Contributions < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add contributions documentation."
  10. 1 on "--[no-]contributions"
  11. 12 default { Container[:settings].build_contributions }
  12. 1 def call(boolean) = settings.build_contributions = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/dcoo.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores Developer Certificate of Origin flag.
  7. 1 class DCOO < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add Developer Certificate of Origin documentation."
  10. 1 on "--[no-]dcoo"
  11. 12 default { Container[:settings].build_dcoo }
  12. 1 def call(boolean) = settings.build_dcoo = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/debug.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores Debug flag.
  7. 1 class Debug < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add Debug gem."
  10. 1 on "--[no-]debug"
  11. 12 default { Container[:settings].build_debug }
  12. 1 def call(boolean) = settings.build_debug = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/dev_container.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores Development Container flag.
  7. 1 class DevContainer < Sod::Action
  8. 1 include Dependencies[:settings, :logger]
  9. 1 description "Add Development Container support."
  10. 1 ancillary "DEPRECATED: Will be removed in Version 9.0.0."
  11. 1 on "--[no-]devcontainer"
  12. 13 default { Container[:settings].build_devcontainer }
  13. 1 def call boolean
  14. 10 logger.warn { "Dev Container support will be removed in Version 9.0.0." }
  15. 5 settings.build_devcontainer = boolean
  16. end
  17. end
  18. end
  19. end
  20. end

lib/rubysmith/cli/actions/docker.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores Docker flag.
  7. 1 class Docker < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add Docker support."
  10. 1 on "--[no-]docker"
  11. 12 default { Container[:settings].build_docker }
  12. 1 def call(boolean) = settings.build_docker = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/funding.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores funding flag.
  7. 1 class Funding < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add GitHub funding."
  10. 1 on "--[no-]funding"
  11. 12 default { Container[:settings].build_funding }
  12. 1 def call(boolean) = settings.build_funding = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/git.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores Git flag.
  7. 1 class Git < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add Git repository."
  10. 1 on "--[no-]git"
  11. 12 default { Container[:settings].build_git }
  12. 1 def call(boolean) = settings.build_git = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/git_hub.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores GitHub flag.
  7. 1 class GitHub < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add GitHub code review and issue templates."
  10. 1 on "--[no-]git_hub"
  11. 12 default { Container[:settings].build_git_hub }
  12. 1 def call(boolean) = settings.build_git_hub = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/git_hub_ci.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores GitHub CI flag.
  7. 1 class GitHubCI < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add GitHub continuous integration support."
  10. 1 on "--[no-]git_hub_ci"
  11. 12 default { Container[:settings].build_git_hub_ci }
  12. 1 def call(boolean) = settings.build_git_hub_ci = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/git_lint.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores Git Lint flag.
  7. 1 class GitLint < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add Git Lint gem."
  10. 1 on "--[no-]git-lint"
  11. 12 default { Container[:settings].build_git_lint }
  12. 1 def call(boolean) = settings.build_git_lint = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/irb_kit.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores IRB Kit flag.
  7. 1 class IRBKit < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add IRB Kit gem."
  10. 1 on "--[no-]irb-kit"
  11. 12 default { Container[:settings].build_irb_kit }
  12. 1 def call(boolean) = settings.build_irb_kit = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/license.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores license flag.
  7. 1 class License < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add license documentation."
  10. 1 on "--[no-]license"
  11. 12 default { Container[:settings].build_license }
  12. 1 def call(boolean) = settings.build_license = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/maximum.rb

100.0% lines covered

100.0% branches covered

12 relevant lines. 12 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 require "sod"
  4. 1 module Rubysmith
  5. 1 module CLI
  6. 1 module Actions
  7. # Forces maximum settings.
  8. 1 class Maximum < Sod::Action
  9. 1 include Dependencies[:settings]
  10. 1 using ::Refinements::Struct
  11. 1 description "Use maximum configuration."
  12. 1 on "--max"
  13. 11 default { Container[:settings].build_maximum }
  14. 1 def call(*) = settings.with! settings.maximize
  15. end
  16. end
  17. end
  18. end

lib/rubysmith/cli/actions/minimum.rb

100.0% lines covered

100.0% branches covered

12 relevant lines. 12 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 require "sod"
  4. 1 module Rubysmith
  5. 1 module CLI
  6. 1 module Actions
  7. # Forces minimum settings.
  8. 1 class Minimum < Sod::Action
  9. 1 include Dependencies[:settings]
  10. 1 using ::Refinements::Struct
  11. 1 description "Use minimum configuration."
  12. 1 on "--min"
  13. 11 default { Container[:settings].build_minimum }
  14. 1 def call(*) = settings.with! settings.minimize
  15. end
  16. end
  17. end
  18. end

lib/rubysmith/cli/actions/monads.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores monads flag.
  7. 1 class Monads < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add Dry Monads gem."
  10. 1 on "--[no-]monads"
  11. 12 default { Container[:settings].build_monads }
  12. 1 def call(boolean) = settings.build_monads = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/name.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores project (build) name.
  7. 1 class Name < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Set project name."
  10. 1 on %w[-n --name], argument: "NAME"
  11. 1 def call(name) = settings.project_name = name
  12. end
  13. end
  14. end
  15. end

lib/rubysmith/cli/actions/rake.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores Rake flag.
  7. 1 class Rake < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add Rake gem."
  10. 1 on "--[no-]rake"
  11. 12 default { Container[:settings].build_rake }
  12. 1 def call(boolean) = settings.build_rake = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/readme.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores readme flag.
  7. 1 class Readme < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add readme documentation."
  10. 1 on "--[no-]readme"
  11. 12 default { Container[:settings].build_readme }
  12. 1 def call(boolean) = settings.build_readme = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/reek.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores Reek flag.
  7. 1 class Reek < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add Reek gem."
  10. 1 on "--[no-]reek"
  11. 12 default { Container[:settings].build_reek }
  12. 1 def call(boolean) = settings.build_reek = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/refinements.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores Refinements flag.
  7. 1 class Refinements < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add Refinements gem."
  10. 1 on "--[no-]refinements"
  11. 12 default { Container[:settings].build_refinements }
  12. 1 def call(boolean) = settings.build_refinements = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/rspec.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores RSpec flag.
  7. 1 class RSpec < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add RSpec gem."
  10. 1 on "--[no-]rspec"
  11. 12 default { Container[:settings].build_rspec }
  12. 1 def call(boolean) = settings.build_rspec = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/rtc.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores Repl Type Completor flag.
  7. 1 class RTC < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add Repl Type Completor gem."
  10. 1 on "--[no-]rtc"
  11. 12 default { Container[:settings].build_rtc }
  12. 1 def call(boolean) = settings.build_rtc = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/security.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores security flag.
  7. 1 class Security < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add security."
  10. 1 on "--[no-]security"
  11. 12 default { Container[:settings].build_security }
  12. 1 def call(boolean) = settings.build_security = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/setup.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores setup flag.
  7. 1 class Setup < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add setup script."
  10. 1 on "--[no-]setup"
  11. 12 default { Container[:settings].build_setup }
  12. 1 def call(boolean) = settings.build_setup = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/simple_cov.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores SimpleCov flag.
  7. 1 class SimpleCov < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add SimpleCov gem."
  10. 1 on "--[no-]simple_cov"
  11. 12 default { Container[:settings].build_simple_cov }
  12. 1 def call(boolean) = settings.build_simple_cov = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/versions.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores versions flag.
  7. 1 class Versions < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add version history."
  10. 1 on "--[no-]versions"
  11. 12 default { Container[:settings].build_versions }
  12. 1 def call(boolean) = settings.build_versions = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/actions/zeitwerk.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. 1 module Actions
  6. # Stores Zeitwerk flag.
  7. 1 class Zeitwerk < Sod::Action
  8. 1 include Dependencies[:settings]
  9. 1 description "Add Zeitwerk gem."
  10. 1 on "--[no-]zeitwerk"
  11. 12 default { Container[:settings].build_zeitwerk }
  12. 1 def call(boolean) = settings.build_zeitwerk = boolean
  13. end
  14. end
  15. end
  16. end

lib/rubysmith/cli/commands/build.rb

100.0% lines covered

100.0% branches covered

55 relevant lines. 55 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/struct"
  3. 1 require "sod"
  4. 1 module Rubysmith
  5. 1 module CLI
  6. 1 module Commands
  7. # Stores table of contents root path.
  8. 1 class Build < Sod::Command
  9. 1 include Dependencies[:settings, :kernel, :logger]
  10. # Order is important.
  11. BUILDERS = [
  12. 1 Builders::Init,
  13. Builders::Core,
  14. Builders::Version,
  15. Builders::Documentation::Readme,
  16. Builders::Documentation::Citation,
  17. Builders::Documentation::License,
  18. Builders::Documentation::Version,
  19. Builders::Git::Setup,
  20. Builders::Git::Ignore,
  21. Builders::Git::Safe,
  22. Builders::Bundler,
  23. Builders::Rake::Binstub,
  24. Builders::Rake::Configuration,
  25. Builders::Console,
  26. Builders::CircleCI,
  27. Builders::Setup,
  28. Builders::GitHub::Template,
  29. Builders::GitHub::Funding,
  30. Builders::GitHub::CI,
  31. Builders::Reek,
  32. Builders::RSpec::Binstub,
  33. Builders::RSpec::Context,
  34. Builders::RSpec::Helper,
  35. Builders::Caliber,
  36. Builders::DevContainer::Dockerfile,
  37. Builders::DevContainer::Compose,
  38. Builders::DevContainer::Configuration,
  39. Builders::Docker::Build,
  40. Builders::Docker::Console,
  41. Builders::Docker::Entrypoint,
  42. Builders::Docker::Compose,
  43. Builders::Docker::File,
  44. Builders::Docker::Ignore,
  45. Extensions::Bundler,
  46. Extensions::Pragmater,
  47. Extensions::Tocer,
  48. Extensions::Rubocop,
  49. Builders::Git::Commit
  50. ].freeze
  51. 1 handle "build"
  52. 1 description "Build new project."
  53. 1 on Actions::Name
  54. 1 on Actions::AmazingPrint
  55. 1 on Actions::Bootsnap
  56. 1 on Actions::Caliber
  57. 1 on Actions::CircleCI
  58. 1 on Actions::Citation
  59. 1 on Actions::Community
  60. 1 on Actions::Conduct
  61. 1 on Actions::Console
  62. 1 on Actions::Contributions
  63. 1 on Actions::DCOO
  64. 1 on Actions::Debug
  65. 1 on Actions::DevContainer
  66. 1 on Actions::Docker
  67. 1 on Actions::Funding
  68. 1 on Actions::Git
  69. 1 on Actions::GitHub
  70. 1 on Actions::GitHubCI
  71. 1 on Actions::GitLint
  72. 1 on Actions::IRBKit
  73. 1 on Actions::License
  74. 1 on Actions::Maximum
  75. 1 on Actions::Minimum
  76. 1 on Actions::Monads
  77. 1 on Actions::Rake
  78. 1 on Actions::Readme
  79. 1 on Actions::Reek
  80. 1 on Actions::Refinements
  81. 1 on Actions::RSpec
  82. 1 on Actions::RTC
  83. 1 on Actions::Security
  84. 1 on Actions::Setup
  85. 1 on Actions::SimpleCov
  86. 1 on Actions::Versions
  87. 1 on Actions::Zeitwerk
  88. 1 def initialize(builders: BUILDERS, **)
  89. 9 super(**)
  90. 9 @builders = builders
  91. end
  92. 1 def call
  93. 6 log_info "Building project skeleton: #{settings.project_name}..."
  94. 160 builders.each { |builder| builder.new(settings:, logger:).call }
  95. 6 log_info "Project skeleton complete!"
  96. end
  97. 1 private
  98. 1 attr_reader :builders
  99. 13 def log_info(message) = logger.info { message }
  100. end
  101. end
  102. end
  103. end

lib/rubysmith/cli/shell.rb

100.0% lines covered

100.0% branches covered

21 relevant lines. 21 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "sod"
  3. 1 module Rubysmith
  4. 1 module CLI
  5. # The main Command Line Interface (CLI) object.
  6. 1 class Shell
  7. 1 include Dependencies[:defaults_path, :xdg_config, :specification]
  8. 1 def initialize(context: Sod::Context, dsl: Sod, **)
  9. 7 super(**)
  10. 7 @context = context
  11. 7 @dsl = dsl
  12. end
  13. 1 def call(...) = cli.call(...)
  14. 1 private
  15. 1 attr_reader :context, :dsl
  16. 1 def cli
  17. 7 context = build_context
  18. 7 dsl.new :rubysmith, banner: specification.banner do
  19. 7 on(Sod::Prefabs::Commands::Config, context:)
  20. 7 on Commands::Build
  21. 7 on(Sod::Prefabs::Actions::Version, context:)
  22. 7 on Sod::Prefabs::Actions::Help, self
  23. end
  24. end
  25. 1 def build_context
  26. 7 context[defaults_path:, xdg_config:, version_label: specification.labeled_version]
  27. end
  28. end
  29. end
  30. end

lib/rubysmith/configuration/contract.rb

100.0% lines covered

100.0% branches covered

76 relevant lines. 76 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "dry/schema"
  3. 1 require "etcher"
  4. 1 Dry::Schema.load_extensions :monads
  5. 1 module Rubysmith
  6. 1 module Configuration
  7. 1 Contract = Dry::Schema.Params do
  8. 1 optional(:author_email).filled :string
  9. 1 optional(:author_family_name).filled :string
  10. 1 optional(:author_given_name).filled :string
  11. 1 required(:author_handle).filled :string
  12. 1 required(:author_uri).filled :string
  13. 1 required(:build_amazing_print).filled :bool
  14. 1 required(:build_bootsnap).filled :bool
  15. 1 required(:build_caliber).filled :bool
  16. 1 required(:build_circle_ci).filled :bool
  17. 1 required(:build_citation).filled :bool
  18. 1 required(:build_cli).filled :bool
  19. 1 required(:build_community).filled :bool
  20. 1 required(:build_conduct).filled :bool
  21. 1 required(:build_console).filled :bool
  22. 1 required(:build_contributions).filled :bool
  23. 1 required(:build_dcoo).filled :bool
  24. 1 required(:build_debug).filled :bool
  25. 1 required(:build_devcontainer).filled :bool
  26. 1 required(:build_docker).filled :bool
  27. 1 required(:build_funding).filled :bool
  28. 1 required(:build_git).filled :bool
  29. 1 required(:build_git_hub).filled :bool
  30. 1 required(:build_git_hub_ci).filled :bool
  31. 1 required(:build_git_lint).filled :bool
  32. 1 required(:build_irb_kit).filled :bool
  33. 1 required(:build_license).filled :bool
  34. 1 required(:build_maximum).filled :bool
  35. 1 required(:build_minimum).filled :bool
  36. 1 required(:build_monads).filled :bool
  37. 1 required(:build_rake).filled :bool
  38. 1 required(:build_readme).filled :bool
  39. 1 required(:build_reek).filled :bool
  40. 1 required(:build_refinements).filled :bool
  41. 1 required(:build_rspec).filled :bool
  42. 1 required(:build_rtc).filled :bool
  43. 1 required(:build_security).filled :bool
  44. 1 required(:build_setup).filled :bool
  45. 1 required(:build_simple_cov).filled :bool
  46. 1 required(:build_versions).filled :bool
  47. 1 required(:build_zeitwerk).filled :bool
  48. 1 optional(:citation_affiliation).filled :string
  49. 1 optional(:citation_message).filled :string
  50. 1 optional(:citation_orcid).filled :string
  51. 1 required(:documentation_format).filled :string
  52. 1 required(:gems_uri).filled :string
  53. 1 required(:loaded_at).filled :time
  54. 1 required(:license_label).filled :string
  55. 1 required(:license_name).filled :string
  56. 1 required(:license_version).filled :string
  57. 1 optional(:organization_label).filled :string
  58. 1 required(:organization_uri).filled :string
  59. 1 optional(:project_name).filled :string
  60. 1 optional(:project_uri_community).filled :string
  61. 1 optional(:project_uri_conduct).filled :string
  62. 1 optional(:project_uri_contributions).filled :string
  63. 1 optional(:project_uri_dcoo).filled :string
  64. 1 optional(:project_uri_download).filled :string
  65. 1 optional(:project_uri_funding).filled :string
  66. 1 optional(:project_uri_home).filled :string
  67. 1 optional(:project_uri_issues).filled :string
  68. 1 optional(:project_uri_license).filled :string
  69. 1 optional(:project_uri_security).filled :string
  70. 1 optional(:project_uri_source).filled :string
  71. 1 optional(:project_uri_versions).filled :string
  72. 1 required(:project_version).filled :string
  73. 1 required(:repository_handle).filled :string
  74. 1 required(:repository_uri).filled :string
  75. 1 required(:target_root).filled Etcher::Types::Pathname
  76. 1 optional(:template_path).filled Etcher::Types::Pathname
  77. 1 required(:template_roots).array Etcher::Types::Pathname
  78. end
  79. end
  80. end

lib/rubysmith/configuration/model.rb

100.0% lines covered

100.0% branches covered

49 relevant lines. 49 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "pathname"
  3. 1 require "refinements/array"
  4. 1 require "refinements/string"
  5. 1 require "refinements/struct"
  6. 1 module Rubysmith
  7. 1 module Configuration
  8. # Defines the common configuration content for use throughout the gem.
  9. 1 Model = Struct.new(
  10. :author_email,
  11. :author_family_name,
  12. :author_given_name,
  13. :author_handle,
  14. :author_uri,
  15. :build_amazing_print,
  16. :build_bootsnap,
  17. :build_caliber,
  18. :build_circle_ci,
  19. :build_citation,
  20. :build_cli,
  21. :build_community,
  22. :build_conduct,
  23. :build_console,
  24. :build_contributions,
  25. :build_dcoo,
  26. :build_debug,
  27. :build_devcontainer,
  28. :build_docker,
  29. :build_funding,
  30. :build_git,
  31. :build_git_hub,
  32. :build_git_hub_ci,
  33. :build_git_lint,
  34. :build_irb_kit,
  35. :build_license,
  36. :build_maximum,
  37. :build_minimum,
  38. :build_monads,
  39. :build_rake,
  40. :build_readme,
  41. :build_reek,
  42. :build_refinements,
  43. :build_rspec,
  44. :build_rtc,
  45. :build_security,
  46. :build_setup,
  47. :build_simple_cov,
  48. :build_versions,
  49. :build_zeitwerk,
  50. :citation_affiliation,
  51. :citation_message,
  52. :citation_orcid,
  53. :documentation_format,
  54. :gems_uri,
  55. :license_label,
  56. :license_name,
  57. :license_version,
  58. :loaded_at,
  59. :organization_label,
  60. :organization_uri,
  61. :project_name,
  62. :project_uri_community,
  63. :project_uri_conduct,
  64. :project_uri_contributions,
  65. :project_uri_dcoo,
  66. :project_uri_download,
  67. :project_uri_funding,
  68. :project_uri_home,
  69. :project_uri_issues,
  70. :project_uri_license,
  71. :project_uri_security,
  72. :project_uri_source,
  73. :project_uri_versions,
  74. :project_version,
  75. :repository_handle,
  76. :repository_uri,
  77. :target_root,
  78. :template_path,
  79. :template_roots
  80. ) do
  81. 1 using Refinements::Array
  82. 1 using Refinements::String
  83. 1 using Refinements::Struct
  84. 1 def maximize = update_build_options true
  85. 1 def minimize = update_build_options false
  86. 1 def author_name = [author_given_name, author_family_name].compress.join(" ")
  87. 1 def license_label_version = [license_label, license_version].compress.join("-")
  88. 1 def project_class = project_namespaced_class.split("::").last
  89. 1 def project_namespaced_class = project_name.camelcase
  90. 1 def project_label = project_name.titleize
  91. 1 def project_levels = project_namespaced_class.split("::").size - 1
  92. 1 def project_path = project_name.snakecase
  93. 1 def project_root = target_root.join(project_name)
  94. 1 def computed_project_uri_community = format_uri(__method__)
  95. 1 def computed_project_uri_conduct = format_uri(__method__)
  96. 1 def computed_project_uri_contributions = format_uri(__method__)
  97. 1 def computed_project_uri_dcoo = format_uri(__method__)
  98. 1 def computed_project_uri_download = format_uri(__method__)
  99. 1 def computed_project_uri_funding = format_uri(__method__)
  100. 1 def computed_project_uri_home = format_uri(__method__)
  101. 1 def computed_project_uri_issues = format_uri(__method__)
  102. 1 def computed_project_uri_license = format_uri(__method__)
  103. 1 def computed_project_uri_security = format_uri(__method__)
  104. 1 def computed_project_uri_source = format_uri(__method__)
  105. 1 def computed_project_uri_versions = format_uri(__method__)
  106. 1 def ascii_doc? = documentation_format == "adoc"
  107. 1 def markdown? = documentation_format == "md"
  108. 1 def pathway
  109. 1779 Pathway[start_root: template_root, start_path: template_path, end_root: target_root]
  110. end
  111. 1 def template_root
  112. 1783 Array(template_roots).map(&:expand_path)
  113. 1784 .find { |path| path.join(String(template_path)).exist? }
  114. end
  115. 1 private
  116. 1 def format_uri kind
  117. 89 kind.to_s
  118. .sub("computed_", "")
  119. 89 .then { |method| public_send method }
  120. 89 .then { |uri| String uri }
  121. 89 .then { |uri| uri.sub "%<project_name>s", project_name }
  122. end
  123. 1 def update_build_options value
  124. 13916 to_h.select { |key, _value| key.start_with? "build_" }
  125. 6860 .transform_values { value }
  126. 196 .then { |attributes| dup.with!(**attributes, build_minimum: !value) }
  127. .freeze
  128. end
  129. end
  130. end
  131. end

lib/rubysmith/configuration/transformers/git_email.rb

100.0% lines covered

100.0% branches covered

17 relevant lines. 17 lines covered and 0 lines missed.
4 total branches, 4 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "dry/monads"
  3. 1 module Rubysmith
  4. 1 module Configuration
  5. 1 module Transformers
  6. # Dynamically adds Git email if defined.
  7. 1 class GitEmail
  8. 1 include Dependencies[:git]
  9. 1 include Dry::Monads[:result]
  10. 1 def initialize(key = :author_email, **)
  11. 381 @key = key
  12. 381 super(**)
  13. end
  14. 382 then: 1 else: 380 def call(attributes) = attributes[key] ? Success(attributes) : email_or(attributes)
  15. 1 private
  16. 1 attr_reader :key
  17. 1 def email_or attributes
  18. 380 git.get("user.email", nil)
  19. 379 then: 378 else: 1 .fmap { |value| value ? attributes.merge!(key => value) : attributes }
  20. 1 .or { Success attributes }
  21. end
  22. end
  23. end
  24. end
  25. end

lib/rubysmith/configuration/transformers/git_hub_user.rb

100.0% lines covered

100.0% branches covered

17 relevant lines. 17 lines covered and 0 lines missed.
4 total branches, 4 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "dry/monads"
  3. 1 module Rubysmith
  4. 1 module Configuration
  5. 1 module Transformers
  6. # Dynamically updates repository handle if GitHub user is defined.
  7. 1 class GitHubUser
  8. 1 include Dependencies[:git]
  9. 1 include Dry::Monads[:result]
  10. 1 def initialize(key = :repository_handle, **)
  11. 381 @key = key
  12. 381 super(**)
  13. end
  14. 382 then: 378 else: 3 def call(attributes) = attributes[key] ? Success(attributes) : user_or(attributes)
  15. 1 private
  16. 1 attr_reader :key
  17. 1 def user_or attributes
  18. 3 git.get("github.user", nil)
  19. 2 then: 1 else: 1 .fmap { |value| value ? attributes.merge!(key => value) : attributes }
  20. 1 .or { Success attributes }
  21. end
  22. end
  23. end
  24. end
  25. end

lib/rubysmith/configuration/transformers/git_user.rb

100.0% lines covered

100.0% branches covered

18 relevant lines. 18 lines covered and 0 lines missed.
4 total branches, 4 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "dry/monads"
  3. 1 module Rubysmith
  4. 1 module Configuration
  5. 1 module Transformers
  6. # Dynamically adds Git user if defined.
  7. 1 class GitUser
  8. 1 include Dependencies[:git]
  9. 1 include Dry::Monads[:result]
  10. 1 def call attributes
  11. 383 then: 3 if attributes[:author_given_name] || attributes[:author_family_name]
  12. 3 Success attributes
  13. else: 380 else
  14. 380 name_or attributes
  15. end
  16. end
  17. 1 private
  18. 2 def name_or(attributes) = split(attributes).or { Success attributes }
  19. 1 def split attributes
  20. 380 git.get("user.name", nil).fmap do |name|
  21. 379 else: 378 then: 1 next attributes unless name
  22. 378 first, last = String(name).split
  23. 378 attributes.merge! author_given_name: first, author_family_name: last
  24. end
  25. end
  26. end
  27. end
  28. end
  29. end

lib/rubysmith/configuration/transformers/template_root.rb

100.0% lines covered

100.0% branches covered

16 relevant lines. 16 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "dry/monads"
  3. 1 require "refinements/array"
  4. 1 module Rubysmith
  5. 1 module Configuration
  6. 1 module Transformers
  7. # Appends custom path to default template roots.
  8. 1 class TemplateRoot
  9. 1 include Dry::Monads[:result]
  10. 1 using Refinements::Array
  11. 1 def initialize key = :template_roots, default: Pathname(__dir__).join("../../templates")
  12. 383 @key = key
  13. 383 @default = default
  14. end
  15. 1 def call attributes
  16. 764 Array(default).map { |path| Pathname path }
  17. .including(attributes[key])
  18. .compact
  19. 383 .then { |value| Success attributes.merge!(key => value) }
  20. end
  21. 1 private
  22. 1 attr_reader :key, :default
  23. end
  24. end
  25. end
  26. end

lib/rubysmith/dependencies.rb

100.0% lines covered

100.0% branches covered

3 relevant lines. 3 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "infusible"
  3. 1 module Rubysmith
  4. 1 Dependencies = Infusible[Container]
  5. end

lib/rubysmith/extensions/bundler.rb

100.0% lines covered

100.0% branches covered

27 relevant lines. 27 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "bundler"
  3. 1 require "bundler/cli"
  4. 1 require "refinements/io"
  5. 1 require "refinements/pathname"
  6. 1 module Rubysmith
  7. 1 module Extensions
  8. # Ensures gem dependencies are installed.
  9. 1 class Bundler
  10. 1 include Dependencies[:settings, :logger]
  11. 1 using Refinements::IO
  12. 1 using Refinements::Pathname
  13. 1 def initialize(client: ::Bundler::CLI, **)
  14. 10 @client = client
  15. 10 super(**)
  16. end
  17. 1 def call
  18. 20 logger.info { "Installing gem dependencies..." }
  19. 10 install
  20. rescue ::Bundler::HTTPError
  21. 2 log_error
  22. end
  23. 1 private
  24. 1 attr_reader :client
  25. 1 def install
  26. 10 settings.project_root.change_dir do
  27. 10 client.start %w[install --quiet]
  28. 16 STDOUT.squelch { client.start %w[lock --add-platform x86_64-linux --update] }
  29. end
  30. 8 true
  31. end
  32. 1 def log_error
  33. 4 logger.error { "Unable to install gem dependencies. Is your network stable?" }
  34. 2 false
  35. end
  36. end
  37. end
  38. end

lib/rubysmith/extensions/pragmater.rb

100.0% lines covered

100.0% branches covered

17 relevant lines. 17 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "pragmater"
  3. 1 require "refinements/pathname"
  4. 1 module Rubysmith
  5. 1 module Extensions
  6. # Ensures project skeleton has pragmas.
  7. 1 class Pragmater
  8. 1 include Dependencies[:settings, :logger]
  9. 1 using Refinements::Pathname
  10. 1 CLIENT = ::Pragmater::Inserter.new(
  11. settings: ::Pragmater::Configuration::Model[
  12. comments: ["# frozen_string_literal: true"],
  13. patterns: %w[
  14. **/*.rake
  15. **/*.rb
  16. *.gemspec
  17. exe/*
  18. bin/console
  19. bin/rake
  20. bin/rspec
  21. bin/rubocop
  22. bin/setup
  23. config.ru
  24. Gemfile
  25. Rakefile
  26. ]
  27. ]
  28. ).freeze
  29. 1 def initialize(client: CLIENT, **)
  30. 7 @client = client
  31. 7 super(**)
  32. end
  33. 1 def call
  34. 14 logger.info { "Adding frozen string literal pragmas..." }
  35. 14 settings.project_root.change_dir { client.call }
  36. 7 true
  37. end
  38. 1 private
  39. 1 attr_reader :client
  40. end
  41. end
  42. end

lib/rubysmith/extensions/rubocop.rb

100.0% lines covered

100.0% branches covered

22 relevant lines. 22 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/io"
  3. 1 require "refinements/pathname"
  4. 1 require "rubocop"
  5. 1 module Rubysmith
  6. 1 module Extensions
  7. # Ensures project skeleton adheres to style guide.
  8. 1 class Rubocop
  9. 1 include Dependencies[:settings, :logger]
  10. 1 using Refinements::IO
  11. 1 using Refinements::Pathname
  12. 1 def initialize(client: ::RuboCop::CLI.new, **)
  13. 7 @client = client
  14. 7 super(**)
  15. end
  16. 1 def call
  17. 14 logger.info { "Running RuboCop autocorrect..." }
  18. 7 autocorrect
  19. 7 true
  20. end
  21. 1 private
  22. 1 attr_reader :client
  23. 1 def autocorrect
  24. 7 project_root = settings.project_root
  25. 7 project_root.change_dir do
  26. 14 STDOUT.squelch { client.run ["--autocorrect-all", project_root.to_s] }
  27. end
  28. end
  29. end
  30. end
  31. end

lib/rubysmith/extensions/tocer.rb

100.0% lines covered

100.0% branches covered

19 relevant lines. 19 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/pathname"
  3. 1 require "stringio"
  4. 1 require "tocer"
  5. 1 module Rubysmith
  6. 1 module Extensions
  7. # Ensures project skeleton documentation has table of content.
  8. 1 class Tocer
  9. 1 include Dependencies[:settings, :logger]
  10. 1 using Refinements::Pathname
  11. 1 def initialize(client: ::Tocer::Runner.new(io: StringIO.new), **)
  12. 13 @client = client
  13. 13 super(**)
  14. end
  15. 1 def call
  16. 13 else: 3 then: 10 return false unless settings.build_readme && settings.markdown?
  17. 6 logger.info { "Adding table of contents..." }
  18. 3 upsert
  19. 3 true
  20. end
  21. 1 private
  22. 1 attr_reader :client
  23. 4 def upsert = settings.project_root.change_dir { client.call }
  24. end
  25. end
  26. end

lib/rubysmith/pathway.rb

100.0% lines covered

100.0% branches covered

16 relevant lines. 16 lines covered and 0 lines missed.
4 total branches, 4 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/pathname"
  3. 1 module Rubysmith
  4. # Represents a pathway which has source start and destination end.
  5. 1 Pathway = Struct.new :start_root, :start_path, :end_root, keyword_init: true do
  6. 1 using Refinements::Pathname
  7. # :reek:TooManyStatements
  8. 1 def initialize *arguments
  9. 1804 super
  10. 7216 each_pair { |key, value| self[key] = Pathname value }
  11. 1804 then: 21 else: 1783 self[:start_path] = start_path.absolute? ? start_path : start_root.join(start_path)
  12. 1804 freeze
  13. end
  14. 1 def with(attributes) = self.class.new(to_h.merge(attributes))
  15. 1 def end_path = end_root.join(from_parent, start_path.basename)
  16. 1 def partial? = start_path.basename.fnmatch?("_*")
  17. 1 private
  18. 1 def from_parent
  19. 1511 then: 16 else: 1495 return end_root.join start_path.parent if start_path.relative?
  20. 1495 start_path.relative_parent start_root
  21. end
  22. end
  23. end

lib/rubysmith/renderers/erb.rb

100.0% lines covered

100.0% branches covered

17 relevant lines. 17 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "erb"
  3. 1 module Rubysmith
  4. 1 module Renderers
  5. # Renders ERB templates as fully functional files.
  6. 1 class ERB
  7. 1 def initialize settings,
  8. scope: Renderers::Namespace.new(settings.project_namespaced_class),
  9. client: ::ERB
  10. 280 @settings = settings
  11. 280 @scope = scope
  12. 280 @client = client
  13. end
  14. 1 def call(content) = client.new(content, trim_mode: "<>", eoutvar: "@buffer").result(binding)
  15. 1 private
  16. 1 attr_accessor :buffer
  17. 1 attr_reader :settings, :scope, :client
  18. 1 def namespace
  19. 24 source = buffer.dup
  20. 24 then: 12 self.buffer = source + if block_given?
  21. 12 scope.call yield.sub(source, "")
  22. else: 12 else
  23. 12 scope.call
  24. end
  25. end
  26. end
  27. end
  28. end

lib/rubysmith/renderers/namespace.rb

100.0% lines covered

100.0% branches covered

22 relevant lines. 22 lines covered and 0 lines missed.
2 total branches, 2 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "refinements/string"
  3. 1 module Rubysmith
  4. 1 module Renderers
  5. # Renders single or multiple modules with correct, two-space indentation for templates.
  6. 1 class Namespace
  7. 1 using Refinements::String
  8. 1 def initialize namespace, delimiter: "::"
  9. 285 @namespace = namespace
  10. 285 @modules = namespace.split delimiter
  11. 285 @depth = namespace.scan(delimiter).length
  12. end
  13. 1 def call(content = nil) = "#{prefix}#{body content}#{suffix}"
  14. 1 private
  15. 1 attr_reader :namespace, :modules, :depth
  16. 1 def prefix
  17. 29 modules.each.with_index.reduce "" do |snippet, (module_name, index)|
  18. 45 %(#{snippet}#{"module".indent index} #{module_name}\n)
  19. end
  20. end
  21. # :reek:FeatureEnvy
  22. 1 def body content
  23. 29 String(content).lstrip.split("\n").reduce "" do |snippet, line|
  24. 57 then: 11 else: 46 next "#{snippet}\n" if line.blank?
  25. 46 "#{snippet}#{line.gsub(/^\s{2}/, "").indent depth + 1}\n"
  26. end
  27. end
  28. 1 def suffix
  29. 29 modules.each.with_index.reduce "" do |snippet, (_, index)|
  30. 45 %(#{snippet}#{"end".indent depth - index}\n)
  31. end
  32. end
  33. end
  34. end
  35. end

lib/rubysmith/text/inserter.rb

100.0% lines covered

100.0% branches covered

17 relevant lines. 17 lines covered and 0 lines missed.
5 total branches, 5 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module Rubysmith
  3. 1 module Text
  4. # Inserts content before or after a line for a given pattern in an array of lines.
  5. 1 class Inserter
  6. 1 def initialize lines, kind = :after
  7. 55 @lines = lines.dup
  8. 55 @kind = kind
  9. end
  10. 1 def call content, pattern
  11. 242 lines.index { |line| line.match? pattern }
  12. 54 then: 52 else: 2 .then { |index| lines.insert index + offset, content if index }
  13. 53 lines
  14. end
  15. 1 private
  16. 1 attr_reader :lines, :kind
  17. 1 def offset
  18. 52 when: 21 case kind
  19. 21 when: 30 when :before then 0
  20. 30 else: 1 when :after then 1
  21. 1 else fail StandardError, "Unknown kind of insert: #{kind}."
  22. end
  23. end
  24. end
  25. end
  26. end