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.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'] = 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
63 64 65 |
# File 'lib/configuration.rb', line 63 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
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
131 132 133 |
# File 'lib/configuration.rb', line 131 def blank_evasion? @config['lowlevel']['blank_evasion'] end |
#blank_threshold ⇒ Object
127 128 129 |
# File 'lib/configuration.rb', line 127 def blank_threshold @config['lowlevel']['blank_threshold'].to_f end |
#columns ⇒ Object
71 72 73 |
# File 'lib/configuration.rb', line 71 def columns @config['main']['columns'] ? @config['main']['columns'].to_i : nil end |
#contact_background ⇒ Object
107 108 109 |
# File 'lib/configuration.rb', line 107 def contact_background @config['style']['contact']['background'] end |
#header_background ⇒ Object
87 88 89 |
# File 'lib/configuration.rb', line 87 def header_background @config['style']['header']['background'] end |
#header_color ⇒ Object
91 92 93 |
# File 'lib/configuration.rb', line 91 def header_color @config['style']['header']['color'] end |
#highlight_background ⇒ Object
103 104 105 |
# File 'lib/configuration.rb', line 103 def highlight_background @config['style']['highlight']['background'] end |
#interval ⇒ Object
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.("#{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 |
#padding ⇒ Object
79 80 81 |
# File 'lib/configuration.rb', line 79 def padding @config['main']['padding'] ? @config['main']['padding'].to_i : 2 end |
#polaroid ⇒ Object
143 144 145 |
# File 'lib/configuration.rb', line 143 def polaroid !!@config['filter']['polaroid'] end |
#quality ⇒ Object
83 84 85 |
# File 'lib/configuration.rb', line 83 def quality @config['main']['quality'] ? @config['main']['quality'].to_i : 90 end |
#quiet? ⇒ Boolean
59 60 61 |
# File 'lib/configuration.rb', line 59 def quiet? @quiet end |
#rows ⇒ Object
67 68 69 |
# File 'lib/configuration.rb', line 67 def rows @config['main']['rows'] ? @config['main']['rows'].to_i : nil end |
#signature_background ⇒ Object
119 120 121 |
# File 'lib/configuration.rb', line 119 def signature_background @config['style']['signature']['background'] end |
#signature_color ⇒ Object
123 124 125 |
# File 'lib/configuration.rb', line 123 def signature_color @config['style']['signature']['color'] end |
#softshadow ⇒ Object
147 148 149 |
# File 'lib/configuration.rb', line 147 def softshadow !!@config['filter']['softshadow'] end |
#timestamp ⇒ Object
139 140 141 |
# File 'lib/configuration.rb', line 139 def !!@config['filter']['timestamp'] end |
#timestamp_background ⇒ Object
111 112 113 |
# File 'lib/configuration.rb', line 111 def @config['style']['timestamp']['background'] end |
#timestamp_color ⇒ Object
115 116 117 |
# File 'lib/configuration.rb', line 115 def @config['style']['timestamp']['color'] end |
#title_background ⇒ Object
95 96 97 |
# File 'lib/configuration.rb', line 95 def title_background @config['style']['title']['background'] end |
#title_color ⇒ Object
99 100 101 |
# File 'lib/configuration.rb', line 99 def title_color @config['style']['title']['color'] end |
#verbose? ⇒ Boolean
55 56 57 |
# File 'lib/configuration.rb', line 55 def verbose? @verbose end |