am 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/am/version.rb +1 -1
- data/lib/config.rb +3 -3
- data/spec/lib/config_spec.rb +6 -2
- data/spec/spec_helper.rb +11 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d2e53ad6a321f7951f515ed2300015b68e4c781
|
4
|
+
data.tar.gz: 55d4870231f2333634c71dd4af4347c00de77c4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1ebc90929226e09fb9598c15edd8e0ea96ed399e1b0256a45b8291f3c4244272bd363e76a6d3ea05eec895b5e3c99bcc1c5ac13f914746d7cd60f790ff2a3fc
|
7
|
+
data.tar.gz: 8f21b5cd9c8da7c896a08a8c7d26762ebaef517cbb67b50112382a2d5bef5d4604b7380dbf1d3a7105abb1e649cc90315a85580b14553ea200361bbbca1c7863
|
data/lib/am/version.rb
CHANGED
data/lib/config.rb
CHANGED
@@ -37,16 +37,16 @@ module AM
|
|
37
37
|
|
38
38
|
def save_config
|
39
39
|
(
|
40
|
-
file_write(CONFIG_FILE, @al.merge({"aml" => 'source ~/.am_config'}))
|
40
|
+
file_write(CONFIG_FILE, @al.merge({"aml" => "'source ~/.am_config'"}))
|
41
41
|
)
|
42
42
|
end
|
43
43
|
|
44
|
-
def file_write(file_name, config
|
44
|
+
def file_write(file_name, config)
|
45
45
|
tmp_file = file_name + '.tmp'
|
46
46
|
file = File.open(tmp_file, "w")
|
47
47
|
|
48
48
|
config.each do |k,v|
|
49
|
-
r = "#{
|
49
|
+
r = "alias #{k.to_s}=#{v.to_s}"
|
50
50
|
file.puts(r)
|
51
51
|
end
|
52
52
|
|
data/spec/lib/config_spec.rb
CHANGED
@@ -9,12 +9,16 @@ describe AM::Config do
|
|
9
9
|
describe 'load config' do
|
10
10
|
before do
|
11
11
|
file_write(AM::CONFIG_FILE,"alias test1='test az - AZ 09 _", 'w')
|
12
|
-
|
13
|
-
@ak,@av =
|
12
|
+
config= AM::Config.new
|
13
|
+
@ak,@av = config.al.first
|
14
|
+
config.save_config
|
15
|
+
@all_config = file_load(AM::CONFIG_FILE)
|
14
16
|
end
|
15
17
|
it 'load' do
|
16
18
|
expect(@ak).to eq 'test1'
|
17
19
|
expect(@av).to eq "'test az - AZ 09 _"
|
20
|
+
expect(@all_config.key?('aml')).to be true
|
21
|
+
expect(@all_config['aml']).to eq "'source ~/.am_config'"
|
18
22
|
end
|
19
23
|
end
|
20
24
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# encoding: utf-8
|
1
|
+
# encoding: utf-8
|
2
2
|
require "codeclimate-test-reporter"
|
3
3
|
CodeClimate::TestReporter.start
|
4
4
|
require 'am'
|
@@ -80,3 +80,13 @@ current commands of the config
|
|
80
80
|
5 : ほげ = 'ふがふが'
|
81
81
|
EOS
|
82
82
|
end
|
83
|
+
def file_load(file_name)
|
84
|
+
buf = []
|
85
|
+
File.open(file_name, 'r') do |file|
|
86
|
+
file.each_line do |line|
|
87
|
+
line = line.strip
|
88
|
+
buf << line.gsub(/^alias /, '').split('=', 2) if line !~ /^$/ && line =~ /.+=.+/ && line !~ /^#.*/
|
89
|
+
end
|
90
|
+
end if File.exists?(file_name)
|
91
|
+
Hash[buf]
|
92
|
+
end
|