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.exists?(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



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

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



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

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

#blank_evasion?Boolean

Returns:

  • (Boolean)


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

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

#blank_thresholdObject



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

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

#columnsObject



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

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

#contact_backgroundObject



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

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

#header_backgroundObject



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

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

#header_colorObject



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

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

#highlight_backgroundObject



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

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

#intervalObject



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

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
53
# File 'lib/configuration.rb', line 39

def load_profile profile
  profiles = [File.expand_path("#{profile}.yml", File.dirname(__FILE__)), "~/#{profile}.yml"]

  found = false
  profiles.each do |p|
    if File.exists?(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



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

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

#polaroidObject



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

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

#qualityObject



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

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

#quiet?Boolean

Returns:

  • (Boolean)


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

def quiet?
  @quiet
end

#rowsObject



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

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

#signature_backgroundObject



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

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

#signature_colorObject



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

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

#softshadowObject



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

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

#timestampObject



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

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

#timestamp_backgroundObject



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

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

#timestamp_colorObject



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

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

#title_backgroundObject



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

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

#title_colorObject



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

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

#verbose?Boolean

Returns:

  • (Boolean)


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

def verbose?
  @verbose
end