Skip to content

Commit

Permalink
moved things around to create Rake tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelson Silva committed May 22, 2009
1 parent 21f56ce commit 49e5564
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*~
shoes2.run
1 change: 1 addition & 0 deletions init.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require File.join(File.dirname(__FILE__), "lib", "yUMLmeRails")
File renamed without changes.
2 changes: 2 additions & 0 deletions railroad/app_diagram.rb → lib/railroad/app_diagram.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# Root class for RailRoad diagrams
class AppDiagram

attr :graph

def initialize(options)
@options = options
@graph = DiagramGraph.new
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def to_yuml
end
"[#{from}]#{association}[#{to}]"
}
"http://yuml.me/diagram/scruffy/class/" << parts.join(",")
parts.join(",")
end

private
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions lib/shoes_app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require "yUMLmeRails"

Shoes.app do
image "http://yuml.me/diagram/scruffy/class/" << YUMLmeRails.generate_diagram
end
49 changes: 49 additions & 0 deletions lib/yUMLmeRails.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
APP_NAME = "railroad"
APP_HUMAN_NAME = "RailRoad"
APP_VERSION = [0,5,0]
COPYRIGHT = "Copyright (C) 2007-2008 Javier Smaldone"

require 'ostruct'
require 'railroad/models_diagram'
#require 'railroad/controllers_diagram'
#require 'railroad/aasm_diagram'

class YUMLmeRails
class << self
def generate_diagram
options = OpenStruct.new(
:all => true,
:brief => true,
:exclude => [],
:inheritance => false,
:join => false,
:label => false,
:modules => false,
:hide_magic => false,
:hide_types => false,
:hide_public => false,
:hide_protected => false,
:hide_private => false,
:plugins_models => false,
:root => '',
:transitive => true,
:verbose => false,
:xmi => false,
:yuml => true,
:command => 'models'
)


if options.command == 'models'
diagram = ModelsDiagram.new options
#elsif options.command == 'controllers'
# diagram = ControllersDiagram.new options
#elsif options.command == 'aasm'
# diagram = AasmDiagram.new options
end

diagram.generate
diagram.graph.to_yuml
end
end
end
24 changes: 24 additions & 0 deletions tasks/yUMLmeRails.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace :yUMLmeRails do
desc "Show model diagram"
task :app do
system "shoes app.rb"
end

desc "Get yUML URL"
task :model_diagram_url => :environment do
puts "http://yuml.me/diagram/scruffy/class/" << YUMLmeRails.generate_diagram
end

desc "Download yUML model diagram"
task :model_diagram => :environment do
url="http://yuml.me/diagram/scruffy/class/" << YUMLmeRails.generate_diagram
DIR="diagrams"
FileUtils.mkdir_p DIR
filename="#{DIR}/model_" << Time.new.strftime("%b_%d_%Y") << ".png"
system "wget -O #{filename} #{url}"
# TODO - Make the following work
#require 'open-uri'
#open(, "wb").
# write(open("http://yuml.me/diagram/scruffy/class/" << YUMLmeRails.generate_diagram))
end
end

0 comments on commit 49e5564

Please sign in to comment.