Class: Memo::Config
- Inherits:
-
Object
- Object
- Memo::Config
- Defined in:
- lib/memo/cli/config/config.rb
Instance Attribute Summary collapse
-
#command_alias ⇒ Object
readonly
Returns the value of attribute command_alias.
-
#namespace_alias ⇒ Object
readonly
Returns the value of attribute namespace_alias.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #default_filename ⇒ Object
- #default_namespace ⇒ Object
- #editor ⇒ Object
- #ext ⇒ Object
- #fuzzy_finder ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #pbcopy ⇒ Object
- #preview ⇒ Object
- #root ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/memo/cli/config/config.rb', line 5 def initialize @path = ENV["MEMO_CONFIG"].dup || "~/.memo/config.toml" @path.sub!("~", ENV["HOME"]) @path.sub!("$HOME", ENV["HOME"]) conf = Tomlrb.load_file( @path, symbolize_keys: true, ) rescue {} @config = conf[:config].to_h @namespace_alias = conf[:namespace_alias].to_h @command_alias = conf[:command_alias].to_h system "mkdir -p #{root}" end |
Instance Attribute Details
#command_alias ⇒ Object (readonly)
Returns the value of attribute command_alias.
3 4 5 |
# File 'lib/memo/cli/config/config.rb', line 3 def command_alias @command_alias end |
#namespace_alias ⇒ Object (readonly)
Returns the value of attribute namespace_alias.
3 4 5 |
# File 'lib/memo/cli/config/config.rb', line 3 def namespace_alias @namespace_alias end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/memo/cli/config/config.rb', line 3 def path @path end |
Instance Method Details
#default_filename ⇒ Object
36 37 |
# File 'lib/memo/cli/config/config.rb', line 36 def default_filename = \ @config[:default_filename] || Default::Filename.to_s |
#default_namespace ⇒ Object
39 40 |
# File 'lib/memo/cli/config/config.rb', line 39 def default_namespace = \ @config[:default_namespace] || Default::Namespace.to_s |
#editor ⇒ Object
33 34 |
# File 'lib/memo/cli/config/config.rb', line 33 def editor = @config[:editor] || ENV["EDITOR"] || Default::Editor.to_s |
#ext ⇒ Object
25 |
# File 'lib/memo/cli/config/config.rb', line 25 def ext = @config[:ext] || Default::Ext.to_s |
#fuzzy_finder ⇒ Object
30 31 |
# File 'lib/memo/cli/config/config.rb', line 30 def fuzzy_finder = @config[:fuzzy_finder] || Default::FuzzyFinder.to_s |
#pbcopy ⇒ Object
27 |
# File 'lib/memo/cli/config/config.rb', line 27 def pbcopy = @config[:pbcopy] || Default::Pbcopy.to_s |