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.
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.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/yap/configuration.rb', line 39 def initialize @addon_paths = [ "#{File.dirname(__FILE__)}/../../addons", "#{ENV['HOME']}/.yap/addons" ] @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 |
Class Method Details
.option(name, type = nil, default: nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/yap/configuration.rb', line 14 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
51 52 53 |
# File 'lib/yap/configuration.rb', line 51 def path_for(part) yap_path.join(part) end |
#preferred_yaprc_path ⇒ Object
55 56 57 |
# File 'lib/yap/configuration.rb', line 55 def preferred_yaprc_path yap_path.join("yaprc") end |
#yap_path ⇒ Object
63 64 65 |
# File 'lib/yap/configuration.rb', line 63 def yap_path Pathname.new "#{ENV['HOME']}/.yap" end |
#yaprc_template_path ⇒ Object
59 60 61 |
# File 'lib/yap/configuration.rb', line 59 def yaprc_template_path Pathname.new(File.dirname(__FILE__)).join('../../rcfiles/yaprc') end |