Class: Handlebars::Helpers::Configuration
- Inherits:
-
Object
- Object
- Handlebars::Helpers::Configuration
- Defined in:
- lib/handlebars/helpers/configuration.rb
Overview
Configuration class
Instance Attribute Summary collapse
-
#helper_config_file ⇒ Object
Returns the value of attribute helper_config_file.
-
#padl_char ⇒ Object
Returns the value of attribute padl_char.
-
#padl_count ⇒ Object
Returns the value of attribute padl_count.
-
#padr_char ⇒ Object
Returns the value of attribute padr_char.
-
#padr_count ⇒ Object
Returns the value of attribute padr_count.
- #string_formatter_config ⇒ Object
-
#string_formatter_config_file ⇒ Object
Returns the value of attribute string_formatter_config_file.
-
#tokenizer ⇒ Object
Returns the value of attribute tokenizer.
Instance Method Summary collapse
- #build_string_formatter_config ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
36 37 38 39 40 41 42 43 44 |
# File 'lib/handlebars/helpers/configuration.rb', line 36 def initialize @tokenizer = ::Helpers::StringTokenizer.new @helper_config_file = '.handlebars_helpers.json' @string_formatter_config_file = '.handlebars_string_formatters.json' @padr_count = 30 @padr_char = ' ' @padl_count = 30 @padl_char = ' ' end |
Instance Attribute Details
#helper_config_file ⇒ Object
Returns the value of attribute helper_config_file.
27 28 29 |
# File 'lib/handlebars/helpers/configuration.rb', line 27 def helper_config_file @helper_config_file end |
#padl_char ⇒ Object
Returns the value of attribute padl_char.
27 28 29 |
# File 'lib/handlebars/helpers/configuration.rb', line 27 def padl_char @padl_char end |
#padl_count ⇒ Object
Returns the value of attribute padl_count.
27 28 29 |
# File 'lib/handlebars/helpers/configuration.rb', line 27 def padl_count @padl_count end |
#padr_char ⇒ Object
Returns the value of attribute padr_char.
27 28 29 |
# File 'lib/handlebars/helpers/configuration.rb', line 27 def padr_char @padr_char end |
#padr_count ⇒ Object
Returns the value of attribute padr_count.
27 28 29 |
# File 'lib/handlebars/helpers/configuration.rb', line 27 def padr_count @padr_count end |
#string_formatter_config ⇒ Object
53 54 55 |
# File 'lib/handlebars/helpers/configuration.rb', line 53 def string_formatter_config @string_formatter_config ||= build_string_formatter_config end |
#string_formatter_config_file ⇒ Object
Returns the value of attribute string_formatter_config_file.
33 34 35 |
# File 'lib/handlebars/helpers/configuration.rb', line 33 def string_formatter_config_file @string_formatter_config_file end |
#tokenizer ⇒ Object
Returns the value of attribute tokenizer.
27 28 29 |
# File 'lib/handlebars/helpers/configuration.rb', line 27 def tokenizer @tokenizer end |
Instance Method Details
#build_string_formatter_config ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/handlebars/helpers/configuration.rb', line 57 def build_string_formatter_config config_content = File.read(string_formatter_config_file) config = JSON.parse(config_content) configured_formatters = config['formatters'] configured_formatters.each_with_object({}) do |formatter, result| require formatter['require_path'] helper_instance = Object.const_get(formatter['class_namespace']).new formatter['aliases'].each do |name| result[name.to_sym] = helper_instance end end end |