Skip to content

Commit

Permalink
added #sh method, some tweaks to info command and Implementation class
Browse files Browse the repository at this point in the history
  • Loading branch information
vertiginous committed Nov 8, 2009
1 parent 7bc3bee commit 20ae5d3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
5 changes: 5 additions & 0 deletions lib/pik/commands/command.rb
Expand Up @@ -168,6 +168,11 @@ def delete_old_pik_batches( cutoff=(Time.now - (2 * 60 * 60)) )
end
end

def sh(cmd)
puts cmd if debug
system(cmd)
end

def cmd_name
self.class.cmd_name
end
Expand Down
5 changes: 2 additions & 3 deletions lib/pik/commands/info_command.rb
Expand Up @@ -46,15 +46,14 @@ def info
file associations:
.rb: #{file_associations('.rb')}
.rbw: #{file_associations('.rbw')}
#{check_path}
.rbw: #{file_associations('.rbw')}#{check_path}
INFO
end

def check_path
dirs = Which::Ruby.find_all
unless dirs.size == 1
dirs.unshift("\nwarning: There is more than one version of ruby in the system path")
dirs.unshift("\n\nwarning: There is more than one version of ruby in the system path")
dirs.join("\n")
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/pik/commands/install_command.rb
Expand Up @@ -19,7 +19,7 @@ def initialize(args=ARGV, config_=nil)
def execute
implementation = Implementations[@args.shift]
target, package = implementation.find(*@args)
target = @install_root + "#{implementation.subclass}-#{target.gsub('.','')}"
target = @install_root + implementation.name + target.gsub('.','')
file = download(package)
extract(target, file)
add( Pathname(target) + 'bin' )
Expand Down
11 changes: 2 additions & 9 deletions lib/pik/commands/update_command.rb
Expand Up @@ -7,15 +7,8 @@ class Update < Command
include BatchFileEditor

def execute
default
results = `#{Which::Gem.exe} update pik`
puts results
update_re = /Nothing to update/
@batch.call("pik_install #{PIK_BATCH.dirname}") unless results.match(update_re)
end

def default
# should move to default implementation before attemping an update
sh "#{Which::Gem.exe} install pik"
@batch.call("pik_install #{PIK_BATCH.dirname}")
end

end
Expand Down
1 change: 1 addition & 0 deletions lib/pik/implementations.rb
Expand Up @@ -71,6 +71,7 @@ def read
def subclass
self.class.to_s.split('::').last
end
alias :name :subclass

end

Expand Down

0 comments on commit 20ae5d3

Please sign in to comment.