Class: VCSRuby::Configuration
- Inherits:
-
Object
- Object
- VCSRuby::Configuration
- Includes:
- Singleton
- Defined in:
- lib/configuration.rb
Instance Attribute Summary collapse
- #capturer ⇒ Object
-
#header_font ⇒ Object
readonly
Returns the value of attribute header_font.
-
#quiet ⇒ Object
writeonly
Sets the attribute quiet.
-
#signature_font ⇒ Object
readonly
Returns the value of attribute signature_font.
-
#timestamp_font ⇒ Object
readonly
Returns the value of attribute timestamp_font.
-
#title_font ⇒ Object
readonly
Returns the value of attribute title_font.
-
#verbose ⇒ Object
writeonly
Sets the attribute verbose.
Instance Method Summary collapse
- #blank_alternatives ⇒ Object
- #blank_evasion? ⇒ Boolean
- #blank_threshold ⇒ Object
- #columns ⇒ Object
- #contact_background ⇒ Object
- #header_background ⇒ Object
- #header_color ⇒ Object
- #highlight_background ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #interval ⇒ Object
- #load_profile(profile) ⇒ Object
- #padding ⇒ Object
- #polaroid ⇒ Object
- #quality ⇒ Object
- #quiet? ⇒ Boolean
- #rows ⇒ Object
- #signature_background ⇒ Object
- #signature_color ⇒ Object
- #softshadow ⇒ Object
- #timestamp ⇒ Object
- #timestamp_background ⇒ Object
- #timestamp_color ⇒ Object
- #title_background ⇒ Object
- #title_color ⇒ Object
- #verbose? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
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.("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'] = 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
#capturer ⇒ Object
62 63 64 |
# File 'lib/configuration.rb', line 62 def capturer @capturer || :any end |
#header_font ⇒ Object (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
20 21 22 |
# File 'lib/configuration.rb', line 20 def quiet=(value) @quiet = value end |
#signature_font ⇒ Object (readonly)
Returns the value of attribute signature_font.
19 20 21 |
# File 'lib/configuration.rb', line 19 def signature_font @signature_font end |
#timestamp_font ⇒ Object (readonly)
Returns the value of attribute timestamp_font.
19 20 21 |
# File 'lib/configuration.rb', line 19 def end |
#title_font ⇒ Object (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
20 21 22 |
# File 'lib/configuration.rb', line 20 def verbose=(value) @verbose = value end |
Instance Method Details
#blank_alternatives ⇒ Object
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
130 131 132 |
# File 'lib/configuration.rb', line 130 def blank_evasion? @config['lowlevel']['blank_evasion'] end |
#blank_threshold ⇒ Object
126 127 128 |
# File 'lib/configuration.rb', line 126 def blank_threshold @config['lowlevel']['blank_threshold'].to_f end |
#columns ⇒ Object
70 71 72 |
# File 'lib/configuration.rb', line 70 def columns @config['main']['columns'] ? @config['main']['columns'].to_i : nil end |
#contact_background ⇒ Object
106 107 108 |
# File 'lib/configuration.rb', line 106 def contact_background @config['style']['contact']['background'] end |
#header_background ⇒ Object
86 87 88 |
# File 'lib/configuration.rb', line 86 def header_background @config['style']['header']['background'] end |
#header_color ⇒ Object
90 91 92 |
# File 'lib/configuration.rb', line 90 def header_color @config['style']['header']['color'] end |
#highlight_background ⇒ Object
102 103 104 |
# File 'lib/configuration.rb', line 102 def highlight_background @config['style']['highlight']['background'] end |
#interval ⇒ Object
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.("#{profile}.yml", File.dirname(__FILE__)), File.("~/#{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 |
#padding ⇒ Object
78 79 80 |
# File 'lib/configuration.rb', line 78 def padding @config['main']['padding'] ? @config['main']['padding'].to_i : 2 end |
#polaroid ⇒ Object
142 143 144 |
# File 'lib/configuration.rb', line 142 def polaroid !!@config['filter']['polaroid'] end |
#quality ⇒ Object
82 83 84 |
# File 'lib/configuration.rb', line 82 def quality @config['main']['quality'] ? @config['main']['quality'].to_i : 90 end |
#quiet? ⇒ Boolean
58 59 60 |
# File 'lib/configuration.rb', line 58 def quiet? @quiet end |
#rows ⇒ Object
66 67 68 |
# File 'lib/configuration.rb', line 66 def rows @config['main']['rows'] ? @config['main']['rows'].to_i : nil end |
#signature_background ⇒ Object
118 119 120 |
# File 'lib/configuration.rb', line 118 def signature_background @config['style']['signature']['background'] end |
#signature_color ⇒ Object
122 123 124 |
# File 'lib/configuration.rb', line 122 def signature_color @config['style']['signature']['color'] end |
#softshadow ⇒ Object
146 147 148 |
# File 'lib/configuration.rb', line 146 def softshadow !!@config['filter']['softshadow'] end |
#timestamp ⇒ Object
138 139 140 |
# File 'lib/configuration.rb', line 138 def !!@config['filter']['timestamp'] end |
#timestamp_background ⇒ Object
110 111 112 |
# File 'lib/configuration.rb', line 110 def @config['style']['timestamp']['background'] end |
#timestamp_color ⇒ Object
114 115 116 |
# File 'lib/configuration.rb', line 114 def @config['style']['timestamp']['color'] end |
#title_background ⇒ Object
94 95 96 |
# File 'lib/configuration.rb', line 94 def title_background @config['style']['title']['background'] end |
#title_color ⇒ Object
98 99 100 |
# File 'lib/configuration.rb', line 98 def title_color @config['style']['title']['color'] end |
#verbose? ⇒ Boolean
54 55 56 |
# File 'lib/configuration.rb', line 54 def verbose? @verbose end |