cmd_tools 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cmd_tools/config.rb +28 -30
- data/lib/cmd_tools/version.rb +1 -1
- metadata +3 -3
data/lib/cmd_tools/config.rb
CHANGED
@@ -1,36 +1,34 @@
|
|
1
|
-
module CmdTools
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
extend ::RubyPatch::AutoLoad
|
1
|
+
module ::CmdTools::Config
|
2
|
+
require 'yaml'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'ruby_patch'
|
5
|
+
extend ::RubyPatch::AutoLoad
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
CONFIG_DIR = File.join(ENV['HOME'], '.config/cmd_tools')
|
8
|
+
CONFIG_FILE = File.join(CONFIG_DIR, 'config.yaml')
|
9
|
+
CONFIG_DEFAULT = {
|
10
|
+
emacs: ENV['ALTERNATE_EDITOR'] || 'emacs',
|
11
|
+
}
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
13
|
+
# (Re)load config file.
|
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))
|
17
|
+
else
|
18
|
+
FileUtils.mkdir_p(CONFIG_DIR)
|
19
|
+
open(CONFIG_FILE, 'w'){|io|
|
20
|
+
io.write(CONFIG_DEFAULT.to_yaml)
|
21
|
+
io.flush
|
22
|
+
}
|
23
|
+
CONFIG_DEFAULT
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
def self.emacs
|
31
|
-
@config[:emacs]
|
32
|
-
end
|
26
|
+
self
|
27
|
+
end
|
33
28
|
|
34
|
-
|
29
|
+
def self.emacs
|
30
|
+
@config[:emacs]
|
35
31
|
end
|
32
|
+
|
33
|
+
self.load
|
36
34
|
end
|
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: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-09-01 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby_patch
|
16
|
-
requirement: &
|
16
|
+
requirement: &72814280 !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: *72814280
|
25
25
|
description: ! 'Command line tools. Please type
|
26
26
|
|
27
27
|
|