Class: Riven::Config
- Inherits:
-
Object
- Object
- Riven::Config
- Defined in:
- lib/riven/config.rb
Instance Attribute Summary collapse
-
#config_file ⇒ Object
Returns the value of attribute config_file.
-
#cover_file ⇒ Object
Returns the value of attribute cover_file.
-
#css_file ⇒ Object
Returns the value of attribute css_file.
-
#dir_given ⇒ Object
Returns the value of attribute dir_given.
-
#dump_cover_html ⇒ Object
Returns the value of attribute dump_cover_html.
-
#dump_html ⇒ Object
Returns the value of attribute dump_html.
-
#files ⇒ Object
Returns the value of attribute files.
-
#generate_toc ⇒ Object
Returns the value of attribute generate_toc.
-
#pdf_output_file ⇒ Object
Returns the value of attribute pdf_output_file.
-
#toc_headline ⇒ Object
Returns the value of attribute toc_headline.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Class Method Summary collapse
-
.parse(config_file) ⇒ Object
Parses a riven config yml file and constructs a Config object.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
Constructor with the default values.
-
#merge(another_config) ⇒ Object
Overrides the value in the current config if the value of the other config is not the default value.
-
#print ⇒ Object
Prints the current config.
Constructor Details
#initialize ⇒ Config
Constructor with the default values
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/riven/config.rb', line 20 public def initialize @pdf_output_file = nil @cover_file = nil @css_file = nil @generate_toc = false @toc_headline = 'Contents' @dump_html = false @dump_cover_html = false @verbose = false @dir_given = false @config_file = nil @files = [] end |
Instance Attribute Details
#config_file ⇒ Object
Returns the value of attribute config_file.
3 4 5 |
# File 'lib/riven/config.rb', line 3 def config_file @config_file end |
#cover_file ⇒ Object
Returns the value of attribute cover_file.
3 4 5 |
# File 'lib/riven/config.rb', line 3 def cover_file @cover_file end |
#css_file ⇒ Object
Returns the value of attribute css_file.
3 4 5 |
# File 'lib/riven/config.rb', line 3 def css_file @css_file end |
#dir_given ⇒ Object
Returns the value of attribute dir_given.
3 4 5 |
# File 'lib/riven/config.rb', line 3 def dir_given @dir_given end |
#dump_cover_html ⇒ Object
Returns the value of attribute dump_cover_html.
3 4 5 |
# File 'lib/riven/config.rb', line 3 def dump_cover_html @dump_cover_html end |
#dump_html ⇒ Object
Returns the value of attribute dump_html.
3 4 5 |
# File 'lib/riven/config.rb', line 3 def dump_html @dump_html end |
#files ⇒ Object
Returns the value of attribute files.
3 4 5 |
# File 'lib/riven/config.rb', line 3 def files @files end |
#generate_toc ⇒ Object
Returns the value of attribute generate_toc.
3 4 5 |
# File 'lib/riven/config.rb', line 3 def generate_toc @generate_toc end |
#pdf_output_file ⇒ Object
Returns the value of attribute pdf_output_file.
3 4 5 |
# File 'lib/riven/config.rb', line 3 def pdf_output_file @pdf_output_file end |
#toc_headline ⇒ Object
Returns the value of attribute toc_headline.
3 4 5 |
# File 'lib/riven/config.rb', line 3 def toc_headline @toc_headline end |
#verbose ⇒ Object
Returns the value of attribute verbose.
3 4 5 |
# File 'lib/riven/config.rb', line 3 def verbose @verbose end |
Class Method Details
.parse(config_file) ⇒ Object
Parses a riven config yml file and constructs a Config object
109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/riven/config.rb', line 109 def self.parse(config_file) require 'yaml' config = Riven::Config.new config.config_file = config_file parsed = YAML::load(File.open(File.(config.config_file))) parsed.each do |key, value| config.send(:"#{key}=", value) end config end |
Instance Method Details
#merge(another_config) ⇒ Object
Overrides the value in the current config if the value of the other config is not the default value
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/riven/config.rb', line 38 public def merge(another_config) @pdf_output_file = another_config.pdf_output_file if another_config.pdf_output_file != nil @cover_file = another_config.cover_file if another_config.cover_file != nil @css_file = another_config.css_file if another_config.css_file != nil @generate_toc = another_config.generate_toc if another_config.generate_toc != false @toc_headline = another_config.toc_headline if another_config.toc_headline != 'Contents' @dump_html = another_config.dump_html if another_config.dump_html != false @dump_cover_html = another_config.dump_cover_html if another_config.dump_cover_html != false @verbose = another_config.verbose if another_config.verbose != false @dir_given = another_config.dir_given if another_config.dir_given != false @config_file = another_config.config_file if another_config.config_file != nil @files = another_config.files if another_config.files != [] end |
#print ⇒ Object
Prints the current config
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/riven/config.rb', line 56 public def print puts puts "Using config file #{config_file}" if config_file != nil puts puts 'Riven configuration:' puts " - pdf_output_file: #{@pdf_output_file}" puts " - cover_file: #{@cover_file.path}" puts " - css_file: #{@css_file}" puts " - generate_toc: #{@generate_toc}" puts " - toc_headline: #{@toc_headline}" puts " - dump_html: #{@dump_html}" puts " - dump_cover_html: #{@dump_cover_html}" puts " - verbose: #{@verbose}" puts " - dir_given: #{@dir_given}" puts " - config_file: #{@config_file}" puts ' - files:' @files.each do |file| puts " - #{file.path}" end puts end |