tobias-railroad 0.10.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,14 @@
1
+ require 'yaml'
2
+ module RailRoad
3
+ module VERSION #:nodoc:
4
+ if File.exist?('../VERSION.yml')
5
+ config = YAML.load(File.read('../VERSION.yml'))
6
+ MAJOR = config[:major]
7
+ MINOR = config[:minor]
8
+ PATCH = config[:patch]
9
+ else
10
+ MAJOR = MINOR = PATCH = 0
11
+ end
12
+ STRING = [MAJOR, MINOR, PATCH].join('.')
13
+ end
14
+ end
@@ -0,0 +1,49 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe AasmDiagram do
4
+ describe 'file processing' do
5
+
6
+ it 'should select all the files under the models dir' do
7
+ ad = AasmDiagram.new
8
+ files = ad.get_files("spec/file_fixture/")
9
+ files.size.should == 3
10
+ end
11
+
12
+ it 'should exclude a specific file' do
13
+ options = OptionsStruct.new(:exclude => ['spec/file_fixture/app/models/dummy1.rb'])
14
+ ad = AasmDiagram.new(options)
15
+ files = ad.get_files("spec/file_fixture/")
16
+ files.size.should == 2
17
+ end
18
+
19
+ it 'should exclude a glob pattern of files' do
20
+ options = OptionsStruct.new(:exclude => ['spec/file_fixture/app/models/*/*.rb'])
21
+ ad = AasmDiagram.new(options)
22
+ files = ad.get_files("spec/file_fixture/")
23
+ files.size.should == 2
24
+ end
25
+
26
+ it 'should include only specific file' do
27
+ options = OptionsStruct.new(:specify => ['spec/file_fixture/app/models/sub-dir/sub_dummy.rb'])
28
+ ad = AasmDiagram.new(options)
29
+ files = ad.get_files("spec/file_fixture/")
30
+ files.size.should == 1
31
+ end
32
+
33
+ it 'should include only specified files' do
34
+ options = OptionsStruct.new(:specify => ['spec/file_fixture/app/models/{dummy1.rb,sub-dir/sub_dummy.rb}'])
35
+ ad = AasmDiagram.new(options)
36
+ files = ad.get_files("spec/file_fixture/")
37
+ files.size.should == 2
38
+ end
39
+
40
+ it 'should include only specified files and exclude specified files' do
41
+ options = OptionsStruct.new(:specify => ['spec/file_fixture/app/models/{dummy1.rb,sub-dir/sub_dummy.rb}'],
42
+ :exclude => ['spec/file_fixture/app/models/sub-dir/sub_dummy.rb'])
43
+ ad = AasmDiagram.new(options)
44
+ files = ad.get_files("spec/file_fixture/")
45
+ files.size.should == 1
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,15 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe AppDiagram do
4
+ describe 'file name processing' do
5
+ it 'should extract a simple name' do
6
+ ad = AppDiagram.new
7
+ name = ad.instance_eval {extract_class_name('app/models/test_this.rb')}
8
+ name.should == 'TestThis'
9
+ end
10
+ it 'should constantize a name' do
11
+ 'String'.constantize.should == String
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,49 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe ControllersDiagram do
4
+ describe 'file processing' do
5
+
6
+ it 'should select all the files under the controllers dir' do
7
+ cd = ControllersDiagram.new
8
+ files = cd.get_files("spec/file_fixture/")
9
+ files.size.should == 4
10
+ end
11
+
12
+ it 'should exclude a specific file' do
13
+ options = OptionsStruct.new(:exclude => ['spec/file_fixture/app/controllers/dummy1_controller.rb'])
14
+ cd = ControllersDiagram.new(options)
15
+ files = cd.get_files("spec/file_fixture/")
16
+ files.size.should == 3
17
+ end
18
+
19
+ it 'should exclude a glob pattern of files' do
20
+ options = OptionsStruct.new(:exclude => ['spec/file_fixture/app/controllers/sub-dir/*.rb'])
21
+ cd = ControllersDiagram.new(options)
22
+ files = cd.get_files("spec/file_fixture/")
23
+ files.size.should == 3
24
+ end
25
+
26
+ it 'should include only specific file' do
27
+ options = OptionsStruct.new(:specify => ['spec/file_fixture/app/controllers/sub-dir/sub_dummy_controller.rb'])
28
+ cd = ControllersDiagram.new(options)
29
+ files = cd.get_files("spec/file_fixture/")
30
+ files.size.should == 1
31
+ end
32
+
33
+ it 'should include only specified files' do
34
+ options = OptionsStruct.new(:specify => ['spec/file_fixture/app/controllers/{dummy1_*.rb,sub-dir/sub_dummy_controller.rb}'])
35
+ cd = ControllersDiagram.new(options)
36
+ files = cd.get_files("spec/file_fixture/")
37
+ files.size.should == 2
38
+ end
39
+
40
+ it 'should include only specified files and exclude specified files' do
41
+ options = OptionsStruct.new(:specify => ['spec/file_fixture/app/controllers/{dummy1_*.rb,sub-dir/sub_dummy_controller.rb}'],
42
+ :exclude => ['spec/file_fixture/app/controllers/sub-dir/sub_dummy_controller.rb'])
43
+ cd = ControllersDiagram.new(options)
44
+ files = cd.get_files("spec/file_fixture/")
45
+ files.size.should == 1
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,49 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ module CustomDotMatchers
4
+ class HaveDotOptions
5
+ def initialize(expected)
6
+ @expected = expected
7
+ end
8
+ def matches?(target)
9
+ @target = target
10
+ return false unless @target =~ /\[(.*)\]/
11
+ @options = $1
12
+ @options == @expected
13
+ end
14
+ def failure_message
15
+ "expected '#{@target.strip}' to have options '[#{@expected}]'"
16
+ end
17
+ def negative_failure_message
18
+ "expected '#{@target.strip}' to not have options '[#{@expected}]'"
19
+ end
20
+ def description
21
+ "have dot options"
22
+ end
23
+ end
24
+ def have_dot_options(expected)
25
+ HaveDotOptions.new expected
26
+ end
27
+ end
28
+
29
+ describe DiagramGraph do
30
+ include CustomDotMatchers
31
+
32
+ before do
33
+ @diagram_graph = DiagramGraph.new
34
+ end
35
+
36
+ describe ".dot_edge" do
37
+ context "has_a/belongs_to" do
38
+ it { @diagram_graph.send(:dot_edge, "one-one", "source", "target").should have_dot_options("arrowtail=odot, arrowhead=dot, dir=both") }
39
+ end
40
+
41
+ context "has_many/belongs_to" do
42
+ it { @diagram_graph.send(:dot_edge, "one-many", "source", "target").should have_dot_options("arrowtail=odot, arrowhead=crow, dir=both") }
43
+ end
44
+
45
+ context "habtm" do
46
+ it { @diagram_graph.send(:dot_edge, "many-many", "source", "target").should have_dot_options("arrowtail=crow, arrowhead=crow, dir=both") }
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::Base
2
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,49 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe ModelsDiagram do
4
+ describe 'file processing' do
5
+
6
+ it 'should select all the files under the models dir' do
7
+ md = ModelsDiagram.new
8
+ files = md.get_files("spec/file_fixture/")
9
+ files.size.should == 3
10
+ end
11
+
12
+ it 'should exclude a specific file' do
13
+ options = OptionsStruct.new(:exclude => ['spec/file_fixture/app/models/dummy1.rb'])
14
+ md = ModelsDiagram.new(options)
15
+ files = md.get_files("spec/file_fixture/")
16
+ files.size.should == 2
17
+ end
18
+
19
+ it 'should exclude a glob pattern of files' do
20
+ options = OptionsStruct.new(:exclude => ['spec/file_fixture/app/models/*/*.rb'])
21
+ md = ModelsDiagram.new(options)
22
+ files = md.get_files("spec/file_fixture/")
23
+ files.size.should == 2
24
+ end
25
+
26
+ it 'should include only specific file' do
27
+ options = OptionsStruct.new(:specify => ['spec/file_fixture/app/models/sub-dir/sub_dummy.rb'])
28
+ md = ModelsDiagram.new(options)
29
+ files = md.get_files("spec/file_fixture/")
30
+ files.size.should == 1
31
+ end
32
+
33
+ it 'should include only specified files' do
34
+ options = OptionsStruct.new(:specify => ['spec/file_fixture/app/models/{dummy1.rb,sub-dir/sub_dummy.rb}'])
35
+ md = ModelsDiagram.new(options)
36
+ files = md.get_files("spec/file_fixture/")
37
+ files.size.should == 2
38
+ end
39
+
40
+ it 'should include only specified files and exclude specified files' do
41
+ options = OptionsStruct.new(:specify => ['spec/file_fixture/app/models/{dummy1.rb,sub-dir/sub_dummy.rb}'],
42
+ :exclude => ['spec/file_fixture/app/models/sub-dir/sub_dummy.rb'])
43
+ md = ModelsDiagram.new(options)
44
+ files = md.get_files("spec/file_fixture/")
45
+ files.size.should == 1
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec'
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ require 'railroad'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tobias-railroad
3
+ version: !ruby/object:Gem::Version
4
+ hash: 55
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 10
9
+ - 0
10
+ version: 0.10.0
11
+ platform: ruby
12
+ authors:
13
+ - Tobias Crawley
14
+ - Peter Hoeg
15
+ - Javier Smaldone
16
+ autorequire:
17
+ bindir: bin
18
+ cert_chain: []
19
+
20
+ date: 2010-09-23 00:00:00 -04:00
21
+ default_executable: railroad
22
+ dependencies: []
23
+
24
+ description: A DOT diagram generator for Ruby on Rail applications
25
+ email:
26
+ - tcrawley@gmail.com
27
+ - peter@hoeg.com
28
+ - p.hoeg@northwind.sg
29
+ - javier@smaldone.com.ar
30
+ executables:
31
+ - railroad
32
+ extensions: []
33
+
34
+ extra_rdoc_files:
35
+ - AUTHORS.rdoc
36
+ - CHANGELOG.rdoc
37
+ - LICENSE.rdoc
38
+ - README.rdoc
39
+ files:
40
+ - .document
41
+ - AUTHORS.rdoc
42
+ - CHANGELOG.rdoc
43
+ - LICENSE.rdoc
44
+ - README.rdoc
45
+ - Rakefile
46
+ - VERSION.yml
47
+ - bin/railroad
48
+ - lib/railroad.rb
49
+ - lib/railroad/aasm_diagram.rb
50
+ - lib/railroad/app_diagram.rb
51
+ - lib/railroad/controllers_diagram.rb
52
+ - lib/railroad/diagram_graph.rb
53
+ - lib/railroad/models_diagram.rb
54
+ - lib/railroad/options_struct.rb
55
+ - lib/railroad/version.rb
56
+ - spec/aasm_diagram_spec.rb
57
+ - spec/app_diagram_spec.rb
58
+ - spec/controllers_diagram_spec.rb
59
+ - spec/diagram_graph_spec.rb
60
+ - spec/file_fixture/app/controllers/application_controller.rb
61
+ - spec/file_fixture/app/controllers/dummy1_controller.rb
62
+ - spec/file_fixture/app/controllers/dummy2_controller.rb
63
+ - spec/file_fixture/app/controllers/sub-dir/sub_dummy_controller.rb
64
+ - spec/file_fixture/app/models/dummy1.rb
65
+ - spec/file_fixture/app/models/dummy2.rb
66
+ - spec/file_fixture/app/models/sub-dir/sub_dummy.rb
67
+ - spec/models_diagram_spec.rb
68
+ - spec/spec_helper.rb
69
+ has_rdoc: true
70
+ homepage: http://github.com/tobias/RailRoad
71
+ licenses: []
72
+
73
+ post_install_message:
74
+ rdoc_options:
75
+ - --charset=UTF-8
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 3
93
+ segments:
94
+ - 0
95
+ version: "0"
96
+ requirements: []
97
+
98
+ rubyforge_project:
99
+ rubygems_version: 1.3.7
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: A DOT diagram generator for Ruby on Rail applications
103
+ test_files:
104
+ - spec/app_diagram_spec.rb
105
+ - spec/diagram_graph_spec.rb
106
+ - spec/controllers_diagram_spec.rb
107
+ - spec/models_diagram_spec.rb
108
+ - spec/spec_helper.rb
109
+ - spec/aasm_diagram_spec.rb
110
+ - spec/file_fixture/app/models/dummy1.rb
111
+ - spec/file_fixture/app/models/dummy2.rb
112
+ - spec/file_fixture/app/models/sub-dir/sub_dummy.rb
113
+ - spec/file_fixture/app/controllers/dummy2_controller.rb
114
+ - spec/file_fixture/app/controllers/application_controller.rb
115
+ - spec/file_fixture/app/controllers/sub-dir/sub_dummy_controller.rb
116
+ - spec/file_fixture/app/controllers/dummy1_controller.rb