Permalink
Browse files

fixed alias behavior, trying to create an existing alias overwrites t…

…he old alias, fixed spelling error
  • Loading branch information...
1 parent 178e066 commit 40746bf34f29c888b8d328361c949671ae670141 @vertiginous committed Mar 3, 2011
Showing with 11 additions and 6 deletions.
  1. +5 −5 lib/pik/commands/alias_command.rb
  2. +1 −1 lib/pik/commands/use_command.rb
  3. +5 −0 lib/pik/config_file.rb
@@ -19,19 +19,19 @@ def execute
end
end
- def create(pseudonum, name)
+ def create(pseudonym, name)
if version = config.find_pattern(name)
- config[version.first][:alias] = pseudonum
+ config.create_alias(version.first, pseudonym)
else
Log.error "Ruby version not found."
end
end
- def delete(pseudonum)
- if version = config.find_alias(pseudonum)
+ def delete(pseudonym)
+ if version = config.find_alias(pseudonym)
config[version.first].delete(:alias)
else
- Log.error "Ruby version '#{pseudonum}' not found."
+ Log.error "Ruby version '#{pseudonym}' not found."
end
end
@@ -16,7 +16,7 @@ def execute
ver_name, ver_config = *new_ver
- ver_config[:alias] = 'default' if default
+ config.create_alias(ver_name,'default') if default
switch_path_to(ver_config)
switch_gem_home_to(ver_config[:gem_home])
@@ -25,6 +25,11 @@ def initialize(file = File.join(Pik.home, 'config.yml'))
def_delegators :@rubies, :[], :[]=, :clear, :sort, :find, :keys,
:delete, :each, :include?, :select
+ def create_alias(key, alias_name)
+ each{|name,data| data.delete_if{|k,v| k == :alias && v == alias_name }}
+ self[key][:alias] = alias_name
+ end
+
def match(string)
find do |pattern, ver|
VersionPattern.parse(pattern).include?(string) || ver[:alias] == string

0 comments on commit 40746bf

Please sign in to comment.