am 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ed54a2838657b508701ab2bfeb4761cc46008e9
4
- data.tar.gz: 7e18590971c2c43c4c39246b43a72d8e0f037e74
3
+ metadata.gz: 3d2e53ad6a321f7951f515ed2300015b68e4c781
4
+ data.tar.gz: 55d4870231f2333634c71dd4af4347c00de77c4a
5
5
  SHA512:
6
- metadata.gz: 13168b80a8a7d7348d92ce8e50db49b13c614c1925484d7d4120076e3ff988f7b8a2861a4373a2833f06be69d8de8a58cf1dd4e890d6420874e3f7c3507e2994
7
- data.tar.gz: e400ea2db125f6c3d17db65be2d632f0fe17ab2fb0abcd593e7758d56dbca3c16607bc29f56da6790e9a11815a2417bf222e49d39dbfdc34b0520c956ebfbd3d
6
+ metadata.gz: e1ebc90929226e09fb9598c15edd8e0ea96ed399e1b0256a45b8291f3c4244272bd363e76a6d3ea05eec895b5e3c99bcc1c5ac13f914746d7cd60f790ff2a3fc
7
+ data.tar.gz: 8f21b5cd9c8da7c896a08a8c7d26762ebaef517cbb67b50112382a2d5bef5d4604b7380dbf1d3a7105abb1e649cc90315a85580b14553ea200361bbbca1c7863
data/lib/am/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Am
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
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, prefix=nil)
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 = "#{prefix}#{k.to_s}=#{v.to_s}"
49
+ r = "alias #{k.to_s}=#{v.to_s}"
50
50
  file.puts(r)
51
51
  end
52
52
 
@@ -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
- @config= AM::Config.new
13
- @ak,@av = @config.al.first
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: am
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ka-yamashita