Class: Memo::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/memo/cli/config/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

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_aliasObject (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_aliasObject (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

#pathObject (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_filenameObject



36
37
# File 'lib/memo/cli/config/config.rb', line 36

def default_filename = \
@config[:default_filename] || Default::Filename.to_s

#default_namespaceObject



39
40
# File 'lib/memo/cli/config/config.rb', line 39

def default_namespace = \
@config[:default_namespace] || Default::Namespace.to_s

#editorObject



33
34
# File 'lib/memo/cli/config/config.rb', line 33

def editor = @config[:editor] ||
ENV["EDITOR"] || Default::Editor.to_s

#extObject



25
# File 'lib/memo/cli/config/config.rb', line 25

def ext = @config[:ext] || Default::Ext.to_s

#fuzzy_finderObject



30
31
# File 'lib/memo/cli/config/config.rb', line 30

def fuzzy_finder = @config[:fuzzy_finder] ||
Default::FuzzyFinder.to_s

#pbcopyObject



27
# File 'lib/memo/cli/config/config.rb', line 27

def pbcopy = @config[:pbcopy] || Default::Pbcopy.to_s

#previewObject



28
# File 'lib/memo/cli/config/config.rb', line 28

def preview = @config[:preview] || Default::Preview.to_s

#rootObject



26
# File 'lib/memo/cli/config/config.rb', line 26

def root = @config[:root] || Default::Root.to_s