railroady 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -9,10 +9,19 @@ I (Preston Lee) am not trying to hijack Peter Hoeg or Javier's project, but rath
9
9
  = System Requirements
10
10
 
11
11
  You MUST have the the following utilities available at the command line.
12
- * `dot` and `neato`. MacPorts users can install in via `sudo port install graphviz`.
12
+ * `dot` and `neato`.
13
13
 
14
14
  * `sed`, which should already be available on all sane UNIX systems.
15
15
 
16
+ = Mac users
17
+
18
+ MacPorts users can install in via `sudo port install graphviz`.
19
+ Brew user can install via `brew install graphviz`.
20
+
21
+ = Ubuntu users
22
+
23
+ Ubuntu users can install in via `sudo apt-get install graphviz`.
24
+
16
25
  = Usage
17
26
 
18
27
  The easiest (and recommend) usage is to include railroady as a development dependency with your Rails 3 Gemfile, like so...
@@ -52,6 +61,8 @@ Common options:
52
61
  Models diagram options:
53
62
  -a, --all Include all models
54
63
  (not only ActiveRecord::Base derived)
64
+ --all-columns Show all columns
65
+ (not just content columns)
55
66
  --hide-magic Hide magic field names
56
67
  --hide-types Hide attributes type
57
68
  -j, --join Concentrate edges
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 0
4
- :patch: 2
4
+ :patch: 3
5
5
  :build:
@@ -54,9 +54,12 @@ class ModelsDiagram < AppDiagram
54
54
  else
55
55
  node_type = 'model'
56
56
 
57
- # Collect model's content columns
58
-
59
- content_columns = current_class.content_columns
57
+ # Collect model's content columns or all columns if all_columns flag is passed
58
+ if @options.all_columns
59
+ columns = current_class.columns
60
+ else
61
+ columns = current_class.content_columns
62
+ end
60
63
 
61
64
  if @options.hide_magic
62
65
  # From patch #13351
@@ -67,17 +70,16 @@ class ModelsDiagram < AppDiagram
67
70
  "rgt", "quote", "template"
68
71
  ]
69
72
  magic_fields << current_class.table_name + "_count" if current_class.respond_to? 'table_name'
70
- content_columns = current_class.content_columns.select {|c| ! magic_fields.include? c.name}
71
- else
72
- content_columns = current_class.content_columns
73
+ columns = current_class.content_columns.select {|c| ! magic_fields.include? c.name}
73
74
  end
74
-
75
- content_columns.each do |a|
76
- content_column = a.name
77
- content_column += ' :' + a.type.to_s unless @options.hide_types
78
- node_attribs << content_column
75
+
76
+ columns.each do |a|
77
+ column = a.name
78
+ column += ' :' + a.type.to_s unless @options.hide_types
79
+ node_attribs << column
79
80
  end
80
81
  end
82
+
81
83
  @graph.add_node [node_type, current_class.name, node_attribs]
82
84
  generated = true
83
85
  # Process class associations
@@ -122,7 +124,7 @@ class ModelsDiagram < AppDiagram
122
124
 
123
125
  # from patch #12384
124
126
  # if assoc.class_name == assoc.name.to_s.singularize.camelize
125
- assoc_class_name = (assoc.class_name.respond_to? 'underscore') ? assoc.class_name.underscore.singularize.camelize : assoc.class_name
127
+ assoc_class_name = (assoc.class_name.respond_to? 'underscore') ? assoc.class_name.underscore.camelize : assoc.class_name
126
128
  if assoc_class_name == assoc.name.to_s.singularize.camelize
127
129
  assoc_name = ''
128
130
  else
@@ -20,6 +20,7 @@ class OptionsStruct < OpenStruct
20
20
  :join => false,
21
21
  :label => false,
22
22
  :modules => false,
23
+ :all_columns => false,
23
24
  :hide_magic => false,
24
25
  :hide_types => false,
25
26
  :hide_public => false,
@@ -81,6 +82,9 @@ class OptionsStruct < OpenStruct
81
82
  opts.on("--show-belongs_to", "Show belongs_to associations") do |s|
82
83
  self.show_belongs_to = s
83
84
  end
85
+ opts.on("--all-columns", "Show all columns (not just content columns)") do |h|
86
+ self.all_columns = h
87
+ end
84
88
  opts.on("--hide-magic", "Hide magic field names") do |h|
85
89
  self.hide_magic = h
86
90
  end
@@ -1,7 +1,7 @@
1
1
  require 'yaml'
2
2
  module RailRoady
3
3
  module VERSION #:nodoc:
4
- f = File.join(File.dirname(__FILE__), '..', '..', 'VERSION.yml')
4
+ f = File.join(File.dirname(__FILE__), '..', '..', 'VERSION.yml')
5
5
  if File.exist?(f)
6
6
  config = YAML.load(File.read(f))
7
7
  MAJOR = config[:major]
data/tasks/railroady.rake CHANGED
@@ -6,57 +6,61 @@
6
6
  # * The `sed` command-line utility, which should already be available on all sane UNIX systems.
7
7
  #
8
8
  # Author: Preston Lee, http://railroady.prestonlee.com
9
-
9
+
10
10
  # Returns an absolute path for the following file.
11
+ def format
12
+ @@DIAGRAM_FORMAT ||= 'SVG'
13
+ end
14
+
11
15
  def full_path(name = 'test.txt')
12
16
  f = File.join(Rails.root.to_s.gsub(' ', '\ '), 'doc', name)
13
17
  f.to_s
14
18
  end
15
-
19
+
16
20
  namespace :diagram do
17
-
18
- @MODELS_ALL_SVG = full_path('models_complete.svg').freeze
19
- @MODELS_BRIEF_SVG = full_path('models_brief.svg').freeze
20
- @CONTROLLERS_ALL_SVG = full_path('controllers_complete.svg').freeze
21
- @CONTROLLERS_BRIEF_SVG = full_path('controllers_brief.svg').freeze
22
-
21
+
22
+ @MODELS_ALL = full_path("models_complete.#{format}").freeze
23
+ @MODELS_BRIEF = full_path("models_brief.#{format}").freeze
24
+ @CONTROLLERS_ALL = full_path("controllers_complete.#{format}").freeze
25
+ @CONTROLLERS_BRIEF = full_path("controllers_brief.#{format}").freeze
26
+
23
27
  namespace :models do
24
-
25
- desc 'Generates an SVG class diagram for all models.'
28
+
29
+ desc 'Generates an class diagram for all models.'
26
30
  task :complete do
27
- f = @MODELS_ALL_SVG
31
+ f = @MODELS_ALL
28
32
  puts "Generating #{f}"
29
- sh "railroady -ilamM | dot -Tsvg > #{f}"
33
+ sh "railroady -ilamM | dot -T#{format} > #{f}"
30
34
  end
31
-
32
- desc 'Generates an abbreviated SVG class diagram for all models.'
35
+
36
+ desc 'Generates an abbreviated class diagram for all models.'
33
37
  task :brief do
34
- f = @MODELS_BRIEF_SVG
38
+ f = @MODELS_BRIEF
35
39
  puts "Generating #{f}"
36
- sh "railroady -bilamM | dot -Tsvg > #{f}"
40
+ sh "railroady -bilamM | dot -T#{format} > #{f}"
37
41
  end
38
-
42
+
39
43
  end
40
-
44
+
41
45
  namespace :controllers do
42
-
43
- desc 'Generates an SVG class diagram for all controllers.'
46
+
47
+ desc 'Generates an class diagram for all controllers.'
44
48
  task :complete do
45
- f = @CONTROLLERS_ALL_SVG
49
+ f = @CONTROLLERS_ALL
46
50
  puts "Generating #{f}"
47
- sh "railroady -ilC | neato -Tsvg > #{f}"
51
+ sh "railroady -ilC | neato -T#{format} > #{f}"
48
52
  end
49
-
50
- desc 'Generates an abbreviated SVG class diagram for all controllers.'
53
+
54
+ desc 'Generates an abbreviated class diagram for all controllers.'
51
55
  task :brief do
52
- f = @CONTROLLERS_BRIEF_SVG
56
+ f = @CONTROLLERS_BRIEF
53
57
  puts "Generating #{f}"
54
- sh "railroady -bilC | neato -Tsvg > #{f}"
58
+ sh "railroady -bilC | neato -T#{format} > #{f}"
55
59
  end
56
-
60
+
57
61
  end
58
-
59
- desc 'Generates all SVG class diagrams.'
62
+
63
+ desc 'Generates all class diagrams.'
60
64
  task :all => ['diagram:models:complete', 'diagram:models:brief', 'diagram:controllers:complete', 'diagram:controllers:brief']
61
-
62
- end
65
+
66
+ end
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railroady
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.0.2
4
+ hash: 17
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 3
10
+ version: 1.0.3
6
11
  platform: ruby
7
12
  authors:
8
13
  - Preston Lee
@@ -13,7 +18,7 @@ autorequire:
13
18
  bindir: bin
14
19
  cert_chain: []
15
20
 
16
- date: 2011-03-14 00:00:00 -07:00
21
+ date: 2011-12-28 00:00:00 +05:30
17
22
  default_executable: railroady
18
23
  dependencies: []
19
24
 
@@ -66,17 +71,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
66
71
  requirements:
67
72
  - - ">="
68
73
  - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
69
77
  version: "0"
70
78
  required_rubygems_version: !ruby/object:Gem::Requirement
71
79
  none: false
72
80
  requirements:
73
81
  - - ">="
74
82
  - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
75
86
  version: "0"
76
87
  requirements: []
77
88
 
78
89
  rubyforge_project:
79
- rubygems_version: 1.6.2
90
+ rubygems_version: 1.3.7
80
91
  signing_key:
81
92
  specification_version: 3
82
93
  summary: Ruby on Rails 3 model and controller UML class diagram generator.