Class: Yap::Configuration
- Inherits:
-
Object
- Object
- Yap::Configuration
- Defined in:
- lib/yap/configuration.rb
Instance Attribute Summary collapse
-
#addon_paths ⇒ Object
Returns the value of attribute addon_paths.
-
#rcfiles ⇒ Object
Returns the value of attribute rcfiles.
-
#yap_addons_configuration_path ⇒ Object
Returns the value of attribute yap_addons_configuration_path.
-
#yap_binpath ⇒ Object
Returns the value of attribute yap_binpath.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #path_for(part) ⇒ Object
- #preferred_yaprc_path ⇒ Object
- #yap_path ⇒ Object
- #yaprc_template_path ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/yap/configuration.rb', line 42 def initialize @yap_addons_configuration_path = yap_path.join('addons.yml') @addon_paths = [ # "#{File.dirname(__FILE__)}/../../addons", # "#{ENV['HOME']}/.yap/addons" ].concat(Gem.path.map { |gems_path| "#{gems_path}/gems" }).map do |path| File.(path) end @rcfiles = [ "#{ENV['HOME']}/.yaprc", preferred_yaprc_path ] end |
Instance Attribute Details
#addon_paths ⇒ Object
Returns the value of attribute addon_paths.
11 12 13 |
# File 'lib/yap/configuration.rb', line 11 def addon_paths @addon_paths end |
#rcfiles ⇒ Object
Returns the value of attribute rcfiles.
12 13 14 |
# File 'lib/yap/configuration.rb', line 12 def rcfiles @rcfiles end |
#yap_addons_configuration_path ⇒ Object
Returns the value of attribute yap_addons_configuration_path.
13 14 15 |
# File 'lib/yap/configuration.rb', line 13 def yap_addons_configuration_path @yap_addons_configuration_path end |
#yap_binpath ⇒ Object
Returns the value of attribute yap_binpath.
14 15 16 |
# File 'lib/yap/configuration.rb', line 14 def yap_binpath @yap_binpath end |
Class Method Details
.option(name, type = nil, default: nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/yap/configuration.rb', line 16 def self.option(name, type=nil, default: nil) reader_method = name.to_s define_method(reader_method) do return default unless instance_variable_defined?("@#{name}") value = instance_variable_get("@#{name}") return !!value if type == :boolean value end writer_method = "#{reader_method}=" define_method(writer_method) do |value| instance_variable_set("@#{name}", value) end if type == :boolean query_method = "#{reader_method}?" alias_method query_method, reader_method end end |
Instance Method Details
#path_for(part) ⇒ Object
58 59 60 |
# File 'lib/yap/configuration.rb', line 58 def path_for(part) yap_path.join(part) end |
#preferred_yaprc_path ⇒ Object
62 63 64 |
# File 'lib/yap/configuration.rb', line 62 def preferred_yaprc_path yap_path.join("yaprc") end |
#yap_path ⇒ Object
70 71 72 |
# File 'lib/yap/configuration.rb', line 70 def yap_path Pathname.new "#{ENV['HOME']}/.yap" end |
#yaprc_template_path ⇒ Object
66 67 68 |
# File 'lib/yap/configuration.rb', line 66 def yaprc_template_path Pathname.new(File.dirname(__FILE__)).join('../../rcfiles/yaprc') end |