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.
- data/lib/cmd_tools/config.rb +15 -9
- data/lib/cmd_tools/version.rb +1 -1
- metadata +5 -5
data/lib/cmd_tools/config.rb
CHANGED
@@ -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
|
10
|
+
'emacs' => ENV['ALTERNATE_EDITOR'] || 'emacs',
|
11
11
|
}
|
12
12
|
|
13
13
|
# (Re)load config file.
|
14
14
|
def self.load
|
15
|
-
|
16
|
-
|
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
|
-
|
19
|
-
|
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[
|
36
|
+
@config['emacs']
|
31
37
|
end
|
32
38
|
|
33
39
|
self.load
|
data/lib/cmd_tools/version.rb
CHANGED
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
|
+
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-
|
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: &
|
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: *
|
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.
|
86
|
+
rubygems_version: 1.8.15
|
87
87
|
signing_key:
|
88
88
|
specification_version: 3
|
89
89
|
summary: Command line tools.
|