ruby-graphviz 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
data/AUTHORS CHANGED
@@ -2,6 +2,7 @@ Gregoire Lejeune <glejeune.lejeune@free.fr>
2
2
  Brandon Coleman <metrix1978@gmail.com>
3
3
  Dave Burt <http://github.com/dburt>
4
4
  Miguel Cabrera <http://mfcabrera.com>
5
+ obruening <http://github.com/obruening>
5
6
 
6
7
  Thanks to :
7
8
 
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ 0.9.6 :
2
+ * jRuby support (by obruening)
3
+ * Issue #1 : STDOUT in binmode
4
+
1
5
  0.9.5 :
2
6
  * Remove 'mkmf' dependency
3
7
  * GraphViz::Edge#[] modification
data/examples/maketest.sh CHANGED
@@ -1,36 +1,36 @@
1
1
  #!/bin/sh
2
2
 
3
3
  echo "arrowhead.rb"
4
- ruby arrowhead.rb $1
4
+ ruby arrowhead.rb
5
5
  echo "HTML-Labels.rb"
6
6
  ruby HTML-Labels.rb
7
7
  echo "p2p.rb"
8
- ruby p2p.rb $1
8
+ ruby p2p.rb
9
9
 
10
10
  echo "sample01.rb"
11
- ruby sample01.rb $1
11
+ ruby sample01.rb
12
12
  echo "sample02.rb"
13
- ruby sample02.rb $1
13
+ ruby sample02.rb
14
14
  echo "sample03.rb"
15
- ruby sample03.rb $1
15
+ ruby sample03.rb
16
16
  echo "sample04.rb"
17
- ruby sample04.rb $1
17
+ ruby sample04.rb
18
18
  echo "sample05.rb"
19
- ruby sample05.rb $1
19
+ ruby sample05.rb
20
20
  echo "sample06.rb"
21
21
  ruby sample06.rb
22
22
  echo "sample07.rb"
23
- ruby sample07.rb $1
23
+ ruby sample07.rb
24
24
  echo "sample08.rb"
25
- ruby sample08.rb $1
25
+ ruby sample08.rb
26
26
  echo "sample09.rb"
27
- ruby sample09.rb $1
27
+ ruby sample09.rb
28
28
  echo "sample10.rb"
29
- ruby sample10.rb $1
29
+ ruby sample10.rb
30
30
  echo "sample11.rb"
31
- ruby sample11.rb $1
31
+ ruby sample11.rb
32
32
  echo "sample12.rb"
33
- ruby sample12.rb $1
33
+ ruby sample12.rb
34
34
  echo "sample13.rb"
35
35
  ruby sample13.rb
36
36
  echo "sample14.rb"
@@ -59,11 +59,11 @@ echo "sample25.rb"
59
59
  ruby sample25.rb
60
60
 
61
61
  echo "shapes.rb"
62
- ruby shapes.rb $1
62
+ ruby shapes.rb
63
63
  echo "testorder.rb"
64
- ruby testorder.rb $1
64
+ ruby testorder.rb
65
65
  echo "testxml.rb"
66
- ruby testxml.rb $1
66
+ ruby testxml.rb
67
67
 
68
68
  cd dot
69
69
  pwd
data/lib/graphviz.rb CHANGED
@@ -14,6 +14,15 @@
14
14
  # along with this program; if not, write to the Free Software
15
15
  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
16
 
17
+
18
+ begin
19
+ include Java
20
+ IS_JRUBY = true
21
+ rescue
22
+ IS_JRUBY= false
23
+ end
24
+
25
+
17
26
  require 'tempfile'
18
27
  # require 'mkmf'
19
28
 
@@ -369,6 +378,7 @@ class GraphViz
369
378
  else
370
379
  Tempfile::open( File.basename($0) )
371
380
  end
381
+
372
382
  t.print( xDOTScript )
373
383
  t.close
374
384
 
@@ -376,7 +386,9 @@ class GraphViz
376
386
  if cmd == nil
377
387
  raise StandardError, "GraphViz not installed or #{@prog} not in PATH. Install GraphViz or use the 'path' option"
378
388
  end
379
-
389
+
390
+ cmd = escape_path_containing_blanks(cmd) if IS_JRUBY
391
+
380
392
  xOutputWithFile = ""
381
393
  xOutputWithoutFile = ""
382
394
  unless @format.nil?
@@ -402,7 +414,12 @@ class GraphViz
402
414
 
403
415
  #xCmd = "#{cmd} #{xOutputWithFile} #{xOutputWithoutFile} #{t.path}"
404
416
  #if /Windows/.match( ENV['OS'] )
417
+
418
+ if IS_JRUBY
419
+ xCmd = "#{cmd} -q#{@errors} #{xOutputWithFile} #{xOutputWithoutFile} #{t.path}"
420
+ else
405
421
  xCmd = "\"#{cmd}\" -q#{@errors} #{xOutputWithFile} #{xOutputWithoutFile} #{t.path}"
422
+ end
406
423
  #end
407
424
 
408
425
  output_from_command( xCmd )
@@ -419,7 +436,7 @@ class GraphViz
419
436
  end
420
437
 
421
438
  alias :save :output
422
-
439
+
423
440
  def output_and_errors_from_command(cmd) #:nodoc:
424
441
  unless defined? Open3
425
442
  begin
@@ -431,10 +448,12 @@ class GraphViz
431
448
  begin
432
449
  Open3.popen3( cmd ) do |stdin, stdout, stderr|
433
450
  stdin.close
451
+ stdout.binmode
434
452
  [stdout.read, stderr.read]
435
453
  end
436
454
  rescue NotImplementedError, NoMethodError
437
455
  IO.popen( cmd ) do |stdout|
456
+ stdout.binmode
438
457
  [stdout.read, nil]
439
458
  end
440
459
  end
@@ -660,7 +679,7 @@ class GraphViz
660
679
  # purpose with or without fee is hereby granted, provided that the above
661
680
  # copyright notice and this permission notice appear in all copies.
662
681
  #
663
- # THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
682
+ # THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
664
683
  # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
665
684
  # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
666
685
  # SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
@@ -668,14 +687,41 @@ class GraphViz
668
687
  # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
669
688
  # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
670
689
  def find_executable(bin = @prog, *paths) #:nodoc:
690
+
671
691
  paths = ENV['PATH'].split(File::PATH_SEPARATOR) if paths.empty?
672
692
  paths.each do |path|
673
- file = File.join(path,bin)
693
+ file = File.join(path, add_exe_suffix(bin))
674
694
  if File.executable?(file) then
675
695
  return file
676
696
  end
677
697
  end
678
698
  return nil
679
699
  end
700
+
701
+
702
+ def add_exe_suffix(prog)
703
+ if /Windows/.match( ENV['OS'] )
704
+ suffix = '.exe'
705
+ else
706
+ suffix = ''
707
+ end
708
+ "#{prog}#{suffix}"
709
+ end
710
+
711
+
712
+ def escape_path_containing_blanks(path)
713
+ path.gsub!(File::ALT_SEPARATOR, File::SEPARATOR)
714
+ path_elements = path.split(File::SEPARATOR)
715
+ path_elements.map! do |element|
716
+ if element.include?(' ')
717
+ "\"#{element}\""
718
+ else
719
+ element
720
+ end
721
+ end
722
+ path_elements.join(File::SEPARATOR)
723
+ end
724
+
725
+
680
726
  end
681
727
 
@@ -15,7 +15,7 @@
15
15
  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
16
 
17
17
  module Constants
18
- RGV_VERSION = "0.9.5"
18
+ RGV_VERSION = "0.9.6"
19
19
 
20
20
  ## Const: Output formats
21
21
  FORMATS = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-graphviz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregoire Lejeune
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-17 00:00:00 +01:00
12
+ date: 2009-12-05 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency