ditaarb 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +64 -0
- data/lib/ditaarb/version.rb +3 -0
- data/lib/ditaarb.rb +45 -0
- data/vendor/ditaa0_9.jar +0 -0
- metadata +84 -0
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Ditaa
|
2
|
+
|
3
|
+
A simple wrapper around [ditaa](http://ditaa.sourceforge.net) to produce pngs out of ascii art
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'ditaarb'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install ditaarb
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'ditaarb'
|
25
|
+
|
26
|
+
File.open('diagram.png', 'w+') do |f|
|
27
|
+
f.write Ditaa.render(<<-ASCII)
|
28
|
+
/-------+
|
29
|
+
|Cluster|<----------------------------------+
|
30
|
+
+-------/ |
|
31
|
+
^ |
|
32
|
+
| |
|
33
|
+
+-------------------------+-------------------------+ |
|
34
|
+
: : : |
|
35
|
+
/---+---+ /---+---+ /---+---+ |
|
36
|
+
|Session| |Session| |Session| |
|
37
|
+
+-------/ +-------/ +-------/ |
|
38
|
+
^ ^ ^ |
|
39
|
+
| | | |
|
40
|
+
+------+-----+ +------+-----+ +------+-----+ |
|
41
|
+
: : : : : : |
|
42
|
+
/----+-----+ /----+-----+ /----+-----+ /----+-----+ /----+-----+ /----+-----+ |
|
43
|
+
|Connection| |Connection| |Connection| |Connection| |Connection| |Connection| |
|
44
|
+
+----+-----/ +----+-----/ +----+-----/ +----+-----/ +----+-----/ +----+-----/ |
|
45
|
+
: : : : : : |
|
46
|
+
+------------+-=----------+------+-----+-=----------+------------+ |
|
47
|
+
| |
|
48
|
+
v |
|
49
|
+
/----------+ |
|
50
|
+
|IO Reactor| |
|
51
|
+
+-----+----/ |
|
52
|
+
: |
|
53
|
+
+---------------------------------------+
|
54
|
+
ASCII
|
55
|
+
end
|
56
|
+
```
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
1. Fork it ( https://github.com/[my-github-username]/ditaarb/fork )
|
61
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
62
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
63
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
64
|
+
5. Create a new Pull Request
|
data/lib/ditaarb.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
3
|
+
module Ditaa
|
4
|
+
# @param ascii_art [String] original ascii diagram to render as image.
|
5
|
+
# @option options [Boolean] :antialiasing (true) Turns anti-aliasing on/off.
|
6
|
+
# @option options [Boolean] :debug (false) Renders the debug grid over the
|
7
|
+
# resulting image.
|
8
|
+
# @option options [Boolean] :separation (true) Prevents the separation of
|
9
|
+
# common edges of shapes.
|
10
|
+
# @option options [Boolean] :rounded_corneres (false) Causes all corners to
|
11
|
+
# be rendered as round.
|
12
|
+
# @option options [Numeric] :scale (1.0) A natural number that determines the
|
13
|
+
# size of the rendered image. The units are fractions of the default size
|
14
|
+
# (2.5 renders 1.5 times bigger than the default).
|
15
|
+
# @option options [Boolean] :shadows (true) Turns shadows on/off.
|
16
|
+
# @option options [Boolean] :tabs (false) Tabs are normally interpreted as 8
|
17
|
+
# spaces but it is possible to change that using this option. It is not
|
18
|
+
# advisable to use tabs in your diagrams.
|
19
|
+
# @return [String] processed image
|
20
|
+
def self.render(ascii_art, options = {})
|
21
|
+
ditaa_jar = File.expand_path(File.dirname(__FILE__) + '/../vendor/ditaa0_9.jar')
|
22
|
+
ditaa_jar << ' -A' if options[:antialiasing]
|
23
|
+
ditaa_jar << ' -d' if options[:debug]
|
24
|
+
ditaa_jar << ' -E' if options[:separation] == false
|
25
|
+
ditaa_jar << ' -r' if options[:rounded_corneres]
|
26
|
+
ditaa_jar << " -s #{options[:scale]}" if options[:scale]
|
27
|
+
ditaa_jar << ' -S' if options[:shadows] == false
|
28
|
+
ditaa_jar << ' -t' if options[:tabs]
|
29
|
+
|
30
|
+
input_file = Tempfile.new('ditaa.input')
|
31
|
+
input_file.write(ascii_art)
|
32
|
+
input_file.flush
|
33
|
+
|
34
|
+
output_file = Tempfile.new('ditaa.output')
|
35
|
+
|
36
|
+
pid = Process.spawn("java -jar #{ditaa_jar} -v #{input_file.path} #{output_file.path}", [:err, :out] => '/dev/null')
|
37
|
+
Process.wait(pid)
|
38
|
+
File.read(output_file.path)
|
39
|
+
ensure
|
40
|
+
input_file.close!
|
41
|
+
output_file.close!
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
require 'ditaarb/version'
|
data/vendor/ditaa0_9.jar
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ditaarb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Bulat Shakirzyanov
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-08-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
type: :development
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '1.6'
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.6'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
type: :development
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ~>
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '10.0'
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '10.0'
|
46
|
+
description: A wrapper around ditaa, to produce images from ascii art
|
47
|
+
email:
|
48
|
+
- mallluhuct@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- lib/ditaarb/version.rb
|
54
|
+
- lib/ditaarb.rb
|
55
|
+
- README.md
|
56
|
+
- vendor/ditaa0_9.jar
|
57
|
+
homepage: https://github.com/avalanche123/ditaarb
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements:
|
77
|
+
- java
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 1.8.23
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: A wrapper around ditaa, to produce images from ascii art
|
83
|
+
test_files: []
|
84
|
+
has_rdoc:
|