cmd_tools 2.1.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,27 +7,33 @@ module ::CmdTools::Config
7
7
  CONFIG_DIR = File.join(ENV['HOME'], '.config/cmd_tools')
8
8
  CONFIG_FILE = File.join(CONFIG_DIR, 'config.yaml')
9
9
  CONFIG_DEFAULT = {
10
- emacs: ENV['ALTERNATE_EDITOR'] || 'emacs',
10
+ 'emacs' => ENV['ALTERNATE_EDITOR'] || 'emacs',
11
11
  }
12
12
 
13
13
  # (Re)load config file.
14
14
  def self.load
15
- @config = if File.size?(CONFIG_FILE) and File.readable?(CONFIG_FILE)
16
- CONFIG_DEFAULT.merge(YAML.load_file(CONFIG_FILE))
15
+ need_dump = false
16
+ @config = if File.readable?(CONFIG_FILE)
17
+ config = CONFIG_DEFAULT.merge(YAML.load_file(CONFIG_FILE))
18
+ need_dump = config.size > CONFIG_DEFAULT.size
19
+
20
+ config
17
21
  else
18
- FileUtils.mkdir_p(CONFIG_DIR)
19
- open(CONFIG_FILE, 'w'){|io|
20
- io.write(CONFIG_DEFAULT.to_yaml)
21
- io.flush
22
- }
22
+ need_dump = true
23
+
23
24
  CONFIG_DEFAULT
24
25
  end
25
26
 
27
+ if need_dump
28
+ FileUtils.mkdir_p(CONFIG_DIR)
29
+ open(CONFIG_FILE, 'w').write(@config.to_yaml)
30
+ end
31
+
26
32
  self
27
33
  end
28
34
 
29
35
  def self.emacs
30
- @config[:emacs]
36
+ @config['emacs']
31
37
  end
32
38
 
33
39
  self.load
@@ -1,3 +1,3 @@
1
1
  module CmdTools
2
- VERSION = '2.1.0'
2
+ VERSION = '3.0.0'
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: 2.1.0
4
+ version: 3.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-07 00:00:00.000000000 Z
12
+ 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: &73308010 !ruby/object:Gem::Requirement
16
+ requirement: &2153006140 !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: *73308010
24
+ version_requirements: *2153006140
25
25
  description: ! 'Command line tools. Please type
26
26
 
27
27
 
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  version: '0'
84
84
  requirements: []
85
85
  rubyforge_project:
86
- rubygems_version: 1.8.11
86
+ rubygems_version: 1.8.15
87
87
  signing_key:
88
88
  specification_version: 3
89
89
  summary: Command line tools.