ditaarb 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +15 -0
  2. data/README.md +1 -1
  3. data/lib/ditaarb.rb +62 -21
  4. data/lib/ditaarb/version.rb +1 -1
  5. metadata +11 -17
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NDVhYmYxNjBmOTM4ZTgwMTlmNTM0YzE3YWZmZjQyM2RlMzkxNGJlMQ==
5
+ data.tar.gz: !binary |-
6
+ YjRjOGFkMjQ5MWU3MGU3YmM3ZDA0MGRiMmFlNzUyY2UyZTgxYTg2OQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NWI5Y2QxZTZmNDQ4MDRmZTM5MjNmZmY4MDE5NDQ0NDQxYTQxYjg4ZTk2Y2Yw
10
+ ZDMzNDI2YmZmMGI3ZjM2MmNjZTY3MTQwMDFjOWE2YzNlNjEwNjlmYzE2ZWFm
11
+ MThhNTRhNGVlMDI1YWY2ZTc4NTRiY2EyZDEyYzhjNzFhOGJlNzA=
12
+ data.tar.gz: !binary |-
13
+ ZDZlODVjNWJjODFjMzhiNTg4ZGEwMTkxNjJkOTFmYTFhOTM1ZWVkZTM3MzJl
14
+ MzE1OGJiZGMyN2E3YjAxMjYwM2Q1MjlkNzU0OWU4ZmRhMTAyZTE1MTMzOWNm
15
+ OWU2MzAxYjc1Njk3Yjk5NjFhNDI2ODUzZTVjYjBjNjM0NDA1YmI=
data/README.md CHANGED
@@ -57,7 +57,7 @@ end
57
57
 
58
58
  ## Contributing
59
59
 
60
- 1. Fork it ( https://github.com/[my-github-username]/ditaarb/fork )
60
+ 1. Fork it ( https://github.com/avalanche123/ditaarb/fork )
61
61
  2. Create your feature branch (`git checkout -b my-new-feature`)
62
62
  3. Commit your changes (`git commit -am 'Add some feature'`)
63
63
  4. Push to the branch (`git push origin my-new-feature`)
data/lib/ditaarb.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require 'tempfile'
2
+ require 'tmpdir'
3
+ require 'digest'
2
4
 
3
5
  module Ditaa
4
6
  # @param ascii_art [String] original ascii diagram to render as image.
@@ -18,28 +20,67 @@ module Ditaa
18
20
  # advisable to use tabs in your diagrams.
19
21
  # @return [String] processed image
20
22
  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!
23
+ filename = File.join(Dir.tmpdir, 'ditaarb-' + Digest::MD5.hexdigest(ascii_art) + '.tmp')
24
+
25
+ return File.read(filename) if File.exists?(filename)
26
+
27
+ begin
28
+ input_file = Tempfile.new('ditaa.input')
29
+ input_file.write(ascii_art)
30
+ input_file.flush
31
+
32
+ args = ['java', '-jar']
33
+ args << File.expand_path(__FILE__ + '/../../vendor/ditaa0_9.jar')
34
+ args << '-A' if options[:antialiasing]
35
+ args << '-d' if options[:debug]
36
+ args << '-E' if options[:separation] == false
37
+ args << '-r' if options[:rounded_corneres]
38
+ args << '-s' << options[:scale] if options[:scale]
39
+ args << '-S' if options[:shadows] == false
40
+ args << '-t' if options[:tabs]
41
+ args << '-v'
42
+ args << input_file.path
43
+ args << filename
44
+ args << { [:err, :out] => '/dev/null' }
45
+
46
+ system(*args)
47
+ ensure
48
+ input_file.close!
49
+ end
50
+
51
+ File.read(filename)
42
52
  end
43
53
  end
44
54
 
45
55
  require 'ditaarb/version'
56
+
57
+ File.open('diagram.png', 'w+') do |f|
58
+ f.write Ditaa.render(<<-ASCII)
59
+ /-------+
60
+ |Cluster|<----------------------------------+
61
+ +-------/ |
62
+ ^ |
63
+ | |
64
+ +-------------------------+-------------------------+ |
65
+ : : : |
66
+ /---+---+ /---+---+ /---+---+ |
67
+ |Session| |Session| |Session| |
68
+ +-------/ +-------/ +-------/ |
69
+ ^ ^ ^ |
70
+ | | | |
71
+ +------+-----+ +------+-----+ +------+-----+ |
72
+ : : : : : : |
73
+ /----+-----+ /----+-----+ /----+-----+ /----+-----+ /----+-----+ /----+-----+ |
74
+ |Connection| |Connection| |Connection| |Connection| |Connection| |Connection| |
75
+ +----+-----/ +----+-----/ +----+-----/ +----+-----/ +----+-----/ +----+-----/ |
76
+ : : : : : : |
77
+ +------------+-=----------+------+-----+-=----------+------------+ |
78
+ | |
79
+ v |
80
+ /----------+ |
81
+ |IO Reactor| |
82
+ +-----+----/ |
83
+ : |
84
+ +---------------------------------------+
85
+ ASCII
86
+ end
@@ -1,3 +1,3 @@
1
1
  module Ditaa
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,44 +1,39 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ditaarb
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.1.1
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Bulat Shakirzyanov
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-08-28 00:00:00.000000000 Z
11
+ date: 2015-01-23 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
- type: :development
17
15
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
16
  requirements:
20
17
  - - ~>
21
18
  - !ruby/object:Gem::Version
22
19
  version: '1.6'
20
+ type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.6'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
- type: :development
33
29
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
30
  requirements:
36
31
  - - ~>
37
32
  - !ruby/object:Gem::Version
38
33
  version: '10.0'
34
+ type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -50,35 +45,34 @@ executables: []
50
45
  extensions: []
51
46
  extra_rdoc_files: []
52
47
  files:
53
- - lib/ditaarb/version.rb
54
- - lib/ditaarb.rb
55
48
  - README.md
49
+ - lib/ditaarb.rb
50
+ - lib/ditaarb/version.rb
56
51
  - vendor/ditaa0_9.jar
57
52
  homepage: https://github.com/avalanche123/ditaarb
58
53
  licenses:
59
54
  - MIT
55
+ metadata: {}
60
56
  post_install_message:
61
57
  rdoc_options: []
62
58
  require_paths:
63
59
  - lib
64
60
  required_ruby_version: !ruby/object:Gem::Requirement
65
- none: false
66
61
  requirements:
67
- - - '>='
62
+ - - ! '>='
68
63
  - !ruby/object:Gem::Version
69
64
  version: '0'
70
65
  required_rubygems_version: !ruby/object:Gem::Requirement
71
- none: false
72
66
  requirements:
73
- - - '>='
67
+ - - ! '>='
74
68
  - !ruby/object:Gem::Version
75
69
  version: '0'
76
70
  requirements:
77
71
  - java
78
72
  rubyforge_project:
79
- rubygems_version: 1.8.23
73
+ rubygems_version: 2.4.2
80
74
  signing_key:
81
- specification_version: 3
75
+ specification_version: 4
82
76
  summary: A wrapper around ditaa, to produce images from ascii art
83
77
  test_files: []
84
78
  has_rdoc: