@@ -58,184 +58,3 @@ namespace :profile do
5858end
5959
6060
61- namespace :rvm do
62-
63- RUBIES = {
64- 'ruby-1.8.6' => { :alias => 'sqlsvr186' , :odbc => '0.99992' } ,
65- 'ruby-1.8.7' => { :alias => 'sqlsvr187' , :odbc => '0.99992' } ,
66- 'ruby-1.9.1' => { :alias => 'sqlsvr191' , :odbc => '0.99992' } ,
67- 'ruby-1.9.2' => { :alias => 'sqlsvr192' , :odbc => '0.99992' } ,
68- 'ree-1.8.7' => { :alias => 'sqlsvrree' , :odbc => '0.99992' }
69- }
70-
71- task :setup do
72- unless @rvm_setup
73- rvm_lib_path = "#{ `echo $rvm_path` . strip } /lib"
74- $LOAD_PATH. unshift ( rvm_lib_path ) unless $LOAD_PATH. include? ( rvm_lib_path )
75- require 'rvm'
76- require 'tmpdir'
77- @rvm_setup = true
78- end
79- end
80-
81- desc "Shows the command to run tests on all rubie versions."
82- task :test => :setup do
83- rubies = RUBIES . map { |rubie , info | info [ :alias ] }
84- puts "Run this:\n rvm #{ rubies . join ( ',' ) } rake test"
85- end
86-
87- task :wipe => :setup do
88- rvm_rubies . each { |rubie | RVM . remove ( rubie , :gems => true ) }
89- RVM . cleanup_all
90- end
91-
92- namespace :install do
93-
94- desc "Install the following rubie versions if not already: #{ RUBIES . keys . inspect } "
95- task :rubies => :setup do
96- installed_rubies = RVM . list_strings
97- RUBIES . keys . each do |rubie |
98- if installed_rubies . any? { |ir | ir =~ /#{ rubie } / }
99- puts "info: Rubie #{ rubie } already installed."
100- else
101- with_my_environment_vars do
102- good_msg = "info: Rubie #{ rubie } installed."
103- bad_msg = "Failed #{ rubie } install! Check RVM logs here: #{ RVM . path } /log/#{ rubie } "
104- puts "info: Rubie #{ rubie } installation inprogress. This could take awhile..."
105- RVM . install ( rubie , rvm_install_options ) ? puts ( good_msg ) : abort ( bad_msg )
106- end
107- end
108- end
109- rvm_each_rubie do
110- RVM . gemset_create rvm_gemset_name
111- RVM . alias_create rvm_current_rubie_info [ :alias ] , rvm_current_name
112- end
113- end
114-
115- desc "Install ruby-odbc for each rubie version."
116- task :odbc => :setup do
117- rvm_each_rubie do
118- odbc = "ruby-odbc-#{ rvm_current_rubie_info [ :odbc ] } "
119- RVM . chdir ( Dir . tmpdir ) do
120- RVM . run "rm -rf #{ odbc } *"
121- puts "info: RubyODBC downloading #{ odbc } ..."
122- RVM . run "curl -O http://www.ch-werner.de/rubyodbc/#{ odbc } .tar.gz"
123- puts "info: RubyODBC extracting clean work directory..."
124- RVM . run "tar -xf #{ odbc } .tar.gz"
125- [ 'ext' , 'ext/utf8' ] . each do |extdir |
126- RVM . chdir ( "#{ odbc } /#{ extdir } " ) do
127- puts "info: RubyODBC configuring in #{ extdir } ..."
128- RVM . ruby 'extconf.rb' , "--with-odbc-dir=#{ rvm_odbc_dir } "
129- puts "info: RubyODBC make and installing for #{ rvm_current_name } ..."
130- RVM . run "make && make install"
131- end
132- end
133- end
134- end
135- end
136-
137- desc "Install development gems using bundler to each rubie version, installing bundler if not already."
138- task :bundle => :setup do
139- rvm_each_rubie ( :gemset => 'global' ) { rvm_install_gem 'bundler' }
140- rvm_each_rubie { RVM . run 'bundle install' }
141- end
142-
143- end
144-
145- end
146-
147-
148-
149- # RVM Helper Methods
150-
151- def rvm_each_rubie ( options = { } )
152- rvm_rubies ( options ) . each do |rubie |
153- RVM . use ( rubie )
154- yield
155- end
156- ensure
157- RVM . reset_current!
158- end
159-
160- def rvm_rubies ( options = { } )
161- gemset = options [ :gemset ] || rvm_gemset_name
162- RUBIES . keys . map { |rubie | "#{ rubie } @#{ gemset } " }
163- end
164-
165- def rvm_current_rubie_info
166- key = rvm_current_rubie_name
167- while !key . empty?
168- info = RUBIES [ key ]
169- return info if info
170- new_key = key . split ( '-' ) ; new_key . pop
171- key = new_key . join ( '-' )
172- end
173- end
174-
175- def rvm_current_rubie_name
176- rvm_current_name . sub ( "@#{ rvm_gemset_name } " , '' )
177- end
178-
179- def rvm_current_name
180- RVM . current . expanded_name
181- end
182-
183- def rvm_gemset_name
184- 'sqlserver'
185- end
186-
187- def rvm_with_macports?
188- `uname` . strip == 'Darwin' && !`which port` . empty?
189- end
190-
191- def rvm_install_options
192- { }
193- end
194-
195- def rvm_odbc_dir
196- rvm_with_macports? ? '/opt/local' : '/usr/local'
197- end
198-
199- def rvm_gem_available? ( *specs )
200- available_args = specs . map { |s | "'#{ s } '" } . join ( ',' )
201- RVM . ruby_eval ( "require 'rubygems' ; print Gem.available?(#{ available_args } )" ) . stdout == 'true'
202- end
203-
204- def rvm_install_gem ( *specs )
205- gem , version = specs
206- spec_info = specs . join ( ', ' )
207- if rvm_gem_available? ( *specs )
208- puts "info: Gem #{ spec_info } already installed in #{ rvm_current_name } ."
209- else
210- puts "info: Installing gem #{ spec_info } in #{ rvm_current_name } ..."
211- install_args = [ :gem , 'install' , gem ]
212- install_args += [ '-v' , version ] if version && !version . empty?
213- puts RVM . perform_set_operation ( *install_args ) . stdout
214- end
215- end
216-
217- def with_my_environment_vars
218- my_vars = my_environment_vars
219- current_vars = my_vars . inject ( { } ) { |cvars , kv | k , v = kv ; cvars [ k ] = ENV [ k ] ; cvars }
220- set_environment_vars ( my_vars )
221- yield
222- ensure
223- set_environment_vars ( current_vars )
224- end
225-
226- def my_environment_vars
227- if rvm_with_macports?
228- { 'CC' => '/usr/bin/gcc-4.2' ,
229- 'CFLAGS' => '-O2 -arch x86_64' ,
230- 'LDFLAGS' => '-L/opt/local/lib -arch x86_64' ,
231- 'CPPFLAGS' => '-I/opt/local/include' }
232- else
233- { }
234- end
235- end
236-
237- def set_environment_vars ( vars )
238- vars . each { |k , v | ENV [ k ] = v }
239- end
240-
241-
0 commit comments