pik 0.2.7 → 0.2.8

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.
@@ -1,3 +1,12 @@
1
+ === 0.2.8 / 2010-06-22
2
+ ** BACKWARD COMPATIBILITY CHANGE
3
+ pik will now install new rubies to %USERPROFILE%\rubies\, instead of %PIK_BIN%\pik\ this was necessary to all for installation into %PROGRAMFILES% dir. If you'd like to keep the old path, run:
4
+ >pik config install_dir=C:\path\to\pik
5
+ **
6
+ * fixed bug in 'devkit update' - gcc.bat file was writing to/overwriting sh.bat
7
+ * added support for powershell
8
+ * added support for Git Bash
9
+ * it is now possible to install pik to %PROGRAMFILES%
1
10
 
2
11
  === 0.2.7 / 2010-06-15
3
12
  * cleaner list output
@@ -18,15 +18,13 @@ features/run_command.feature
18
18
  features/step_definitions/pik_commands.rb
19
19
  features/support/env.rb
20
20
  features/support/proxy.ru
21
- features/switch_command.feature
22
21
  features/tag_command.feature
23
22
  features/uninstall_command.feature
23
+ features/use_command.feature
24
24
  features/version.feature
25
25
  lib/pik.rb
26
- lib/pik/batch_file.rb
27
26
  lib/pik/commands.rb
28
27
  lib/pik/commands/add_command.rb
29
- lib/pik/commands/batch_file_editor.rb
30
28
  lib/pik/commands/command.rb
31
29
  lib/pik/commands/config_command.rb
32
30
  lib/pik/commands/config_file_editor.rb
@@ -40,10 +38,11 @@ lib/pik/commands/install_command.rb
40
38
  lib/pik/commands/list_command.rb
41
39
  lib/pik/commands/remove_command.rb
42
40
  lib/pik/commands/run_command.rb
43
- lib/pik/commands/switch_command.rb
41
+ lib/pik/commands/script_file_editor.rb
44
42
  lib/pik/commands/tag_command.rb
45
43
  lib/pik/commands/uninstall_command.rb
46
44
  lib/pik/commands/update_command.rb
45
+ lib/pik/commands/use_command.rb
47
46
  lib/pik/config_file.rb
48
47
  lib/pik/contrib/progressbar.rb
49
48
  lib/pik/contrib/unzip.rb
@@ -57,7 +56,10 @@ lib/pik/contrib/zip/ziprequire.rb
57
56
  lib/pik/core_ext/pathname.rb
58
57
  lib/pik/implementations.rb
59
58
  lib/pik/options.rb
60
- lib/pik/pik.rb
59
+ lib/pik/scripts/bash_file.rb
60
+ lib/pik/scripts/batch_file.rb
61
+ lib/pik/scripts/ps_file.rb
62
+ lib/pik/scripts/script_file.rb
61
63
  lib/pik/search_path.rb
62
64
  lib/pik/version_parser.rb
63
65
  lib/pik/which.rb
@@ -83,6 +85,5 @@ spec/switch_command_spec.rb
83
85
  spec/version_parser_spec.rb
84
86
  spec/which_spec.rb
85
87
  tools/pik.bat
86
- tools/pik/pik_runner
87
- tools/pik/pik_runner.exe
88
- tools/pik/pik_runner.exy
88
+ tools/pik.ps1
89
+ tools/pik_runner.exe
@@ -12,7 +12,7 @@ Gordon Thiesfeld
12
12
 
13
13
  == DESCRIPTION:
14
14
 
15
- Pik is a tool to manage multiple versions of ruby on Windows.
15
+ Pik is a tool to manage multiple versions of ruby on Windows. It can be used from the Windows command line (cmd.exe), Windows PowerShell, or Git Bash. I have yet to test on cygwin.
16
16
 
17
17
  >pik help commands
18
18
 
@@ -42,15 +42,17 @@ Pik is a tool to manage multiple versions of ruby on Windows.
42
42
 
43
43
  == REQUIREMENTS:
44
44
 
45
- Windows, more than one version of Ruby (otherwise, what's the point?) and Rubygems
45
+ Windows
46
46
 
47
47
  * Build dependencies: exerb-mingw, highline, hpricot, crown, upx, wix
48
48
 
49
49
  * Development dependencies: rake, cucumber, rspec, hoe, hoe-git, rack, rack-cache
50
50
 
51
51
  == INSTALL:
52
+
53
+ You can install pik via rubygems, or the Windows installer, or you can update pik with pik
52
54
 
53
- * install pik using rubygems.
55
+ === Install pik using rubygems
54
56
 
55
57
  >gem install pik
56
58
  ...
@@ -73,7 +75,15 @@ So I run:
73
75
  ...
74
76
 
75
77
  pik is installed
78
+
79
+ === Install pik using the installer
80
+
81
+ If you want to install to a machine that doesn't have Ruby installed yet, you can download the latest msi file from github[http://github.com/vertiginous/pik/downloads]. Or, just run:
76
82
 
83
+ >msiexec /i http://github.com/downloads/vertiginous/pik/pik-n.n.n.msi
84
+
85
+ The MSI installer currently doesn't install the needed files to use Pik from Git Bash. Also, there was a bug in the upgrade code in 0.2.7, so you should uninstall the current version before installing the new one.
86
+
77
87
  If you install to a directory that's not in your path, you'll need to add it to the path yourself. Microsoft has good instructions[http://support.microsoft.com/kb/310519] on that. After that, you should be ready to run pik.
78
88
 
79
89
  * If this is a first-time install, look at pik add, and pik install to set up your environment.
data/Rakefile CHANGED
@@ -24,11 +24,11 @@ ENV['SPEC_OPTS']= '-O spec/spec.opts'
24
24
 
25
25
  lib = FileList["lib/**/*.rb"]
26
26
 
27
- file 'tools/pik/pik_runner.exy', :needs => ['tools/pik/pik_runner'] + lib do
28
- Dir.chdir 'tools/pik' do
29
- sh('ruby -rexerb/mkexy pik_runner -v')
27
+ file 'tools/pik_runner.exy', :needs => ['tools/pik_runner'] + lib do
28
+ Dir.chdir 'tools' do
29
+ sh('ruby -rexerb/mkexy pik_runner pik.bat -v')
30
30
  end
31
- exy = YAML.load(File.read('tools/pik/pik_runner.exy'))
31
+ exy = YAML.load(File.read('tools/pik_runner.exy'))
32
32
  zlib1 = {
33
33
  'file' => File.join(RbConfig::CONFIG['bindir'], 'zlib1.dll'),
34
34
  'type' => 'extension-library'
@@ -36,28 +36,28 @@ file 'tools/pik/pik_runner.exy', :needs => ['tools/pik/pik_runner'] + lib do
36
36
  exy['file']['zlib1.dll'] = zlib1
37
37
  exy['resource'] = EXE_VERSION
38
38
 
39
- File.open('tools/pik/pik_runner.exy', 'w+'){ |f| f.puts YAML.dump(exy) }
39
+ File.open('tools/pik_runner.exy', 'w+'){ |f| f.puts YAML.dump(exy) }
40
40
  end
41
41
 
42
- file 'tools/pik/pik_runner.exe', :needs => ['tools/pik/pik_runner.exy'] do
43
- Dir.chdir 'tools/pik' do
42
+ file 'tools/pik_runner.exe', :needs => ['tools/pik_runner.exy'] do
43
+ Dir.chdir 'tools' do
44
44
  sh('ruby -S exerb pik_runner.exy')
45
45
  sh('upx -9 pik_runner.exe') unless ENV['QUICK']
46
46
  end
47
47
  end
48
48
 
49
- task :build, :needs => 'tools/pik/pik_runner.exe'
49
+ task :build, :needs => 'tools/pik_runner.exe'
50
50
 
51
51
  task :install, :needs => :build do
52
52
  sh('ruby bin/pik_install C:\\bin')
53
53
  end
54
54
 
55
55
  task :clobber_exe do
56
- rm_rf 'tools/pik/pik_runner.exe'
56
+ rm_rf 'tools/pik_runner.exe'
57
57
  end
58
58
 
59
59
  task :clobber_exy, :needs => :clobber_exe do
60
- rm_rf 'tools/pik/pik_runner.exy'
60
+ rm_rf 'tools/pik_runner.exy'
61
61
  end
62
62
 
63
63
  task :rebuild, :needs => [:clobber_exy, :build]
@@ -73,7 +73,6 @@ Hoe.spec('pik') do
73
73
  developer('Gordon Thiesfeld', 'gthiesfeld@gmail.com')
74
74
 
75
75
  self.need_tar = false
76
- self.extra_deps = {'highline' => '>= 0.0.0'}
77
76
  self.readme_file = 'README.rdoc'
78
77
  self.post_install_message =<<-PIM
79
78
 
@@ -130,17 +129,22 @@ Cucumber::Rake::Task.new(:features) do |t|
130
129
  t.cucumber_opts = "features -f html -o ../pik_cucumber.html -f progress"
131
130
  end
132
131
 
132
+ desc "generate a guid"
133
133
  task :guid do
134
134
  puts
135
135
  puts UUID.new.generate.upcase
136
136
  end
137
137
 
138
+ require 'nokogiri'
138
139
  directory 'pkg'
140
+ @package = 'pik'
141
+ @wix_file = "lib/installer/#{@package}.wxs"
142
+ @wxs = Nokogiri::XML(File.open(@wix_file))
143
+ @product = @wxs.at_css("Product")
139
144
 
140
- @package = 'pik'
145
+ msi_file = "pkg/#{@package}-#{Pik::VERSION}.msi"
141
146
 
142
- msi_file = "pkg/#{@package}-#{Pik::VERSION}.msi"
143
- file msi_file, :needs => 'tools/pik/pik_runner.exe'
147
+ file msi_file, :needs => 'tools/pik_runner.exe'
144
148
 
145
149
  task :installer, :needs => [msi_file, :light]
146
150
 
@@ -163,5 +167,22 @@ task :light, :needs => :candle do
163
167
  sh("light -nologo -ext WixUtilExtension -ext WixUIExtension #{wixobj_files} -o ../../#{msi_file}")
164
168
  end
165
169
  end
170
+
171
+ def version_string
172
+ @version.gsub(".","")
173
+ end
174
+
175
+ task :upgrade do
176
+ @product["Version"] = Pik::VERSION
177
+
178
+ upgrade_max = @product.at_css("UpgradeVersion[Property = 'OLDAPPFOUND']")
179
+ upgrade_max["Maximum"] = Pik::VERSION
180
+
181
+ upgrade_min = @product.at_css("UpgradeVersion[Property = 'NEWAPPFOUND']")
182
+ upgrade_min["Minimum"] = Pik::VERSION
183
+
184
+ @product["Id"] = UUID.new.generate
185
+ File.open(@wix_file, 'w+'){|f| f.puts @wxs }
186
+ end
166
187
  # vim: syntax=Ruby
167
188
 
@@ -25,18 +25,50 @@ abort usage unless ARGV.first
25
25
 
26
26
  puts "Thank you for using pik.\n\n"
27
27
 
28
- install_dir = ARGV.first
29
- tools_dir = File.join(File.dirname(__FILE__), '..', 'tools')
28
+ install_dir = ARGV.first
29
+
30
+ pik_home = File.join(ENV['USERPROFILE'], '.pik')
31
+
32
+ src_dir = File.join(File.dirname(File.dirname(__FILE__)), 'tools')
33
+
34
+ bash_install_dir = install_dir.tr('\\','/').sub(/^(.):/){|s| "/#{s[0,1].downcase}"}
35
+
36
+ mkdir_p install_dir, :verbose => true
37
+ mkdir_p pik_home, :verbose => true
38
+
39
+ old_dir = File.join(install_dir, 'pik')
40
+ old_pik = File.join(old_dir, 'pik_runner.exe')
41
+ if File.exist? old_pik
42
+ puts "cleaning up old files"
43
+ rm old_pik, :verbose => true
44
+ end
45
+
46
+ begin
47
+ rmdir(old_dir, :verbose=> true) if File.exist? old_dir
48
+ rescue Errno::ENOTEMPTY
49
+ puts "warning: can't delete #{old_dir}, directory not empty"
50
+ puts "continuing intall..."
51
+ end
30
52
 
31
53
  puts "Installing to #{install_dir}\n\n"
32
- cp File.join(tools_dir, 'pik.bat'), install_dir ,
33
- :verbose => true
54
+ cp File.join(src_dir, 'pik_runner.exe'), install_dir, :verbose => true
55
+ cp File.join(src_dir, 'pik.bat'), install_dir, :verbose => true
56
+ cp File.join(src_dir, 'pik.ps1'), install_dir, :verbose => true
57
+
58
+ pikrc_file = File.join(pik_home, '.pikrc')
59
+ pikrc_contents =<<PIKRC
60
+ #!/bin/sh
61
+ pik_path=#{bash_install_dir}
62
+
63
+ function pik {
64
+ $pik_path/pik_runner.exe pik.sh $@
65
+ [[ -s $USERPROFILE/.pik/pik.sh ]] && source $USERPROFILE/.pik/pik.sh
66
+ }
67
+ PIKRC
68
+ puts
69
+ puts "creating #{pikrc_file}"
70
+ File.open(pikrc_file, 'w+'){|f| f.puts pikrc_contents }
34
71
 
35
- mkdir_p File.join(install_dir, 'pik'), :verbose => true
36
- cp File.join(tools_dir, 'pik', 'pik_runner.exe'),
37
- File.join(install_dir, 'pik') ,
38
- :verbose => true
39
-
40
72
  puts "\npik is installed"
41
73
 
42
74
  unless ENV['PATH'].downcase.include?( install_dir.downcase.gsub('/',"\\") )
@@ -52,4 +84,12 @@ SYSTEM_PATH_MSG
52
84
 
53
85
  puts system_path_msg
54
86
 
55
- end
87
+ end
88
+
89
+ puts
90
+ puts bash_msg =<<BASH_MSG
91
+ if you want to use pik with git bash, add the following line to your ~/.bashrc:
92
+
93
+ [[ -s $USERPROFILE/.pik/.pikrc ]] && source $USERPROFILE/.pik/.pikrc
94
+
95
+ BASH_MSG
@@ -35,11 +35,11 @@ require 'win32/process'
35
35
  REAL_PATH = SearchPath.new(ENV['PATH']).replace(RbConfig::CONFIG['bindir'], 'C:\temp\more spaces in path\ruby\Ruby-186-p398-2\bin').join
36
36
  OTHER_RUBY = 'c:\\temp\\more spaces in path\\ruby\\Ruby-191-p378-1\\bin'
37
37
 
38
- ENV['HOME'] = "C:\\temp\\path with spaces"
38
+ ENV['USERPROFILE'] = "C:\\temp\\path with spaces"
39
39
  ENV['http_proxy'] = "http://localhost:9292"
40
40
 
41
41
  PIK_LOG = 'log\\output.log'
42
- TEST_PIK_HOME = Pathname.new( ENV['HOME'] || ENV['USERPROFILE'] ) + '.pik'
42
+ TEST_PIK_HOME = Pathname.new( ENV['USERPROFILE'] ) + '.pik'
43
43
  FAKE_PIK_HOME = 'c:/temp/path with spaces/.pik'
44
44
  PID_FILE = 'c:/temp/proxy/proxy.pid'
45
45
 
@@ -1,12 +1,12 @@
1
- Feature: switch command
1
+ Feature: use command
2
2
  In order to switch from one ruby version to another
3
3
  A developer
4
4
  Wants an interface to the program
5
5
  So that she can easily update the path and other environment variables.
6
6
 
7
- Scenario Outline: Switching versions with switch command
7
+ Scenario Outline: Switching versions with use command
8
8
  Given I have added "<version>" to pik
9
- When I run "pik switch <patterns> -v" and check the path
9
+ When I run "pik use <patterns> -v" and check the path
10
10
  Then I should see "<version>"
11
11
  And the path should point to it.
12
12
  And the GEM_HOME might get set.
data/lib/pik.rb CHANGED
@@ -1,7 +1,3 @@
1
- module Pik
2
- VERSION = '0.2.7'
3
- end
4
-
5
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
6
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'vendor/lib'))
7
3
 
@@ -12,24 +8,17 @@ require 'find'
12
8
  require 'open-uri'
13
9
  require 'rbconfig'
14
10
 
15
- ENV['GEM_HOME'] = nil
16
- ENV['GEM_PATH'] = nil
17
- # real_home = ENV['HOME']
18
- # ENV['HOME'] = "nul"
19
-
20
- # require 'rubygems'
21
-
22
- # ENV['HOME'] = real_home
23
-
24
11
  require 'hpricot'
25
12
  require 'highline'
26
13
 
27
- require 'pik/pik'
28
- require 'pik/batch_file'
29
14
  require 'pik/core_ext/pathname'
15
+ require 'pik/scripts/script_file'
16
+ require 'pik/scripts/batch_file'
17
+ require 'pik/scripts/ps_file'
18
+ require 'pik/scripts/bash_file'
30
19
  require 'pik/commands'
31
20
  require 'pik/commands/config_file_editor'
32
- require 'pik/commands/batch_file_editor'
21
+ require 'pik/commands/script_file_editor'
33
22
  require 'pik/commands/command'
34
23
  require 'pik/commands/devkit_command'
35
24
  require 'pik/commands/install_command'
@@ -37,7 +26,7 @@ require 'pik/commands/list_command'
37
26
  require 'pik/commands/add_command'
38
27
  require 'pik/commands/help_command'
39
28
  require 'pik/commands/info_command'
40
- require 'pik/commands/switch_command'
29
+ require 'pik/commands/use_command'
41
30
  require 'pik/commands/run_command'
42
31
  require 'pik/commands/remove_command'
43
32
  require 'pik/commands/config_command'
@@ -54,14 +43,34 @@ require 'pik/version_parser'
54
43
  require 'pik/windows_env'
55
44
  require 'pik/which'
56
45
 
57
- PIK_HOME = Pathname.new( ENV['HOME'] || ENV['USERPROFILE'] ) + '.pik'
46
+ module Pik
47
+ VERSION = '0.2.8'
48
+ Scripts = {
49
+ '.cmd' => BatchFile,
50
+ '.bat' => BatchFile,
51
+ '.ps1' => PsFile,
52
+ '.sh' => BashFile
53
+ }
58
54
 
59
- if defined? ExerbRuntime
60
- PIK_BATCH = Pathname.new(ARGV.shift).ruby
61
- else
62
- pik_exe = Pathname.new($0).expand_path + '..'
63
- PIK_BATCH = pik_exe.dirname + "#{pik_exe.basename}.bat"
55
+ def self.print_error(error)
56
+ puts "\nThere was an error."
57
+ puts " Error: #{error.message}\n\n"
58
+ puts error.backtrace.map{|m| " in: #{m}" }
59
+ puts
60
+ end
61
+
64
62
  end
65
63
 
64
+
66
65
  Pik::Commands.deprecate(:checkup => "The checkup command is deprecated, using the info command instead.")
67
66
  Pik::Commands.deprecate(:cu => "The cu command is deprecated, using the info command instead.")
67
+
68
+ PIK_HOME = Pathname.new( ENV['USERPROFILE'] ) + '.pik'
69
+
70
+ if defined?(ExerbRuntime) || $0 =~ /pik_runner/
71
+ PIK_SCRIPT = Pathname.new(ARGV.shift).ruby
72
+ SCRIPT_LANG = Pik::Scripts[PIK_SCRIPT.extname]
73
+ SCRIPT_FILE = SCRIPT_LANG.new(PIK_HOME + 'pik')
74
+ else
75
+ SCRIPT_FILE = Pik::BatchFile.new(PIK_HOME + 'pik')
76
+ end
@@ -9,7 +9,7 @@ module Pik
9
9
  end
10
10
 
11
11
  class Command
12
-
12
+
13
13
  attr_reader :config
14
14
 
15
15
  attr_reader :options
@@ -47,14 +47,6 @@ module Pik
47
47
  def self.names
48
48
  @names ||= [cmd_name]
49
49
  end
50
-
51
- def self.clean_gem_batch
52
- BatchFile.open(PIK_BATCH) do |gem_bat|
53
- # remove old calls to .pik/pik batches
54
- gem_bat.remove_line( /call.+pik.+bat/i )
55
- gem_bat.write
56
- end
57
- end
58
50
 
59
51
  def self.choose_from(patterns, config)
60
52
  if patterns.empty?
@@ -85,11 +77,11 @@ module Pik
85
77
  @config = config_ || ConfigFile.new
86
78
  @hl = HighLine.new
87
79
  add_sigint_handler
88
- options.program_name = "#{PIK_BATCH.basename('.*')} #{self.class.names.join('|')}"
80
+ options.program_name = "pik #{self.class.names.join('|')}"
89
81
  command_options
90
82
  parse_options
91
83
  create(PIK_HOME) unless PIK_HOME.exist?
92
- delete_old_pik_batches
84
+ delete_old_pik_script
93
85
  end
94
86
 
95
87
  def close
@@ -162,10 +154,8 @@ module Pik
162
154
  home.mkpath
163
155
  end
164
156
 
165
- def delete_old_pik_batches( cutoff=(Time.now - (2 * 60 * 60)) )
166
- Dir[(PIK_HOME + "*.bat").to_ruby.to_s].each do |f|
167
- File.delete(f) if File.ctime(f) < cutoff
168
- end
157
+ def delete_old_pik_script
158
+ SCRIPT_FILE.path.delete if SCRIPT_FILE.path.exist?
169
159
  end
170
160
 
171
161
  def sh(cmd)