draw_uml 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e9e424fce3edd91c448e800ae8e84b4c07fb03f
4
- data.tar.gz: 8c6525c225b817c8f326b12f37d11f5779d8b72f
3
+ metadata.gz: 86908c27699847e4e49ecd3e0f4f76c25bc9d929
4
+ data.tar.gz: 98c770b3c7a3a49698f775b693033c3503e2a2e1
5
5
  SHA512:
6
- metadata.gz: 5fd3054cd9cf0d3f35a5ce03c6621d80378ac3e2e596b8fdba0adfdf3a13b75b7c5b8b9c9d893d5ce122f4d267c9891e32b98f532dcf6ad41f597b8d359023db
7
- data.tar.gz: 3d0dd57faaa43dca9a5eafc6d16ccf4bb0dae9e0510871c661e5f1772f6926dd37c96881f192aa5117bc20bf47ada7fd9e812519dfcdea1bb6f1d7dbf5fdcac2
6
+ metadata.gz: 8342d7334734b458e48e566614b1a78c94928b723cd3b3a1f8dfaaee46bf433d125d7c10e6f1e574c743517b53762e8f7e4772cf12b076c9b72e5ac41efcf21e
7
+ data.tar.gz: 459c443e3e93b395e3268cd107868a848d04f12691f9ccf646126129f105f033603f01a0f21a4f8f1708f379d1eb60a2c34b8c549c7e98c3349eeb82efd9c504
data/.gitignore CHANGED
@@ -1,6 +1,6 @@
1
1
  .bundle
2
- doc
3
- pkg
4
- public
5
- tmp
2
+ /doc
3
+ /pkg
4
+ /public
5
+ /tmp
6
6
  Gemfile.lock
data/config.ru CHANGED
@@ -1,3 +1,3 @@
1
1
  require_relative './lib/draw_uml'
2
- use Rack::Static, :urls => ['/images'], :root => "public"
2
+ use Rack::Static, urls: ['/images'], root: 'public'
3
3
  run DrawUml::Engine
@@ -0,0 +1,7 @@
1
+ @startuml
2
+ Alice -> Bob: Authentication Request
3
+ Bob --> Alice: Authentication Response
4
+
5
+ Alice -> Bob: Another authentication Request
6
+ Alice <-- Bob: another authentication Response
7
+ @enduml
data/lib/draw_uml.rb CHANGED
@@ -4,6 +4,7 @@ require_relative 'draw_uml/version'
4
4
  require_relative 'draw_uml/configure'
5
5
  require_relative 'draw_uml/default'
6
6
  require_relative 'draw_uml/engine'
7
+ require_relative 'draw_uml/tree'
7
8
  require_relative 'draw_uml/diagram'
8
9
 
9
10
  module DrawUml
@@ -13,8 +13,12 @@ module DrawUml
13
13
  @keys ||= %i[diagram_extension diagram_path static_path image_path]
14
14
  end
15
15
 
16
+ def source_path
17
+ File.expand_path(self.diagram_path)
18
+ end
19
+
16
20
  def source_file
17
- Dir[File.expand_path('**/*.' + self.diagram_extension, self.diagram_path)]
21
+ Dir[File.join(self.source_path, '**/*.' + self.diagram_extension)]
18
22
  end
19
23
 
20
24
  def dest_path
@@ -3,7 +3,7 @@ module DrawUml
3
3
  DIAGRAM_EXTENSION = 'uml'.freeze
4
4
  DIAGRAM_PATH = 'doc/diagrams/uml'.freeze
5
5
  STATIC_PATH = 'public'.freeze
6
- IMAGE_PATH = 'images/uml'.freeze
6
+ IMAGE_PATH = '/images/uml'.freeze
7
7
 
8
8
  class << self
9
9
  def options
@@ -1,18 +1,23 @@
1
1
  require 'rack'
2
2
  require 'erb'
3
+ require 'pp'
3
4
 
4
5
  module DrawUml
5
6
  class Engine
6
7
  class << self
7
8
  def call(env)
8
- params = Rack::Request.new(env).params
9
- id = params['id'].to_i ||= 0
9
+ request = Rack::Request.new(env)
10
+ id = request.params['id'].to_i ||= 0
11
+
12
+ # root = DrawUml::Tree.create(DrawUml::Configure.source_path)
13
+ # root.each do |node|
14
+ # end
10
15
 
11
16
  diagram = DrawUml::Diagram.new(DrawUml::Configure.dest_path)
12
17
  diagram.create(DrawUml::Configure.source_file[id])
13
18
 
14
19
  files = DrawUml::Configure.source_file.map { |file| File.basename(file, '.*') }
15
- path = File.join(DrawUml::Configure.image_path, files[id] + '.png')
20
+ image_path = File.join(DrawUml::Configure.image_path, files[id] + '.png')
16
21
 
17
22
  erb = ERB.new(DrawUml::Configure.application_template)
18
23
  body = erb.result(binding)
@@ -0,0 +1,10 @@
1
+ require_relative 'tree/leaf'
2
+ require_relative 'tree/branch'
3
+
4
+ module DrawUml
5
+ module Tree
6
+ def self.create(path)
7
+ DrawUml::Tree::Branch.new(path)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,32 @@
1
+ module DrawUml
2
+ module Tree
3
+ class Branch < DrawUml::Tree::Leaf
4
+ attr_reader :entries
5
+
6
+ def initialize(name)
7
+ @entries = []
8
+ super
9
+ node
10
+ end
11
+
12
+ def each(&block)
13
+ entries.each do |entry|
14
+ block.call(entry)
15
+ entry.each(&block) if entry.is_a?(DrawUml::Tree::Branch)
16
+ end
17
+ end
18
+
19
+ private
20
+ def node
21
+ Dir[File.join(path, '*')].each do |path|
22
+ if File.directory?(path)
23
+ entries << DrawUml::Tree::Branch.new(path)
24
+ else
25
+ entries << DrawUml::Tree::Leaf.new(path)
26
+ end
27
+ end
28
+ end
29
+ # end private
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,12 @@
1
+ module DrawUml
2
+ module Tree
3
+ class Leaf
4
+ attr_reader :name, :path
5
+
6
+ def initialize(name)
7
+ @name = File.basename(name, '.*')
8
+ @path = File.expand_path(name)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module DrawUml
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -1,15 +1,29 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title>UML</title>
3
+ <head><title>Diagrams</title>
4
+ <style type="text/css">
5
+ div.diagrams {
6
+ padding-top: 20px;
7
+ float:left;
8
+ }
9
+
10
+ div.draw img {
11
+ padding-top: 40px;
12
+ padding-left: 80px;
13
+ }
14
+ </style>
5
15
  </head>
6
16
  <body>
7
17
 
8
- <% files.each_with_index do |item, idx| %>
9
- <a href="./?id=<%= idx %>"><%= item %></a><br>
10
- <% end %>
18
+ <div class='diagrams'>
19
+ <% files.each_with_index do |item, idx| %>
20
+ <a href="<%= request.path %>?id=<%= idx %>"><%= item %></a><br>
21
+ <% end %>
22
+ </div>
11
23
 
12
- <img src=<%= path %>>
24
+ <div class='draw'>
25
+ <img src=<%= image_path %>>
26
+ </div>
13
27
 
14
28
  </body>
15
29
  </html>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: draw_uml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ogom
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-08 00:00:00.000000000 Z
11
+ date: 2014-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -68,11 +68,15 @@ files:
68
68
  - config.ru
69
69
  - draw_uml.gemspec
70
70
  - example/bin/draw_uml
71
+ - example/doc/diagrams/uml/sequence.uml
71
72
  - lib/draw_uml.rb
72
73
  - lib/draw_uml/configure.rb
73
74
  - lib/draw_uml/default.rb
74
75
  - lib/draw_uml/diagram.rb
75
76
  - lib/draw_uml/engine.rb
77
+ - lib/draw_uml/tree.rb
78
+ - lib/draw_uml/tree/branch.rb
79
+ - lib/draw_uml/tree/leaf.rb
76
80
  - lib/draw_uml/version.rb
77
81
  - lib/templates/layouts/application.html.erb
78
82
  - spec/lib/version_spec.rb