Permalink
Browse files

commiting what I've got and starting over

  • Loading branch information...
1 parent ba7e8fd commit 24af97b546bda97ce9f097e2bf879f143654544a @vertiginous committed Nov 18, 2010
View
@@ -0,0 +1,3 @@
+--colour
+--require=rubygems
+--require=lib/pik
View
@@ -0,0 +1,53 @@
+TODO
+
+new directory structure
+.pik
+|-- config
+|-- downloads
+|-- gems
+|-- rubies
+`-- scripts
+
+Where should devkit get installed to?
+
+config.yml should be .pik/config/user.yml
+
+Change all instance vars to attrs (config, log, options, args)
+Change all output to use log
+Add stories for gemset command
+
+-v == --version
+-v != --verbose
+# Add --default to 'pik use'
+
+# Change 'pik default' to 'pik system'
+# 'pik system' will return PATH, GEM_HOME, GEM_PATH to pre pik state
+# Add 'pik default' (default will switch to default ruby)
+
+install should only install to PIK_HOME
+
+remove 'pik add' replace with 'pik install' [--some-switch=path]
+ where path is a package file (zip, 7z, tar) or path (C:\repo\rubyinstaller\sandbox\ruby19)
+
+change (or remove altogether) 'pik remove'. it won't be needed after 'pik add' is gone.
+
+# Change 'pik use pattern'/'pik pattern' to 'pik use selector'/'pik selector'
+# Add 'gemset select' to 'pik use' (version@gemset)
+# Add global gemset
+# make sure global gemset and default/specified gemset bin dir is added to path.
+
+GEM_HOME and GEM_PATH will always be used (except after 'pik system')
+
+# all gems will be installed to PIK_HOME\gems
+
+# Add pik list known
+# Add pik list default
+
+Add pik monitor
+#Add pik spec
+Add pik test
+
+remove pik config
+
+change 'pik install devkit' to 'pik package install devkit'
+#remove 'pik devkit update' make this action an "after_install" action when the platform is mingw.
@@ -0,0 +1,34 @@
+
+module Pik
+
+ class System < Command
+
+ it "Switches back to the default settings."
+
+ attr_accessor :verbose
+
+ include ScriptFileEditor
+
+ def execute
+ sys = WindowsEnv.system
+ usr = WindowsEnv.user
+ new_path = [sys['PATH'],usr['PATH']].compact.join(';')
+ env['PATH'] = SearchPath.new(new_path)
+ env['GEM_PATH'] = usr['GEM_PATH'] || sys['GEM_PATH']
+ env['BUNDLE_PATH'] = usr['BUNDLE_PATH'] || sys['BUNDLE_PATH']
+ env['GEM_HOME'] = usr['GEM_HOME'] || sys['GEM_HOME']
+ echo_ruby_version(Which::Ruby.find(new_path)) if verbose
+ end
+
+ def command_options
+ super
+ @options.on("--verbose", "-v",
+ "Verbose output"
+ ) do |value|
+ @verbose = value
+ end
+ end
+
+ end
+
+end
@@ -0,0 +1,33 @@
+
+describe Pik::BashFile do
+
+ before do
+ @bf = Pik::BashFile.new('pik')
+ end
+
+ it "should have the correct file name" do
+ @bf.path.to_s.should == 'pik.sh'
+
+ bf2 = Pik::BashFile.new('pik.sh')
+ bf2.path.to_s.should == 'pik.sh'
+ end
+
+ it "should have a header" do
+ string = "#!/bin/sh\n# This bash script generated by Pik, the\n# Ruby Manager for Windows\n"
+ @bf.to_s.should == string
+ end
+
+ it "should generate a path command with the updated ruby path" do
+ @bf.set('PATH' => Pathname("C:\\ruby\\191\\bin")).to_s.should match(/export PATH\='\/c\/ruby\/191\/bin'/)
+ @bf.set('GEM_HOME' => nil).to_s.should match(/unset GEM_HOME/)
+ end
+
+ it "should echo a string given" do
+ @bf.echo("Hello World").to_s.should match(/ECHO Hello World/)
+ end
+
+ it "should call the command given" do
+ @bf.call('pik.bat').to_s.should match(/pik\.bat/)
+ end
+
+end
@@ -0,0 +1,35 @@
+
+describe Pik::BatchFile do
+
+ before do
+ @bf = Pik::BatchFile.new('pik')
+ end
+
+ it "should have the correct file name" do
+ @bf.path.to_s.should == 'pik.bat'
+
+ bf2 = Pik::BatchFile.new('pik.bat')
+ bf2.path.to_s.should == 'pik.bat'
+ end
+
+ it "should have a header" do
+ string = "@ECHO OFF\n\n"
+ string << ":: This batch file generated by Pik, the\n"
+ string << ":: Ruby Manager for Windows\n"
+ @bf.to_s.should == string
+ end
+
+ it "should generate a path command with the updated ruby path" do
+ @bf.set('PATH' => "C:\\ruby\\191\\bin").to_s.should match(/SET PATH\=C:\\ruby\\191\\bin/)
+ @bf.set('GEM_HOME' => nil).to_s.should match(/SET GEM_HOME\=/)
+ end
+
+ it "should echo a string given" do
+ @bf.echo("Hello World").to_s.should match(/ECHO Hello World/)
+ end
+
+ it "should call the command given" do
+ @bf.call('pik.bat').to_s.should match(/CALL pik\.bat/)
+ end
+
+end
@@ -0,0 +1,27 @@
+describe Pik::Command do
+
+ before(:each) do
+ @cmd = Pik::Command.new([])
+ end
+
+ # describe "get_version" do
+ # it "should create a version string" do
+ # ver = `ruby -v`.chomp
+
+ # cmd_ver = @cmd.get_version
+ # cmd_ver.should include(ver)
+
+ # ver =~ /ruby (\d)\.(\d)\.(\d)/
+ # ver = $1 + $2 + $3
+ # cmd_ver.should match(/^#{ver}:/)
+ # end
+ # end
+
+ describe "current_version?" do
+ it "should match the current version" do
+ ver = @cmd.get_version
+ @cmd.current_version?(ver.chomp).should be_true
+ end
+ end
+
+end
@@ -0,0 +1,13 @@
+
+describe Pik::Add do
+
+ it "should have a summary" do
+ Pik::Add.summary.should eql("Adds another ruby location to pik.")
+ end
+
+ it "should have an interactive option" do
+ add = Pik::Add.new(['-i'])
+ add.interactive.should be_true
+ end
+
+end
@@ -0,0 +1,6 @@
+
+# describe Pik::Default do
+
+
+
+# end
@@ -0,0 +1,7 @@
+# describe Pik::GemSync do
+# it "should have a summary" do
+# summary = "Synchronizes gems from the version specified to the current version."
+# Pik::GemSync.summary.should eql(summary)
+# end
+
+# end
@@ -0,0 +1,9 @@
+
+describe Pik::Help do
+
+ it "should have a summary" do
+ Pik::Help.summary.should eql("Displays help information.")
+ end
+
+
+end
@@ -0,0 +1,23 @@
+describe Pik::List do
+
+ before do
+ @cmd = 'tools\\pik.bat'
+ Pik::Commands.clear
+ Pik::Commands.add(Pik::List)
+ #Pik::ConfigFile.stub!(:new).and_return({})
+ end
+
+ describe 'execute' do
+
+ # it "should have an alias of ls" do
+ # Pik::List.names.should include(:ls)
+ # end
+
+ # it "should have a verbose options" do
+ # @ls = Pik::List.new(['-v'])
+ # @ls.verbose.should be_true
+ # end
+
+ end
+
+end
@@ -0,0 +1,33 @@
+describe Pik::Remove do
+
+ it "should have a summary" do
+ Pik::Remove.summary.should eql("Removes a ruby location from pik.")
+ end
+
+ it "should have a 'force' option" do
+ cmd = Pik::Remove.new(['--force'])
+ cmd.force.should be_true
+
+ cmd = Pik::Remove.new(['-f'])
+ cmd.force.should be_true
+ end
+
+ it "should have a 'quiet' option" do
+ cmd = Pik::Remove.new(['--quiet'])
+ cmd.quiet.should be_true
+
+ cmd = Pik::Remove.new(['-q'])
+ cmd.quiet.should be_true
+ end
+
+ it "should remove items from the config" do
+ cmd = Pik::Remove.new(['a', '-f', '-q'], {
+ 'a' => {:path => 'C:/ruby/bin', :gem_home => 'C:/users/rupert/.gems'},
+ 'b' => {:path => 'C:/Ruby19/bin'}
+ }
+ )
+ cmd.execute
+ cmd.config.should == ( {'b' => {:path => 'C:/Ruby19/bin'}} )
+ end
+
+end
@@ -0,0 +1,8 @@
+
+describe Pik::Run do
+
+ it "should have a summary" do
+ Pik::Run.summary.should eql("Runs command with all versions of ruby that pik is aware of.")
+ end
+
+end
@@ -0,0 +1,56 @@
+require 'pathname'
+
+describe Pik::Use do
+
+ it "should have a summary" do
+ Pik::Use.summary.should eql("Switches ruby versions based on patterns.")
+ end
+
+ # it "should have an alias of sw" do
+ # Pik::Use.names.should include(:sw)
+ # end
+
+ # it "should have an alias of use" do
+ # Pik::Use.names.should include(:use)
+ # end
+
+ it "should have a global option" #do
+ # sw = Pik::Use.new(['-g'])
+ # sw.global.should be_true
+ # end
+
+ it "should have a gem_home option" # do
+ # sw = Pik::Use.new(['-m', 'test'])
+ # sw.gem_home.should eql("test")
+ # end
+
+ it "should use a batch file to switch paths" do
+ conf = {
+ 'spec ' => {:path => Pathname('C:/ruby/bin')},
+ 'real ' => {:path => Pathname(::RbConfig::CONFIG['bindir'] )}
+ }
+ cmd = Pik::Use.new(['spec'], conf)
+ cmd.execute
+ batch = cmd.instance_variable_get('@script').lines
+ batch.should include("SET GEM_PATH=")
+ batch.should include("SET GEM_HOME=")
+ set_path = batch.grep(/set/i).first
+ set_path.should match(/SET PATH=.+C\:\\ruby\\bin.+/i)
+ end
+
+ it "should switch gem_home and gem_path if the config has a :gem_home" do
+ conf = {
+ 'spec ' => {
+ :path => Pathname('C:/ruby/bin'),
+ :gem_home => Pathname('C:/Users/martin_blanke/.gems')
+ },
+ 'real ' => {:path => Pathname.new(::RbConfig::CONFIG['bindir'] )}
+ }
+ cmd = Pik::Use.new(['spec'], conf)
+ cmd.execute
+ batch = cmd.instance_variable_get('@script').lines
+ batch.should include("SET GEM_PATH=C:\\Users\\martin_blanke\\.gems")
+ batch.should include("SET GEM_HOME=C:\\Users\\martin_blanke\\.gems")
+ end
+
+end
Oops, something went wrong.

0 comments on commit 24af97b

Please sign in to comment.