Class: VCSRuby::Configuration

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/configuration.rb', line 22

def initialize
  default_config_file = File.expand_path("defaults.yml", File.dirname(__FILE__))
  @config = ::YAML::load_file(default_config_file)
  @verbose = false

  local_config_files = ['~/.vcs.rb.yml']
  local_config_files.select{ |f| File.exist?(f) }.each do |local_config_file|
    local_config = YAML::load_file(local_config_file)
    @config = @config.deep_merge(local_config)
  end

  @header_font    = Font.new @config['style']['header']['font'],    @config['style']['header']['size']
  @title_font     = Font.new @config['style']['title']['font'],     @config['style']['title']['size']
  @timestamp_font = Font.new @config['style']['timestamp']['font'], @config['style']['timestamp']['size']
  @signature_font = Font.new @config['style']['signature']['font'], @config['style']['signature']['size']
end

Instance Attribute Details

#capturerObject



62
63
64
# File 'lib/configuration.rb', line 62

def capturer
  @capturer || :any
end

#header_fontObject (readonly)

Returns the value of attribute header_font.



19
20
21
# File 'lib/configuration.rb', line 19

def header_font
  @header_font
end

#quiet=(value) ⇒ Object (writeonly)

Sets the attribute quiet

Parameters:

  • value

    the value to set the attribute quiet to.



20
21
22
# File 'lib/configuration.rb', line 20

def quiet=(value)
  @quiet = value
end

#signature_fontObject (readonly)

Returns the value of attribute signature_font.



19
20
21
# File 'lib/configuration.rb', line 19

def signature_font
  @signature_font
end

#timestamp_fontObject (readonly)

Returns the value of attribute timestamp_font.



19
20
21
# File 'lib/configuration.rb', line 19

def timestamp_font
  @timestamp_font
end

#title_fontObject (readonly)

Returns the value of attribute title_font.



19
20
21
# File 'lib/configuration.rb', line 19

def title_font
  @title_font
end

#verbose=(value) ⇒ Object (writeonly)

Sets the attribute verbose

Parameters:

  • value

    the value to set the attribute verbose to.



20
21
22
# File 'lib/configuration.rb', line 20

def verbose=(value)
  @verbose = value
end

Instance Method Details

#blank_alternativesObject



134
135
136
# File 'lib/configuration.rb', line 134

def blank_alternatives
  @config['lowlevel']['blank_alternatives'].map{ |e| TimeIndex.new e.to_i }
end

#blank_evasion?Boolean

Returns:

  • (Boolean)


130
131
132
# File 'lib/configuration.rb', line 130

def blank_evasion?
  @config['lowlevel']['blank_evasion']
end

#blank_thresholdObject



126
127
128
# File 'lib/configuration.rb', line 126

def blank_threshold
  @config['lowlevel']['blank_threshold'].to_f
end

#columnsObject



70
71
72
# File 'lib/configuration.rb', line 70

def columns
  @config['main']['columns'] ? @config['main']['columns'].to_i : nil
end

#contact_backgroundObject



106
107
108
# File 'lib/configuration.rb', line 106

def contact_background
  @config['style']['contact']['background']
end

#header_backgroundObject



86
87
88
# File 'lib/configuration.rb', line 86

def header_background
  @config['style']['header']['background']
end

#header_colorObject



90
91
92
# File 'lib/configuration.rb', line 90

def header_color
  @config['style']['header']['color']
end

#highlight_backgroundObject



102
103
104
# File 'lib/configuration.rb', line 102

def highlight_background
  @config['style']['highlight']['background']
end

#intervalObject



74
75
76
# File 'lib/configuration.rb', line 74

def interval
  @config['main']['interval'] ? TimeIndex.new(@config['main']['interval']) : nil
end

#load_profile(profile) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/configuration.rb', line 39

def load_profile profile
  profiles = [File.expand_path("#{profile}.yml", File.dirname(__FILE__)), File.expand_path("~/#{profile}.yml")]
  found = false
  profiles.each do |p|
    if File.exist?(p)
      puts "Profile loaded: #{profile}" if verbose?
      config = YAML::load_file(p)
      @config = @config.deep_merge(config)
      found = true
    end
  end

  raise "No profile '#{profile}' found" unless found
end

#paddingObject



78
79
80
# File 'lib/configuration.rb', line 78

def padding
  @config['main']['padding'] ? @config['main']['padding'].to_i : 2
end

#polaroidObject



142
143
144
# File 'lib/configuration.rb', line 142

def polaroid
  !!@config['filter']['polaroid']
end

#qualityObject



82
83
84
# File 'lib/configuration.rb', line 82

def quality
  @config['main']['quality'] ? @config['main']['quality'].to_i : 90
end

#quiet?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/configuration.rb', line 58

def quiet?
  @quiet
end

#rowsObject



66
67
68
# File 'lib/configuration.rb', line 66

def rows
  @config['main']['rows'] ? @config['main']['rows'].to_i : nil
end

#signature_backgroundObject



118
119
120
# File 'lib/configuration.rb', line 118

def signature_background
  @config['style']['signature']['background']
end

#signature_colorObject



122
123
124
# File 'lib/configuration.rb', line 122

def signature_color
  @config['style']['signature']['color']
end

#softshadowObject



146
147
148
# File 'lib/configuration.rb', line 146

def softshadow
  !!@config['filter']['softshadow']
end

#timestampObject



138
139
140
# File 'lib/configuration.rb', line 138

def timestamp
  !!@config['filter']['timestamp']
end

#timestamp_backgroundObject



110
111
112
# File 'lib/configuration.rb', line 110

def timestamp_background
  @config['style']['timestamp']['background']
end

#timestamp_colorObject



114
115
116
# File 'lib/configuration.rb', line 114

def timestamp_color
  @config['style']['timestamp']['color']
end

#title_backgroundObject



94
95
96
# File 'lib/configuration.rb', line 94

def title_background
  @config['style']['title']['background']
end

#title_colorObject



98
99
100
# File 'lib/configuration.rb', line 98

def title_color
  @config['style']['title']['color']
end

#verbose?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/configuration.rb', line 54

def verbose?
  @verbose
end