DepGraph 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,48 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+ require 'rubygems'
3
+ require 'spec'
4
+ require 'dependable_filter_manager'
5
+ include DepGraph
6
+
7
+ describe DependableFilterManager do
8
+
9
+ it "should return the available filter types" do
10
+ dependency_types_in_file = YAML.load_file(DependableFilterManager.dependency_types_file).map do |filter_type_in_file, _|
11
+ filter_type_in_file
12
+ end
13
+
14
+ dependency_types_in_file.should == dependency_types.map {|filter_type| filter_type.to_s}
15
+ end
16
+
17
+ it "should use default values if the specified filter type is not found" do
18
+ dependable_filter_manager = DependableFilterManager.new non_existent_filter_type
19
+
20
+ dependable_filter_manager.dependable_regexp.should == /.+/
21
+ dependable_filter_manager.dependable_regexp_capture_group_index.should == 0
22
+ dependable_filter_manager.file_name_pattern.should == '*'
23
+ end
24
+
25
+
26
+ sample_contents = {
27
+ :ruby_requires => {:content => ['require "something/dependency"',
28
+ " require 'something/dependency.rb'"],
29
+ :file_pattern => '*.rb'},
30
+
31
+ :csproj => {:content => ['sdff "directory\\dependency.csproj"hyhyhy',
32
+ 'asdfffd"directory\\anotherdir\\dependency.dll" gfgfgg'],
33
+ :file_pattern => '*.csproj'}
34
+ }
35
+
36
+ dependency_types.each do |filter_type|
37
+ it "should have a #{filter_type} filter type" do
38
+ dependable_filter_manager = DependableFilterManager.new filter_type
39
+
40
+ capture_index = dependable_filter_manager.dependable_regexp_capture_group_index
41
+ sample_contents[filter_type][:content].each do |sample_dependency|
42
+ dependable_filter_manager.dependable_regexp.match(sample_dependency).captures[capture_index].should == 'dependency'
43
+ end
44
+ dependable_filter_manager.file_name_pattern.should == sample_contents[filter_type][:file_pattern]
45
+ end
46
+ end
47
+ end
48
+
@@ -0,0 +1,102 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+ require 'stringio'
3
+ require 'dependent'
4
+ require 'rubygems'
5
+ require 'spec'
6
+ include DepGraph
7
+
8
+ describe Dependent do
9
+ it 'should not accept empty uris in the constructor' do
10
+ lambda{Dependent.new('')}.should raise_error
11
+ end
12
+
13
+ it 'should have a non empty name' do
14
+ dependent = Dependent.new('a')
15
+ dependent.name.should_not be_empty
16
+ end
17
+
18
+ it 'should have the name of the file specified in the constructor excluding the extension' do
19
+ dependent = Dependent.new('/directory1/directory2/file.name.ext')
20
+ dependent.name.should == 'file.name'
21
+ end
22
+
23
+ it 'should be equal to another dependent with the same name' do
24
+ dependent1 = Dependent.new('abc')
25
+ dependent2 = Dependent.new('abc')
26
+ dependent3 = Dependent.new('abd')
27
+
28
+ dependent1.should == dependent2
29
+ dependent1.should be_eql(dependent2)
30
+
31
+ dependent1.should_not == dependent3
32
+ dependent1.should_not be_eql(dependent3)
33
+
34
+ dependent2.should_not == dependent3
35
+ dependent2.should_not be_eql(dependent3)
36
+ end
37
+
38
+ it 'should allow setting dependent dependents' do
39
+ dependent = Dependent.new('a')
40
+ dependent.depends_on('b')
41
+
42
+ dependent.dependencies.size.should == 1
43
+ end
44
+
45
+ it 'should allow querying for a dependent dependent' do
46
+ dependent = Dependent.new('a')
47
+ dependent.depends_on('b')
48
+
49
+ dependent.depends_on?('b').should be_true
50
+ dependent.depends_on?('c').should be_false
51
+ end
52
+
53
+ it 'should be able to get the dependencies to csproj and dll files from a string' do
54
+ dependent = Dependent.new('a', :csproj)
55
+ dependencies_string = 'from this string the dependable to "\\a.dir\\dependent1.csproj", \n"\\tgg.hyhy\\dependent2.dll" and "dependent3.csproj" should be found'
56
+
57
+ dependent.load_dependencies_from_string(dependencies_string)
58
+
59
+ dependent.dependencies.should == ["dependent1", "dependent2", "dependent3"]
60
+ end
61
+
62
+ it 'should be able to use a custom regexp filter to get the dependent dependencies from a string' do
63
+ dependent = Dependent.new('a')
64
+ dependencies_string = 'from this string the dependable to dependent.csproj \n and dependent1.dll should be found'
65
+ dependent.dependable_filter = /\s([^\s]+)\.(csproj|dll)[^\w]/
66
+ dependent.dependable_filter_capture_group_index = 0
67
+
68
+ dependent.load_dependencies_from_string(dependencies_string)
69
+
70
+ dependent.dependencies.should == ["dependent", "dependent1"]
71
+ end
72
+
73
+ it 'should be able to select the capture group that must be used in the dependable custom regexp filter' do
74
+ dependent = Dependent.new('a')
75
+ dependencies_string = 'from this string the dependable to prefix.dependent.csproj \n and prefix.dependent1.dll should be found'
76
+ dependent.dependable_filter = /\s(prefix\.)([^\s]+)\.(csproj|dll)[^\w]/
77
+ dependent.dependable_filter_capture_group_index = 1
78
+
79
+ dependent.load_dependencies_from_string(dependencies_string)
80
+
81
+ dependent.dependencies.should == ["dependent", "dependent1"]
82
+ end
83
+
84
+ it 'should ignore repeated dependencies in the string' do
85
+ dependent = Dependent.new('a', :csproj)
86
+ dependencies_string = 'this string has only one dependable that is repeated 3 times: "\\a.dir\\dependent.csproj", \n"\\tgg.hyhy\\dependent.dll" and "dependent.csproj"'
87
+
88
+ dependent.load_dependencies_from_string(dependencies_string)
89
+
90
+ dependent.dependencies.should == ["dependent"]
91
+ end
92
+
93
+ it 'should ignore the capture group index if the dependable filter regexp has no capture groups' do
94
+ dependent = Dependent.new('a')
95
+ dependent.dependable_filter = /dep[0-9]/
96
+ dependent.dependable_filter_capture_group_index = 1
97
+
98
+ dependent.load_dependencies_from_string('dep1 is in the first line \n in the second dep2')
99
+
100
+ dependent.dependencies.size.should == 2
101
+ end
102
+ end
@@ -0,0 +1,64 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+ require 'rubygems'
3
+ gem 'filetesthelper'
4
+ require 'filetesthelper'
5
+
6
+ include FileTestHelper
7
+
8
+ default_graph_file = 'dependency_graph.png'
9
+ tool_name = 'depgraph'
10
+ tool_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', tool_name))
11
+
12
+ describe "#{tool_name} (integration tests)" do
13
+
14
+ test_data = {
15
+ :csproj => {'proj1.csproj' => '"proj2.csproj"', 'proj2.csproj' => '"proj1.csproj"'},
16
+ :ruby_requires => {'rubyfile1.rb' => 'require "rubyfile2"', 'rubyfile2.rb' => 'require "rubyfile3"'},
17
+ }
18
+
19
+ dependency_types.each do |filter_type|
20
+ it "should create a file from the #{filter_type} files found in the current directory" do
21
+ test_files = test_data[filter_type]
22
+ with_files(test_files) do
23
+ system "ruby #{tool_path} -type #{filter_type}"
24
+
25
+ non_empty_file_created(default_graph_file).should be_true
26
+ end
27
+ end
28
+ end
29
+
30
+ two_files_with_one_dependency_from_file1_to_file2 = {'file1.csproj' => '"file2.csproj"', 'file2.csproj' => ''}
31
+ it 'should not create a file when the "-from" filter does not find matches' do
32
+ with_files(two_files_with_one_dependency_from_file1_to_file2) do
33
+ system "ruby #{tool_path} -type csproj -from file2"
34
+
35
+ File.exist?(default_graph_file).should be_false
36
+ end
37
+ end
38
+
39
+ it 'should create a file when the "-from" filter finds matches' do
40
+ with_files(two_files_with_one_dependency_from_file1_to_file2) do
41
+ system "ruby #{tool_path} -type csproj -from file1"
42
+
43
+ File.exist?(default_graph_file).should be_true
44
+ end
45
+ end
46
+
47
+ it 'should not create a file when the "-to" filter does not find matches' do
48
+ with_files(two_files_with_one_dependency_from_file1_to_file2) do
49
+ system "ruby #{tool_path} -type csproj -to file1"
50
+
51
+ File.exist?(default_graph_file).should be_false
52
+ end
53
+ end
54
+
55
+ it 'should create a file when the "-to" filter finds matches' do
56
+ with_files(two_files_with_one_dependency_from_file1_to_file2) do
57
+ system "ruby #{tool_path} -type csproj -to file2"
58
+
59
+ File.exist?(default_graph_file).should be_true
60
+ end
61
+ end
62
+ end
63
+
64
+
@@ -0,0 +1,48 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+ require 'file_system_dependent_finder'
3
+ require 'rubygems'
4
+ gem 'filetesthelper'
5
+ require 'filetesthelper'
6
+ require 'spec'
7
+
8
+ include FileTestHelper
9
+ include DepGraph
10
+
11
+ describe FileSystemDependentFinder, '(integration tests)' do
12
+ it 'should search only in the specified directories' do
13
+ with_files('good1/file1' => '', 'good2/file2' => '', 'bad/file3' => '') do
14
+ dependent_finder = FileSystemDependentFinder.new(non_existent_filter_type)
15
+ dependent_finder.dirs = ['good1', 'good2']
16
+
17
+ dependents = dependent_finder.get_dependents
18
+ dependents.should == ['file1', 'file2']
19
+ end
20
+ end
21
+ end
22
+
23
+ #To setup the test files for each filter type, include three sample dependent files
24
+ #and make the first file, named 'a' depend on the next two, named 'b' and 'c'
25
+ test_set = {
26
+ :ruby_requires => {'a.rb' => 'require "b"\nrequire "c"', 'dir/b.rb' => '', 'dir/c.rb' => '', 'not_a_ruby_file' => ''},
27
+ :csproj => {'a.csproj' => '"b.csproj"\n"c.csproj"', 'dir/b.csproj' => '', 'dir/c.csproj' => '', 'not_a_csproj_file' => ''}
28
+ }
29
+
30
+ dependency_types.each do |filter_type|
31
+ test_files = test_set[filter_type]
32
+
33
+ describe FileSystemDependentFinder, "for #{filter_type.to_s} (integration tests)" do
34
+ it "should find the correct number of dependents" do
35
+ with_files(test_files) do
36
+ dependents = FileSystemDependentFinder.new(filter_type).get_dependents
37
+ dependents.should == ['a', 'b', 'c']
38
+ end
39
+ end
40
+ it "should correctly find the dependencies from each file" do
41
+ with_files(test_files) do
42
+ dependent = FileSystemDependentFinder.new(filter_type).get_dependents[0]
43
+ dependent.should_not be_nil
44
+ dependent.dependencies.should == ['b', 'c']
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,103 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+ require 'graph_creator'
3
+ require 'rubygems'
4
+ gem 'filetesthelper'
5
+ require 'spec'
6
+ require 'filetesthelper'
7
+ include DepGraph
8
+ include FileTestHelper
9
+
10
+ describe GraphCreator do
11
+ it 'should not create a file if the graph is empty' do
12
+ create_graph_creator_with_no_dependents.create_image.should be_false
13
+ end
14
+
15
+ it 'should return a nil graph if an empty set of dependents is specified' do
16
+ create_graph_creator_with_no_dependents.create_graph.should == nil
17
+ end
18
+
19
+ it 'should return a nil graph if only one dependent is specified' do
20
+ create_graph_creator_with_only_one_dependent.create_graph.should == nil
21
+ end
22
+
23
+ it 'should return a nil graph if all dependents specified are equal' do
24
+ create_graph_creator_with_three_dependents_that_are_equal.create_graph.should == nil
25
+ end
26
+
27
+ it 'should return a graph with 2 nodes and no edges if 2 dependents with no dependencies are specified' do
28
+ graph = create_graph_creator_with_two_dependents_and_no_dependencies.create_graph
29
+
30
+ graph.node_count.should == 2
31
+ graph.edge_count.should == 0
32
+ end
33
+
34
+ it 'should ignore dependencies to non existent dependents' do
35
+ graph = create_graph_creator_with_two_nodes_and_one_orphan_dependency.create_graph
36
+
37
+ graph.node_count.should == 2
38
+ graph.edge_count.should == 0
39
+ end
40
+
41
+ it 'should return a graph with one edge if two dependents with one dependable are specified' do
42
+ graph = create_graph_creator_with_two_nodes_and_one_dependency.create_graph
43
+
44
+ graph.node_count.should == 2
45
+ graph.edge_count.should == 1
46
+ end
47
+
48
+ it 'should be possible to filter dependents with a regular expression' do
49
+ graph_creator = create_dependency_chain_graph_creator('node1', 'node2', 'node3', 'node4')
50
+ graph_creator.from = 'e2$'
51
+ graph = graph_creator.create_graph
52
+
53
+ graph.node_count.should == 2
54
+ graph.edge_count.should == 1
55
+ graph.has_node?('node2').should be_true
56
+ graph.has_node?('node3').should be_true
57
+ graph.has_edge?('node2', 'node3').should be_true
58
+ end
59
+
60
+ it 'should be possible to filter dependables with a regular expression' do
61
+ graph_creator = create_dependency_chain_graph_creator('node1', 'node2', 'node3', 'node4')
62
+ graph_creator.to = 'e4$'
63
+ graph = graph_creator.create_graph
64
+
65
+ graph.node_count.should == 2
66
+ graph.edge_count.should == 1
67
+ graph.has_node?('node3').should be_true
68
+ graph.has_node?('node4').should be_true
69
+ graph.has_edge?('node3', 'node4').should be_true
70
+ end
71
+
72
+
73
+ invalid_graph_creators.each do |invalid_graph_creator_description, invalid_graph_creator|
74
+ it "should return false when trying to create an image from a #{invalid_graph_creator_description}" do
75
+ invalid_graph_creator.graph_class = NoOutputGraph
76
+ invalid_graph_creator.create_image('graph.png').should be_false
77
+ end
78
+ end
79
+ end
80
+
81
+ test_data = {
82
+ :csproj => {'file1.csproj'=>'"file2.csproj"', 'dir/file2.csproj'=>'"file1.csproj"' },
83
+ :ruby_requires => {'file1.rb'=>'require "file2"', 'dir/file2.rb'=>'require "file1"' }
84
+ }
85
+
86
+ describe GraphCreator, '(integration tests)' do
87
+ dependency_types.each do |filter_type|
88
+ it "should create a png image from the #{filter_type} dependencies found in the current directory tree" do
89
+ with_files(test_data[filter_type]) do
90
+ GraphCreator.new(filter_type).create_image('test.png')
91
+
92
+ non_empty_file_created('test.png').should be_true
93
+ end
94
+ end
95
+ end
96
+ end
97
+
98
+
99
+
100
+
101
+
102
+
103
+
@@ -0,0 +1,120 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+ require 'graph'
3
+ require 'rubygems'
4
+ gem 'filetesthelper'
5
+ require 'spec'
6
+ require 'filetesthelper'
7
+ include FileTestHelper
8
+ include DepGraph
9
+
10
+ def create_empty_graph
11
+ Graph.new
12
+ end
13
+
14
+ def create_graph_with_2_nodes_and_1_edge
15
+ graph = create_empty_graph
16
+ graph.add_node('node 1')
17
+ graph.add_node('node 2')
18
+ graph.add_edge('node 1', 'node 2')
19
+ return graph
20
+ end
21
+
22
+ def create_graph_with_2_nodes_and_0_edges
23
+ graph = create_empty_graph
24
+ graph.add_node('node 1')
25
+ graph.add_node('node 2')
26
+ return graph
27
+ end
28
+
29
+ def no_output_generation
30
+ lambda {true}
31
+ end
32
+
33
+ describe Graph do
34
+
35
+ it "should start with no nodes" do
36
+ create_empty_graph.node_count.should == 0
37
+ end
38
+
39
+ it "should be possible to add nodes" do
40
+ graph = create_graph_with_2_nodes_and_0_edges
41
+
42
+ graph.node_count.should == 2
43
+ graph.edge_count.should == 0
44
+ end
45
+
46
+ it "should not be allowed to add a node without a name" do
47
+ lambda {create_empty_graph.add_node('')}.should raise_error
48
+ end
49
+
50
+ it "should start with no edges" do
51
+ create_empty_graph.edge_count.should == 0
52
+ end
53
+
54
+ it "should be possible to add an edge" do
55
+ graph = create_graph_with_2_nodes_and_1_edge
56
+
57
+ graph.node_count.should == 2
58
+ graph.edge_count.should == 1
59
+ end
60
+
61
+ it "can be reset" do
62
+ graph = create_graph_with_2_nodes_and_1_edge
63
+
64
+ graph.reset
65
+ graph.node_count.should == 0
66
+ graph.edge_count.should == 0
67
+ end
68
+
69
+ it "should not be allowed to add edges between non existent nodes" do
70
+ lambda {create_empty_graph.add_edge('no node 1', 'no node 2')}.should raise_error
71
+ end
72
+
73
+ it "should return true when a new image file is created" do
74
+ graph = create_graph_with_2_nodes_and_1_edge
75
+ graph.output_generation = no_output_generation
76
+ graph.create_image('graph.png').should be_true
77
+ end
78
+
79
+ it "should return false when trying to create an empty graph" do
80
+ graph = create_empty_graph
81
+ graph.output_generation = no_output_generation
82
+ graph.create_image('graph.png').should be_false
83
+ end
84
+ end
85
+
86
+ describe Graph, '(integration tests)' do
87
+ it "should create a file with the graph image" do
88
+ with_files do
89
+ graph = create_graph_with_2_nodes_and_1_edge
90
+ graph.create_image('graph.png')
91
+
92
+ non_empty_file_created('graph.png').should be_true
93
+ end
94
+ end
95
+
96
+ it "should not create an image file from an empty graph" do
97
+ with_files do
98
+ create_empty_graph.create_image('graph.png')
99
+ non_empty_file_created('graph.png').should be_false
100
+ end
101
+ end
102
+
103
+ it "should not create an image file from a graph with no edges" do
104
+ with_files do
105
+ create_graph_with_2_nodes_and_0_edges.create_image('graph.png')
106
+
107
+ non_empty_file_created('graph.png').should be_false
108
+ end
109
+ end
110
+
111
+ it 'can change output generation behaviour'do
112
+ graph = create_graph_with_2_nodes_and_1_edge
113
+ graph.output_generation = no_output_generation
114
+ with_files do
115
+ graph.create_image('test.png')
116
+ File.exist?('test.png').should be_false
117
+ end
118
+ end
119
+ end
120
+
data/spec/spec.opts ADDED
@@ -0,0 +1,7 @@
1
+ --format
2
+ specdoc
3
+ --format
4
+ html:specs.html
5
+ --timeout
6
+ 20
7
+ --diff
@@ -0,0 +1,123 @@
1
+ require 'enumerator'
2
+ begin
3
+ require 'spec'
4
+ rescue LoadError
5
+ require 'rubygems'
6
+ gem 'rspec'
7
+ require 'spec'
8
+ end
9
+
10
+ dir = File.expand_path(File.dirname(__FILE__))
11
+ $LOAD_PATH.unshift("#{dir}/")
12
+ $LOAD_PATH.unshift("#{dir}/../lib")
13
+
14
+ require 'dependable_filter_manager'
15
+ require 'graph'
16
+ def dependency_types
17
+ DepGraph::DependableFilterManager.types
18
+ end
19
+
20
+ def non_empty_file_created(file_name)
21
+ File.exist?(file_name) and File.size(file_name) > 0
22
+ end
23
+
24
+ def non_existent_filter_type
25
+ DependableFilterManager.types.join + 'thisdoesntexist'
26
+ end
27
+
28
+ ########## Stubs ###########
29
+ class MockDependentFinder
30
+ def initialize(dependents)
31
+ @dependents = dependents
32
+ end
33
+
34
+ def get_dependents
35
+ @dependents
36
+ end
37
+ end
38
+
39
+ class NoOutputGraph < DepGraph::Graph
40
+ def initialize
41
+ super
42
+ output_generation = lambda { true }
43
+ end
44
+ end
45
+
46
+
47
+ ########## graph creator tests helper methods ###########
48
+ def create_graph_creator_with_no_dependents
49
+ graph_creator = GraphCreator.new
50
+ graph_creator.dependent_finder = MockDependentFinder.new([])
51
+
52
+ return graph_creator
53
+ end
54
+
55
+ def create_graph_creator_with_only_one_dependent
56
+ graph_creator = GraphCreator.new
57
+ graph_creator.dependent_finder = MockDependentFinder.new([Dependent.new('dependent/path')])
58
+
59
+ return graph_creator
60
+ end
61
+
62
+ def create_graph_creator_with_three_dependents_that_are_equal
63
+ dependent1 = Dependent.new('directory/path')
64
+ dependent2 = Dependent.new('directory/path')
65
+ dependent3 = Dependent.new('directory/anotherdir/path')
66
+
67
+ graph_creator = GraphCreator.new
68
+ graph_creator.dependent_finder = MockDependentFinder.new([dependent1, dependent2, dependent3])
69
+
70
+ return graph_creator
71
+ end
72
+
73
+ def create_graph_creator_with_two_dependents_and_no_dependencies
74
+ dependent1 = Dependent.new('dependent1/path1')
75
+ dependent2 = Dependent.new('dependent2/path2')
76
+
77
+ graph_creator = GraphCreator.new
78
+ graph_creator.dependent_finder = MockDependentFinder.new([dependent1, dependent2])
79
+
80
+ return graph_creator
81
+ end
82
+
83
+ def create_dependency_chain_graph_creator(*nodes)
84
+ dependents = []
85
+
86
+ nodes.each do |node|
87
+ dependents << Dependent.new(node)
88
+ end
89
+
90
+ dependents.each_cons(2) do |dependent, dependable|
91
+ dependent.depends_on(dependable)
92
+ end
93
+
94
+ graph_creator = GraphCreator.new(:none)
95
+ graph_creator.dependent_finder = MockDependentFinder.new(dependents)
96
+
97
+ return graph_creator
98
+ end
99
+
100
+ def create_graph_creator_with_two_nodes_and_one_dependency
101
+ return create_dependency_chain_graph_creator('dependent1/path1.csproj', 'dependent2/path2.dll')
102
+ end
103
+
104
+ def create_graph_creator_with_two_nodes_and_one_orphan_dependency
105
+ dependent1 = Dependent.new('file1.csproj')
106
+ dependent2 = Dependent.new('file2.csproj')
107
+ dependent2.depends_on('file3')
108
+
109
+ graph_creator = GraphCreator.new(:none)
110
+ graph_creator.dependent_finder = MockDependentFinder.new([dependent1, dependent2])
111
+
112
+ return graph_creator
113
+ end
114
+
115
+ def invalid_graph_creators
116
+ {
117
+ 'graph creator with no dependents' => create_graph_creator_with_no_dependents,
118
+ 'graph creator with only one dependent' => create_graph_creator_with_only_one_dependent,
119
+ 'graph creator with three dependents that are equal' => create_graph_creator_with_three_dependents_that_are_equal,
120
+ 'graph creator with an orphan depencency' => create_graph_creator_with_two_nodes_and_one_orphan_dependency
121
+ }
122
+ end
123
+
@@ -0,0 +1,34 @@
1
+ desc 'Release the website and new gem version'
2
+ task :deploy => [:check_version, :website, :release] do
3
+ puts "Remember to create SVN tag:"
4
+ puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
5
+ "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
6
+ puts "Suggested comment:"
7
+ puts "Tagging release #{CHANGES}"
8
+ end
9
+
10
+ desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
11
+ task :local_deploy => [:spec, :website_generate, :install_gem]
12
+
13
+ task :check_version do
14
+ unless ENV['VERSION']
15
+ puts 'Must pass a VERSION=x.y.z release version'
16
+ exit
17
+ end
18
+ unless ENV['VERSION'] == VERS
19
+ puts "Please update your version.rb to match the release version, currently #{VERS}"
20
+ exit
21
+ end
22
+ end
23
+
24
+ desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
25
+ task :install_gem_no_doc => [:clean, :package] do
26
+ sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
27
+ end
28
+
29
+ namespace :manifest do
30
+ desc 'Recreate Manifest.txt to include ALL files'
31
+ task :refresh do
32
+ `rake check_manifest | patch -p0 > Manifest.txt`
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ task :ruby_env do
2
+ RUBY_APP = if RUBY_PLATFORM =~ /java/
3
+ "jruby"
4
+ else
5
+ "ruby"
6
+ end unless defined? RUBY_APP
7
+ end
data/tasks/rspec.rake ADDED
@@ -0,0 +1,23 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ require 'spec'
6
+ end
7
+ begin
8
+ require 'spec/rake/spectask'
9
+ rescue LoadError
10
+ puts <<-EOS
11
+ To use rspec for testing you must install rspec gem:
12
+ gem install rspec
13
+ EOS
14
+ exit(0)
15
+ end
16
+
17
+ desc "Run the specs under spec/models"
18
+ Spec::Rake::SpecTask.new do |t|
19
+ t.spec_opts = ['--options', "spec/spec.opts"]
20
+ t.spec_files = FileList['spec/*_spec.rb']
21
+ t.rcov = true
22
+ t.rcov_opts = ['--text-summary']
23
+ end