Class: Rubbr::Options

Inherits:
Object
  • Object
show all
Extended by:
Cli
Defined in:
lib/rubbr/options.rb

Class Method Summary collapse

Methods included from Cli

color?, disable_stderr, disable_stdinn, disable_stdout, error, executable?, notice, valid_executable, warning

Class Method Details

.defaultsObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rubbr/options.rb', line 5

def defaults
  root_dir         = Dir.pwd
  source_dir       = 'src'

  @defaults ||= {
    :root_dir          => root_dir,
    :source_dir        => source_dir,
    :build_dir         => 'tmp',
    :distribution_dir  => 'dist',
    :base_file         => 'base',
    :vendor_dir        => source_dir + '/vendor',
    :graphics_dir      => source_dir + '/graphics',
    :spell_dir         => source_dir,
    :spell_file        => 'dictionary.ispell',
    :inventory_file    => '.inventory',
    :distribution_name => distribution_name(root_dir),
    :verbose           => false,
    :verboser          => false,
    :color             => false,
    :format            => :dvi,
    :engine            => :latex
  }
end

.setupObject

Fetching options from a config file if present and merges it with the defaults.



31
32
33
34
35
36
37
38
39
# File 'lib/rubbr/options.rb', line 31

def setup
  preference_file = "#{defaults[:root_dir]}/config.yml"
  preferences = {}
  if File.exists? preference_file
    require 'yaml'
    File.open(preference_file) { |file| preferences = YAML.load(file) }
  end
  base_file_variations(absolute_paths(defaults.merge(preferences)))
end