depgraph 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/History.txt +28 -0
  2. data/License.txt +20 -0
  3. data/README.rdoc +40 -0
  4. data/Rakefile +31 -0
  5. data/VERSION +1 -0
  6. data/bin/depgraph +89 -0
  7. data/config/hoe.rb +71 -0
  8. data/config/requirements.rb +19 -0
  9. data/lib/DepGraph/version.rb +9 -0
  10. data/lib/dependency_types.yaml +11 -0
  11. data/lib/dependency_types_manager.rb +49 -0
  12. data/lib/file_system_node_finder.rb +64 -0
  13. data/lib/graph_creator.rb +122 -0
  14. data/lib/graph_image_creator.rb +125 -0
  15. data/lib/node.rb +44 -0
  16. data/lib/nodefinders/gems_node_finder.rb +58 -0
  17. data/lib/nodefinders/test_node_finder.rb +26 -0
  18. data/script/destroy +14 -0
  19. data/script/destroy.cmd +1 -0
  20. data/script/generate +14 -0
  21. data/script/generate.cmd +1 -0
  22. data/script/txt2html +74 -0
  23. data/script/txt2html.cmd +1 -0
  24. data/setup.rb +1585 -0
  25. data/spec/IntegrationTests/depgraph_spec.rb +90 -0
  26. data/spec/IntegrationTests/file_system_node_finder_spec.rb +54 -0
  27. data/spec/IntegrationTests/gems_node_finder_spec.rb +20 -0
  28. data/spec/IntegrationTests/graph_creator_spec.rb +30 -0
  29. data/spec/IntegrationTests/graph_image_creator_spec.rb +50 -0
  30. data/spec/UnitTests/dependency_types_manager_spec.rb +46 -0
  31. data/spec/UnitTests/file_system_node_finder_spec.rb +62 -0
  32. data/spec/UnitTests/graph_creator_spec.rb +140 -0
  33. data/spec/UnitTests/graph_image_creator_spec.rb +56 -0
  34. data/spec/UnitTests/node_spec.rb +45 -0
  35. data/spec/integration_spec.opts +4 -0
  36. data/spec/spec.opts +6 -0
  37. data/spec/spec_helper.rb +179 -0
  38. data/spec/unit_spec.opts +4 -0
  39. data/tasks/deployment.rake +34 -0
  40. data/tasks/environment.rake +7 -0
  41. data/tasks/rspec.rake +35 -0
  42. data/tasks/website.rake +17 -0
  43. data/todo.txt +4 -0
  44. metadata +128 -0
@@ -0,0 +1,56 @@
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+ require 'graph_image_creator'
3
+ include DepGraph
4
+
5
+ describe GraphImageCreator do
6
+
7
+ it "should start with no nodes" do
8
+ create_empty_graph.node_count.should == 0
9
+ end
10
+
11
+ it "should be possible to add nodes" do
12
+ graph = create_graph_with_2_nodes_and_0_edges
13
+
14
+ graph.node_count.should == 2
15
+ graph.edge_count.should == 0
16
+ end
17
+
18
+ it "should not be allowed to add a node without a name" do
19
+ lambda {create_empty_graph.add_node('')}.should raise_error
20
+ end
21
+
22
+ it "should start with no edges" do
23
+ create_empty_graph.edge_count.should == 0
24
+ end
25
+
26
+ it "should be possible to add an edge" do
27
+ graph = create_graph_with_2_nodes_and_1_edge
28
+
29
+ graph.node_count.should == 2
30
+ graph.edge_count.should == 1
31
+ end
32
+
33
+ it "can be reset" do
34
+ graph = create_graph_with_2_nodes_and_1_edge
35
+
36
+ graph.reset
37
+ graph.node_count.should == 0
38
+ graph.edge_count.should == 0
39
+ end
40
+
41
+ it "should not be allowed to add edges between non existent nodes" do
42
+ lambda {create_empty_graph.add_edge('no node 1', 'no node 2')}.should raise_error
43
+ end
44
+
45
+ it "should return true when a new image file is created" do
46
+ graph = create_graph_with_2_nodes_and_1_edge
47
+ graph.output_generation = no_output_generation
48
+ graph.create_image('graph.png').should be_true
49
+ end
50
+
51
+ it "should return false when trying to create an empty graph" do
52
+ graph = create_empty_graph
53
+ graph.output_generation = no_output_generation
54
+ graph.create_image('graph.png').should be_false
55
+ end
56
+ end
@@ -0,0 +1,45 @@
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+ require 'stringio'
3
+ require 'node'
4
+ include DepGraph
5
+
6
+ describe Node do
7
+ it 'should not accept empty uris in the constructor' do
8
+ lambda{Node.new('')}.should raise_error
9
+ end
10
+
11
+ it 'should have a non empty name' do
12
+ node = Node.new('a')
13
+ node.name.should_not be_empty
14
+ end
15
+
16
+ it 'should be equal to another node with the same name' do
17
+ node1 = Node.new('abc')
18
+ node2 = Node.new('abc')
19
+ node3 = Node.new('abd')
20
+
21
+ node1.should == node2
22
+ node1.should be_eql(node2)
23
+
24
+ node1.should_not == node3
25
+ node1.should_not be_eql(node3)
26
+
27
+ node2.should_not == node3
28
+ node2.should_not be_eql(node3)
29
+ end
30
+
31
+ it 'should allow setting node dependencies' do
32
+ node = Node.new('a')
33
+ node.depends_on('b')
34
+
35
+ node.dependencies.size.should == 1
36
+ end
37
+
38
+ it 'should allow querying for a node' do
39
+ node = Node.new('a')
40
+ node.depends_on('b')
41
+
42
+ node.depends_on?('b').should be_true
43
+ node.depends_on?('c').should be_false
44
+ end
45
+ end
@@ -0,0 +1,4 @@
1
+ --format
2
+ specdoc
3
+ --timeout
4
+ 20
@@ -0,0 +1,6 @@
1
+ --format
2
+ specdoc
3
+ --format
4
+ html:specs.html
5
+ --timeout
6
+ 20
@@ -0,0 +1,179 @@
1
+ require 'enumerator'
2
+ require 'file_test_helper'
3
+
4
+ dir = File.expand_path(File.dirname(__FILE__))
5
+ $LOAD_PATH.unshift("#{dir}/")
6
+ $LOAD_PATH.unshift("#{dir}/../lib")
7
+
8
+ require 'dependency_types_manager'
9
+ require 'graph_image_creator'
10
+ def dependency_types
11
+ DepGraph::DependencyTypesManager.types
12
+ end
13
+
14
+ def non_empty_file_created(file_name)
15
+ File.exist?(file_name) and File.size(file_name) > 0
16
+ end
17
+
18
+ def non_existent_filter_type
19
+ DependencyTypesManager.types.join + 'thisdoesntexist'
20
+ end
21
+
22
+ ########## Stubs ###########
23
+ class MockNodeFinder
24
+ def initialize(nodes)
25
+ @nodes = nodes
26
+ end
27
+
28
+ def get_nodes
29
+ @nodes
30
+ end
31
+ end
32
+
33
+ class NoOutputGraph < DepGraph::GraphImageCreator
34
+ def initialize
35
+ super
36
+ output_generation = lambda { true }
37
+ end
38
+ end
39
+
40
+ ########## graph helper methods
41
+
42
+ def create_empty_graph
43
+ GraphImageCreator.new
44
+ end
45
+
46
+ def create_graph_with_2_nodes_and_1_edge
47
+ graph = create_empty_graph
48
+ graph.add_node('node 1')
49
+ graph.add_node('node 2')
50
+ graph.add_edge('node 1', 'node 2')
51
+ return graph
52
+ end
53
+
54
+ def create_graph_with_2_nodes_and_0_edges
55
+ graph = create_empty_graph
56
+ graph.add_node('node 1')
57
+ graph.add_node('node 2')
58
+ return graph
59
+ end
60
+
61
+ def no_output_generation
62
+ lambda {|*args| true}
63
+ end
64
+
65
+ def dependency_exists?(graph, from, to)
66
+ graph.has_node?(from) and graph.has_node?(to) and graph.has_edge?(from, to)
67
+ end
68
+
69
+
70
+ ########## graph creator tests helper methods ###########
71
+ def create_graph_creator_with_no_nodes
72
+ graph_creator = GraphCreator.new
73
+ graph_creator.node_finder = MockNodeFinder.new([])
74
+
75
+ return graph_creator
76
+ end
77
+
78
+ def create_graph_creator_with_only_one_node
79
+ graph_creator = GraphCreator.new
80
+ graph_creator.node_finder = MockNodeFinder.new([Node.new('node/path')])
81
+
82
+ return graph_creator
83
+ end
84
+
85
+ def create_2_connected_plus_2_disconnected_nodes_graph_creator
86
+ node1 = Node.new('directory/path1')
87
+ node2 = Node.new('directory/path2')
88
+ node3 = Node.new('directory/anotherdir/path3')
89
+ node4 = Node.new('directory2/path4')
90
+ node5 = Node.new('directory2/anotherdir/path5')
91
+ node1.depends_on(node2)
92
+ node3.depends_on(node5)
93
+ node4.depends_on(node5)
94
+
95
+ graph_creator = GraphCreator.new
96
+ graph_creator.node_finder = MockNodeFinder.new([node1, node2, node3, node4])
97
+
98
+ return graph_creator
99
+ end
100
+
101
+ def create_graph_creator_with_three_nodes_that_are_equal
102
+ node1 = Node.new('directory/path')
103
+ node2 = Node.new('directory/path')
104
+ node3 = Node.new('directory/anotherdir/path')
105
+
106
+ graph_creator = GraphCreator.new
107
+ graph_creator.node_finder = MockNodeFinder.new([node1, node2, node3])
108
+
109
+ return graph_creator
110
+ end
111
+
112
+ def create_graph_creator_with_two_nodes_and_no_dependencies
113
+ node1 = Node.new('node1/path1')
114
+ node2 = Node.new('node2/path2')
115
+
116
+ graph_creator = GraphCreator.new
117
+ graph_creator.node_finder = MockNodeFinder.new([node1, node2])
118
+
119
+ return graph_creator
120
+ end
121
+
122
+ def create_dependency_chain_graph_creator(*node_names)
123
+ nodes = []
124
+
125
+ node_names.each do |node|
126
+ nodes << Node.new(node)
127
+ end
128
+
129
+ nodes.each_cons(2) do |node, dependable|
130
+ node.depends_on(dependable)
131
+ end
132
+
133
+ graph_creator = GraphCreator.new(:none)
134
+ graph_creator.node_finder = MockNodeFinder.new(nodes)
135
+
136
+ return graph_creator
137
+ end
138
+
139
+ def create_graph_creator_with_two_nodes_and_one_dependency
140
+ return create_dependency_chain_graph_creator('node1/path1.csproj', 'node2/path2.dll')
141
+ end
142
+
143
+ def create_2_node_graph_creator_with_1_normal_and_1_orphan_dependency
144
+ node1 = Node.new('file1.csproj')
145
+ node2 = Node.new('file2.csproj')
146
+ node1.depends_on(node2)
147
+ node2.depends_on('non existent file3')
148
+
149
+ graph_creator = GraphCreator.new(:none)
150
+ graph_creator.node_finder = MockNodeFinder.new([node1, node2])
151
+
152
+ return graph_creator
153
+ end
154
+
155
+ def create_2_connected_and_1_disconnected_node_with_an_orphan_dependency_graph_creator
156
+ node1 = Node.new('file1.csproj')
157
+ node2 = Node.new('file2.csproj')
158
+ node3 = Node.new('file3.csproj')
159
+ node4 = Node.new('file4.csproj')
160
+
161
+ node1.depends_on(node2)
162
+
163
+ #create an orphan dependency of disconnected node file3 because node4 will not be included in the graph
164
+ node3.depends_on(node4)
165
+
166
+ graph_creator = GraphCreator.new(:none)
167
+ graph_creator.node_finder = MockNodeFinder.new([node1, node2, node3])
168
+
169
+ return graph_creator
170
+ end
171
+
172
+ def invalid_graph_creators
173
+ {
174
+ 'graph creator with no nodes' => create_graph_creator_with_no_nodes,
175
+ 'graph creator with only one node' => create_graph_creator_with_only_one_node,
176
+ 'graph creator with three nodes that are equal' => create_graph_creator_with_three_nodes_that_are_equal,
177
+ }
178
+ end
179
+
@@ -0,0 +1,4 @@
1
+ --format
2
+ specdoc
3
+ --timeout
4
+ 20
@@ -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 => [:allspec, :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
@@ -0,0 +1,35 @@
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/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']
33
+ t.rcov = true
34
+ t.rcov_opts = ['--text-summary']
35
+ end
@@ -0,0 +1,17 @@
1
+ desc 'Generate website files'
2
+ task :website_generate => :ruby_env do
3
+ (Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
4
+ sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
5
+ end
6
+ end
7
+
8
+ desc 'Upload website files to rubyforge'
9
+ task :website_upload do
10
+ host = "#{rubyforge_username}@rubyforge.org"
11
+ remote_dir = "/var/www/gforge-projects/#{PATH}/"
12
+ local_dir = 'website'
13
+ sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
14
+ end
15
+
16
+ desc 'Generate and upload website files'
17
+ task :website => [:website_generate, :website_upload, :publish_docs]
@@ -0,0 +1,4 @@
1
+ -Separate integration tests form unit tests
2
+
3
+
4
+
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: depgraph
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.11.0
6
+ platform: ruby
7
+ authors:
8
+ - Daniel Cadenas
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-07-05 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 2.8.0
24
+ type: :development
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: ruby-graphviz
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 1.0.8
35
+ type: :runtime
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: optiflag
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.6.5
46
+ type: :runtime
47
+ version_requirements: *id003
48
+ description: A tool to create dependency graph images from source code directories
49
+ email: dcadenas@gmail.com
50
+ executables:
51
+ - depgraph
52
+ extensions: []
53
+
54
+ extra_rdoc_files: []
55
+
56
+ files:
57
+ - History.txt
58
+ - License.txt
59
+ - README.rdoc
60
+ - Rakefile
61
+ - VERSION
62
+ - bin/depgraph
63
+ - config/hoe.rb
64
+ - config/requirements.rb
65
+ - lib/DepGraph/version.rb
66
+ - lib/dependency_types.yaml
67
+ - lib/dependency_types_manager.rb
68
+ - lib/file_system_node_finder.rb
69
+ - lib/graph_creator.rb
70
+ - lib/graph_image_creator.rb
71
+ - lib/node.rb
72
+ - lib/nodefinders/gems_node_finder.rb
73
+ - lib/nodefinders/test_node_finder.rb
74
+ - script/destroy
75
+ - script/destroy.cmd
76
+ - script/generate
77
+ - script/generate.cmd
78
+ - script/txt2html
79
+ - script/txt2html.cmd
80
+ - setup.rb
81
+ - spec/IntegrationTests/depgraph_spec.rb
82
+ - spec/IntegrationTests/file_system_node_finder_spec.rb
83
+ - spec/IntegrationTests/gems_node_finder_spec.rb
84
+ - spec/IntegrationTests/graph_creator_spec.rb
85
+ - spec/IntegrationTests/graph_image_creator_spec.rb
86
+ - spec/UnitTests/dependency_types_manager_spec.rb
87
+ - spec/UnitTests/file_system_node_finder_spec.rb
88
+ - spec/UnitTests/graph_creator_spec.rb
89
+ - spec/UnitTests/graph_image_creator_spec.rb
90
+ - spec/UnitTests/node_spec.rb
91
+ - spec/integration_spec.opts
92
+ - spec/spec.opts
93
+ - spec/spec_helper.rb
94
+ - spec/unit_spec.opts
95
+ - tasks/deployment.rake
96
+ - tasks/environment.rake
97
+ - tasks/rspec.rake
98
+ - tasks/website.rake
99
+ - todo.txt
100
+ homepage: http://github.com/dcadenas/depgraph
101
+ licenses: []
102
+
103
+ post_install_message:
104
+ rdoc_options: []
105
+
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: "0"
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: "0"
120
+ requirements: []
121
+
122
+ rubyforge_project:
123
+ rubygems_version: 1.8.16
124
+ signing_key:
125
+ specification_version: 3
126
+ summary: A tool to create dependency graph images from source code directories
127
+ test_files: []
128
+