draw_uml 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/draw_uml/configure.rb +0 -4
- data/lib/draw_uml/default.rb +2 -2
- data/lib/draw_uml/diagram.rb +10 -4
- data/lib/draw_uml/engine.rb +25 -43
- data/lib/draw_uml/tree/branch.rb +7 -0
- data/lib/draw_uml/tree/leaf.rb +4 -1
- data/lib/draw_uml/version.rb +1 -1
- data/lib/templates/layouts/application.html.erb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ceb3e8989bb14bc8cf5566082e8141a34f5b27a9
|
4
|
+
data.tar.gz: b3b09a7a300aea789dd171453d54d64f62a1ce72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af9528a752388a7dae0584c702968363a5f6ae2b7d616c33eae1bbea014c56fefc6114b5ea0e8fb65efef339e07280c47aad9192ccf3a1b092019c2640ed2d39
|
7
|
+
data.tar.gz: 628067ce7c291d5c5c30ba9878fd7f4302dc2af990ccae4d2c4afb162d07f70a1d49d3e4904346ad216e291a0c6c4b055004e393a2607749e030760b18c94719
|
data/lib/draw_uml/configure.rb
CHANGED
data/lib/draw_uml/default.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module DrawUml
|
2
2
|
module Default
|
3
3
|
DIAGRAM_EXTENSION = 'uml'.freeze
|
4
|
-
DIAGRAM_PATH = 'doc/diagrams
|
4
|
+
DIAGRAM_PATH = 'doc/diagrams'.freeze
|
5
5
|
STATIC_PATH = 'public'.freeze
|
6
|
-
IMAGE_PATH = '/images/
|
6
|
+
IMAGE_PATH = '/images/draw_uml'.freeze
|
7
7
|
|
8
8
|
class << self
|
9
9
|
def options
|
data/lib/draw_uml/diagram.rb
CHANGED
@@ -7,11 +7,17 @@ module DrawUml
|
|
7
7
|
FileUtils.mkdir_p(@path)
|
8
8
|
end
|
9
9
|
|
10
|
-
def create(
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
def create(path)
|
11
|
+
file = File.join(@path, path + '.png')
|
12
|
+
raw = File.read(File.join(config.source_path, path + '.' + config.diagram_extension))
|
13
|
+
FileUtils.mkdir_p(File.dirname(file))
|
14
|
+
|
15
|
+
cmd = 'plantuml -pipe > ' + file
|
14
16
|
stdout, status = Open3.capture2(cmd, stdin_data: raw)
|
15
17
|
end
|
18
|
+
|
19
|
+
def config
|
20
|
+
DrawUml::Configure
|
21
|
+
end
|
16
22
|
end
|
17
23
|
end
|
data/lib/draw_uml/engine.rb
CHANGED
@@ -6,14 +6,13 @@ module DrawUml
|
|
6
6
|
class << self
|
7
7
|
def call(env)
|
8
8
|
@request = Rack::Request.new(env)
|
9
|
-
|
10
|
-
|
9
|
+
id = @request.params['id'] ||= nil
|
10
|
+
path = nil
|
11
11
|
|
12
|
-
unless
|
12
|
+
unless id.nil?
|
13
13
|
diagram = DrawUml::Diagram.new(DrawUml::Configure.dest_path)
|
14
|
-
diagram.create(
|
15
|
-
|
16
|
-
image_path = File.join(DrawUml::Configure.image_path, file + '.png')
|
14
|
+
diagram.create(id)
|
15
|
+
path = File.join(DrawUml::Configure.image_path, id + '.png')
|
17
16
|
end
|
18
17
|
|
19
18
|
erb = ERB.new(DrawUml::Configure.application_template)
|
@@ -24,46 +23,29 @@ module DrawUml
|
|
24
23
|
[status, headers, [body]]
|
25
24
|
end
|
26
25
|
|
27
|
-
def tree
|
28
|
-
@raw = ''
|
29
|
-
branch(DrawUml::Tree.create(DrawUml::Configure.source_path))
|
30
|
-
@raw
|
31
|
-
end
|
32
|
-
|
33
|
-
def branch(node)
|
34
|
-
@raw += "<div style=\"padding-left: #{node.level}0px;\">\n"
|
35
|
-
@raw += "<h3>#{node.name}</h3>\n"
|
36
|
-
arr = []
|
37
|
-
node.entries.each do |entry|
|
38
|
-
if entry.leaf?
|
39
|
-
arr << entry
|
40
|
-
else
|
41
|
-
branch(entry)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
@raw += "<ul>"
|
45
|
-
@raw += arr.map do |entry|
|
46
|
-
link_to(entry)
|
47
|
-
end.join("\n")
|
48
|
-
@raw += "</ul></div>\n"
|
49
|
-
end
|
50
|
-
|
51
26
|
private
|
52
|
-
def
|
53
|
-
raw = ''
|
54
|
-
|
55
|
-
raw
|
56
|
-
raw += "#{contract_path(entry.path)}>#{entry.name}</a>"
|
57
|
-
raw += "</li>"
|
58
|
-
raw
|
59
|
-
end
|
60
|
-
|
61
|
-
def contract_path(path)
|
62
|
-
path.sub(DrawUml::Configure.parent_path, '')
|
27
|
+
def diagrams
|
28
|
+
@raw = ''
|
29
|
+
branch(DrawUml::Tree.create(DrawUml::Configure.source_path))
|
30
|
+
@raw
|
63
31
|
end
|
64
32
|
|
65
|
-
def
|
66
|
-
|
33
|
+
def branch(node)
|
34
|
+
@raw += "<div style=\"padding-left: #{node.level}0px;\">\n"
|
35
|
+
@raw += "<h3>#{node.name}</h3>\n"
|
36
|
+
arr = []
|
37
|
+
node.entries.each do |entry|
|
38
|
+
if entry.leaf?
|
39
|
+
arr << entry
|
40
|
+
else
|
41
|
+
branch(entry)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
@raw += "<ul>"
|
45
|
+
@raw += arr.map do |entry|
|
46
|
+
"<li><a href=#{@request.path}?id=#{entry.id}>#{entry.name}</a></li>"
|
47
|
+
end.join("\n")
|
48
|
+
@raw += "</ul></div>\n"
|
67
49
|
end
|
68
50
|
# end private
|
69
51
|
end
|
data/lib/draw_uml/tree/branch.rb
CHANGED
data/lib/draw_uml/tree/leaf.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
module DrawUml
|
2
2
|
module Tree
|
3
3
|
class Leaf
|
4
|
-
attr_reader :name, :path, :level
|
4
|
+
attr_reader :name, :path, :level, :id
|
5
5
|
|
6
6
|
def initialize(name, level=0)
|
7
7
|
@name = File.basename(name, '.*')
|
8
8
|
@path = File.expand_path(name)
|
9
9
|
@level = level
|
10
|
+
|
11
|
+
raw = path.sub(DrawUml::Configure.source_path, '')
|
12
|
+
@id = raw.sub('.' + DrawUml::Configure.diagram_extension, '')
|
10
13
|
end
|
11
14
|
|
12
15
|
def leaf?
|
data/lib/draw_uml/version.rb
CHANGED
@@ -25,7 +25,7 @@
|
|
25
25
|
h2 { padding-left: 10px; }
|
26
26
|
h3 { padding-left: 10px; }
|
27
27
|
|
28
|
-
div.
|
28
|
+
div.diagrams {
|
29
29
|
float:left;
|
30
30
|
}
|
31
31
|
|
@@ -38,12 +38,12 @@
|
|
38
38
|
<body>
|
39
39
|
<h2>Unified Modeling Language</h2>
|
40
40
|
|
41
|
-
<div class='
|
42
|
-
<%=
|
41
|
+
<div class='diagrams'>
|
42
|
+
<%= diagrams %>
|
43
43
|
</div>
|
44
44
|
|
45
45
|
<div class='draw'>
|
46
|
-
<img src=<%=
|
46
|
+
<img src=<%= path %>>
|
47
47
|
</div>
|
48
48
|
</body>
|
49
49
|
</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.
|
4
|
+
version: 0.0.5
|
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-
|
11
|
+
date: 2014-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|