gem-alias 0.0.2 → 0.0.3
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.
- data/README.md +11 -9
- data/lib/gem-alias/extension.rb +12 -6
- data/lib/gem-alias/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -15,16 +15,17 @@ Add `:aliases` key to your ~/.gemrc and put definitions as a hash.
|
|
15
15
|
Example:
|
16
16
|
|
17
17
|
:aliases:
|
18
|
-
upgrade
|
19
|
-
ls
|
20
|
-
|
18
|
+
upgrade: update
|
19
|
+
ls: list
|
20
|
+
lsd: ls -d
|
21
|
+
rsearch = search --remote
|
21
22
|
|
22
23
|
Now you can use them!
|
23
24
|
|
24
|
-
$ gem
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
$ gem lsd
|
26
|
+
*** expanding lsd to ls -d ***
|
27
|
+
*** expanding ls -d to list -d ***
|
28
|
+
actionmailer (3.2.6)
|
28
29
|
<snip>
|
29
30
|
|
30
31
|
Verbose expansion message above can be suppressed with the `:verbose` configuration.
|
@@ -32,7 +33,8 @@ Verbose expansion message above can be suppressed with the `:verbose` configurat
|
|
32
33
|
You can list the definitions by `gem aliases`:
|
33
34
|
|
34
35
|
ls = list
|
35
|
-
|
36
|
+
lsd = ls -d
|
37
|
+
rsearch = search --remote
|
36
38
|
upgrade = update
|
37
39
|
|
38
40
|
Note that this list is sorted.
|
@@ -48,4 +50,4 @@ Note that this list is sorted.
|
|
48
50
|
## ToDo
|
49
51
|
|
50
52
|
* Like normal commands, aliases should also be looked up with shorter, but unambiguous names.
|
51
|
-
* Support multi-level expanstion without falling into infinite loop
|
53
|
+
* <del>Support multi-level expanstion without falling into infinite loop.</del>
|
data/lib/gem-alias/extension.rb
CHANGED
@@ -21,14 +21,20 @@ module Gem
|
|
21
21
|
|
22
22
|
private
|
23
23
|
|
24
|
-
def expand_alias(args)
|
25
|
-
|
24
|
+
def expand_alias(args, expansion_count=Hash.new(0))
|
25
|
+
command_name, *rest = args
|
26
|
+
if expansion_count[command_name] > 1
|
27
|
+
say "Alias loop: #{command_name}"
|
28
|
+
terminate_interaction 1
|
29
|
+
end
|
30
|
+
definition = Gem.configuration.aliases[command_name]
|
26
31
|
if definition
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
32
|
+
expanded_args = definition.shellsplit + rest
|
33
|
+
if Gem.configuration.verbose
|
34
|
+
say "*** expanding #{args.shelljoin} to #{expanded_args.shelljoin} ***"
|
31
35
|
end
|
36
|
+
expansion_count[expanded_args.first] += 1
|
37
|
+
expand_alias(expanded_args, expansion_count)
|
32
38
|
else
|
33
39
|
args
|
34
40
|
end
|
data/lib/gem-alias/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem-alias
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-17 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! 'This gem adds alias expansion feature to the ''gem'' command.
|
15
15
|
|