Class: Bwkfanboy::Home
- Inherits:
-
Object
- Object
- Bwkfanboy::Home
- Defined in:
- lib/bwkfanboy/home.rb
Constant Summary collapse
- ROOT =
Home root directory
Pathname.new "#{Dir.home}/.#{Meta::NAME.downcase}"
- PLUGINS =
'plugins'
- LOGS =
'log'
- SYSTEM_PLUGINS =
CliUtils::DIR_LIB_SRC.parent.parent + 'plugins'
Instance Attribute Summary collapse
-
#conf ⇒ Object
Returns the value of attribute conf.
-
#logs ⇒ Object
readonly
Returns the value of attribute logs.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#initialize(dir = nil) ⇒ Home
constructor
Load config & create all required directories.
- #print_env ⇒ Object
- #print_plugins_path ⇒ Object
Constructor Details
#initialize(dir = nil) ⇒ Home
Load config & create all required directories.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bwkfanboy/home.rb', line 19 def initialize dir = nil # yield loader, o @root = (dir && Pathname(dir)) || ROOT @logs = @root + LOGS CliConfig::DIR_CONFIG.unshift @root @conf = CliConfig.new @conf[:plugins_path] = [@root + PLUGINS, SYSTEM_PLUGINS] @conf.load do |o| yield self, o if block_given? o.on('-I DIR', 'Include DIR in search for plugins.') {|i| @conf[:plugins_path] << Pathname.new(i) if File.directory?(i) } o.on('--plugins-path', 'Print all searchable directories.') { print_plugins_path exit EX_OK } end print_env FileUtils.mkdir_p [@conf[:plugins_path], @logs] end |
Instance Attribute Details
#conf ⇒ Object
Returns the value of attribute conf.
16 17 18 |
# File 'lib/bwkfanboy/home.rb', line 16 def conf @conf end |
#logs ⇒ Object (readonly)
Returns the value of attribute logs.
15 16 17 |
# File 'lib/bwkfanboy/home.rb', line 15 def logs @logs end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
15 16 17 |
# File 'lib/bwkfanboy/home.rb', line 15 def root @root end |
Instance Method Details
#print_env ⇒ Object
45 46 47 48 49 50 |
# File 'lib/bwkfanboy/home.rb', line 45 def print_env if @conf[:verbose] >= 2 puts "Libs dir: #{CliUtils::DIR_LIB_SRC}" pp @conf end end |
#print_plugins_path ⇒ Object
41 42 43 |
# File 'lib/bwkfanboy/home.rb', line 41 def print_plugins_path @conf[:plugins_path].each {|i| puts i } end |