MDA/MDD/TDD/DDD/DDDDDDD
          posts - 536, comments - 111, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          railroad使用

          Posted on 2010-10-14 18:56 leekiang 閱讀(366) 評論(0)  編輯  收藏 所屬分類: rails
          1,gem install railroad 裝的版本是0.5.0
          2, 安裝graphviz-2.26.3.msi
          3, 在應(yīng)用目錄下railroad -M | dot -Tsvg > models.svg,報錯:
          C:/Ruby186/lib/ruby/gems/1.8/gems/railroad-0.5.0/lib/railroad/app_diagram.rb:54:
          in `reopen': No such file or directory - /dev/null (Errno::ENOENT)
          ?? 搜到篇文章說把c:/Ruby186/lib\ruby\gems\1.8\gems\railroad-0.5.5\lib\railroad下的app_diagram.rb的54行改為STDOUT.reopen('NUL:')
          把controllers_diagram.rb的39行改為require "app/controllers/application_controller.rb"
          按要求修改后在應(yīng)用下執(zhí)行railroad -a -i -M | dot -Tpng > models.png,又報:
          D:/netbeansWorkSpace/redmine/vendor/rails/activesupport/lib/active_support/w
          hiny_nil.rb:52:in `method_missing': undefined method `klass' for nil:NilClass (N
          oMethodError)

          注:ruby為1.8.6,rails為2.3.5
          參考:
          http://www.javaeye.com/topic/88700
          http://blog.brzezinka.eu/webmaster-tips/ruby/ror-railroad-plugin-with-rails-2-3-5-on-windows-error


          該文章后面講了如何使用rake自動生成,copy如下:
          To automate the process of creating schemes, you can create Rails task. In your rails_project_dir/Libs/tasks create diagrams.rake and copy the text:
          namespace?:doc?do
          ??namespace?
          :diagram?do
          ????task?
          :models?do
          ??????sh?
          "railroad?-a?-i?-M?|?dot?-Tpng?>?doc/models.png"
          ??????sh?
          "railroad?-i?-l?-a?-m?-M?|?dot?-Tsvg?doc/models.svg"
          ????end

          ????task?
          :controllers?do
          ??????sh?
          "railroad?-i?-l?-C?|?neato?-Tsvg?>?doc/controllers.svg"
          ????end
          ??end

          ??task?
          :diagrams?=>?%w(diagram:models?diagram:controllers)

          end

          Now you can run the task by typing in console: rake doc:diagrams to generate all diagrams (for models an controllers) or rake doc:diagram:models to generate diagram for models only.

          Due to the information on RailsRoad Docs, there is a bug in Graphvis while crating svg graphic. There is a simple way to correct it (citation from RailsRoad Docs):

          Important: There is a bug in?Graphviz tools when generatingSVG files that cause a text overflow. You can solve this problem editing (with a text editor, not a graphical?SVG editor) the file and replacing around line 12 ?font-size:14.00;” by ?font-size:11.00;?, or by issuing the following command (see ?man sed?):

          sed?-i?'s/font-size:14.00/font-size:11.00/g'?file.svg

          Note: For viewing and editing?SVG there is an excellent opensource tool called?Inkscape (similar to?Adobe Illustrator.) For?DOTprocessing you can also use?Omnigraffle (on?Mac OS X).



          主站蜘蛛池模板: 隆林| 册亨县| 全南县| 大理市| 吉木萨尔县| 武乡县| 永登县| 夏津县| 兴隆县| 东阳市| 嵩明县| 新建县| 莆田市| 江津市| 武胜县| 纳雍县| 荆门市| 招远市| 呼和浩特市| 嘉兴市| 永年县| 民乐县| 石棉县| 竹山县| 饶河县| 临潭县| 清远市| 溧阳市| 台中县| 自治县| 铜山县| 南川市| 北京市| 全州县| 霍城县| 二连浩特市| 河津市| 鄂托克前旗| 寿光市| 上饶市| 胶南市|