rake_tasks 2.0.6 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
metadata.gz.sig ADDED
Binary file
data/README.md DELETED
@@ -1,106 +0,0 @@
1
- Welcome to RakeTasks
2
- ====================
3
-
4
- RakeTasks provides basic rake tasks for generating documentation,
5
- building and installing gems, and running tests.
6
- It will also load additional rake tasks if they are in a folder named 'tasks'.
7
- mmmm yummy
8
-
9
- The following assumptions are currently made:
10
-
11
- * There is a valid .gemspec file in the root folder that is named the same
12
- as the root folder.
13
-
14
- * Tests reside in a folder named either 'test' or 'tests'
15
- and test files are named *_test.rb or test_*.rb.
16
-
17
- Additionally, if you have sub-folders under test(s)
18
- (i.e. test/unit, test/performance), they will be available
19
- using rake test:unit and rake test:performance.
20
- Sub-folders that do not contain files matching the test file name patterns
21
- will not be included in this set.
22
-
23
- You may run a single test from any test file by using the following:
24
-
25
- rake test:test_file[test_method]
26
-
27
- test_file is the name of the test file without the pattern,
28
- so if you have a test named my_class_test.rb with a test method
29
- named my_test_method, it would be invoked by:
30
-
31
- rake test:my_class[my_test_method]
32
-
33
- * Additional rake tasks are named *.rb and reside in a folder named 'tasks'.
34
-
35
- * README generation useo the gemspec data to populate the license information.
36
-
37
- If README.md does not exist, one will be created.
38
- If README.md does exist, a README_GENERATED.md file will be created,
39
- so as not to overwrite a 'real' README.md file.
40
-
41
- The default task will be set in the following order:
42
-
43
- 1. If tests are found, rake will run test:all.
44
-
45
- 2. If tests are not found, but an appropriately named .gemspec file is,
46
- gem:build will be run.
47
-
48
- 3. If no tests or .gemspec are found, rdoc:app will be run.
49
-
50
- Getting Started
51
- ---------------
52
-
53
- Install RakeTasks at the command prompt if you haven't yet:
54
-
55
- $ gem install rake_tasks
56
-
57
- Require the gem in your Gemfile:
58
-
59
- gem 'rake_tasks', '~> 2.0.6'
60
-
61
- Require the gem wherever you need to use it:
62
-
63
- require 'rake_tasks'
64
-
65
- Updates
66
- -------
67
-
68
- 2.0.6 Use markdown for generated README.
69
- Convert rake_task's README to markdown and rename it to README.md.
70
-
71
- The gemspec is now located by extension rather than root folder.
72
-
73
- 2.0.5 Specify load order of rake tasks.
74
-
75
- 2.0.4 Added license files to the included files in the gemspec.
76
- Excluded Gemfile.lock from included fileo in the gemspec.
77
-
78
- 2.0.3 Added bundle_install.sh to the included files in the gemspec.
79
-
80
- 2.0.2 test:[test_file] will now run all the tests in the specified file
81
- if a method is not specified. It should be noted that 'test_file' is
82
- the name of the file with the test pattern removed
83
- (i.e. 'my_module_test.rb' => 'my_module',
84
- 'test_my_module.rb' => 'my_module').
85
-
86
- 2.0.1 Added test:full task (requires rvm).
87
-
88
- test:full allows a user to run tests against multiple ruby/gemset/rake
89
- configurations by specifying them in a yaml file in the test folder.
90
-
91
- A common rubies.yml file might look something like this:
92
-
93
- - ruby: 1.9.2
94
- gemset: my_gem_test
95
- - ruby: 1.9.3
96
- gemset: my_gem_test
97
-
98
- Additional Documentation
99
- ------------------------
100
-
101
- rake rdoc:app
102
-
103
- License
104
- -------
105
-
106
- RakeTasks is released under the LGPLv3 license.
@@ -1,17 +0,0 @@
1
- #!/bin/bash
2
-
3
- if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
4
- source "$HOME/.rvm/scripts/rvm"
5
- elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
6
- source "/usr/local/rvm/scripts/rvm"
7
- else
8
- printf "ERROR: An RVM installation was not found.\n"
9
- fi
10
-
11
- rvm use $1
12
- rvm gemset create $2
13
- rvm use $1@$2
14
-
15
- gem install bundler --no-rdoc --no-ri
16
- bundle install
17
- bundle clean --force
@@ -1,95 +0,0 @@
1
- # This file holds the class that handles gem 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 gem utilities.
36
- class Gem
37
- class << self
38
- # Check whether a gem spec file exists for this project.
39
- def gem_file?
40
- return !gem_spec_file.nil?
41
- end
42
-
43
- # Returns the gem title.
44
- # This is the gem name with underscores removed.
45
- # Wherever an underscore is removed, the next letter is capitalized.
46
- def gem_title(spec = gem_spec)
47
- return nil unless spec.respond_to?(:name)
48
- spec.name.split('_').map { |w| w.capitalize }.join('')
49
- end
50
-
51
- # Get the gem specification.
52
- def gem_spec
53
- ::Gem::Specification.load(gem_spec_file) if gem_file?
54
- end
55
-
56
- # Check for a gem spec file.
57
- def gem_spec_file
58
- file_name = Dir['*.gemspec'].first
59
- return file_name
60
- end
61
-
62
- # Returns the name and version from the specified gem specification.
63
- def version(spec = gem_spec)
64
- if spec.respond_to?(:name) && spec.respond_to?(:version)
65
- "#{spec.name} version #{spec.version}"
66
- end
67
- end
68
-
69
- # Updates the version in the gem specification file.
70
- def version!(value, spec = gem_spec)
71
- return unless gem_spec_file
72
-
73
- temp = StringIO.new
74
-
75
- File.open(gem_spec_file, 'r') do |file|
76
- while line = file.gets
77
- if line =~ /version *= *['"]#{spec.version}['"]/
78
- temp.puts line.sub(/['"].*['"]/, "'#{value}'")
79
- else
80
- temp.puts line
81
- end
82
- end
83
- end
84
-
85
- temp.rewind
86
-
87
- File.open(gem_spec_file, 'w') do |file|
88
- while line = temp.gets
89
- file.puts line
90
- end
91
- end
92
- end
93
- end
94
- end
95
- end
@@ -1,18 +0,0 @@
1
- #!/bin/bash
2
-
3
- if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
4
- source "$HOME/.rvm/scripts/rvm"
5
- elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
6
- source "/usr/local/rvm/scripts/rvm"
7
- else
8
- printf "ERROR: An RVM installation was not found.\n"
9
- fi
10
-
11
- rvm use $2
12
-
13
- if [ $# -ge 3 ]; then
14
- gem install rake -v $3 --no-rdoc --no-ri
15
- rake _$3_ $1
16
- else
17
- bundle exec rake $1
18
- fi
@@ -1,284 +0,0 @@
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
- require_relative '../require'
32
-
33
- class TestsUnitTest < Test::Unit::TestCase
34
- include RakeTasks::RakeTasksShared
35
-
36
- def setup
37
- super
38
- FakeFS.activate!
39
- FileUtils.mkdir_p root
40
- Dir.chdir root
41
- @module = RakeTasks
42
- @class = @module::Tests
43
- end
44
-
45
- def teardown
46
- FakeFS::FileSystem.clear
47
- FakeFS.deactivate!
48
- super
49
- end
50
-
51
- def test_file_name_to_task_name
52
- assert_equal 'something', @class.task_name('test/unit/something_test.rb')
53
- assert_equal 'something', @class.task_name('test/unit/test_something.rb')
54
- end
55
-
56
- def test_tests_exist
57
- paths.each do |path|
58
- files.each do |file|
59
- clear_test_files
60
-
61
- assert !@class.exist?, "#{path} folder should not contain anything."
62
- FileUtils.mkdir_p File.join(path, 'something')
63
- assert !@class.exist?,
64
- "#{path} folder should not contain any matching files."
65
-
66
- FileUtils.touch File.join(path, file.gsub(/\*/, 'abc'))
67
- assert @class.exist?, "#{path} should contain one matching file."
68
- end
69
- end
70
- end
71
-
72
- def test_file_list_and_types
73
- file_list = [
74
- { :path => 'alphabet', :file => 'abc' },
75
- { :path => 'alphabet', :file => 'def' },
76
- { :path => 'number' , :file => 'add' },
77
- ]
78
-
79
- paths.each do |path|
80
- files.each do |file|
81
- clear_test_files
82
- list = file_list.map do |f|
83
- file_path = file.gsub(/\*/, f[:file])
84
- file_path = File.join(path, f[:path], file_path)
85
-
86
- FileUtils.mkdir_p File.dirname(file_path)
87
- FileUtils.touch file_path
88
- File.join root, file_path
89
- end
90
-
91
- FileUtils.mkdir_p File.join(root, path, 'color')
92
- FileUtils.touch File.join(root, path, 'color', 'red.txt')
93
-
94
- assert_equal list, @class.file_list
95
- assert_equal file_list.map { |f| f[:path] }.uniq, @class.types
96
- end
97
- end
98
- end
99
-
100
- def test_rubies_check
101
- paths.each do |path|
102
- clear_test_files
103
- FileUtils.mkdir_p path
104
- assert !@class.run_rubies?,
105
- 'The user should not be able to run tests agaisnt multiple Rubies.'
106
- FileUtils.touch File.join(path, rubies_yaml_file)
107
- assert @class.run_rubies?,
108
- 'The user should be able to run tests agaisnt multiple Rubies.'
109
- end
110
- end
111
-
112
- def test_config_data
113
- paths.each do |path|
114
- clear_test_files
115
-
116
- FileUtils.mkdir_p path
117
-
118
- configs.keys.each do |config|
119
- File.open("./#{path}/rubies.yml", 'w') do |file|
120
- file.write configs[config][:in]
121
- end
122
-
123
- assert_equal configs[config][:out], @class.test_configs,
124
- "rubies.yml in #{path} did not result in expected outcome"
125
- end
126
- end
127
- end
128
-
129
- def test_run_rubies
130
- path = paths[0]
131
- FileUtils.mkdir_p path
132
-
133
- configs.each do |k, v|
134
- next unless v[:out].is_a?(Array)
135
-
136
- File.open("./#{path}/rubies.yml", 'w') do |file|
137
- file.write v[:in]
138
- end
139
-
140
- matches = []
141
- gem_rubies = []
142
- v[:out].each_with_index do |config, i|
143
- if config[:ruby] and !config[:ruby].strip.empty?
144
- unless gem_rubies.include?(config[:ruby])
145
- gem_rubies << config[:ruby]
146
- gems = ['bash', @module::SCRIPTS[:gemsets]]
147
-
148
- Process.expects(:spawn).with(*gems, *config[:ruby].split('@'))
149
- .returns(101 + i).once
150
- Process.expects(:wait).with(101 + i).once
151
- end
152
-
153
- rubies = ['bash', @module::SCRIPTS[:rubies], 'test:all']
154
- rubies << config[:ruby]
155
- rubies << config[:rake] if config[:rake]
156
-
157
- Process.expects(:spawn).with(*rubies,
158
- :out => 'out.log', :err => 'err.log').
159
- returns(71 + i).once
160
- Process.expects(:wait).with(71 + i).once
161
-
162
- matches << "#{config[:ruby]} - #{config[:rake]}\n*" if config[:rake]
163
- end
164
- end
165
-
166
- FileUtils.touch 'out.log'
167
- FileUtils.touch 'err.log'
168
-
169
- reset_io
170
- wrap_output { @class.run_ruby_tests }
171
-
172
- assert !File.file?('out.log'), 'Log file (out.log) should be deleted.'
173
- assert !File.file?('err.log'), 'Log file (err.log) should be deleted.'
174
-
175
- matches.each do |match|
176
- assert_match match, out
177
- end
178
-
179
- assert_no_match Regexp.new(" - \n"), out
180
- end
181
- end
182
-
183
- ############################################################################
184
- private
185
- ############################################################################
186
-
187
- def clear_test_files
188
- paths.each do |path|
189
- FileUtils.rm_rf(path) if File.directory?(path)
190
- end
191
- end
192
-
193
- def configs
194
- yaml = {
195
- :basic => {
196
- :out => [
197
- {:ruby => '1.9.2@my_gemset', :rake => '0.8.7'},
198
- {:ruby => '1.9.3@my_gems' , :rake => '0.9.2'},
199
- ], # :out
200
- }, # :basic
201
- :no_rake => {
202
- :out => [
203
- {:ruby => '1.9.2@my_gemset'},
204
- {:ruby => '1.9.3@my_gems' },
205
- ], # :out
206
- }, # :no_rake
207
- :ruby_only => {
208
- :out => [
209
- {:ruby => '1.9.2'},
210
- {:ruby => '1.9.3'},
211
- ], # :out
212
- }, # :ruby_only
213
- :gemset_only => {
214
- :out => [
215
- {:ruby => '@the_gem'},
216
- {:ruby => '@a_gem'},
217
- ], # :out
218
- }, # :gemset_only
219
- :multi_rake => {
220
- :out => [
221
- {:ruby => '1.9.3@multi_rake', :rake => '0.8.7'},
222
- {:ruby => '1.9.3@multi_rake', :rake => '0.9.2'},
223
- ], # :multi_rake
224
- }, # :basic
225
- :nothing => {
226
- :in => '',
227
- :out => nil,
228
- }, # :nothing
229
- :nonsense => {
230
- :out => [],
231
- }, # :nonsense
232
- }
233
-
234
- yaml[:basic][:in] = <<-BASIC
235
- - ruby: 1.9.2
236
- gemset: my_gemset
237
- rake: 0.8.7
238
- - ruby: 1.9.3
239
- gemset: my_gems
240
- rake: 0.9.2
241
- BASIC
242
-
243
- yaml[:no_rake][:in] = <<-NO_RAKE
244
- - ruby: 1.9.2
245
- gemset: my_gemset
246
- - ruby: 1.9.3
247
- gemset: my_gems
248
- NO_RAKE
249
-
250
- yaml[:ruby_only][:in] = <<-RUBY_ONLY
251
- - ruby: 1.9.2
252
- - ruby: 1.9.3
253
- RUBY_ONLY
254
-
255
- yaml[:gemset_only][:in] = <<-GEMSET_ONLY
256
- - gemset: the_gem
257
- - gemset: a_gem
258
- GEMSET_ONLY
259
-
260
- yaml[:multi_rake][:in] = <<-MULTI_RAKE
261
- - ruby: 1.9.3
262
- gemset: multi_rake
263
- rake: 0.8.7
264
- - ruby: 1.9.3
265
- gemset: multi_rake
266
- rake: 0.9.2
267
- MULTI_RAKE
268
-
269
- yaml[:nonsense][:in] = <<-NONSENSE
270
- - key1: value1
271
- - key2: value2
272
- NONSENSE
273
-
274
- yaml.each_key do |k|
275
- yaml[k][:in] = yaml[k][:in].strip
276
- end
277
-
278
- yaml
279
- end
280
-
281
- def rubies_yaml_file
282
- 'rubies.yml'
283
- end
284
- end