draw_uml 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/example/bin/draw_uml +12 -0
- data/lib/draw_uml.rb +22 -0
- data/lib/draw_uml/configure.rb +33 -0
- data/lib/draw_uml/default.rb +30 -0
- data/lib/draw_uml/diagram.rb +9 -5
- data/lib/draw_uml/engine.rb +10 -6
- data/lib/draw_uml/version.rb +1 -1
- data/lib/templates/layouts/application.html.erb +4 -0
- metadata +6 -6
- data/bin/draw_uml +0 -5
- data/doc/uml/sequence.md +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e9e424fce3edd91c448e800ae8e84b4c07fb03f
|
4
|
+
data.tar.gz: 8c6525c225b817c8f326b12f37d11f5779d8b72f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fd3054cd9cf0d3f35a5ce03c6621d80378ac3e2e596b8fdba0adfdf3a13b75b7c5b8b9c9d893d5ce122f4d267c9891e32b98f532dcf6ad41f597b8d359023db
|
7
|
+
data.tar.gz: 3d0dd57faaa43dca9a5eafc6d16ccf4bb0dae9e0510871c661e5f1772f6926dd37c96881f192aa5117bc20bf47ada7fd9e812519dfcdea1bb6f1d7dbf5fdcac2
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative '../../lib/draw_uml'
|
4
|
+
|
5
|
+
DrawUml.configure do |config|
|
6
|
+
config.diagram_path = 'example/doc/diagrams/uml'
|
7
|
+
end
|
8
|
+
|
9
|
+
diagram = DrawUml::Diagram.new(DrawUml::Configure.dest_path)
|
10
|
+
DrawUml::Configure.source_file.each do |file|
|
11
|
+
diagram.create(file)
|
12
|
+
end
|
data/lib/draw_uml.rb
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
1
3
|
require_relative 'draw_uml/version'
|
4
|
+
require_relative 'draw_uml/configure'
|
5
|
+
require_relative 'draw_uml/default'
|
2
6
|
require_relative 'draw_uml/engine'
|
3
7
|
require_relative 'draw_uml/diagram'
|
8
|
+
|
9
|
+
module DrawUml
|
10
|
+
class << self
|
11
|
+
def configure
|
12
|
+
yield DrawUml::Configure
|
13
|
+
end
|
14
|
+
|
15
|
+
def config
|
16
|
+
DrawUml::Configure
|
17
|
+
end
|
18
|
+
|
19
|
+
def root
|
20
|
+
@root ||= Pathname.new(File.expand_path('../', File.dirname(__FILE__)))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
DrawUml::Configure.setup
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module DrawUml
|
2
|
+
module Configure
|
3
|
+
class << self
|
4
|
+
attr_accessor :diagram_extension, :diagram_path, :static_path, :image_path
|
5
|
+
|
6
|
+
def setup
|
7
|
+
keys.each do |key|
|
8
|
+
instance_variable_set(:"@#{key}", DrawUml::Default.send(key))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def keys
|
13
|
+
@keys ||= %i[diagram_extension diagram_path static_path image_path]
|
14
|
+
end
|
15
|
+
|
16
|
+
def source_file
|
17
|
+
Dir[File.expand_path('**/*.' + self.diagram_extension, self.diagram_path)]
|
18
|
+
end
|
19
|
+
|
20
|
+
def dest_path
|
21
|
+
File.expand_path(File.join(self.static_path, self.image_path))
|
22
|
+
end
|
23
|
+
|
24
|
+
def templates_path
|
25
|
+
DrawUml.root.join('lib', 'templates').to_s
|
26
|
+
end
|
27
|
+
|
28
|
+
def application_template
|
29
|
+
File.read(File.expand_path('application.html.erb', File.join(self.templates_path, 'layouts')))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module DrawUml
|
2
|
+
module Default
|
3
|
+
DIAGRAM_EXTENSION = 'uml'.freeze
|
4
|
+
DIAGRAM_PATH = 'doc/diagrams/uml'.freeze
|
5
|
+
STATIC_PATH = 'public'.freeze
|
6
|
+
IMAGE_PATH = 'images/uml'.freeze
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def options
|
10
|
+
Hash[DrawUml::Configure.keys.map{|key| [key, send(key)]}]
|
11
|
+
end
|
12
|
+
|
13
|
+
def diagram_extension
|
14
|
+
DIAGRAM_EXTENSION
|
15
|
+
end
|
16
|
+
|
17
|
+
def diagram_path
|
18
|
+
DIAGRAM_PATH
|
19
|
+
end
|
20
|
+
|
21
|
+
def static_path
|
22
|
+
STATIC_PATH
|
23
|
+
end
|
24
|
+
|
25
|
+
def image_path
|
26
|
+
IMAGE_PATH
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/draw_uml/diagram.rb
CHANGED
@@ -2,12 +2,16 @@ require 'open3'
|
|
2
2
|
|
3
3
|
module DrawUml
|
4
4
|
class Diagram
|
5
|
-
def
|
6
|
-
|
7
|
-
|
5
|
+
def initialize(path)
|
6
|
+
@path = path
|
7
|
+
FileUtils.mkdir_p(@path)
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
def create(file)
|
11
|
+
raw = File.read(file)
|
12
|
+
filename = File.basename(file, '.*')
|
13
|
+
cmd = 'plantuml -pipe > ' + File.join(@path, filename + '.png')
|
14
|
+
stdout, status = Open3.capture2(cmd, stdin_data: raw)
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
data/lib/draw_uml/engine.rb
CHANGED
@@ -5,16 +5,20 @@ module DrawUml
|
|
5
5
|
class Engine
|
6
6
|
class << self
|
7
7
|
def call(env)
|
8
|
-
|
8
|
+
params = Rack::Request.new(env).params
|
9
|
+
id = params['id'].to_i ||= 0
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
diagram = DrawUml::Diagram.new(DrawUml::Configure.dest_path)
|
12
|
+
diagram.create(DrawUml::Configure.source_file[id])
|
13
|
+
|
14
|
+
files = DrawUml::Configure.source_file.map { |file| File.basename(file, '.*') }
|
15
|
+
path = File.join(DrawUml::Configure.image_path, files[id] + '.png')
|
12
16
|
|
13
|
-
|
14
|
-
path = File.join('images', 'draw-uml', 'sequence.png')
|
15
|
-
erb = ERB.new(file)
|
17
|
+
erb = ERB.new(DrawUml::Configure.application_template)
|
16
18
|
body = erb.result(binding)
|
17
19
|
|
20
|
+
status = 200
|
21
|
+
headers = {'Content-Type' => 'text/html'}
|
18
22
|
[status, headers, [body]]
|
19
23
|
end
|
20
24
|
end
|
data/lib/draw_uml/version.rb
CHANGED
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.2
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -55,8 +55,7 @@ dependencies:
|
|
55
55
|
description: Drawing the Unified Modeling Language of Rack.
|
56
56
|
email:
|
57
57
|
- ogom@hotmail.co.jp
|
58
|
-
executables:
|
59
|
-
- draw_uml
|
58
|
+
executables: []
|
60
59
|
extensions: []
|
61
60
|
extra_rdoc_files: []
|
62
61
|
files:
|
@@ -66,11 +65,12 @@ files:
|
|
66
65
|
- LICENSE.txt
|
67
66
|
- README.md
|
68
67
|
- Rakefile
|
69
|
-
- bin/draw_uml
|
70
68
|
- config.ru
|
71
|
-
- doc/uml/sequence.md
|
72
69
|
- draw_uml.gemspec
|
70
|
+
- example/bin/draw_uml
|
73
71
|
- lib/draw_uml.rb
|
72
|
+
- lib/draw_uml/configure.rb
|
73
|
+
- lib/draw_uml/default.rb
|
74
74
|
- lib/draw_uml/diagram.rb
|
75
75
|
- lib/draw_uml/engine.rb
|
76
76
|
- lib/draw_uml/version.rb
|
data/bin/draw_uml
DELETED