class Rubysmith::Builders::Documentation
Builds project skeleton documentation.
Public Class Methods
call(...)
click to toggle source
# File lib/rubysmith/builders/documentation.rb, line 7 def self.call(...) = new(...).call def initialize configuration, builder: Builder @configuration = configuration @builder = builder end def call return unless configuration.build_documentation private_methods.sort.grep(/render_/).each { |method| __send__ method } end private attr_reader :configuration, :builder def render_changes builder.call(configuration.with(template_path: "%project_name%/CHANGES.#{kind}.erb")) .render end def render_conduct configuration.with(template_path: "%project_name%/CODE_OF_CONDUCT.#{kind}.erb") .then { |updated_configuration| builder.call(updated_configuration).render } end def render_contributions builder.call(configuration.with(template_path: "%project_name%/CONTRIBUTING.#{kind}.erb")) .render end def render_license configuration.with(template_path: "%project_name%/LICENSE-#{license}.#{kind}.erb") .then do |updated_configuration| builder.call(updated_configuration).render.rename "LICENSE.#{kind}" end end def render_readme builder.call(configuration.with(template_path: "%project_name%/README.#{kind}.erb")) .render .replace("\n\n\n", "\n\n") end def kind = configuration.documentation_format || "md" def license = configuration.documentation_license || "mit" end end end
new(configuration, builder: Builder)
click to toggle source
# File lib/rubysmith/builders/documentation.rb, line 9 def initialize configuration, builder: Builder @configuration = configuration @builder = builder end
Public Instance Methods
call()
click to toggle source
# File lib/rubysmith/builders/documentation.rb, line 14 def call return unless configuration.build_documentation private_methods.sort.grep(/render_/).each { |method| __send__ method } end
kind(= configuration.documentation_format || "md")
click to toggle source
# File lib/rubysmith/builders/documentation.rb, line 52 def kind = configuration.documentation_format || "md" def license = configuration.documentation_license || "mit" end end
license(= configuration.documentation_license || "mit")
click to toggle source
# File lib/rubysmith/builders/documentation.rb, line 54 def license = configuration.documentation_license || "mit" end
render_changes()
click to toggle source
# File lib/rubysmith/builders/documentation.rb, line 24 def render_changes builder.call(configuration.with(template_path: "%project_name%/CHANGES.#{kind}.erb")) .render end
render_conduct()
click to toggle source
# File lib/rubysmith/builders/documentation.rb, line 29 def render_conduct configuration.with(template_path: "%project_name%/CODE_OF_CONDUCT.#{kind}.erb") .then { |updated_configuration| builder.call(updated_configuration).render } end
render_contributions()
click to toggle source
# File lib/rubysmith/builders/documentation.rb, line 34 def render_contributions builder.call(configuration.with(template_path: "%project_name%/CONTRIBUTING.#{kind}.erb")) .render end
render_license()
click to toggle source
# File lib/rubysmith/builders/documentation.rb, line 39 def render_license configuration.with(template_path: "%project_name%/LICENSE-#{license}.#{kind}.erb") .then do |updated_configuration| builder.call(updated_configuration).render.rename "LICENSE.#{kind}" end end
render_readme()
click to toggle source
# File lib/rubysmith/builders/documentation.rb, line 46 def render_readme builder.call(configuration.with(template_path: "%project_name%/README.#{kind}.erb")) .render .replace("\n\n\n", "\n\n") end