Class: Emmett::Configuration
- Inherits:
-
Object
- Object
- Emmett::Configuration
- Defined in:
- lib/emmett/configuration.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#index_page ⇒ Object
Returns the value of attribute index_page.
-
#json_path ⇒ Object
Returns the value of attribute json_path.
-
#name ⇒ Object
Returns the value of attribute name.
-
#output_dir ⇒ Object
Returns the value of attribute output_dir.
-
#section_dir ⇒ Object
Returns the value of attribute section_dir.
-
#template ⇒ Object
Returns the value of attribute template.
Instance Method Summary collapse
Instance Attribute Details
#index_page ⇒ Object
Returns the value of attribute index_page.
9 10 11 |
# File 'lib/emmett/configuration.rb', line 9 def index_page @index_page end |
#json_path ⇒ Object
Returns the value of attribute json_path.
9 10 11 |
# File 'lib/emmett/configuration.rb', line 9 def json_path @json_path end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/emmett/configuration.rb', line 9 def name @name end |
#output_dir ⇒ Object
Returns the value of attribute output_dir.
9 10 11 |
# File 'lib/emmett/configuration.rb', line 9 def output_dir @output_dir end |
#section_dir ⇒ Object
Returns the value of attribute section_dir.
9 10 11 |
# File 'lib/emmett/configuration.rb', line 9 def section_dir @section_dir end |
#template ⇒ Object
Returns the value of attribute template.
9 10 11 |
# File 'lib/emmett/configuration.rb', line 9 def template @template end |
Instance Method Details
#from_json ⇒ Object
32 33 34 |
# File 'lib/emmett/configuration.rb', line 32 def from_json @json_config ||= JSON.parse(File.read(json_path)) end |
#to_template ⇒ Object
36 37 38 |
# File 'lib/emmett/configuration.rb', line 36 def to_template @template_instance ||= Template[template] end |
#verify! ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/emmett/configuration.rb', line 11 def verify! errors = [] if json_path && File.exist?(json_path) title = from_json['title'] self.name = title if title else errors << "The json path does not exist (Given #{json_path.inspect})" end errors << "You must set the name attribute for emmett" if !name errors << "You must set the template attribute for emmett" if !template errors << "The index_page file must exist" unless index_page && File.exist?(index_page) errors << "The section_dir directory must exist" unless section_dir && File.directory?(section_dir) errors << "The output_dir must be set" unless output_dir errors << "The specified template does not exist" unless to_template if errors.any? = "Your configuration is invalid:\n" errors.each { |e| << "* #{e}\n" } raise Error.new() end end |