rghost 0.8.7.2 → 0.8.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rghost/callback.rb +2 -2
- data/lib/rghost/color.rb +12 -12
- data/lib/rghost/font.rb +3 -3
- data/lib/rghost/image.rb +7 -4
- data/lib/rghost/paper.rb +7 -7
- data/lib/rghost/parse_text.rb +2 -2
- data/lib/rghost/ps_facade.rb +1 -1
- data/lib/rghost/ruby_ghost_config.rb +4 -2
- data/lib/rghost/ruby_ghost_engine.rb +8 -8
- data/lib/rghost/ruby_to_ps.rb +7 -7
- metadata +23 -12
data/lib/rghost/callback.rb
CHANGED
data/lib/rghost/color.rb
CHANGED
@@ -35,13 +35,13 @@ class RGhost::Color < RGhost::PsObject
|
|
35
35
|
def self.create(color="FFAA99")
|
36
36
|
|
37
37
|
return case color
|
38
|
-
when String
|
39
|
-
when Symbol
|
38
|
+
when String then RGhost::RGB.new(color)
|
39
|
+
when Symbol then
|
40
40
|
c=RGhost::Constants::Colors::RGB[color]
|
41
41
|
raise ArgumentError.new("#{color}##{color.class}") unless c
|
42
42
|
self.create c
|
43
43
|
|
44
|
-
when Array, Hash
|
44
|
+
when Array, Hash then
|
45
45
|
if color.size == 3
|
46
46
|
RGhost::RGB.new(color)
|
47
47
|
elsif color.size == 4
|
@@ -51,7 +51,7 @@ class RGhost::Color < RGhost::PsObject
|
|
51
51
|
else
|
52
52
|
raise ArgumentError.new("#{color}##{color.class}")
|
53
53
|
end
|
54
|
-
when Numeric
|
54
|
+
when Numeric then RGhost::Gray.new(color)
|
55
55
|
else
|
56
56
|
raise ArgumentError.new("#{color}##{color.class}")
|
57
57
|
end
|
@@ -93,10 +93,10 @@ class RGhost::RGB < RGhost::Color
|
|
93
93
|
end
|
94
94
|
def color_params
|
95
95
|
case @color
|
96
|
-
when Hash
|
97
|
-
when Array
|
98
|
-
when String
|
99
|
-
when NilClass
|
96
|
+
when Hash then [@color[:red] || @color[:r],@color[:green] || @color[:g],@color[:blue] || @color[:b]]
|
97
|
+
when Array then @color
|
98
|
+
when String then hex_to_rgb(@color)
|
99
|
+
when NilClass then [0,0,1]
|
100
100
|
end
|
101
101
|
|
102
102
|
|
@@ -126,8 +126,8 @@ class RGhost::CMYK < RGhost::Color
|
|
126
126
|
|
127
127
|
def ps
|
128
128
|
value=case @color
|
129
|
-
when Hash
|
130
|
-
when Array
|
129
|
+
when Hash then [@color[:cyan] || @color[:c],@color[:magenta] || @color[:m],@color[:yellow] || @color[:y],@color[:black] || @color[:k]]
|
130
|
+
when Array then @color
|
131
131
|
end
|
132
132
|
|
133
133
|
array_to_stack(value.map{|n| n > 1 ? n/100.0: n})+"setcmykcolor"
|
@@ -147,8 +147,8 @@ class RGhost::CMYKSpot < RGhost::Color
|
|
147
147
|
|
148
148
|
def ps
|
149
149
|
value=case @color
|
150
|
-
when Hash
|
151
|
-
when Array
|
150
|
+
when Hash then [@color[:cyan] || @color[:c],@color[:magenta] || @color[:m],@color[:yellow] || @color[:y],@color[:black] || @color[:k]]
|
151
|
+
when Array then @color
|
152
152
|
end
|
153
153
|
|
154
154
|
array_to_stack(value.map{|n| n > 1 ? n/100.0: n}) + "(#{@name.to_s}) findcmykcustomcolor \n/#{@name.to_s.gsub(' ', '_')} exch def\n\n#{@name.to_s.gsub(' ', '_')} 1 setcustomcolor"
|
data/lib/rghost/font.rb
CHANGED
@@ -34,9 +34,9 @@ class RGhost::Font < RGhost::PsObject #:nodoc:
|
|
34
34
|
|
35
35
|
size= o[:size]
|
36
36
|
str_ret+=case size
|
37
|
-
when Hash
|
38
|
-
when Array
|
39
|
-
when Fixnum
|
37
|
+
when Hash then "/#{@name} findfont [ #{size[:width]} 0 0 #{size[:height]} 0 0] makefont setfont "
|
38
|
+
when Array then "/#{@name} findfont [ #{size[0]} 0 0 #{size[1]} 0 0] makefont setfont "
|
39
|
+
when Fixnum then "/#{@name} findfont #{size} scalefont setfont "
|
40
40
|
end
|
41
41
|
str_ret
|
42
42
|
end
|
data/lib/rghost/image.rb
CHANGED
@@ -13,9 +13,12 @@ class RGhost::Image < RGhost::PsObject
|
|
13
13
|
def self.for(path,options={})
|
14
14
|
|
15
15
|
clazz=case path
|
16
|
-
when /gif$/i
|
17
|
-
|
18
|
-
when /
|
16
|
+
when /gif$/i
|
17
|
+
RGhost::Gif
|
18
|
+
when /jpe?g$/i
|
19
|
+
RGhost::Jpeg
|
20
|
+
when /(eps|template)$/i
|
21
|
+
RGhost::Eps
|
19
22
|
else raise NameError.new("Unsupported format")
|
20
23
|
end
|
21
24
|
|
@@ -23,4 +26,4 @@ class RGhost::Image < RGhost::PsObject
|
|
23
26
|
end
|
24
27
|
|
25
28
|
|
26
|
-
end
|
29
|
+
end
|
data/lib/rghost/paper.rb
CHANGED
@@ -87,8 +87,8 @@ class RGhost::Paper < RGhost::PsObject
|
|
87
87
|
|
88
88
|
|
89
89
|
return case RGhost::Config::GS[:unit].new
|
90
|
-
when RGhost::Units::Cm
|
91
|
-
when RGhost::Units::Inch
|
90
|
+
when RGhost::Units::Cm then (value.to_f*72/2.545).to_i
|
91
|
+
when RGhost::Units::Inch then (value.to_f*72).to_i
|
92
92
|
else
|
93
93
|
value
|
94
94
|
end
|
@@ -105,8 +105,8 @@ class RGhost::Paper < RGhost::PsObject
|
|
105
105
|
#end
|
106
106
|
|
107
107
|
case @options[:margin]
|
108
|
-
when Numeric
|
109
|
-
when Array
|
108
|
+
when Numeric then mt=mr=mb=ml=RGhost::Units::parse(@options[:margin])
|
109
|
+
when Array then
|
110
110
|
mt=RGhost::Units::parse(@options[:margin][0] || DEFAULT_OPTIONS[:margin_top] )
|
111
111
|
mr=RGhost::Units::parse(@options[:margin][1] || DEFAULT_OPTIONS[:margin_right])
|
112
112
|
mb=RGhost::Units::parse(@options[:margin][2] || DEFAULT_OPTIONS[:margin_bottom])
|
@@ -124,12 +124,12 @@ class RGhost::Paper < RGhost::PsObject
|
|
124
124
|
def format_paper
|
125
125
|
|
126
126
|
case @paper
|
127
|
-
when Symbol
|
127
|
+
when Symbol then
|
128
128
|
|
129
129
|
p=RGhost::Constants::Papers::STANDARD[@paper.to_s.downcase.to_sym]
|
130
130
|
p.reverse! if @options[:landscape]
|
131
131
|
{:rg => "/pagesize #{to_array( p ) } def\n", :gs => p, :done => true}
|
132
|
-
when Array
|
132
|
+
when Array then
|
133
133
|
@paper.reverse! if @options[:landscape]
|
134
134
|
{:rg => "/pagesize #{to_array( @paper.map{|v| to_pt(v) } ) } def\n", :gs => @paper, :done => false}
|
135
135
|
end
|
@@ -144,4 +144,4 @@ class RGhost::Paper < RGhost::PsObject
|
|
144
144
|
|
145
145
|
end
|
146
146
|
|
147
|
-
#puts Paper.new(:A4, :landscape => true, :duplex => true, :margin=> [2,3,4,5])
|
147
|
+
#puts Paper.new(:A4, :landscape => true, :duplex => true, :margin=> [2,3,4,5])
|
data/lib/rghost/parse_text.rb
CHANGED
@@ -5,10 +5,10 @@ module RGhost::ParseText #:nodoc:
|
|
5
5
|
|
6
6
|
unless @tag_parse
|
7
7
|
case @options[:text_align]
|
8
|
-
when :center, :right
|
8
|
+
when :center, :right then
|
9
9
|
@text.split(/\n/).map{|l| "#{to_string(l)} :text_proc_cr :nbw " }.to_s
|
10
10
|
jump_with=':nbw'
|
11
|
-
when :left,nil
|
11
|
+
when :left,nil then
|
12
12
|
if self.class == RGhost::Text
|
13
13
|
return @text.split(/\n/).map{|l| " :text #{to_string(l)} :text_proc nrdp " }.to_s
|
14
14
|
|
data/lib/rghost/ps_facade.rb
CHANGED
@@ -64,7 +64,7 @@ module RGhost::Config
|
|
64
64
|
:default_params=> %w(gs -dNOPAUSE -dBATCH -dQUIET -dNOPAGEPROMPT),
|
65
65
|
:stack_elements => 5000,
|
66
66
|
:font_encoding => :IsoLatin,
|
67
|
-
:charset_convert => lambda {|text| Iconv::iconv('latin1','utf-8', text) },
|
67
|
+
:charset_convert => lambda {|text| Iconv::iconv('latin1','utf-8', text).join },
|
68
68
|
#:charset_convert => nil,
|
69
69
|
:fontsize => 8,
|
70
70
|
:unit => RGhost::Units::Cm
|
@@ -76,7 +76,9 @@ module RGhost::Config
|
|
76
76
|
|
77
77
|
def self.config_platform #:nodoc:
|
78
78
|
|
79
|
-
|
79
|
+
const= 'PLATFORM'
|
80
|
+
const = "RUBY_"+const if RUBY_VERSION =~ /^1.9/
|
81
|
+
GS[:path]=case Object.const_get(const)
|
80
82
|
when /linux/ then "/usr/bin/gs"
|
81
83
|
when /darwin/ then "/opt/local/bin/gs"
|
82
84
|
when /freebsd|bsd/ then "/usr/local/bin/gs"
|
@@ -54,16 +54,16 @@ class RGhost::Engine
|
|
54
54
|
|
55
55
|
|
56
56
|
case @document
|
57
|
-
when RGhost::Document
|
57
|
+
when RGhost::Document
|
58
58
|
file_in="#{tmp_filename}.rgin"
|
59
59
|
params.concat @document.gs_paper
|
60
60
|
fi=File.open(file_in,'w')
|
61
61
|
fi.puts @document.ps
|
62
62
|
fi.close
|
63
|
-
when File
|
63
|
+
when File
|
64
64
|
file_in=@document.path
|
65
65
|
#@delete_input=false unless @options[:debug]
|
66
|
-
when String
|
66
|
+
when String
|
67
67
|
file_in=@document
|
68
68
|
#@delete_input=false unless @options[:debug]
|
69
69
|
end
|
@@ -103,10 +103,10 @@ class RGhost::Engine
|
|
103
103
|
|
104
104
|
def clear_output
|
105
105
|
case @output
|
106
|
-
when File
|
106
|
+
when File
|
107
107
|
@output.close
|
108
108
|
File.delete(@output.path)
|
109
|
-
when Array
|
109
|
+
when Array
|
110
110
|
@output.each do |f|
|
111
111
|
f.close
|
112
112
|
File.delete(f.path)
|
@@ -135,13 +135,13 @@ class RGhost::Engine
|
|
135
135
|
def format_params(v,pre="-d")
|
136
136
|
r=[]
|
137
137
|
case v
|
138
|
-
when Symbol
|
138
|
+
when Symbol
|
139
139
|
r << "#{pre}#{v}"
|
140
|
-
when Array
|
140
|
+
when Array
|
141
141
|
v.each do |av|
|
142
142
|
r << format_params(av,pre).to_s
|
143
143
|
end
|
144
|
-
when Hash
|
144
|
+
when Hash
|
145
145
|
v.each do |k,v|
|
146
146
|
r << "#{pre}#{k}=#{v.to_s.gsub(/ /,'')}"
|
147
147
|
end
|
data/lib/rghost/ruby_to_ps.rb
CHANGED
@@ -21,8 +21,8 @@ module RGhost::RubyToPs
|
|
21
21
|
|
22
22
|
|
23
23
|
def ps_escape(value)
|
24
|
-
value.to_s.gsub(/\(/,
|
25
|
-
|
24
|
+
#value.to_s.gsub(/\(/,'\\(').gsub(/\)/,"\\)").gsub(/\\/,"\134")
|
25
|
+
value.to_s.gsub(/(\(|\)|\\)/,'\\\\\1')
|
26
26
|
end
|
27
27
|
|
28
28
|
def to_bool(value)
|
@@ -39,10 +39,10 @@ module RGhost::RubyToPs
|
|
39
39
|
ps_arr=[]
|
40
40
|
arr.each do |a|
|
41
41
|
ps_arr << case a
|
42
|
-
when TrueClass,FalseClass
|
43
|
-
when Numeric
|
44
|
-
when Proc
|
45
|
-
when Array
|
42
|
+
when TrueClass,FalseClass then to_bool(a)
|
43
|
+
when Numeric then a
|
44
|
+
when Proc then a.to_s
|
45
|
+
when Array then to_array(a)
|
46
46
|
else
|
47
47
|
to_string(a.to_s)
|
48
48
|
end
|
@@ -67,7 +67,7 @@ module RGhost::RubyToPs
|
|
67
67
|
tudo=""
|
68
68
|
s.each do |v|
|
69
69
|
case v
|
70
|
-
when
|
70
|
+
when /^%/ then tudo << "#{v.gsub(/%/,'')} to_s show "
|
71
71
|
else
|
72
72
|
tudo << "(#{ps_escape(v)}) show "
|
73
73
|
end
|
metadata
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rghost
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 8
|
9
|
+
- 7
|
10
|
+
- 4
|
11
|
+
version: 0.8.7.4
|
5
12
|
platform: ruby
|
6
13
|
authors:
|
7
14
|
- Shairon Toledo
|
@@ -9,11 +16,11 @@ autorequire:
|
|
9
16
|
bindir: bin
|
10
17
|
cert_chain: []
|
11
18
|
|
12
|
-
date:
|
19
|
+
date: 2011-01-20 00:00:00 -02:00
|
13
20
|
default_executable:
|
14
21
|
dependencies: []
|
15
22
|
|
16
|
-
description:
|
23
|
+
description: Ruby Ghostscript Engine is a document creation and conversion API, support(PDF,PS,GIF,TIF,PNG,JPG...). It uses the GhostScript framework for the format conversion, utilizes EPS templates and is optimized to work with larger documents.
|
17
24
|
email: shairon.toledo@gmail.com
|
18
25
|
executables: []
|
19
26
|
|
@@ -22,7 +29,6 @@ extensions: []
|
|
22
29
|
extra_rdoc_files: []
|
23
30
|
|
24
31
|
files:
|
25
|
-
- lib/rghost
|
26
32
|
- lib/rghost/border.rb
|
27
33
|
- lib/rghost/callback.rb
|
28
34
|
- lib/rghost/circle.rb
|
@@ -42,7 +48,6 @@ files:
|
|
42
48
|
- lib/rghost/function.rb
|
43
49
|
- lib/rghost/gif.rb
|
44
50
|
- lib/rghost/graphic.rb
|
45
|
-
- lib/rghost/grid
|
46
51
|
- lib/rghost/grid/base_grid.rb
|
47
52
|
- lib/rghost/grid/callback_facade.rb
|
48
53
|
- lib/rghost/grid/csv_grid.rb
|
@@ -53,7 +58,6 @@ files:
|
|
53
58
|
- lib/rghost/grid/matrix.rb
|
54
59
|
- lib/rghost/grid/rails_grid.rb
|
55
60
|
- lib/rghost/grid/static_callback.rb
|
56
|
-
- lib/rghost/grid/style
|
57
61
|
- lib/rghost/grid/style/border_lines.rb
|
58
62
|
- lib/rghost/grid/style/bottom_lines.rb
|
59
63
|
- lib/rghost/grid/style/old_forms.rb
|
@@ -74,7 +78,6 @@ files:
|
|
74
78
|
- lib/rghost/point.rb
|
75
79
|
- lib/rghost/point_with_command.rb
|
76
80
|
- lib/rghost/polygon.rb
|
77
|
-
- lib/rghost/ps
|
78
81
|
- lib/rghost/ps/_cusor.ps
|
79
82
|
- lib/rghost/ps/AdobeExpert.enc
|
80
83
|
- lib/rghost/ps/AdobeLatinEncoding.enc
|
@@ -157,31 +160,39 @@ files:
|
|
157
160
|
- lib/rghost/vertical_line.rb
|
158
161
|
- lib/rghost/virtual_pages.rb
|
159
162
|
- lib/rghost.rb
|
160
|
-
has_rdoc:
|
163
|
+
has_rdoc: true
|
161
164
|
homepage: http://rghost.rubyforge.org
|
165
|
+
licenses: []
|
166
|
+
|
162
167
|
post_install_message:
|
163
168
|
rdoc_options: []
|
164
169
|
|
165
170
|
require_paths:
|
166
171
|
- lib
|
167
172
|
required_ruby_version: !ruby/object:Gem::Requirement
|
173
|
+
none: false
|
168
174
|
requirements:
|
169
175
|
- - ">="
|
170
176
|
- !ruby/object:Gem::Version
|
177
|
+
hash: 3
|
178
|
+
segments:
|
179
|
+
- 0
|
171
180
|
version: "0"
|
172
|
-
version:
|
173
181
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
none: false
|
174
183
|
requirements:
|
175
184
|
- - ">="
|
176
185
|
- !ruby/object:Gem::Version
|
186
|
+
hash: 3
|
187
|
+
segments:
|
188
|
+
- 0
|
177
189
|
version: "0"
|
178
|
-
version:
|
179
190
|
requirements: []
|
180
191
|
|
181
192
|
rubyforge_project: Ruby Ghostscript Engine is a document creation and conversion API, support(PDF,PS,GIF,TIF,PNG,JPG...). It uses the GhostScript framework for the format conversion, utilizes EPS templates and is optimized to work with larger documents.
|
182
|
-
rubygems_version: 1.3.
|
193
|
+
rubygems_version: 1.3.7
|
183
194
|
signing_key:
|
184
|
-
specification_version:
|
195
|
+
specification_version: 3
|
185
196
|
summary: Ruby Ghostscript Engine is a document creation and conversion API, support(PDF,PS,GIF,TIF,PNG,JPG...). It uses the GhostScript framework for the format conversion, utilizes EPS templates and is optimized to work with larger documents.
|
186
197
|
test_files: []
|
187
198
|
|