mkalias 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 121628ea9139c58895d08277e35deac58cc0d104
4
- data.tar.gz: fb5124df5ff7c95a9147ac550b8fe33ce2dbc282
3
+ metadata.gz: 05a6270a896891df2ebb804f034a9def42a8fec9
4
+ data.tar.gz: 04d6f084313700132eeb2071e2c61e8e1167ee76
5
5
  SHA512:
6
- metadata.gz: fbb1f6347c033d947e8a0b6a2a01985b52e8e0d99137decf0e1f9e7acb2125755259136002f07bddeafa2228db1a9f6545dd06353dcd2ab8051624e410cbef11
7
- data.tar.gz: 7fceb313566ae8e5549e00c6ff19c8236f8f7b9b39ade32c51f565be30588743ad78c75018e651f6dc7c92d24d3c9d9a37f42db5c47c0af0861c769ea2ae706e
6
+ metadata.gz: cbcc6657d786caf3949845a46afedc8a5e98c8c6c198bbf00992de26b2141f32daca4c8b4b21f4a36877c4d6c498e25b6a1764057056a4b55a58765e2b3c9937
7
+ data.tar.gz: ef2b38c3aa870140ce2477e7eb9415f6e46bfdc7655ac8560d28dc847caed74991687b1c1867716f9c3f8116af5b1ba2f395a8f8d9a68185fa73aa8e0a4aa5a7
data/.travis.yml CHANGED
@@ -3,3 +3,4 @@ language: ruby
3
3
  rvm:
4
4
  - 2.3.1
5
5
  before_install: gem install bundler -v 1.12.3
6
+ script: bundle exec rspec spec
data/README.md CHANGED
@@ -22,14 +22,20 @@ Or install it yourself as:
22
22
  ## Usage
23
23
 
24
24
  run: $ mkalias [option]
25
+
25
26
  option: new -> mkalias new [alias] [command]
27
+
26
28
  option: list -> mkalias list
29
+
27
30
  option: show -> mkalias show [alias]
31
+
28
32
  option: remove -> mkalias remove [alias]
29
33
 
30
34
  Attention: To make alias with args use #. Example:
31
- $ mkalias new [alias] "echo #1 #2 #3"
32
- - Then you can use: $ [alias] arg1 arg2 arg3
35
+
36
+ $ mkalias new [alias] "echo #1 #2 #3"
37
+
38
+ Then you can use: $ [alias] arg1 arg2 arg3
33
39
 
34
40
 
35
41
  ## Development
data/exe/mkalias CHANGED
@@ -24,7 +24,14 @@ def new_alias
24
24
 
25
25
  alias_name = ARGV[1]
26
26
  command = ARGV[2]
27
- Mkalias.new_alias(alias_name, command)
27
+ result = Mkalias.new_alias(alias_name, command)
28
+
29
+ if result
30
+ puts " - Created Alias: #{alias_name}"
31
+ puts " - Run '$ bash --login' to use your alias"
32
+ else
33
+ puts " ERROR: O Alias [#{alias_name}] já existe"
34
+ end
28
35
  end
29
36
 
30
37
  def list_alias
@@ -1,3 +1,3 @@
1
1
  module Mkalias
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/mkalias.rb CHANGED
@@ -6,6 +6,9 @@ module Mkalias
6
6
  BASHRC_PATH = "#{File.expand_path('~')}/.bashrc"
7
7
 
8
8
  def self.new_alias(alias_name, command, file_path=BASHRC_PATH)
9
+ alias_names = Mkalias.list_alias(file_path)
10
+ return false if alias_names.include?(alias_name)
11
+
9
12
  command = command.gsub('#', '$')
10
13
 
11
14
  function_name = "mkalias_#{alias_name}"
@@ -17,6 +20,8 @@ module Mkalias
17
20
  file.puts(bash_alias)
18
21
  file.puts(bash_function)
19
22
  end
23
+
24
+ true
20
25
  end
21
26
 
22
27
  def self.list_alias(file_path=BASHRC_PATH)
@@ -34,7 +39,7 @@ module Mkalias
34
39
  end
35
40
 
36
41
  def self.show_alias(alias_name, file_path=BASHRC_PATH)
37
- alias_names = Mkalias.list_alias
42
+ alias_names = Mkalias.list_alias(file_path)
38
43
  return nil unless alias_names.include?(alias_name)
39
44
 
40
45
  alias_regex = /\bmkalias_#{alias_name}[(]/
@@ -51,7 +56,7 @@ module Mkalias
51
56
  end
52
57
 
53
58
  def self.remove_alias(alias_name, file_path=BASHRC_PATH)
54
- alias_names = Mkalias.list_alias
59
+ alias_names = Mkalias.list_alias(file_path)
55
60
  return false unless alias_names.include?(alias_name)
56
61
 
57
62
  alias_regex = /\bmkalias_#{alias_name}[(']/
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: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luciano Prestes Cavalcanti