am 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -0
- data/README.md +2 -0
- data/Rakefile +8 -0
- data/lib/am.rb +1 -0
- data/lib/am/cli.rb +26 -20
- data/lib/am/version.rb +1 -1
- data/lib/config.rb +29 -42
- data/lib/tail.rb +20 -6
- data/lib/ui.rb +13 -9
- data/spec/lib/am/cli_spec.rb +79 -0
- data/spec/lib/config_spec.rb +10 -7
- data/spec/lib/tail_spec.rb +2 -5
- data/spec/spec_helper.rb +75 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ac8121440319603d9c34a172b5bf701aa71f7e7
|
4
|
+
data.tar.gz: 40a62d1010f7798019f672535fc55a5451688a1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f6ac069e16b5ad8024520b63b6efa164eab40981ad6872d86abe4b94bc51a04324374a386a369bc289afd6a18f09470c70de7ffc62fd2e1e946f74ef771e916
|
7
|
+
data.tar.gz: ca6af85e41a5f392d4e7f693e6a4360880ba2f9a4ea77571cd39147ec5b41a3925d8e3ade6de0b1468fcef1f92f0171e7d499a88868345c57ad7cc0a5995f34e
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# Am(Alias Manager)
|
2
|
+
[![Build Status](https://travis-ci.org/ka-yamashita/am.svg?branch=master)](https://travis-ci.org/ka-yamashita/am)
|
3
|
+
[![Code Climate](https://codeclimate.com/github/ka-yamashita/am/badges/gpa.svg)](https://codeclimate.com/github/ka-yamashita/am)
|
2
4
|
|
3
5
|
`alias` command wrapper
|
4
6
|
|
data/Rakefile
CHANGED
data/lib/am.rb
CHANGED
data/lib/am/cli.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require 'am'
|
2
3
|
require 'tail'
|
3
4
|
require 'config'
|
@@ -10,7 +11,7 @@ module AM
|
|
10
11
|
def initialize(*args)
|
11
12
|
super
|
12
13
|
@config = Config.new
|
13
|
-
@ui
|
14
|
+
@ui = Ui.new
|
14
15
|
end
|
15
16
|
|
16
17
|
desc "show", "show current alias"
|
@@ -40,7 +41,7 @@ module AM
|
|
40
41
|
end
|
41
42
|
|
42
43
|
if uniq?(add_record) && valid?(add_record)
|
43
|
-
@config.al
|
44
|
+
@config.al.merge!(add_record)
|
44
45
|
add_config(add_record)
|
45
46
|
else
|
46
47
|
AM.p1("")
|
@@ -50,7 +51,6 @@ module AM
|
|
50
51
|
|
51
52
|
desc "del", "delete alias"
|
52
53
|
option :list, :type => :boolean, :aliases => '-l'
|
53
|
-
|
54
54
|
def del(delete_alias=nil)
|
55
55
|
if @config.al.empty?
|
56
56
|
puts 'a blank config'
|
@@ -58,26 +58,29 @@ module AM
|
|
58
58
|
end
|
59
59
|
|
60
60
|
if options[:list] || delete_alias == nil
|
61
|
-
|
62
|
-
|
61
|
+
# convert array
|
62
|
+
arr = @ui.print_current_config(@config)
|
63
|
+
delete_alias = @ui.del_command_with_number(arr)
|
63
64
|
end
|
64
|
-
|
65
|
+
@config.al.delete(delete_alias)
|
66
|
+
delete_config(delete_alias)
|
65
67
|
end
|
66
68
|
|
67
69
|
no_commands do
|
68
|
-
|
70
|
+
# todo merge config
|
69
71
|
def add_config(add_record)
|
70
|
-
|
71
|
-
|
72
|
+
ak,av = add_record.first
|
73
|
+
if @config.save_config
|
74
|
+
AM.p1("[success] #{ak} / #{av} added command")
|
72
75
|
AM.p2("please run: [ source #{CONFIG_FILE} ]")
|
73
76
|
|
74
77
|
else
|
75
|
-
puts "[error] #{
|
78
|
+
puts "[error] #{ak} / #{av} couldn't add command"
|
76
79
|
end
|
77
80
|
end
|
78
81
|
|
79
82
|
def delete_config(exclude)
|
80
|
-
if @config.save_config
|
83
|
+
if @config.save_config
|
81
84
|
AM.p1("[success] delete alias #{exclude}")
|
82
85
|
AM.p2("please run: [ source #{CONFIG_FILE} ]")
|
83
86
|
|
@@ -85,23 +88,26 @@ module AM
|
|
85
88
|
AM.p2("[error] failue delete alias #{exclude}}")
|
86
89
|
end
|
87
90
|
end
|
88
|
-
|
91
|
+
# todo end
|
92
|
+
# todo move config class
|
89
93
|
def uniq?(add_record)
|
90
|
-
|
91
|
-
|
92
|
-
|
94
|
+
ak,av = add_record.first
|
95
|
+
@config.al.each do |k,v|
|
96
|
+
if ak == k
|
97
|
+
AM.p1("[error] not written as duplecate alias is '#{ak}'")
|
93
98
|
return false
|
94
|
-
elsif
|
95
|
-
AM.p1("[error] not written as duplecate command is #{
|
99
|
+
elsif av == v
|
100
|
+
AM.p1("[error] not written as duplecate command is #{av}")
|
96
101
|
return false
|
97
102
|
end
|
98
103
|
end
|
99
104
|
true
|
100
105
|
end
|
101
|
-
|
106
|
+
# end
|
102
107
|
def valid?(add_record)
|
103
|
-
|
104
|
-
|
108
|
+
ak,av = add_record.first
|
109
|
+
unless ak.length > 0 || av.length > 0
|
110
|
+
puts "[error] #{ak} / #{av} length equal 0"
|
105
111
|
return false
|
106
112
|
end
|
107
113
|
true
|
data/lib/am/version.rb
CHANGED
data/lib/config.rb
CHANGED
@@ -1,60 +1,47 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require 'am'
|
2
3
|
|
3
4
|
module AM
|
4
5
|
class Config
|
5
6
|
attr_accessor :al, :pg
|
7
|
+
|
6
8
|
def initialize
|
7
|
-
|
9
|
+
@al = {}
|
10
|
+
@pg = {}
|
11
|
+
load_config
|
8
12
|
end
|
9
13
|
|
10
|
-
def
|
11
|
-
@al
|
12
|
-
@pg
|
13
|
-
|
14
|
-
|
15
|
-
# load alias config
|
16
|
-
File.open(CONFIG_FILE, 'r') do |file|
|
17
|
-
file.each_line do |line|
|
18
|
-
@al << line.gsub(/^alias /, '').strip.split('=', 2) if(line =~ /^alias/)
|
19
|
-
# migration
|
20
|
-
pg_buf << line.strip.split('=', 2) if line.strip =~ /^[^alias]/ && line.strip =~ /^[^#.*]/ && line.strip !~ /^$/
|
21
|
-
end
|
22
|
-
end if File.exists?(CONFIG_FILE)
|
14
|
+
def load_config
|
15
|
+
@al = file_load(CONFIG_FILE)
|
16
|
+
@pg = file_load(LOCAL_FILE)
|
17
|
+
end
|
23
18
|
|
24
|
-
|
25
|
-
|
26
|
-
file.each_line do |line|
|
27
|
-
pg_buf << line.strip.split('=', 2) if line.strip =~ /^[^alias]/ && line.strip =~ /^[^#.*]/ && line.strip !~ /^$/
|
28
|
-
end
|
29
|
-
end if File.exists?(LOCAL_FILE)
|
30
|
-
@pg = Hash[pg_buf] unless pg_buf.empty?
|
19
|
+
def save_config
|
20
|
+
(file_write(CONFIG_FILE, @al, 'alias ') && file_write(LOCAL_FILE, @pg))
|
31
21
|
end
|
32
22
|
|
33
|
-
def
|
34
|
-
|
35
|
-
file = File.open(
|
36
|
-
new_al = []
|
37
|
-
|
38
|
-
file.puts("# alias config")
|
39
|
-
@al.each do |a,c|
|
40
|
-
r = "alias #{a.to_s}=#{c.to_s}"
|
41
|
-
if a.to_s != exclude
|
42
|
-
file.puts(r)
|
43
|
-
new_al << [a, c]
|
44
|
-
end
|
45
|
-
end
|
46
|
-
@al = new_al
|
47
|
-
file.close
|
23
|
+
def file_write(file_name, config, prefix=nil)
|
24
|
+
tmp_file = file_name + '.tmp'
|
25
|
+
file = File.open(tmp_file, "w")
|
48
26
|
|
49
|
-
|
50
|
-
|
51
|
-
file.puts("\n# pg config")
|
52
|
-
@pg.each do |p,v|
|
53
|
-
r = "#{p.to_s}=#{v.to_s}"
|
27
|
+
config.each do |k,v|
|
28
|
+
r = "#{prefix}#{k.to_s}=#{v.to_s}"
|
54
29
|
file.puts(r)
|
55
30
|
end
|
31
|
+
|
56
32
|
file.close
|
57
|
-
(File.rename(
|
33
|
+
(File.rename(tmp_file, file_name) == 0)
|
34
|
+
end
|
35
|
+
|
36
|
+
def file_load(file_name)
|
37
|
+
buf = []
|
38
|
+
File.open(file_name, 'r') do |file|
|
39
|
+
file.each_line do |line|
|
40
|
+
line = line.strip
|
41
|
+
buf << line.gsub(/^alias /, '').split('=', 2) if line !~ /^$/ && line =~ /.+=.+/ && line !~ /^#.*/
|
42
|
+
end
|
43
|
+
end if File.exists?(file_name)
|
44
|
+
Hash[buf]
|
58
45
|
end
|
59
46
|
end
|
60
47
|
end
|
data/lib/tail.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require 'am'
|
2
3
|
|
3
4
|
module AM
|
4
5
|
class Tail
|
6
|
+
attr_accessor :profile
|
5
7
|
def initialize(config)
|
6
8
|
set_profile(config)
|
7
9
|
end
|
@@ -12,14 +14,12 @@ module AM
|
|
12
14
|
|
13
15
|
if shell =~ /zsh/
|
14
16
|
@profile = {
|
15
|
-
pattern: '.*;(.*)',
|
16
17
|
margin: 0,
|
17
18
|
max_line: 5,
|
18
19
|
file: '~/.zsh_history'
|
19
20
|
}
|
20
21
|
elsif shell =~ /bash/
|
21
22
|
@profile = {
|
22
|
-
pattern: '(.*)',
|
23
23
|
margin: 1,
|
24
24
|
max_line: 5,
|
25
25
|
file: '~/.bash_history'
|
@@ -44,8 +44,9 @@ module AM
|
|
44
44
|
last_commands = `tail -#{@profile[:max_line] + 1 - @profile[:margin]} #{@profile[:file]} | head -#{@profile[:max_line]}`.split("\n")
|
45
45
|
|
46
46
|
last_commands.each_with_index do |c,i|
|
47
|
-
|
48
|
-
|
47
|
+
if r = sampling(c)
|
48
|
+
commands << r
|
49
|
+
end
|
49
50
|
end unless last_commands.empty?
|
50
51
|
|
51
52
|
commands
|
@@ -54,9 +55,22 @@ module AM
|
|
54
55
|
def get_last_command
|
55
56
|
exit if @profile[:file].empty?
|
56
57
|
|
57
|
-
if
|
58
|
-
|
58
|
+
if c = `tail -#{2-@profile[:margin]} #{@profile[:file]} | head -1`
|
59
|
+
if r = sampling(c)
|
60
|
+
r
|
61
|
+
end
|
59
62
|
end
|
60
63
|
end
|
64
|
+
|
65
|
+
def sampling(command)
|
66
|
+
zsh = '[0-9]+:[0-0];(.*)'
|
67
|
+
bash = '(.*)'
|
68
|
+
if command =~ /#{zsh}/
|
69
|
+
p = zsh
|
70
|
+
else
|
71
|
+
p = bash
|
72
|
+
end
|
73
|
+
command.split(/#{p}/)[COMMAND].strip if command.strip !~ /^$/
|
74
|
+
end
|
61
75
|
end
|
62
76
|
end
|
data/lib/ui.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require 'am'
|
2
3
|
|
3
4
|
module AM
|
@@ -5,13 +6,15 @@ module AM
|
|
5
6
|
def print_current_config(config)
|
6
7
|
aml = config.al.max_by{|c| c[0].length }[0].length #alias max length
|
7
8
|
iml = config.al.length.to_s.length #index max length
|
8
|
-
|
9
|
+
arr = [] #use delete number
|
9
10
|
AM::p1("current commands of the config")
|
10
|
-
config.al.each_with_index do|
|
11
|
+
config.al.each_with_index do|(k,v),i|
|
11
12
|
# 1: name=command
|
12
|
-
puts " #{' '*(iml - (i+1).to_s.length)}#{(i+1).to_s} : #{
|
13
|
+
puts " #{' '*(iml - (i+1).to_s.length)}#{(i+1).to_s} : #{k.to_s}#{' '*(aml-k.length)} = #{v.to_s}"
|
14
|
+
arr << [i,k]
|
13
15
|
end unless config.al.empty?
|
14
16
|
AM::p1
|
17
|
+
arr
|
15
18
|
end
|
16
19
|
|
17
20
|
def print_last_commands(commands)
|
@@ -25,26 +28,27 @@ module AM
|
|
25
28
|
number = please_input
|
26
29
|
valid?(number, '^[^1-5]', '[error] input using number!')
|
27
30
|
alias_name = get_alias
|
28
|
-
|
31
|
+
{alias_name => quot(commands[number.to_i-1].strip)}
|
29
32
|
end
|
30
33
|
|
31
34
|
def add_command_with_last_history(command)
|
32
35
|
puts "add command is #{quot(command.strip)}"
|
33
36
|
alias_name = get_alias
|
34
|
-
|
37
|
+
{alias_name => quot(command)}
|
35
38
|
end
|
36
39
|
|
37
|
-
def del_command_with_number(
|
40
|
+
def del_command_with_number(arr)
|
38
41
|
print 'please input delete command number: '
|
39
42
|
number = please_input
|
40
43
|
valid?(number, '^[^0-9]', '[error] input using number!')
|
41
|
-
|
44
|
+
# return delete hash key
|
45
|
+
arr[number.to_i-1][1] if arr.length >= number.to_i
|
42
46
|
end
|
43
47
|
|
44
48
|
def get_alias
|
45
49
|
print "please input add command alias: "
|
46
50
|
name = please_input
|
47
|
-
valid?(name, '
|
51
|
+
valid?(name, '[^\w-]', '[error] input using a-z or 0-9 or _ or -')
|
48
52
|
name.strip
|
49
53
|
end
|
50
54
|
|
@@ -57,7 +61,7 @@ module AM
|
|
57
61
|
|
58
62
|
def please_input
|
59
63
|
while val = STDIN.gets
|
60
|
-
break if /\n$/ =~ val
|
64
|
+
break if /\n$/ =~ val
|
61
65
|
end
|
62
66
|
val.strip
|
63
67
|
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper.rb'
|
3
|
+
|
4
|
+
describe AM::CLI do
|
5
|
+
shared_examples_for "shell test" do
|
6
|
+
before do
|
7
|
+
ENV['SHELL'] = shell
|
8
|
+
add_history(AM::Tail.new(AM::Config.new).profile[:file])
|
9
|
+
end
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
add_alias_config
|
13
|
+
@cli = AM::CLI.new
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'show' do
|
17
|
+
it 'current' do
|
18
|
+
expect { @cli.show }.to output(match_current_config).to_stdout
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'register' do
|
23
|
+
describe 'add' do
|
24
|
+
before do
|
25
|
+
allow(STDIN).to receive(:gets) { "add_command_alias\n" }
|
26
|
+
expect { @cli.show }.not_to output(/add_command_alias/).to_stdout
|
27
|
+
end
|
28
|
+
it 'single' do
|
29
|
+
expect { @cli.add }.to output(/success/).to_stdout
|
30
|
+
expect { @cli.add }.to output(/duplecate/).to_stdout
|
31
|
+
expect { @cli.show }.to output(/add_command_alias/).to_stdout
|
32
|
+
end
|
33
|
+
end
|
34
|
+
describe 'delete' do
|
35
|
+
before do
|
36
|
+
expect { @cli.show }.to output(/ほげ/).to_stdout
|
37
|
+
end
|
38
|
+
it 'single' do
|
39
|
+
expect { @cli.del('ほげ') }.to output(/success/).to_stdout
|
40
|
+
expect { @cli.show }.not_to output(/ほげ/).to_stdout
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'register option' do
|
46
|
+
describe 'add' do
|
47
|
+
before do
|
48
|
+
allow(STDIN).to receive(:gets).and_return("1\n","last_command_alias\n")
|
49
|
+
expect { @cli.show }.to_not output(/last_command_alias/).to_stdout
|
50
|
+
end
|
51
|
+
it 'list' do
|
52
|
+
expect { @cli.invoke(:add, [], {list: true}) }.to output(/#{match_last_five_command}/).to_stdout
|
53
|
+
expect { AM::CLI.new.show }.to output(/last_command_alias/).to_stdout
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
describe 'del' do
|
58
|
+
before do
|
59
|
+
allow(STDIN).to receive(:gets).and_return("1\n")
|
60
|
+
expect { @cli.show }.to output(/hoge/).to_stdout
|
61
|
+
end
|
62
|
+
it 'list' do
|
63
|
+
expect { @cli.invoke(:del, [], {list: true}) }.to output(/#{match_delete_list}/).to_stdout
|
64
|
+
expect { AM::CLI.new.show }.to_not output(/hoge/).to_stdout
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
describe 'zsh' do
|
70
|
+
let(:shell) {'/bin/zsh' }
|
71
|
+
it_should_behave_like 'shell test'
|
72
|
+
end
|
73
|
+
|
74
|
+
describe 'bash' do
|
75
|
+
let(:shell) {'/bin/bash' }
|
76
|
+
it_should_behave_like 'shell test'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
data/spec/lib/config_spec.rb
CHANGED
@@ -6,27 +6,30 @@ describe AM::Config do
|
|
6
6
|
`echo "alias test1='test az - AZ 09 _'" > #{AM::CONFIG_FILE}`
|
7
7
|
`echo "history_file=~/.zsh_history" > #{AM::LOCAL_FILE}`
|
8
8
|
@config= AM::Config.new
|
9
|
+
@ak,@av = @config.al.first
|
9
10
|
end
|
10
11
|
|
11
12
|
it 'load config' do
|
12
|
-
expect(@
|
13
|
-
expect(@
|
13
|
+
expect(@ak).to eq 'test1'
|
14
|
+
expect(@av).to eq "'test az - AZ 09 _'"
|
14
15
|
expect(@config.pg['history_file']).to eq "~/.zsh_history"
|
15
16
|
end
|
16
17
|
|
17
18
|
it 'save config'do
|
18
19
|
# add
|
19
|
-
|
20
|
+
@config.al.merge!({'test2' => "'abcdefgeijklmn'"})
|
20
21
|
expect(@config.save_config).to be true
|
21
22
|
expect(@config.al.length).to eql(2)
|
22
23
|
|
23
24
|
# delete
|
24
|
-
|
25
|
+
#
|
26
|
+
@config.al.delete('test1')
|
27
|
+
expect(@config.save_config()).to be true
|
25
28
|
expect(@config.al.length).to eql(1)
|
26
29
|
|
27
|
-
#
|
28
|
-
expect(@config.al
|
29
|
-
expect(@config.al[
|
30
|
+
# value check
|
31
|
+
expect(@config.al.key?('test2')).to be true
|
32
|
+
expect(@config.al['test2']).to eq "'abcdefgeijklmn'"
|
30
33
|
expect(@config.pg['history_file']).to eq "~/.zsh_history"
|
31
34
|
|
32
35
|
end
|
data/spec/lib/tail_spec.rb
CHANGED
@@ -4,10 +4,9 @@ describe AM::Tail do
|
|
4
4
|
context 'tail commands tests' do
|
5
5
|
shared_examples_for "shell test" do
|
6
6
|
before do
|
7
|
-
config= AM::Config.new
|
8
|
-
config.pg['history_file'] = hist_file
|
9
7
|
ENV['SHELL'] = shell
|
10
|
-
@tail = AM::Tail.new(
|
8
|
+
@tail = AM::Tail.new(AM::Config.new)
|
9
|
+
add_history(@tail.profile[:file])
|
11
10
|
end
|
12
11
|
|
13
12
|
it 'get_last_five_commands' do
|
@@ -22,13 +21,11 @@ describe AM::Tail do
|
|
22
21
|
end
|
23
22
|
|
24
23
|
describe 'zsh' do
|
25
|
-
let(:hist_file) { '~/.zsh_history' }
|
26
24
|
let(:shell) {'/bin/zsh' }
|
27
25
|
it_should_behave_like 'shell test'
|
28
26
|
end
|
29
27
|
|
30
28
|
describe 'bash' do
|
31
|
-
let(:hist_file) { '~/.bash_history' }
|
32
29
|
let(:shell) {'/bin/bash' }
|
33
30
|
it_should_behave_like 'shell test'
|
34
31
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,78 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require 'am'
|
3
|
+
require 'am/cli'
|
2
4
|
require 'tail'
|
3
5
|
require 'config'
|
6
|
+
|
7
|
+
|
8
|
+
def add_history(hist_file)
|
9
|
+
|
10
|
+
record = <<'EOS'
|
11
|
+
: 1426499455:0;rake
|
12
|
+
rake
|
13
|
+
: 1426500006:0;rails
|
14
|
+
rails
|
15
|
+
: 1426500107:0;cd /hoge/fuga/hoge/fuga
|
16
|
+
cd /hoge/fuga/hoge/fuga
|
17
|
+
: 1426500307:0;cat /hoge | grep 'hoge'
|
18
|
+
cat /hoge | grep 'hoge'
|
19
|
+
: 1426500358:0;pepabo
|
20
|
+
pepabo
|
21
|
+
: 1426500618:0;abcd ABCD 1234 あいうえ
|
22
|
+
abcd ABCD 1234 あいうえ"
|
23
|
+
EOS
|
24
|
+
hist_file = File.expand_path(hist_file)
|
25
|
+
type = File.exists?(hist_file)? 'a' : 'w'
|
26
|
+
file = File.open(hist_file, type)
|
27
|
+
record.split("\n").each {|r| file.puts(r) }
|
28
|
+
file.close
|
29
|
+
end
|
30
|
+
|
31
|
+
def add_alias_config
|
32
|
+
record = <<'EOS'
|
33
|
+
alias hoge='fuga'
|
34
|
+
alias 123='123'
|
35
|
+
alias ABC='ABC'
|
36
|
+
alias aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa='bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
|
37
|
+
alias ほげ='ふがふが'
|
38
|
+
EOS
|
39
|
+
|
40
|
+
config_file = File.expand_path(AM::CONFIG_FILE)
|
41
|
+
file = File.open(config_file, "w")
|
42
|
+
record.split("\n").each {|r| file.puts(r) }
|
43
|
+
file.close
|
44
|
+
end
|
45
|
+
|
46
|
+
def match_current_config
|
47
|
+
return <<'EOS'
|
48
|
+
|
49
|
+
current commands of the config
|
50
|
+
1 : hoge = 'fuga'
|
51
|
+
2 : 123 = '123'
|
52
|
+
3 : ABC = 'ABC'
|
53
|
+
4 : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
|
54
|
+
5 : ほげ = 'ふがふが'
|
55
|
+
|
56
|
+
EOS
|
57
|
+
end
|
58
|
+
|
59
|
+
def match_last_five_command
|
60
|
+
return <<'EOS'
|
61
|
+
1 : cat /hoge | grep 'hoge'
|
62
|
+
2 : cat /hoge | grep 'hoge'
|
63
|
+
3 : pepabo
|
64
|
+
4 : pepabo
|
65
|
+
5 : abcd ABCD 1234 あいうえ
|
66
|
+
EOS
|
67
|
+
end
|
68
|
+
|
69
|
+
def match_delete_list
|
70
|
+
return <<'EOS'
|
71
|
+
current commands of the config
|
72
|
+
1 : hoge = 'fuga'
|
73
|
+
2 : 123 = '123'
|
74
|
+
3 : ABC = 'ABC'
|
75
|
+
4 : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
|
76
|
+
5 : ほげ = 'ふがふが'
|
77
|
+
EOS
|
78
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: am
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ka-yamashita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,6 +75,7 @@ extensions: []
|
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
77
|
- ".gitignore"
|
78
|
+
- ".travis.yml"
|
78
79
|
- Gemfile
|
79
80
|
- LICENSE.txt
|
80
81
|
- README.md
|
@@ -87,6 +88,7 @@ files:
|
|
87
88
|
- lib/config.rb
|
88
89
|
- lib/tail.rb
|
89
90
|
- lib/ui.rb
|
91
|
+
- spec/lib/am/cli_spec.rb
|
90
92
|
- spec/lib/config_spec.rb
|
91
93
|
- spec/lib/tail_spec.rb
|
92
94
|
- spec/spec_helper.rb
|
@@ -115,6 +117,7 @@ signing_key:
|
|
115
117
|
specification_version: 4
|
116
118
|
summary: command note command.
|
117
119
|
test_files:
|
120
|
+
- spec/lib/am/cli_spec.rb
|
118
121
|
- spec/lib/config_spec.rb
|
119
122
|
- spec/lib/tail_spec.rb
|
120
123
|
- spec/spec_helper.rb
|