cmd_tools 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -42,6 +42,6 @@ module ::CmdTools::Commands::EmacsLaunch
42
42
  end
43
43
 
44
44
  def self.is_gui_running?
45
- %w[x ns].include?(`emacsclient -e "(window-system)"`.strip)
45
+ ::CmdTools::Config.emacs_window_systems.include?(`emacsclient -e "(window-system)"`.strip)
46
46
  end
47
47
  end
@@ -8,14 +8,18 @@ module ::CmdTools::Config
8
8
  CONFIG_FILE = File.join(CONFIG_DIR, 'config.yaml')
9
9
  CONFIG_DEFAULT = {
10
10
  'emacs' => ENV['ALTERNATE_EDITOR'] || 'emacs',
11
+ 'emacs_window_systems' => %w[x ns mac],
11
12
  }
12
13
 
14
+ @config = nil
15
+
13
16
  # (Re)load config file.
14
17
  def self.load
15
18
  need_dump = false
16
19
  @config = if File.readable?(CONFIG_FILE)
17
- config = CONFIG_DEFAULT.merge(YAML.load_file(CONFIG_FILE))
18
- need_dump = config.size > CONFIG_DEFAULT.size
20
+ config_from_file = YAML.load_file(CONFIG_FILE)
21
+ config = CONFIG_DEFAULT.merge(config_from_file)
22
+ need_dump = config_from_file.size != CONFIG_DEFAULT.size
19
23
 
20
24
  config
21
25
  else
@@ -29,11 +33,17 @@ module ::CmdTools::Config
29
33
  open(CONFIG_FILE, 'w').write(@config.to_yaml)
30
34
  end
31
35
 
32
- self
33
- end
36
+ @config.each{|name, val|
37
+ var = "@#{name}"
38
+ instance_variable_set(var, val)
39
+ eval <<-EOS
40
+ def self.#{name}
41
+ #{var}
42
+ end
43
+ EOS
44
+ }
34
45
 
35
- def self.emacs
36
- @config['emacs']
46
+ self
37
47
  end
38
48
 
39
49
  self.load
@@ -1,3 +1,3 @@
1
1
  module CmdTools
2
- VERSION = '4.0.0'
2
+ VERSION = '4.0.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmd_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-10-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby_patch
16
- requirement: &87071520 !ruby/object:Gem::Requirement
16
+ requirement: &83228330 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0.3'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *87071520
24
+ version_requirements: *83228330
25
25
  description: ! 'Command line tools. Please type
26
26
 
27
27