Class: QuickStart::Config
- Inherits:
-
Object
- Object
- QuickStart::Config
- Defined in:
- lib/quick_start/config.rb
Constant Summary collapse
- TEMPLATE_PATH =
Pathname.new(File.join(File.dirname(__FILE__), 'templates', 'quick_start'))
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
- #create_config! ⇒ Object
- #executables ⇒ Object
-
#initialize(file) ⇒ Config
constructor
A new instance of Config.
-
#parse ⇒ Object
firefox = /usr/bin/firefox gnome-terminal = /usr/bin/gnome-terminal, checked thunderbird = /usr/bin/mozilla-thunderbird, unchecked.
- #readlines ⇒ Object
Constructor Details
#initialize(file) ⇒ Config
Returns a new instance of Config.
12 13 14 |
# File 'lib/quick_start/config.rb', line 12 def initialize(file) @file = file end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
8 9 10 |
# File 'lib/quick_start/config.rb', line 8 def file @file end |
Instance Method Details
#create_config! ⇒ Object
41 42 43 44 |
# File 'lib/quick_start/config.rb', line 41 def create_config! FileUtils.cp(TEMPLATE_PATH, Core.config_path) return Core.config_path end |
#executables ⇒ Object
32 33 34 |
# File 'lib/quick_start/config.rb', line 32 def executables @executables ||= [] end |
#parse ⇒ Object
firefox = /usr/bin/firefox gnome-terminal = /usr/bin/gnome-terminal, checked thunderbird = /usr/bin/mozilla-thunderbird, unchecked
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/quick_start/config.rb', line 19 def parse readlines.each do |line| next if line =~ /\s*#/ name, = line.split('=', 2).map! { |arg| arg.strip } path, = .split(',', 2).map! { |arg| arg.strip } = {} .split(',').each do |option| [option.to_sym] = true end if executables << Executable.new(name, path, ) end end |
#readlines ⇒ Object
36 37 38 39 |
# File 'lib/quick_start/config.rb', line 36 def readlines config = File.readable?(@file) ? @file : create_config! return File.readlines(config) end |