recursive_rake_tasks 0.1.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,6 @@
1
+ === 0.1.0 / 2009-04-23
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
@@ -0,0 +1,11 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ rakefile
5
+ lib/recursive_rake_tasks.rb
6
+ spec/recursive_spec.rb
7
+ sandbox/spec/dummy_spec.rb
8
+ sandbox/spec/foo/dummy_spec.rb
9
+ sandbox/spec/foo/nested/dummy_spec.rb
10
+ sandbox/spec/bar/dummy_spec.rb
11
+ sandbox/rakefile
@@ -0,0 +1,73 @@
1
+ = recursive_rake_tasks
2
+
3
+ * more info at rraketasks.rubyforge.org
4
+
5
+
6
+ == DESCRIPTION:
7
+
8
+ Recursive Rake Tasks meant for generating rake tasks for all directories which contains *_spec files
9
+ Under given directory.
10
+
11
+ == FEATURES/PROBLEMS:
12
+
13
+ Generate rake tasks for all directories which contains *_spec files
14
+ under given directory
15
+
16
+ == SYNOPSIS:
17
+
18
+ If the given directory structure like the following for this gem
19
+ sandbox
20
+ spec
21
+ bar
22
+ dummy_bar_spec.rb
23
+ foo
24
+ dummy_foo_spec.rb
25
+ nested
26
+ dummy_nested_spec.rb
27
+ dummy_spec.rb
28
+
29
+ If will create the following rake spec tasks
30
+
31
+ rake spec
32
+ rake spec:bar
33
+ rake spec:bar:dummy_bar
34
+ rake spec:dummy
35
+ rake spec:foo
36
+ rake spec:foo:dummy_foo
37
+ rake spec:foo:nested
38
+ rake spec:foo:nested:dummy_nested
39
+
40
+
41
+ == REQUIREMENTS:
42
+
43
+ * taglob
44
+
45
+ == INSTALL:
46
+
47
+ * sudo gem install recursive_rake_tasks
48
+ * gem install recursive_rake_tasks
49
+
50
+ == LICENSE:
51
+
52
+ (The MIT License)
53
+
54
+ Copyright (c) 2009 Venkat
55
+
56
+ Permission is hereby granted, free of charge, to any person obtaining
57
+ a copy of this software and associated documentation files (the
58
+ 'Software'), to deal in the Software without restriction, including
59
+ without limitation the rights to use, copy, modify, merge, publish,
60
+ distribute, sublicense, and/or sell copies of the Software, and to
61
+ permit persons to whom the Software is furnished to do so, subject to
62
+ the following conditions:
63
+
64
+ The above copyright notice and this permission notice shall be
65
+ included in all copies or substantial portions of the Software.
66
+
67
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
68
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
69
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
70
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
71
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
72
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
73
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,45 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'spec/rake/spectask'
4
+ require 'taglob'
5
+
6
+ #Recursive Rake Tasks meant for generating rake tasks for all directories
7
+ #which contains *_spec files under given directory.
8
+ class RecursiveRakeTasks
9
+
10
+ VERSION = '0.1.0'
11
+
12
+ def initialize dir='spec'
13
+ recursive_spec_task dir
14
+ end
15
+ #Recursively creates rake spec tasks for the given dir and sub dir underneath it.
16
+ def recursive_spec_task dir
17
+ current_context = File.basename(dir)
18
+ sub_directories = Dir["#{dir}/*/"]
19
+ spec_files = Dir["#{dir}/*_spec.rb"]
20
+
21
+ create_spec_task(current_context,"#{dir}/**/*_spec.rb")
22
+
23
+ namespace current_context do
24
+ sub_directories.each do |sub_dir|
25
+ recursive_spec_task sub_dir if has_spec_files? sub_dir
26
+ end
27
+ spec_files.each do |spec_file|
28
+ create_spec_task(File.basename(spec_file,'_spec.rb'),spec_file)
29
+ end
30
+ end
31
+ end
32
+
33
+ #Creates Spec::Rake::SpecTask.new with taglog support
34
+ def create_spec_task name, files
35
+ Spec::Rake::SpecTask.new(name) do |t|
36
+ t.spec_files = Dir.taglob(files,ENV['TAGS'])
37
+ end
38
+ end
39
+
40
+ #Checks wheather the given dir contains any spec files or not.
41
+ def has_spec_files? dir
42
+ not Dir.glob("#{dir}/**/*_spec.rb").empty?
43
+ end
44
+
45
+ end
@@ -0,0 +1,12 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/recursive_rake_tasks.rb'
6
+
7
+ Hoe.new('recursive_rake_tasks', RecursiveRakeTasks::VERSION) do |p|
8
+ p.rubyforge_name = 'recursive_rake_tasks' # if different than lowercase project name
9
+ p.developer('Venkat', 'avrao5@yahoo.com')
10
+ end
11
+
12
+ # vim: syntax=Ruby
@@ -0,0 +1,3 @@
1
+ require '../lib/recursive_rake_tasks'
2
+
3
+ RecursiveRakeTasks.new
@@ -0,0 +1,7 @@
1
+ describe "Dummy" do
2
+
3
+ it "should pass" do
4
+ true.should be_true
5
+ end
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ describe "Dummy" do
2
+
3
+ it "should pass" do
4
+ true.should be_true
5
+ end
6
+
7
+ end
@@ -0,0 +1,8 @@
1
+ #tags: foo
2
+ describe "Dummy" do
3
+
4
+ it "should pass" do
5
+ true.should be_true
6
+ end
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ #tags: nested
2
+ describe "Dummy" do
3
+
4
+ it "should pass" do
5
+ true.should be_true
6
+ end
7
+
8
+ end
@@ -0,0 +1,69 @@
1
+ require 'lib/recursive_spec_task'
2
+
3
+ describe RecursiveSpecTask do
4
+
5
+ before do
6
+ @top_level_folder = 'sandbox/spec'
7
+ @root_task = File.basename(@top_level_folder)
8
+ Rake.application = Rake::Application.new
9
+ load 'lib/recursive_spec_task.rb'
10
+ RecursiveSpecTask.new @top_level_folder
11
+ @tasks = Rake.application.tasks.collect{|task| task.name }
12
+ @shell_command_separator = PLATFORM =~ /win/ ? '&' : ';'
13
+ end
14
+
15
+ it 'should generate top level folder task' do
16
+ @tasks.should include(@root_task)
17
+ end
18
+
19
+ it 'should generate task for sub folder' do
20
+ @tasks.should include("#{@root_task}:foo")
21
+ @tasks.should include("#{@root_task}:bar")
22
+ end
23
+
24
+ it "should generate a task for an individual spec file" do
25
+ @tasks.should include("#{@root_task}:foo:nested:dummy")
26
+ end
27
+
28
+ it "should not regenerate a namespaced top level folder task" do
29
+ @tasks.should_not include("#{@root_task}:#{@root_task}")
30
+ end
31
+
32
+ it "should generate nested folder tasks with the correct namespace" do
33
+ @tasks.should_not include("#{@root_task}:nested")
34
+ @tasks.should include("#{@root_task}:foo:nested")
35
+ end
36
+
37
+ it "should generate a spec task of top level folder" do
38
+ Rake.application.tasks.first.actions.first.to_s.should match(/spec\/rake\/spectask.rb/)
39
+ end
40
+
41
+ it "should run all the specs" do
42
+ all_examples = `cd sandbox#{@shell_command_separator}rake spec`
43
+ all_examples.should include('4 examples, 0 failures')
44
+ end
45
+
46
+ it "should run a subfolder's specs" do
47
+ bar_examples = `cd sandbox#{@shell_command_separator}rake spec:bar`
48
+ bar_examples.should include('1 example, 0 failures')
49
+
50
+ foo_examples = `cd sandbox#{@shell_command_separator}rake spec:foo`
51
+ foo_examples.should include('2 examples, 0 failures')
52
+ end
53
+
54
+ it "should run a nested subfolder's specs" do
55
+ foo_nested_examples = `cd sandbox#{@shell_command_separator}rake spec:foo:nested`
56
+ foo_nested_examples.should include('1 example, 0 failures')
57
+ end
58
+
59
+ it "should run a single file's examples" do
60
+ single_file_examples = `cd sandbox#{@shell_command_separator}rake spec:foo:nested:dummy`
61
+ single_file_examples.should include('1 example, 0 failures')
62
+ end
63
+
64
+ it "should get tags support for the rake tasks" do
65
+ foo_tag_examples = `cd sandbox#{@shell_command_separator}rake spec TAGS=foo`
66
+ foo_tag_examples.should include('1 example, 0 failures')
67
+ end
68
+
69
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: recursive_rake_tasks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Venkat
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-04-24 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.11.0
24
+ version:
25
+ description: Recursive Rake Tasks meant for generating rake tasks for all directories which contains *_spec files Under given directory.
26
+ email:
27
+ - avrao5@yahoo.com
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files:
33
+ - History.txt
34
+ - Manifest.txt
35
+ - README.txt
36
+ files:
37
+ - History.txt
38
+ - Manifest.txt
39
+ - README.txt
40
+ - rakefile
41
+ - lib/recursive_rake_tasks.rb
42
+ - spec/recursive_spec.rb
43
+ - sandbox/spec/dummy_spec.rb
44
+ - sandbox/spec/foo/dummy_spec.rb
45
+ - sandbox/spec/foo/nested/dummy_spec.rb
46
+ - sandbox/spec/bar/dummy_spec.rb
47
+ - sandbox/rakefile
48
+ has_rdoc: true
49
+ homepage: more info at rraketasks.rubyforge.org
50
+ post_install_message:
51
+ rdoc_options:
52
+ - --main
53
+ - README.txt
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ version:
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ requirements: []
69
+
70
+ rubyforge_project: recursive_rake_tasks
71
+ rubygems_version: 1.2.0
72
+ signing_key:
73
+ specification_version: 2
74
+ summary: Recursive Rake Tasks meant for generating rake tasks for all directories which contains *_spec files Under given directory.
75
+ test_files: []
76
+