rake_tasks 2.0.6 → 3.0.0

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.
@@ -0,0 +1,59 @@
1
+ #--
2
+ ################################################################################
3
+ # Copyright (C) 2011 Travis Herrick #
4
+ ################################################################################
5
+ # #
6
+ # \v^V,^!v\^/ #
7
+ # ~% %~ #
8
+ # { _ _ } #
9
+ # ( * - ) #
10
+ # | / | #
11
+ # \ _, / #
12
+ # \__.__/ #
13
+ # #
14
+ ################################################################################
15
+ # This program is free software: you can redistribute it #
16
+ # and/or modify it under the terms of the GNU Lesser General Public License #
17
+ # as published by the Free Software Foundation, #
18
+ # either version 3 of the License, or (at your option) any later version. #
19
+ ################################################################################
20
+ # This program is distributed in the hope that it will be useful, #
21
+ # but WITHOUT ANY WARRANTY; #
22
+ # without even the implied warranty of MERCHANTABILITY #
23
+ # or FITNESS FOR A PARTICULAR PURPOSE. #
24
+ # See the GNU Lesser General Public License for more details. #
25
+ # #
26
+ # You should have received a copy of the GNU Lesser General Public License #
27
+ # along with this program. If not, see <http://www.gnu.org/licenses/>. #
28
+ ################################################################################
29
+ #++
30
+
31
+ if RakeTasks::Gem.gemspec_file?
32
+ ############################################################################
33
+ namespace :doc do
34
+ ############################################################################
35
+
36
+ gem_spec_file = RakeTasks::Gem.gem_spec_file
37
+
38
+ readme = 'readme.md'
39
+ readme = 'readme_generated.md' if File.file?(readme)
40
+
41
+ file readme => gem_spec_file do |t|
42
+ doc_obj = RakeTasks::Doc.new
43
+ Util.write_file readme, doc_obj.readme_contents
44
+ end
45
+
46
+ desc "Generate a #{readme} file."
47
+ task :readme => readme
48
+
49
+ desc "Removes files associated with generating documentation."
50
+ task :clobber do |t|
51
+ rm_f readme
52
+ end
53
+
54
+ ############################################################################
55
+ end # :doc
56
+ ############################################################################
57
+
58
+ task :clobber => 'doc:clobber'
59
+ end
@@ -1,110 +1,77 @@
1
- # This file holds the class that handles documentation utilities.
2
-
3
- #--
4
- ################################################################################
5
- # Copyright (C) 2011 Travis Herrick #
6
- ################################################################################
7
- # #
8
- # \v^V,^!v\^/ #
9
- # ~% %~ #
10
- # { _ _ } #
11
- # ( * - ) #
12
- # | / | #
13
- # \ _, / #
14
- # \__.__/ #
15
- # #
16
- ################################################################################
17
- # This program is free software: you can redistribute it #
18
- # and/or modify it under the terms of the GNU Lesser General Public License #
19
- # as published by the Free Software Foundation, #
20
- # either version 3 of the License, or (at your option) any later version. #
21
- ################################################################################
22
- # This program is distributed in the hope that it will be useful, #
23
- # but WITHOUT ANY WARRANTY; #
24
- # without even the implied warranty of MERCHANTABILITY #
25
- # or FITNESS FOR A PARTICULAR PURPOSE. #
26
- # See the GNU Lesser General Public License for more details. #
27
- # #
28
- # You should have received a copy of the GNU Lesser General Public License #
29
- # along with this program. If not, see <http://www.gnu.org/licenses/>. #
30
- ################################################################################
31
- #++
32
-
33
- # The main module for this gem.
34
- module RakeTasks
35
- # This class will handle documentation utilities.
36
- class Doc
37
- # Constructor.
38
- def initialize(gem_info = RakeTasks::Gem)
39
- @gem_spec = gem_info.gem_spec
40
- @gem_title = gem_info.gem_title(@gem_spec)
41
- @license_path = 'license'
42
- @contents = nil
43
- end
44
-
45
- # The default contents for a readme file.
46
- def readme_contents
47
- gem_title = @gem_title
48
- gem_spec = @gem_spec
49
-
50
- @contents ||= %Q{
51
- #{header :h1, "Welcome to #{gem_title}"}
52
-
53
- #{gem_spec.description}
54
-
55
- #{header :h2, 'Getting Started'}
56
-
57
- Install #{gem_title} at the command prompt if you haven't yet:
58
-
59
- $ gem install #{gem_spec.name}
60
-
61
- Require the gem in your Gemfile:
62
-
63
- gem '#{gem_spec.name}', '~> #{gem_spec.version}'
64
-
65
- Require the gem wherever you need to use it:
66
-
67
- require '#{gem_spec.name}'
68
-
69
- #{header :h2, 'Usage'}
70
-
71
- TODO
72
-
73
- #{header :h2, 'Additional Notes'}
74
-
75
- TODO
76
-
77
- #{header :h2, 'Additional Documentation'}
78
-
79
- $ rake rdoc:app
80
- #{license_details}}.strip
81
-
82
- return @contents
83
- end
84
-
85
- ########################################################################
86
- private
87
- ########################################################################
88
-
89
- # Returns formatted headers.
90
- def header(type, text = nil)
91
- case type
92
- when :h1
93
- "#{text}\n#{'=' * text.length}"
94
- when :h2
95
- "#{text}\n#{'-' * text.length}"
96
- end
97
- end
98
-
99
- # Compose the license details.
100
- def license_details
101
- return if @gem_spec.licenses.empty?
102
-
103
- %Q{
104
- #{header :h2, 'License'}
105
-
106
- #{@gem_title} is released under the #{@gem_spec.licenses.first} license.
107
- }
108
- end
109
- end
110
- end
1
+ #--
2
+ ################################################################################
3
+ # Copyright (C) 2011 Travis Herrick #
4
+ ################################################################################
5
+ # #
6
+ # \v^V,^!v\^/ #
7
+ # ~% %~ #
8
+ # { _ _ } #
9
+ # ( * - ) #
10
+ # | / | #
11
+ # \ _, / #
12
+ # \__.__/ #
13
+ # #
14
+ ################################################################################
15
+ # This program is free software: you can redistribute it #
16
+ # and/or modify it under the terms of the GNU Lesser General Public License #
17
+ # as published by the Free Software Foundation, #
18
+ # either version 3 of the License, or (at your option) any later version. #
19
+ ################################################################################
20
+ # This program is distributed in the hope that it will be useful, #
21
+ # but WITHOUT ANY WARRANTY; #
22
+ # without even the implied warranty of MERCHANTABILITY #
23
+ # or FITNESS FOR A PARTICULAR PURPOSE. #
24
+ # See the GNU Lesser General Public License for more details. #
25
+ # #
26
+ # You should have received a copy of the GNU Lesser General Public License #
27
+ # along with this program. If not, see <http://www.gnu.org/licenses/>. #
28
+ ################################################################################
29
+ #++
30
+
31
+ if RakeTasks::Gem.gemspec_file?
32
+ ############################################################################
33
+ namespace :gem do
34
+ ############################################################################
35
+
36
+ gem_spec = RakeTasks::Gem.gem_spec
37
+ gem_spec_file = RakeTasks::Gem.gem_spec_file
38
+
39
+ file gem_spec.file_name =>
40
+ [gem_spec_file, *Dir['lib/**/*.rb'], 'Gemfile', 'Gemfile.lock'] do |t|
41
+ puts `gem build #{gem_spec_file}`
42
+ end
43
+
44
+ desc "Build #{gem_spec.name} gem version #{gem_spec.version}."
45
+ task :build => gem_spec.file_name
46
+
47
+ desc "Install the #{gem_spec.name} gem."
48
+ task :install => [gem_spec.file_name] do |t|
49
+ puts `gem install #{gem_spec.file_name} --no-rdoc --no-ri`
50
+ end
51
+
52
+ desc "Removes files associated with building " +
53
+ "and installing #{gem_spec.name}."
54
+ task :clobber do |t|
55
+ rm_f gem_spec.file_name
56
+ end
57
+
58
+ desc "Removes the gem file, builds, and installs."
59
+ task :generate => ['gem:clobber', gem_spec.file_name, 'gem:install']
60
+
61
+ desc "Show/Set the version number."
62
+ task :version, [:number] do |t, args|
63
+ if args[:number].nil?
64
+ puts RakeTasks::Gem.version(gem_spec)
65
+ else
66
+ RakeTasks::Gem.version! args[:number], gem_spec
67
+ gem_spec = RakeTasks::Gem.gem_spec
68
+ puts RakeTasks::Gem.version(gem_spec)
69
+ end
70
+ end
71
+
72
+ ############################################################################
73
+ end # :gem
74
+ ############################################################################
75
+
76
+ task :clobber => 'gem:clobber'
77
+ end
@@ -28,6 +28,8 @@
28
28
  ################################################################################
29
29
  #++
30
30
 
31
+ require 'rdoc/task'
32
+
31
33
  ################################################################################
32
34
  namespace :rdoc do
33
35
  ################################################################################
@@ -55,8 +57,8 @@ namespace :rdoc do
55
57
  rdtask.title = ''
56
58
  rdtask.rdoc_dir = File.join(base_path, rdoc_task.to_s)
57
59
  rdtask.options << '--charset' << 'utf8'
58
- rdtask.rdoc_files.include 'README', rdoc_files[rdoc_task]
59
- rdtask.main = 'README'
60
+ rdtask.rdoc_files.include 'readme.md', rdoc_files[rdoc_task]
61
+ rdtask.main = 'readme.md'
60
62
  end
61
63
 
62
64
  Rake::Task[rdoc_task].comment =
@@ -64,9 +66,12 @@ namespace :rdoc do
64
66
  end
65
67
  end
66
68
 
67
- CLOBBER.include(base_path)
69
+ desc 'Remove all generated rdoc files'
70
+ task :clobber do |t|
71
+ rm_f 'rdoc'
72
+ end
68
73
  ################################################################################
69
74
  end # :rdoc
70
75
  ################################################################################
71
76
 
72
- task :default => ["rdoc:app"]
77
+ task :clobber => 'rdoc:clobber'
@@ -28,6 +28,8 @@
28
28
  ################################################################################
29
29
  #++
30
30
 
31
+ require 'rake/testtask'
32
+
31
33
  if RakeTasks::Tests.exist?
32
34
  ############################################################################
33
35
  namespace :test do
@@ -68,11 +70,13 @@ if RakeTasks::Tests.exist?
68
70
  task :full do |t|
69
71
  RakeTasks::Tests::run_ruby_tests
70
72
  end
73
+
74
+ desc 'Generates a shell script that will run specs against all rubies'
75
+ task :script do |t|
76
+ RakeTasks::Tests::rubies_shell_script
77
+ end
71
78
  end
72
79
  ############################################################################
73
80
  end # :test
74
81
  ############################################################################
75
-
76
- Rake::Task[:default].prerequisites.clear
77
- task :default => 'test:all'
78
82
  end
@@ -1,246 +1,314 @@
1
- # This file contains the class that assists in setting up test tasks.
2
-
3
- #--
4
- ################################################################################
5
- # Copyright (C) 2011 Travis Herrick #
6
- ################################################################################
7
- # #
8
- # \v^V,^!v\^/ #
9
- # ~% %~ #
10
- # { _ _ } #
11
- # ( * - ) #
12
- # | / | #
13
- # \ _, / #
14
- # \__.__/ #
15
- # #
16
- ################################################################################
17
- # This program is free software: you can redistribute it #
18
- # and/or modify it under the terms of the GNU Lesser General Public License #
19
- # as published by the Free Software Foundation, #
20
- # either version 3 of the License, or (at your option) any later version. #
21
- ################################################################################
22
- # This program is distributed in the hope that it will be useful, #
23
- # but WITHOUT ANY WARRANTY; #
24
- # without even the implied warranty of MERCHANTABILITY #
25
- # or FITNESS FOR A PARTICULAR PURPOSE. #
26
- # See the GNU Lesser General Public License for more details. #
27
- # #
28
- # You should have received a copy of the GNU Lesser General Public License #
29
- # along with this program. If not, see <http://www.gnu.org/licenses/>. #
30
- ################################################################################
31
- #++
32
-
33
- # The main module for this gem.
34
- module RakeTasks
35
- # This class assists in setting up test tasks.
36
- class Tests
37
- class << self
38
- # Indicates that tests exist.
39
- def exist?
40
- return !root.nil? && !file_list.empty?
41
- end
42
-
43
- # Returns an array of test files for the specified group.
44
- def file_list(group = :all)
45
- group = group.to_sym unless group.is_a?(Symbol)
46
-
47
- list = []
48
-
49
- paths(group).each do |path|
50
- patterns.each do |pattern|
51
- files = Dir[File.join(path, pattern)]
52
- list << files unless files.empty?
53
- end
54
- end
55
-
56
- return list.flatten
57
- end
58
-
59
- # Convert a path to a file into an appropriate task name.
60
- # This is done by removing the pattern that is used to indicate
61
- # it is a test file.
62
- def task_name(file_path)
63
- file = File.basename(file_path, '.rb')
64
-
65
- patterns.each do |pattern|
66
- pattern = pattern.sub(/\.rb$/, '').sub(/\*/, '.+?')
67
-
68
- if file =~ /#{pattern}/
69
- pattern = pattern.sub(/\.\+\?/, '')
70
-
71
- if pattern.index('_') == 0
72
- return file.sub(/#{pattern}$/, '')
73
- else
74
- return file.sub(/^#{pattern}/, '')
75
- end
76
- end
77
-
78
- end
79
- end
80
-
81
- # Return an array containing the types of tests that are included.
82
- def types
83
- types = []
84
-
85
- Dir[File.join(root, '**')].each do |path|
86
- next if !File.directory?(path)
87
-
88
- patterns.each do |pattern|
89
- next if types.include?(File.basename(path))
90
- types << File.basename(path) unless Dir[File.join(path, pattern)].empty?
91
- end
92
- end
93
-
94
- return types
95
- end
96
-
97
- # Indicates whether tests can be run against multiple rubies.
98
- def run_rubies?
99
- File.file? rubies_yaml
100
- end
101
-
102
- # Runs tests against specified ruby/gemset/rake configurations.
103
- def run_ruby_tests
104
- parser = Parser.new
105
-
106
- configs = test_configs
107
-
108
- # Loop through the test configurations to initialize gemsets.
109
- gem_rubies = []
110
- configs.each do |config|
111
- next if gem_rubies.include?(config[:ruby])
112
- gem_rubies << config[:ruby]
113
-
114
- cmd = ['bash', RakeTasks::SCRIPTS[:gemsets]]
115
- cmd << config[:ruby].split('@')
116
-
117
- pid = Process.spawn(*cmd.flatten)
118
- Process.wait pid
119
- end
120
-
121
- # Loop through the test configurations.
122
- configs.each do |config|
123
- puts '*' * 80
124
-
125
- if config[:rake]
126
- puts "#{config[:ruby]} - #{config[:rake]}"
127
- end
128
-
129
- cmd = ['bash', RakeTasks::SCRIPTS[:rubies], 'test:all']
130
- cmd << config[:ruby]
131
- cmd << config[:rake] if config[:rake]
132
-
133
- # Run the tests.
134
- pid = Process.spawn(*cmd, :out => 'out.log', :err => 'err.log')
135
- Process.wait pid
136
-
137
- File.open('out.log', 'r') do |file|
138
- while line = file.gets
139
- parser.parse line
140
- end
141
- end
142
- end
143
-
144
- FileUtils.rm 'out.log'
145
- FileUtils.rm 'err.log'
146
-
147
- puts '*' * 80
148
- parser.summarize
149
- end
150
-
151
- # Returns a hash containing all testable rubies/gemsets.
152
- # ==== Output
153
- # [Hash] The configurations that will be tested.
154
- def test_configs
155
- configs = Psych.load(rubies_list)
156
- return unless configs
157
-
158
- # Loop through the configurations to set keys to symbols
159
- # and add gemsets to rubies.
160
- for i in 0..configs.length - 1 do
161
- config = configs[i]
162
-
163
- # Change keys to symbols (and remove the string-based pairs).
164
- ['ruby', 'gemset', 'rake'].each do |key|
165
- if config[key]
166
- config[key.to_sym] = config[key]
167
- config.delete(key)
168
- end
169
- end
170
-
171
- # Add the '@' symbol to include gemsets.
172
- config[:gemset] = '@' + config[:gemset] if config[:gemset]
173
- config[:ruby] = config[:ruby].to_s + config[:gemset].to_s
174
- config.delete(:gemset)
175
- end
176
-
177
- return configs.reject { |x| x[:ruby] and x[:ruby].strip.empty? }
178
- end
179
-
180
- ####################################################################
181
- private
182
- ####################################################################
183
-
184
- # Paths to check for test files.
185
- # Only paths for a specified type will be returned, if specified.
186
- def paths(group = :all)
187
- paths = []
188
-
189
- paths << [root] if group == :all
190
-
191
- types.each do |type|
192
- if group == type.to_sym || group == :all
193
- paths << File.join(root, type)
194
- end
195
- end
196
-
197
- return paths
198
- end
199
-
200
- # The patterns that indicate that a file contains tests.
201
- def patterns
202
- [
203
- '*_test.rb',
204
- 'test_*.rb',
205
- ]
206
- end
207
-
208
- # The root test folder.
209
- def root
210
- roots.each do |r|
211
- unless Dir[r].empty?
212
- return r
213
- end
214
- end
215
- return
216
- end
217
-
218
- # Returns an array of potential root folder names.
219
- def roots
220
- [
221
- 'test',
222
- 'tests'
223
- ]
224
- end
225
-
226
- # Returns the contents of the rubies.yml file.
227
- # ==== Output
228
- # [String] The contents of the rubies yaml file.
229
- def rubies_list
230
- file = File.join(rubies_yaml)
231
-
232
- # Read the yaml file.
233
- # Psych must be available on the system,
234
- # preferably via installing ruby with libyaml already installed.
235
- File.open(file, 'r') do |f|
236
- return f.read
237
- end
238
- end
239
-
240
- # Returns the location of the rubies yaml file.
241
- def rubies_yaml
242
- File.join('.', root, 'rubies.yml')
243
- end
244
- end
245
- end
246
- end
1
+ # This file contains the class that assists in setting up test tasks.
2
+
3
+ #--
4
+ ################################################################################
5
+ # Copyright (C) 2011 Travis Herrick #
6
+ ################################################################################
7
+ # #
8
+ # \v^V,^!v\^/ #
9
+ # ~% %~ #
10
+ # { _ _ } #
11
+ # ( * - ) #
12
+ # | / | #
13
+ # \ _, / #
14
+ # \__.__/ #
15
+ # #
16
+ ################################################################################
17
+ # This program is free software: you can redistribute it #
18
+ # and/or modify it under the terms of the GNU Lesser General Public License #
19
+ # as published by the Free Software Foundation, #
20
+ # either version 3 of the License, or (at your option) any later version. #
21
+ ################################################################################
22
+ # This program is distributed in the hope that it will be useful, #
23
+ # but WITHOUT ANY WARRANTY; #
24
+ # without even the implied warranty of MERCHANTABILITY #
25
+ # or FITNESS FOR A PARTICULAR PURPOSE. #
26
+ # See the GNU Lesser General Public License for more details. #
27
+ # #
28
+ # You should have received a copy of the GNU Lesser General Public License #
29
+ # along with this program. If not, see <http://www.gnu.org/licenses/>. #
30
+ ################################################################################
31
+ #++
32
+
33
+ # The main module for this gem.
34
+ module RakeTasks
35
+ # This class assists in setting up test tasks.
36
+ class Tests
37
+ # Returns an array of potential root folder names.
38
+ ROOTS = [
39
+ 'test',
40
+ 'tests',
41
+ 'spec',
42
+ ]
43
+
44
+ # The patterns that indicate that a file contains tests.
45
+ PATTERNS = [
46
+ '*_test.rb',
47
+ 'test_*.rb',
48
+ ]
49
+
50
+ class << self
51
+ # Indicates that tests exist.
52
+ def exist?
53
+ !file_list.empty?
54
+ end
55
+
56
+ # Returns an array of test files for the specified group.
57
+ def file_list(group = :all)
58
+ list = []
59
+
60
+ PATTERNS.each do |pattern|
61
+ paths(group).each do |path|
62
+ files = Util.dir_glob(File.join(path, pattern))
63
+ list << files
64
+ end
65
+ end
66
+
67
+ return list.flatten
68
+ end
69
+
70
+ # Convert a path to a file into an appropriate task name.
71
+ # This is done by removing the pattern that is used to indicate
72
+ # it is a test file.
73
+ def task_name(file_path)
74
+ file = File.basename(file_path, '.rb')
75
+
76
+ PATTERNS.each do |pattern|
77
+ pattern = pattern.sub(/\.rb$/, '').sub(/\*/, '.+?')
78
+
79
+ if file =~ /#{pattern}/
80
+ pattern = pattern.sub(/\.\+\?/, '')
81
+ return file_task(file, pattern)
82
+
83
+ end
84
+ end
85
+ end
86
+
87
+ # Return an array containing the types of tests that are included.
88
+ def types
89
+ return [] unless root
90
+
91
+ types = []
92
+
93
+ Util.dir_glob(File.join(root, '**')).each do |path|
94
+ next unless Util.directory?(path)
95
+ types << get_types(path)
96
+ end
97
+
98
+ return types.flatten
99
+ end
100
+
101
+ def get_types(path)
102
+ types = []
103
+ PATTERNS.each do |pattern|
104
+ next if types.include?(File.basename(path))
105
+ unless Util.dir_glob(File.join(path, pattern)).empty?
106
+ types << File.basename(path)
107
+ end
108
+ end
109
+ types
110
+ end
111
+
112
+ # Indicates whether tests can be run against multiple rubies.
113
+ def run_rubies?
114
+ Util.file? rubies_yaml
115
+ end
116
+
117
+ # Runs tests against specified ruby/gemset/rake configurations.
118
+ def run_ruby_tests
119
+ parser = Parser.new
120
+
121
+ configs = test_configs
122
+
123
+ init_rubies configs
124
+
125
+ # Loop through the test configurations.
126
+ configs.each do |config|
127
+ puts '*' * 80
128
+
129
+ if config[:rake]
130
+ puts "#{config[:ruby]} - #{config[:rake]}"
131
+ end
132
+
133
+ cmd = ['bash', RakeTasks::SCRIPTS[:rubies], 'test:all']
134
+ cmd << config[:ruby]
135
+ cmd << config[:rake] if config[:rake]
136
+
137
+ # Run the tests.
138
+ pid = Process.spawn(*cmd, :out => 'out.log', :err => 'err.log')
139
+ Process.wait pid
140
+
141
+ parse_log parser
142
+ end
143
+
144
+ Util.rm 'out.log'
145
+ Util.rm 'err.log'
146
+
147
+ puts '*' * 80
148
+ parser.summarize
149
+ end
150
+
151
+ # Outputs commands to run all tests.
152
+ def rubies_shell_script
153
+ configs = test_configs
154
+
155
+ # Loop through the test configurations.
156
+ commands = setup_commands(configs)
157
+
158
+ run_commands(configs).each do |command|
159
+ commands << command
160
+ end
161
+
162
+ Util.write_file 'rubies.sh', commands.map { |c| c.join(' ') }
163
+ end
164
+
165
+ # Initialize gemsets for rubies.
166
+ def init_rubies(configs)
167
+ # Loop through the test configurations to initialize gemsets.
168
+ gem_rubies = []
169
+ configs.each do |config|
170
+ next if gem_rubies.include?(config[:ruby])
171
+ gem_rubies << config[:ruby]
172
+
173
+ cmd = ['bash', RakeTasks::SCRIPTS[:gemsets]]
174
+ cmd << config[:ruby].split('@')
175
+
176
+ pid = Process.spawn(*cmd.flatten)
177
+ Process.wait pid
178
+ end
179
+ end
180
+
181
+ # Returns an array of hashes containing all testable rubies/gemsets.
182
+ # ==== Output
183
+ # [Array] The configurations that will be tested.
184
+ def test_configs
185
+ configs = Util.load_yaml(rubies_yaml)
186
+ return [] unless configs.is_a?(Array)
187
+
188
+ configs.select! { |c| c['ruby'] || c['gemset'] }
189
+
190
+ set_configs configs
191
+
192
+ configs
193
+ end
194
+
195
+ # Paths to check for test files.
196
+ # Only paths for a specified type will be returned, if specified.
197
+ def paths(group = :all)
198
+ group = group.to_sym
199
+ paths = []
200
+
201
+ paths << root if group == :all && root
202
+
203
+ types.each do |type|
204
+ if group == type.to_sym || group == :all
205
+ paths << File.join(root, type)
206
+ end
207
+ end
208
+
209
+ return paths
210
+ end
211
+
212
+ # The root test folder.
213
+ def root
214
+ ROOTS.each do |r|
215
+ return r if Util.directory?(r)
216
+ end
217
+ return
218
+ end
219
+
220
+ # Returns the location of the rubies yaml file.
221
+ def rubies_yaml
222
+ return unless root
223
+ File.join '.', root, 'rubies.yml'
224
+ end
225
+
226
+ #########################################################################
227
+ private
228
+ #########################################################################
229
+
230
+ def file_task(file, pattern)
231
+ if pattern.index('_') == 0
232
+ return file.sub(/#{pattern}$/, '')
233
+ else
234
+ return file.sub(/^#{pattern}/, '')
235
+ end
236
+ end
237
+
238
+ def parse_log(parser)
239
+ Util.open_file('out.log', 'r') do |file|
240
+ while line = file.gets
241
+ parser.parse line
242
+ end
243
+ end
244
+ end
245
+
246
+ def set_configs(configs)
247
+ for i in 0..configs.length - 1 do
248
+ config = configs[i]
249
+
250
+ config.keys.each do |key|
251
+ config[key.to_sym] = config[key]
252
+ config.delete key
253
+ end
254
+
255
+ if config[:gemset]
256
+ config[:ruby] = "#{config[:ruby]}@#{config[:gemset]}"
257
+ end
258
+
259
+ config.delete(:gemset)
260
+ end
261
+ end
262
+
263
+ def setup_commands(configs)
264
+ cmds = gemset_create_commands(configs)
265
+ cmds << ['rvm', rvm_rubies(configs), 'do', 'gem', 'install',
266
+ 'bundler', '--no-rdoc', '--no-ri']
267
+ cmds << ['rvm', rvm_rubies(configs), 'do', 'bundle', 'install']
268
+ cmds << ['rvm', rvm_rubies(configs), 'do', 'bundle', 'clean', '--force']
269
+ configs.each do |config|
270
+ if config[:rake]
271
+ cmds << ['rvm', config[:ruby], 'do', 'gem', 'install',
272
+ 'rake', '-v', config[:rake], '--no-rdoc', '--no-ri']
273
+ end
274
+ end
275
+ cmds
276
+ end
277
+
278
+ def run_commands(configs)
279
+ cmds = []
280
+ if configs.any? { |c| c[:rake] }
281
+ configs.each do |config|
282
+ if config[:rake]
283
+ cmds << ['echo',
284
+ "ruby: #{config[:ruby]} / rake: #{config[:rake]}"]
285
+ cmds << ['rvm', config[:ruby], 'do', 'rake', "_#{config[:rake]}_"]
286
+ else
287
+ cmds << ['rvm', config[:ruby], 'do', 'bundle', 'exec', 'rake']
288
+ end
289
+ end
290
+ else
291
+ cmds << ['rvm', rvm_rubies(configs), 'do', 'bundle', 'exec', 'rake']
292
+ end
293
+ cmds
294
+ end
295
+
296
+ def gemset_create_commands(configs)
297
+ cmds = []
298
+ cmds << ['set', '-e']
299
+ configs.uniq { |c| c[:ruby] }.each do |config|
300
+ ruby = config[:ruby].sub(/@.*/, '')
301
+ gemset = config[:ruby].sub(/.*@/, '')
302
+ cmds << ['rvm', ruby, 'do', 'rvm', 'gemset', 'create', gemset]
303
+ end
304
+ cmds
305
+ end
306
+
307
+ def rvm_rubies(configs)
308
+ configs.uniq { |c| c[:ruby] }.map do |config|
309
+ config[:ruby]
310
+ end.join(',')
311
+ end
312
+ end
313
+ end
314
+ end