DepGraph 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +18 -0
- data/Manifest.txt +16 -11
- data/bin/depgraph +26 -13
- data/config/hoe.rb +2 -2
- data/lib/DepGraph/version.rb +1 -1
- data/lib/{dependable_filter_manager.rb → dependency_types_manager.rb} +10 -10
- data/lib/file_system_node_finder.rb +60 -0
- data/lib/graph_creator.rb +83 -46
- data/lib/{graph.rb → graph_image_creator.rb} +48 -12
- data/lib/node.rb +44 -0
- data/lib/nodefinders/test_node_finder.rb +26 -0
- data/setup.rb +1585 -1585
- data/spec/{depgraph_spec.rb → IntegrationTests/depgraph_spec.rb} +28 -2
- data/spec/IntegrationTests/file_system_node_finder_spec.rb +57 -0
- data/spec/IntegrationTests/graph_creator_spec.rb +32 -0
- data/spec/IntegrationTests/graph_image_creator_spec.rb +53 -0
- data/spec/{dependable_filter_manager_spec.rb → UnitTests/dependency_types_manager_spec.rb} +6 -6
- data/spec/UnitTests/file_system_node_finder_spec.rb +64 -0
- data/spec/UnitTests/graph_creator_spec.rb +141 -0
- data/spec/UnitTests/graph_image_creator_spec.rb +58 -0
- data/spec/UnitTests/node_spec.rb +47 -0
- data/spec/integration_spec.opts +5 -0
- data/spec/spec_helper.rb +102 -40
- data/spec/unit_spec.opts +5 -0
- data/tasks/deployment.rake +1 -1
- data/tasks/rspec.rake +17 -5
- metadata +28 -21
- data/lib/dependent.rb +0 -73
- data/lib/file_system_dependent_finder.rb +0 -44
- data/spec/dependent_spec.rb +0 -102
- data/spec/file_system_dependent_finder_spec.rb +0 -48
- data/spec/graph_creator_spec.rb +0 -103
- data/spec/graph_spec.rb +0 -120
- data/todo.txt +0 -4
data/spec/spec_helper.rb
CHANGED
@@ -11,10 +11,10 @@ dir = File.expand_path(File.dirname(__FILE__))
|
|
11
11
|
$LOAD_PATH.unshift("#{dir}/")
|
12
12
|
$LOAD_PATH.unshift("#{dir}/../lib")
|
13
13
|
|
14
|
-
require '
|
15
|
-
require '
|
14
|
+
require 'dependency_types_manager'
|
15
|
+
require 'graph_image_creator'
|
16
16
|
def dependency_types
|
17
|
-
DepGraph::
|
17
|
+
DepGraph::DependencyTypesManager.types
|
18
18
|
end
|
19
19
|
|
20
20
|
def non_empty_file_created(file_name)
|
@@ -22,102 +22,164 @@ def non_empty_file_created(file_name)
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def non_existent_filter_type
|
25
|
-
|
25
|
+
DependencyTypesManager.types.join + 'thisdoesntexist'
|
26
26
|
end
|
27
27
|
|
28
28
|
########## Stubs ###########
|
29
|
-
class
|
30
|
-
def initialize(
|
31
|
-
@
|
29
|
+
class MockNodeFinder
|
30
|
+
def initialize(nodes)
|
31
|
+
@nodes = nodes
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
@
|
34
|
+
def get_nodes
|
35
|
+
@nodes
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
class NoOutputGraph < DepGraph::
|
39
|
+
class NoOutputGraph < DepGraph::GraphImageCreator
|
40
40
|
def initialize
|
41
41
|
super
|
42
42
|
output_generation = lambda { true }
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
########## graph helper methods
|
47
|
+
|
48
|
+
def create_empty_graph
|
49
|
+
GraphImageCreator.new
|
50
|
+
end
|
51
|
+
|
52
|
+
def create_graph_with_2_nodes_and_1_edge
|
53
|
+
graph = create_empty_graph
|
54
|
+
graph.add_node('node 1')
|
55
|
+
graph.add_node('node 2')
|
56
|
+
graph.add_edge('node 1', 'node 2')
|
57
|
+
return graph
|
58
|
+
end
|
59
|
+
|
60
|
+
def create_graph_with_2_nodes_and_0_edges
|
61
|
+
graph = create_empty_graph
|
62
|
+
graph.add_node('node 1')
|
63
|
+
graph.add_node('node 2')
|
64
|
+
return graph
|
65
|
+
end
|
66
|
+
|
67
|
+
def no_output_generation
|
68
|
+
lambda {true}
|
69
|
+
end
|
70
|
+
|
71
|
+
def dependency_exists?(graph, from, to)
|
72
|
+
graph.has_node?(from) and graph.has_node?(to) and graph.has_edge?(from, to)
|
73
|
+
end
|
74
|
+
|
46
75
|
|
47
76
|
########## graph creator tests helper methods ###########
|
48
|
-
def
|
77
|
+
def create_graph_creator_with_no_nodes
|
49
78
|
graph_creator = GraphCreator.new
|
50
|
-
graph_creator.
|
79
|
+
graph_creator.node_finder = MockNodeFinder.new([])
|
51
80
|
|
52
81
|
return graph_creator
|
53
82
|
end
|
54
83
|
|
55
|
-
def
|
84
|
+
def create_graph_creator_with_only_one_node
|
56
85
|
graph_creator = GraphCreator.new
|
57
|
-
graph_creator.
|
86
|
+
graph_creator.node_finder = MockNodeFinder.new([Node.new('node/path')])
|
58
87
|
|
59
88
|
return graph_creator
|
60
89
|
end
|
61
90
|
|
62
|
-
def
|
63
|
-
|
64
|
-
|
65
|
-
|
91
|
+
def create_2_connected_plus_2_disconnected_nodes_graph_creator
|
92
|
+
node1 = Node.new('directory/path1')
|
93
|
+
node2 = Node.new('directory/path2')
|
94
|
+
node3 = Node.new('directory/anotherdir/path3')
|
95
|
+
node4 = Node.new('directory2/path4')
|
96
|
+
node5 = Node.new('directory2/anotherdir/path5')
|
97
|
+
node1.depends_on(node2)
|
98
|
+
node3.depends_on(node5)
|
99
|
+
node4.depends_on(node5)
|
100
|
+
|
101
|
+
graph_creator = GraphCreator.new
|
102
|
+
graph_creator.node_finder = MockNodeFinder.new([node1, node2, node3, node4])
|
103
|
+
|
104
|
+
return graph_creator
|
105
|
+
end
|
106
|
+
|
107
|
+
def create_graph_creator_with_three_nodes_that_are_equal
|
108
|
+
node1 = Node.new('directory/path')
|
109
|
+
node2 = Node.new('directory/path')
|
110
|
+
node3 = Node.new('directory/anotherdir/path')
|
66
111
|
|
67
112
|
graph_creator = GraphCreator.new
|
68
|
-
graph_creator.
|
113
|
+
graph_creator.node_finder = MockNodeFinder.new([node1, node2, node3])
|
69
114
|
|
70
115
|
return graph_creator
|
71
116
|
end
|
72
117
|
|
73
|
-
def
|
74
|
-
|
75
|
-
|
118
|
+
def create_graph_creator_with_two_nodes_and_no_dependencies
|
119
|
+
node1 = Node.new('node1/path1')
|
120
|
+
node2 = Node.new('node2/path2')
|
76
121
|
|
77
122
|
graph_creator = GraphCreator.new
|
78
|
-
graph_creator.
|
123
|
+
graph_creator.node_finder = MockNodeFinder.new([node1, node2])
|
79
124
|
|
80
125
|
return graph_creator
|
81
126
|
end
|
82
127
|
|
83
|
-
def create_dependency_chain_graph_creator(*
|
84
|
-
|
128
|
+
def create_dependency_chain_graph_creator(*node_names)
|
129
|
+
nodes = []
|
85
130
|
|
86
|
-
|
87
|
-
|
131
|
+
node_names.each do |node|
|
132
|
+
nodes << Node.new(node)
|
88
133
|
end
|
89
134
|
|
90
|
-
|
91
|
-
|
135
|
+
nodes.each_cons(2) do |node, dependable|
|
136
|
+
node.depends_on(dependable)
|
92
137
|
end
|
93
138
|
|
94
139
|
graph_creator = GraphCreator.new(:none)
|
95
|
-
graph_creator.
|
140
|
+
graph_creator.node_finder = MockNodeFinder.new(nodes)
|
96
141
|
|
97
142
|
return graph_creator
|
98
143
|
end
|
99
144
|
|
100
145
|
def create_graph_creator_with_two_nodes_and_one_dependency
|
101
|
-
return create_dependency_chain_graph_creator('
|
146
|
+
return create_dependency_chain_graph_creator('node1/path1.csproj', 'node2/path2.dll')
|
147
|
+
end
|
148
|
+
|
149
|
+
def create_2_node_graph_creator_with_1_normal_and_1_orphan_dependency
|
150
|
+
node1 = Node.new('file1.csproj')
|
151
|
+
node2 = Node.new('file2.csproj')
|
152
|
+
node1.depends_on(node2)
|
153
|
+
node2.depends_on('non existent file3')
|
154
|
+
|
155
|
+
graph_creator = GraphCreator.new(:none)
|
156
|
+
graph_creator.node_finder = MockNodeFinder.new([node1, node2])
|
157
|
+
|
158
|
+
return graph_creator
|
102
159
|
end
|
103
160
|
|
104
|
-
def
|
105
|
-
|
106
|
-
|
107
|
-
|
161
|
+
def create_2_connected_and_1_disconnected_node_with_an_orphan_dependency_graph_creator
|
162
|
+
node1 = Node.new('file1.csproj')
|
163
|
+
node2 = Node.new('file2.csproj')
|
164
|
+
node3 = Node.new('file3.csproj')
|
165
|
+
node4 = Node.new('file4.csproj')
|
166
|
+
|
167
|
+
node1.depends_on(node2)
|
168
|
+
|
169
|
+
#create an orphan dependency of disconnected node file3 because node4 will not be included in the graph
|
170
|
+
node3.depends_on(node4)
|
108
171
|
|
109
172
|
graph_creator = GraphCreator.new(:none)
|
110
|
-
graph_creator.
|
173
|
+
graph_creator.node_finder = MockNodeFinder.new([node1, node2, node3])
|
111
174
|
|
112
175
|
return graph_creator
|
113
176
|
end
|
114
177
|
|
115
178
|
def invalid_graph_creators
|
116
179
|
{
|
117
|
-
'graph creator with no
|
118
|
-
'graph creator with only one
|
119
|
-
'graph creator with three
|
120
|
-
'graph creator with an orphan depencency' => create_graph_creator_with_two_nodes_and_one_orphan_dependency
|
180
|
+
'graph creator with no nodes' => create_graph_creator_with_no_nodes,
|
181
|
+
'graph creator with only one node' => create_graph_creator_with_only_one_node,
|
182
|
+
'graph creator with three nodes that are equal' => create_graph_creator_with_three_nodes_that_are_equal,
|
121
183
|
}
|
122
184
|
end
|
123
185
|
|
data/spec/unit_spec.opts
ADDED
data/tasks/deployment.rake
CHANGED
@@ -8,7 +8,7 @@ task :deploy => [:check_version, :website, :release] do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
11
|
-
task :local_deploy => [:
|
11
|
+
task :local_deploy => [:allspec, :website_generate, :install_gem]
|
12
12
|
|
13
13
|
task :check_version do
|
14
14
|
unless ENV['VERSION']
|
data/tasks/rspec.rake
CHANGED
@@ -14,10 +14,22 @@ EOS
|
|
14
14
|
exit(0)
|
15
15
|
end
|
16
16
|
|
17
|
-
desc "Run the specs under spec/
|
18
|
-
Spec::Rake::SpecTask.new do |t|
|
19
|
-
t.spec_opts = ['--options', "spec/
|
20
|
-
t.spec_files = FileList['spec/*_spec.rb']
|
17
|
+
desc "Run the specs under spec/unittests"
|
18
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/unit_spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/unittests/*_spec.rb']
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Run the specs under spec/integrationtests"
|
24
|
+
Spec::Rake::SpecTask.new('ispec') do |t|
|
25
|
+
t.spec_opts = ['--options', "spec/integration_spec.opts"]
|
26
|
+
t.spec_files = FileList['spec/integrationtests/*_spec.rb']
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Run the specs under spec"
|
30
|
+
Spec::Rake::SpecTask.new('allspec') do |t|
|
31
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
32
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
33
|
t.rcov = true
|
22
34
|
t.rcov_opts = ['--text-summary']
|
23
|
-
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: DepGraph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Daniel Cadenas Ni\xF3n"
|
@@ -9,13 +9,13 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-03-
|
12
|
+
date: 2008-03-16 00:00:00 -03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: A tool to create dependency graph images from source code directories
|
17
17
|
email:
|
18
|
-
-
|
18
|
+
- dcadenas@gmail.com
|
19
19
|
executables:
|
20
20
|
- depgraph
|
21
21
|
extensions: []
|
@@ -25,7 +25,6 @@ extra_rdoc_files:
|
|
25
25
|
- License.txt
|
26
26
|
- Manifest.txt
|
27
27
|
- README.txt
|
28
|
-
- todo.txt
|
29
28
|
files:
|
30
29
|
- History.txt
|
31
30
|
- License.txt
|
@@ -36,12 +35,13 @@ files:
|
|
36
35
|
- config/hoe.rb
|
37
36
|
- config/requirements.rb
|
38
37
|
- lib/DepGraph/version.rb
|
39
|
-
- lib/
|
38
|
+
- lib/dependency_types_manager.rb
|
40
39
|
- lib/dependency_types.yaml
|
41
|
-
- lib/
|
42
|
-
- lib/
|
43
|
-
- lib/
|
40
|
+
- lib/node.rb
|
41
|
+
- lib/file_system_node_finder.rb
|
42
|
+
- lib/graph_image_creator.rb
|
44
43
|
- lib/graph_creator.rb
|
44
|
+
- lib/nodefinders/test_node_finder.rb
|
45
45
|
- script/destroy
|
46
46
|
- script/destroy.cmd
|
47
47
|
- script/generate
|
@@ -49,19 +49,23 @@ files:
|
|
49
49
|
- script/txt2html
|
50
50
|
- script/txt2html.cmd
|
51
51
|
- setup.rb
|
52
|
-
- spec/
|
53
|
-
- spec/
|
54
|
-
- spec/
|
55
|
-
- spec/
|
56
|
-
- spec/
|
57
|
-
- spec/
|
52
|
+
- spec/IntegrationTests/depgraph_spec.rb
|
53
|
+
- spec/IntegrationTests/file_system_node_finder_spec.rb
|
54
|
+
- spec/IntegrationTests/graph_creator_spec.rb
|
55
|
+
- spec/IntegrationTests/graph_image_creator_spec.rb
|
56
|
+
- spec/UnitTests/dependency_types_manager_spec.rb
|
57
|
+
- spec/UnitTests/node_spec.rb
|
58
|
+
- spec/UnitTests/graph_creator_spec.rb
|
59
|
+
- spec/UnitTests/graph_image_creator_spec.rb
|
60
|
+
- spec/UnitTests/file_system_node_finder_spec.rb
|
61
|
+
- spec/integration_spec.opts
|
58
62
|
- spec/spec.opts
|
59
63
|
- spec/spec_helper.rb
|
64
|
+
- spec/unit_spec.opts
|
60
65
|
- tasks/deployment.rake
|
61
66
|
- tasks/environment.rake
|
62
67
|
- tasks/rspec.rake
|
63
68
|
- tasks/website.rake
|
64
|
-
- todo.txt
|
65
69
|
has_rdoc: true
|
66
70
|
homepage: http://DepGraph.rubyforge.org
|
67
71
|
post_install_message:
|
@@ -90,10 +94,13 @@ signing_key:
|
|
90
94
|
specification_version: 2
|
91
95
|
summary: A tool to create dependency graph images from source code directories
|
92
96
|
test_files:
|
93
|
-
- spec/
|
94
|
-
- spec/
|
95
|
-
- spec/
|
96
|
-
- spec/
|
97
|
-
- spec/graph_creator_spec.rb
|
98
|
-
- spec/graph_spec.rb
|
97
|
+
- spec/IntegrationTests/depgraph_spec.rb
|
98
|
+
- spec/IntegrationTests/file_system_node_finder_spec.rb
|
99
|
+
- spec/IntegrationTests/graph_creator_spec.rb
|
100
|
+
- spec/IntegrationTests/graph_image_creator_spec.rb
|
99
101
|
- spec/spec_helper.rb
|
102
|
+
- spec/UnitTests/dependency_types_manager_spec.rb
|
103
|
+
- spec/UnitTests/file_system_node_finder_spec.rb
|
104
|
+
- spec/UnitTests/graph_creator_spec.rb
|
105
|
+
- spec/UnitTests/graph_image_creator_spec.rb
|
106
|
+
- spec/UnitTests/node_spec.rb
|
data/lib/dependent.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
module DepGraph
|
2
|
-
|
3
|
-
#A Dependent knows its dependables and knows how to get them from a string
|
4
|
-
class Dependent
|
5
|
-
include Comparable
|
6
|
-
attr_reader :name
|
7
|
-
|
8
|
-
def initialize(dependent_uri, dependent_type = :anything)
|
9
|
-
fail 'Empty uris are not allowed' if dependent_uri.empty?
|
10
|
-
@name = remove_extension dependent_uri
|
11
|
-
@dependencies = []
|
12
|
-
|
13
|
-
load_filter_type(dependent_type)
|
14
|
-
end
|
15
|
-
|
16
|
-
def load_filter_type(dependent_type)
|
17
|
-
dependable_filter_manager = DependableFilterManager.new dependent_type
|
18
|
-
@dependable_filter = dependable_filter_manager.dependable_regexp
|
19
|
-
@dependable_filter_capture_group_index = dependable_filter_manager.dependable_regexp_capture_group_index
|
20
|
-
end
|
21
|
-
|
22
|
-
def to_str
|
23
|
-
@name
|
24
|
-
end
|
25
|
-
|
26
|
-
def <=> other_dependent
|
27
|
-
@name <=> other_dependent.to_str
|
28
|
-
end
|
29
|
-
|
30
|
-
def eql? other_dependent
|
31
|
-
(self <=> other_dependent) == 0
|
32
|
-
end
|
33
|
-
|
34
|
-
def hash
|
35
|
-
@name.hash
|
36
|
-
end
|
37
|
-
|
38
|
-
def remove_extension file_path
|
39
|
-
file_extension_regexp = /\.[^\.]+$/
|
40
|
-
return File.basename(file_path).gsub(file_extension_regexp, '')
|
41
|
-
end
|
42
|
-
|
43
|
-
def depends_on dependent
|
44
|
-
@dependencies << dependent
|
45
|
-
end
|
46
|
-
|
47
|
-
def depends_on? dependent
|
48
|
-
@dependencies.include? dependent
|
49
|
-
end
|
50
|
-
|
51
|
-
def dependencies
|
52
|
-
@dependencies
|
53
|
-
end
|
54
|
-
|
55
|
-
def dependable_filter= filter
|
56
|
-
@dependable_filter = filter
|
57
|
-
@dependable_filter_capture_group_index = 0
|
58
|
-
end
|
59
|
-
|
60
|
-
def dependable_filter_capture_group_index= group_index
|
61
|
-
@dependable_filter_capture_group_index = group_index
|
62
|
-
end
|
63
|
-
|
64
|
-
def load_dependencies_from_string(dependencies_string)
|
65
|
-
fail 'The dependable finder Regexp was not set' unless @dependable_filter
|
66
|
-
|
67
|
-
dependencies_string.scan(@dependable_filter).each do |matches|
|
68
|
-
dependable = (matches.respond_to? :to_ary) ? matches[@dependable_filter_capture_group_index] : matches
|
69
|
-
depends_on(dependable) unless depends_on? dependable
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'dependent'
|
2
|
-
require 'dependable_filter_manager'
|
3
|
-
|
4
|
-
module DepGraph
|
5
|
-
class FileSystemDependentFinder
|
6
|
-
attr_reader :dependent_filter, :dependable_filter, :dependable_filter_capture_group_index
|
7
|
-
attr_writer :dirs
|
8
|
-
|
9
|
-
def initialize(dependent_type)
|
10
|
-
|
11
|
-
dependable_filter_manager = DependableFilterManager.new dependent_type
|
12
|
-
@file_name_pattern = dependable_filter_manager.file_name_pattern
|
13
|
-
@dependable_filter = dependable_filter_manager.dependable_regexp
|
14
|
-
@dependable_filter_capture_group_index = dependable_filter_manager.dependable_regexp_capture_group_index
|
15
|
-
@dirs = ['.']
|
16
|
-
end
|
17
|
-
|
18
|
-
def get_dependents
|
19
|
-
files = []
|
20
|
-
@dirs.each do |dir|
|
21
|
-
files += Dir.glob(dir.strip + '/**/' + @file_name_pattern)
|
22
|
-
end
|
23
|
-
|
24
|
-
dependents = []
|
25
|
-
files.each { |file| dependents << create_dependent_from_file(file) }
|
26
|
-
return dependents
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
def create_dependent_from_file file
|
31
|
-
dependent = Dependent.new file
|
32
|
-
dependent.dependable_filter = @dependable_filter
|
33
|
-
dependent.dependable_filter_capture_group_index = @dependable_filter_capture_group_index
|
34
|
-
|
35
|
-
File.open(file) do |f|
|
36
|
-
f.each_line do |line|
|
37
|
-
dependent.load_dependencies_from_string(line)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
return dependent
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/spec/dependent_spec.rb
DELETED
@@ -1,102 +0,0 @@
|
|
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
|
@@ -1,48 +0,0 @@
|
|
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
|