mkalias 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4861ff5dd669c6b5bcfbe0d52da51dc788f0d8b0
4
- data.tar.gz: be747460a6946900005ec4cb25da808274cdbf75
3
+ metadata.gz: f26bcf1444013719cae23a296b2c289749cc6581
4
+ data.tar.gz: 1798b163446ae08f8e53fc401e1a9e07a4863129
5
5
  SHA512:
6
- metadata.gz: a73d22ed32a8be4197b8f5fc86c0d1204c48bf2b0fa2f20355f879d8f5c6cf3e91735d609a077cb3ba410b38e2c35d9fb1feb49b7196a61beb536420e821cae6
7
- data.tar.gz: 0aa50d72cefc132415d1cbeb8388cd0c98b75069503645a1419ad8410bfb42fa4fc568156f7ab4dc1f84ce9487968a4eefc2d6017b01b6ce93b3ab8c559820ae
6
+ metadata.gz: eda527f8759fcf1b75ab4937fce1da812f08f153661f5e97b5d6b76f709b40d7f8f7c9961e8c8a5cf0c5582eda9330809c3a6b26ff8235961280a4ea878c6e24
7
+ data.tar.gz: 317271400eef6aeaa5fc345520ebeb5fe32dc0a642c1c14905921a26b2f5cabea65d053b86192f8e1c56266ab9605d298ff9e29cfabf2168f2363c52d5d3f4ef
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ Fri Jun 17 16:49:50 BRT 2016 Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
2
+
3
+ * Add spec files on gemspec
4
+
1
5
  Fri Jun 17 15:16:40 BRT 2016 Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
2
6
 
3
7
  * Initial Release
@@ -1,3 +1,3 @@
1
1
  module Mkalias
2
- VERSION = '1.0.6'.freeze
2
+ VERSION = '1.0.7'.freeze
3
3
  end
data/mkalias.1 ADDED
@@ -0,0 +1,55 @@
1
+ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.4.
2
+ .TH USAGE: "1" "June 2016" "Usage: mkalias [option]" "User Commands"
3
+ .SH NAME
4
+ Usage: \- manual page for Usage: mkalias [option]
5
+ .SH SYNOPSIS
6
+ .B mkalias
7
+ [\fI\,option\/\fR]
8
+ .SH DESCRIPTION
9
+ options:
10
+ .TP
11
+ new
12
+ $ mkalias new [alias] [command 1] [command 2] ... [command n]
13
+ .IP
14
+ \- Create a new alias to run the commands
15
+ .TP
16
+ list
17
+ $ mkalias list
18
+ .IP
19
+ \- List all alias
20
+ .TP
21
+ show
22
+ $ mkalias show
23
+ \- Show commands of all alias
24
+ .IP
25
+ \f(CW$ mkalias show [alias 1] [alias 2] ... [alias n]\fR
26
+ .IP
27
+ \- Show commands of the specified alias
28
+ .TP
29
+ remove
30
+ $ mkalias remove [alias 1] [alias 2] ... [alias n]
31
+ .IP
32
+ \- Remove the specified alias
33
+ .TP
34
+ add_signal $ mkalias add_signal
35
+ .IP
36
+ \- Add signal to run 'source ~/.bashrc' when
37
+ .IP
38
+ \- add or remove an alias
39
+ .TP
40
+ remove_signal $ mkalias remove_signal
41
+ .IP
42
+ \- Remove signal to run 'source ~/.bashrc' when
43
+ .IP
44
+ \- add or remove an alias
45
+ .TP
46
+ Attention: To make alias with args use #. Example:
47
+ .IP
48
+ \f(CW$ mkalias new [alias] "echo #1 #2 #3"\fR
49
+ .IP
50
+ \- Then you can use: $ [alias] arg1 arg2 arg3
51
+ .SH "SEE ALSO"
52
+ The full documentation for
53
+ .B Usage:
54
+ .TP
55
+ https://github.com/LucianoPC/mkalias
data/mkalias.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.license = 'Expat'
19
19
 
20
20
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
- f.match(%r{^(test|spec|features)/})
21
+ f.match(%r{^(test|features)/})
22
22
  end
23
23
  spec.bindir = 'bin'
24
24
  spec.executables << 'mkalias'
@@ -0,0 +1,132 @@
1
+ require 'spec_helper'
2
+
3
+ FILE_PATH = './test_bashrc'.freeze
4
+
5
+ describe Mkalias do
6
+ it 'has a version number' do
7
+ expect(Mkalias::VERSION).not_to be nil
8
+ end
9
+
10
+ describe 'test Mkalias functions' do
11
+ before do
12
+ File.new(FILE_PATH, 'w')
13
+
14
+ open(FILE_PATH, 'a') do |file|
15
+ file.puts("\n")
16
+ file.puts("alias cd='mkalias_cd'\n")
17
+ file.puts("function mkalias_cd(){ ls -la; }\n")
18
+ file.puts("\n")
19
+ file.puts("alias mv='mkalias_mv'\n")
20
+ file.puts("function mkalias_mv(){ touch; pwd; }\n")
21
+ file.puts("\n")
22
+ file.puts("alias fkd='mkalias_fkd'\n")
23
+ file.puts("function mkalias_fkd(){ flake8 $(git ls-files -m) $@; }\n")
24
+ end
25
+ end
26
+
27
+ after do
28
+ File.delete(FILE_PATH)
29
+ end
30
+
31
+ it 'create new alias' do
32
+ alias_name = 'ls'
33
+ command = 'pwd'
34
+
35
+ Mkalias.new_alias(alias_name, command, FILE_PATH)
36
+ lines = File.readlines(FILE_PATH)
37
+
38
+ expect(lines).to include("alias ls='mkalias_ls'\n")
39
+ expect(lines).to include("function mkalias_ls(){ pwd $@; }\n")
40
+ end
41
+
42
+ it 'create new alias with args' do
43
+ alias_name = 'ls'
44
+ command = 'echo #1 #2'
45
+
46
+ Mkalias.new_alias(alias_name, command, FILE_PATH)
47
+ lines = File.readlines(FILE_PATH)
48
+
49
+ expect(lines).to include("alias ls='mkalias_ls'\n")
50
+ expect(lines).to include("function mkalias_ls(){ echo $1 $2; }\n")
51
+ end
52
+
53
+ it 'create new alias with multiple commands' do
54
+ alias_name = 'ls'
55
+ commands = ['pwd', 'echo a', 'cd']
56
+
57
+ Mkalias.new_alias(alias_name, commands, FILE_PATH)
58
+ lines = File.readlines(FILE_PATH)
59
+
60
+ expect(lines).to include "alias ls='mkalias_ls'\n"
61
+ expect(lines).to include "function mkalias_ls(){ pwd; echo a; cd; }\n"
62
+ end
63
+
64
+ it 'dont create new alias with an existing name' do
65
+ alias_name = 'cd'
66
+ command = 'echo #1 #2'
67
+
68
+ result = Mkalias.new_alias(alias_name, command, FILE_PATH)
69
+
70
+ expect(result).to be false
71
+ end
72
+
73
+ it 'list all alias' do
74
+ alias_names = Mkalias.list_alias(FILE_PATH)
75
+
76
+ expect(alias_names).to include 'cd'
77
+ expect(alias_names).to include 'mv'
78
+ expect(alias_names).to include 'fkd'
79
+ end
80
+
81
+ it 'show alias commands' do
82
+ alias_commands = Mkalias.show_alias(%w(cd mv fkd), FILE_PATH)
83
+
84
+ expect(alias_commands['cd']).to include 'ls -la'
85
+ expect(alias_commands['mv']).to include 'touch'
86
+ expect(alias_commands['mv']).to include 'pwd'
87
+ expect(alias_commands['fkd']).to include 'flake8 $(git ls-files -m) $@'
88
+ end
89
+
90
+ it 'dont show alias commands if alias not exists' do
91
+ alias_commands = Mkalias.show_alias(['dd'], FILE_PATH)
92
+
93
+ expect(alias_commands.keys).not_to include 'dd'
94
+ end
95
+
96
+ it 'remove alias' do
97
+ removed_alias = Mkalias.remove_alias(%w(cd mv), FILE_PATH)
98
+ alias_names = Mkalias.list_alias(FILE_PATH)
99
+
100
+ expect(removed_alias).to include 'cd'
101
+ expect(removed_alias).to include 'mv'
102
+ expect(alias_names).not_to include 'cd'
103
+ expect(alias_names).not_to include 'mv'
104
+ end
105
+
106
+ it 'add signal' do
107
+ result = Mkalias.add_signal(FILE_PATH)
108
+
109
+ expect(result).to be true
110
+ end
111
+
112
+ it 'dont add signal if already exists' do
113
+ Mkalias.add_signal(FILE_PATH)
114
+ result = Mkalias.add_signal(FILE_PATH)
115
+
116
+ expect(result).to be false
117
+ end
118
+
119
+ it 'remove signal' do
120
+ Mkalias.add_signal(FILE_PATH)
121
+ result = Mkalias.remove_signal(FILE_PATH)
122
+
123
+ expect(result).to be true
124
+ end
125
+
126
+ it 'dont remove signal unless already exists' do
127
+ result = Mkalias.remove_signal(FILE_PATH)
128
+
129
+ expect(result).to be false
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'mkalias'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mkalias
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luciano Prestes Cavalcanti
@@ -76,7 +76,10 @@ files:
76
76
  - lib/mkalias.rb
77
77
  - lib/mkalias/version.rb
78
78
  - lib/usage.rb
79
+ - mkalias.1
79
80
  - mkalias.gemspec
81
+ - spec/mkalias_spec.rb
82
+ - spec/spec_helper.rb
80
83
  homepage: https://github.com/LucianoPC/mkalias
81
84
  licenses:
82
85
  - Expat