From a19b247b82431967d045677ac6d0ca5b3e5916d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20W=C3=B6ber?= Date: Mon, 28 Dec 2009 21:43:03 +0800 Subject: [PATCH] optional filename-argument for the yUMLmeRails:download (needs rake >= 0.8.0) --- README.markdown | 3 ++- tasks/yUMLmeRails.rake | 18 +++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.markdown b/README.markdown index 423e7e7..1a35361 100644 --- a/README.markdown +++ b/README.markdown @@ -15,8 +15,9 @@ There's also a small Shoes app to display the downloaded diagram. ## Requirements * Shoes (if you want to use the show-task) + * Rake >= 0.8.0 (or remove the 'arg' in the rake task yUMLmeRails:download) -## Instalation +## Installation * Just clone this into vendor/plugins diff --git a/tasks/yUMLmeRails.rake b/tasks/yUMLmeRails.rake index 259f5de..6d35b2e 100644 --- a/tasks/yUMLmeRails.rake +++ b/tasks/yUMLmeRails.rake @@ -1,10 +1,10 @@ YUMLME_URL="http://yuml.me/diagram/scruffy/class/" FILENAME=File.join(RAILS_ROOT, 'doc','diagrams',"model.#{Time.now.strftime('%Y%m%d-%H%M%S')}.png") -def generate_diagram +def generate_diagram(file=FILENAME) require 'open-uri' - FileUtils.mkdir_p File.dirname(FILENAME) - File.open(FILENAME,'wb') do |f| + FileUtils.mkdir_p File.dirname(file) + File.open(file,'wb') do |f| f.write(open("#{YUMLME_URL}#{CGI.escape(YUMLmeRails.generate_diagram)}").read) end end @@ -28,11 +28,11 @@ namespace :yUMLmeRails do end desc "Download yUML model diagram #{File.dirname(FILENAME)}" - task :download => :environment do - generate_diagram - end + task :download, :filename, :needs => :environment do |t, args| + args.with_defaults(:filename => FILENAME) + generate_diagram args[:filename] + end + end - - - +