Class: Cliqr::Usage::UsageBuilder Private
- Inherits:
-
Object
- Object
- Cliqr::Usage::UsageBuilder
- Defined in:
- lib/cliqr/usage/usage_builder.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Builds the usage information based on the configuration settings
Constant Summary collapse
- TEMPLATES_PATH =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"#{File.(File.dirname(__FILE__))}/templates"
- USAGE_TYPES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ :cli => "#{TEMPLATES_PATH}/usage/cli.erb", :shell => "#{TEMPLATES_PATH}/usage/shell.erb" }
Instance Method Summary collapse
-
#build(config) ⇒ String
private
Build the usage information.
-
#initialize(type) ⇒ UsageBuilder
constructor
private
Create a new usage builder.
Constructor Details
#initialize(type) ⇒ UsageBuilder
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a new usage builder
21 22 23 24 |
# File 'lib/cliqr/usage/usage_builder.rb', line 21 def initialize(type) @type = type @template_file = USAGE_TYPES[type] end |
Instance Method Details
#build(config) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build the usage information
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cliqr/usage/usage_builder.rb', line 31 def build(config) usage_context = Usage::CommandUsageContext.new(@type, config) usage_context.instance_eval do def render(partial_name) TemplateRenderer.render("#{TEMPLATES_PATH}/partial/#{partial_name}.erb", self) end end # Add a extra newline at the end of usage text "#{TemplateRenderer.render(@template_file, usage_context)}\n" end |