DepGraph 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ 0.10.0
2
+ * Now you can create the dependency graph of all the installed gems.
3
+ * Fixed the missing dependencies to optiflag and ruby-graphviz to the deployed gem.
4
+
1
5
  0.9.0
2
6
 
3
7
  * Added dynamic loading of node finders from directory lib/nodefinders.
@@ -14,6 +14,7 @@ lib/file_system_node_finder.rb
14
14
  lib/graph_image_creator.rb
15
15
  lib/graph_creator.rb
16
16
  lib/nodefinders/test_node_finder.rb
17
+ lib/nodefinders/gems_node_finder.rb
17
18
  script/destroy
18
19
  script/destroy.cmd
19
20
  script/generate
@@ -23,6 +24,7 @@ script/txt2html.cmd
23
24
  setup.rb
24
25
  spec/IntegrationTests/depgraph_spec.rb
25
26
  spec/IntegrationTests/file_system_node_finder_spec.rb
27
+ spec/IntegrationTests/gems_node_finder_spec.rb
26
28
  spec/IntegrationTests/graph_creator_spec.rb
27
29
  spec/IntegrationTests/graph_image_creator_spec.rb
28
30
  spec/UnitTests/dependency_types_manager_spec.rb
data/README.txt CHANGED
@@ -1 +1,48 @@
1
- README
1
+ = DepGraph
2
+
3
+ * http://depgraph.rubyforge.org
4
+
5
+ == DESCRIPTION:
6
+
7
+ FIX (describe your package)
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * FIX (list of features or problems)
12
+
13
+ == SYNOPSIS:
14
+
15
+ FIX (code sample of usage)
16
+
17
+ == REQUIREMENTS:
18
+
19
+ * Graphviz, ruby-graphviz and optiflag
20
+
21
+ == INSTALL:
22
+
23
+ * gem install DepGraph
24
+
25
+ == LICENSE:
26
+
27
+ (The MIT License)
28
+
29
+ Copyright (c) 2008 FIX
30
+
31
+ Permission is hereby granted, free of charge, to any person obtaining
32
+ a copy of this software and associated documentation files (the
33
+ 'Software'), to deal in the Software without restriction, including
34
+ without limitation the rights to use, copy, modify, merge, publish,
35
+ distribute, sublicense, and/or sell copies of the Software, and to
36
+ permit persons to whom the Software is furnished to do so, subject to
37
+ the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be
40
+ included in all copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
43
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
46
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
47
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
48
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -60,7 +60,7 @@ end
60
60
 
61
61
  type = CommandLineParameters.flags.type
62
62
  output = CommandLineParameters.flags.output || 'dependency_graph.png'
63
- location = CommandLineParameters.flags.location || '.'
63
+ location = CommandLineParameters.flags.location
64
64
  from = CommandLineParameters.flags.from if CommandLineParameters.flags.from?
65
65
  to = CommandLineParameters.flags.to if CommandLineParameters.flags.to?
66
66
  exc = CommandLineParameters.flags.exc || ''
@@ -69,7 +69,7 @@ trans = CommandLineParameters.flags.trans?
69
69
  puts "Creating #{type} dependency graph. Please wait..."
70
70
 
71
71
  dep_grapher = DepGraph::GraphCreator.new(type)
72
- dep_grapher.location = location.split(',')
72
+ dep_grapher.location = location.split(',') if location
73
73
  dep_grapher.from = from
74
74
  dep_grapher.to = to
75
75
  dep_grapher.trans = trans
@@ -59,6 +59,7 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
59
59
  # == Optional
60
60
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
61
61
  #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
62
+ p.extra_deps = [['ruby-graphviz', '>=0.8.0'], ['optiflag', '>=0.6.5']]
62
63
 
63
64
  #p.spec_extras = {} # A hash of extra values to set in the gemspec.
64
65
 
@@ -67,4 +68,4 @@ end
67
68
  CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
68
69
  PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
69
70
  hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
70
- hoe.rsync_args = '-av --delete --ignore-errors'
71
+ hoe.rsync_args = '-av --delete --ignore-errors'
@@ -1,7 +1,7 @@
1
1
  module DepGraph #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 9
4
+ MINOR = 10
5
5
  TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
@@ -16,7 +16,11 @@ module DepGraph
16
16
  end
17
17
 
18
18
  def location=(locs)
19
- @location = locs.map {|d| d.strip}
19
+ if locs
20
+ @location = locs.map {|d| d.strip}
21
+ else
22
+ @location = ['.']
23
+ end
20
24
  end
21
25
 
22
26
  def get_nodes
@@ -0,0 +1,49 @@
1
+ require 'node'
2
+
3
+ module DepGraph
4
+ module NodeFinders
5
+
6
+ class GemsNodeFinder
7
+ def initialize
8
+ @spec_directories = Gem::SourceIndex.installed_spec_directories
9
+ end
10
+
11
+ def location=(loc)
12
+ @spec_directories = loc
13
+ end
14
+
15
+ def get_nodes
16
+ require 'rubygems'
17
+
18
+ fail 'The gem specification directories were not set' unless @spec_directories and @spec_directories.size > 0
19
+
20
+ nodes = {}
21
+ @spec_directories.each do |spec_directory|
22
+ Dir["#{spec_directory}/**/*.gemspec"].each do |gemspec_file_name|
23
+ add_nodes_from_gemspec(nodes, gemspec_file_name)
24
+ end
25
+ end
26
+
27
+ return nodes.values
28
+ end
29
+
30
+
31
+ def add_nodes_from_gemspec(nodes, gemspec_file_name)
32
+ gem_name = File.basename(gemspec_file_name).match(/(.+)-\d+/)[1].to_s
33
+ gem_dependencies = []
34
+ content = File.read(gemspec_file_name)
35
+ content.scan(/add_dependency\(%q<([^>]+)>/) do |matches|
36
+ matches.each do |match|
37
+ gem_dependencies << match
38
+ end
39
+ end
40
+
41
+ nodes[gem_name] = Node.new(gem_name) unless nodes[gem_name]
42
+ gem_dependencies.each do |gem_dependency|
43
+ nodes[gem_dependency] = Node.new(gem_dependency) unless nodes[gem_dependency]
44
+ nodes[gem_name].depends_on(nodes[gem_dependency])
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -2,6 +2,7 @@ require File.dirname(__FILE__) + "/../spec_helper"
2
2
  require 'rubygems'
3
3
  gem 'filetesthelper'
4
4
  require 'filetesthelper'
5
+ require 'graph_creator'
5
6
 
6
7
  include FileTestHelper
7
8
 
@@ -14,10 +15,11 @@ describe "#{tool_name} (integration tests)" do
14
15
  test_data = {
15
16
  :csproj => {'proj1.csproj' => '"proj2.csproj"', 'proj2.csproj' => '"proj1.csproj"'},
16
17
  :ruby_requires => {'rubyfile1.rb' => 'require "rubyfile2"', 'rubyfile2.rb' => 'require "rubyfile3"'},
18
+ :gems => {}
17
19
  }
18
20
 
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
+ DepGraph::GraphCreator.types.each do |filter_type|
22
+ it "should create an image from the #{filter_type} dependency type" do
21
23
  test_files = test_data[filter_type]
22
24
  with_files(test_files) do
23
25
  system "ruby #{tool_path} -type #{filter_type}"
@@ -0,0 +1,21 @@
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+ require 'rubygems'
3
+ require 'filetesthelper'
4
+ require 'nodefinders/gems_node_finder'
5
+
6
+ include FileTestHelper
7
+ include DepGraph::NodeFinders
8
+
9
+ describe GemsNodeFinder do
10
+ it "should list all gems and its dependencies" do
11
+ with_files('fakegem-0.9.1.gemspec' => 's.add_dependency(%q<fakedependencygem>, [">= 1.5.0"])') do
12
+ gems_node_finder = GemsNodeFinder.new
13
+ gems_node_finder.location = ['./']
14
+ nodes = gems_node_finder.get_nodes
15
+
16
+ nodes.should == ['fakedependencygem', 'fakegem']
17
+ nodes[1].dependencies.size.should == 1
18
+ nodes[1].dependencies[0].name.should == 'fakedependencygem'
19
+ end
20
+ end
21
+ end
@@ -9,12 +9,13 @@ include FileTestHelper
9
9
 
10
10
  test_data = {
11
11
  :csproj => {'file1.csproj'=>'"file2.csproj"', 'dir/file2.csproj'=>'"file1.csproj"' },
12
- :ruby_requires => {'file1.rb'=>'require "file2"', 'dir/file2.rb'=>'require "file1"' }
12
+ :ruby_requires => {'file1.rb'=>'require "file2"', 'dir/file2.rb'=>'require "file1"' },
13
+ :gems => {}
13
14
  }
14
15
 
15
16
  describe GraphCreator, '(integration tests)' do
16
- dependency_types.each do |filter_type|
17
- it "should create a png image from the #{filter_type} dependencies found in the current directory tree" do
17
+ GraphCreator.types.each do |filter_type|
18
+ it "should create a png image from the #{filter_type} dependencies found" do
18
19
  with_files(test_data[filter_type]) do
19
20
  GraphCreator.new(filter_type).create_image('test.png')
20
21
 
@@ -1,5 +1,5 @@
1
1
  require File.dirname(__FILE__) + "/../spec_helper"
2
- require 'graph'
2
+ require 'graph_image_creator'
3
3
  require 'rubygems'
4
4
  gem 'filetesthelper'
5
5
  require 'spec'
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.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Daniel Cadenas Ni\xF3n"
@@ -9,10 +9,27 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-03-16 00:00:00 -03:00
12
+ date: 2008-03-21 00:00:00 -03:00
13
13
  default_executable:
14
- dependencies: []
15
-
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: ruby-graphviz
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.8.0
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: optiflag
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 0.6.5
32
+ version:
16
33
  description: A tool to create dependency graph images from source code directories
17
34
  email:
18
35
  - dcadenas@gmail.com
@@ -42,6 +59,7 @@ files:
42
59
  - lib/graph_image_creator.rb
43
60
  - lib/graph_creator.rb
44
61
  - lib/nodefinders/test_node_finder.rb
62
+ - lib/nodefinders/gems_node_finder.rb
45
63
  - script/destroy
46
64
  - script/destroy.cmd
47
65
  - script/generate
@@ -51,6 +69,7 @@ files:
51
69
  - setup.rb
52
70
  - spec/IntegrationTests/depgraph_spec.rb
53
71
  - spec/IntegrationTests/file_system_node_finder_spec.rb
72
+ - spec/IntegrationTests/gems_node_finder_spec.rb
54
73
  - spec/IntegrationTests/graph_creator_spec.rb
55
74
  - spec/IntegrationTests/graph_image_creator_spec.rb
56
75
  - spec/UnitTests/dependency_types_manager_spec.rb
@@ -96,6 +115,7 @@ summary: A tool to create dependency graph images from source code directories
96
115
  test_files:
97
116
  - spec/IntegrationTests/depgraph_spec.rb
98
117
  - spec/IntegrationTests/file_system_node_finder_spec.rb
118
+ - spec/IntegrationTests/gems_node_finder_spec.rb
99
119
  - spec/IntegrationTests/graph_creator_spec.rb
100
120
  - spec/IntegrationTests/graph_image_creator_spec.rb
101
121
  - spec/spec_helper.rb