rghost 0.8.6.3 → 0.8.6.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rghost/callback.rb +3 -2
- data/lib/rghost/color.rb +21 -13
- data/lib/rghost/font.rb +6 -3
- data/lib/rghost/grid/base_grid.rb +16 -8
- data/lib/rghost/grid/rails_grid.rb +6 -3
- data/lib/rghost/paper.rb +11 -9
- data/lib/rghost/parse_text.rb +2 -2
- data/lib/rghost/ruby_ghost_engine.rb +8 -8
- data/lib/rghost/ruby_to_ps.rb +10 -5
- metadata +2 -2
data/lib/rghost/callback.rb
CHANGED
data/lib/rghost/color.rb
CHANGED
@@ -35,14 +35,14 @@ 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
|
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
|
45
|
-
|
44
|
+
when Array, Hash
|
45
|
+
if color.size == 3
|
46
46
|
RGhost::RGB.new(color)
|
47
47
|
elsif color.size == 4
|
48
48
|
RGhost::CMYK.new(color)
|
@@ -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,14 @@ class RGhost::RGB < RGhost::Color
|
|
93
93
|
end
|
94
94
|
def color_params
|
95
95
|
case @color
|
96
|
-
when Hash
|
97
|
-
|
98
|
-
when
|
99
|
-
|
96
|
+
when Hash
|
97
|
+
[@color[:red] || @color[:r],@color[:green] || @color[:g],@color[:blue] || @color[:b]]
|
98
|
+
when Array
|
99
|
+
@color
|
100
|
+
when String
|
101
|
+
hex_to_rgb(@color)
|
102
|
+
when NilClass
|
103
|
+
[0,0,1]
|
100
104
|
end
|
101
105
|
|
102
106
|
|
@@ -126,8 +130,10 @@ class RGhost::CMYK < RGhost::Color
|
|
126
130
|
|
127
131
|
def ps
|
128
132
|
value=case @color
|
129
|
-
when Hash
|
130
|
-
|
133
|
+
when Hash
|
134
|
+
[@color[:cyan] || @color[:c],@color[:magenta] || @color[:m],@color[:yellow] || @color[:y],@color[:black] || @color[:k]]
|
135
|
+
when Array
|
136
|
+
@color
|
131
137
|
end
|
132
138
|
|
133
139
|
array_to_stack(value.map{|n| n > 1 ? n/100.0: n})+"setcmykcolor"
|
@@ -147,8 +153,10 @@ class RGhost::CMYKSpot < RGhost::Color
|
|
147
153
|
|
148
154
|
def ps
|
149
155
|
value=case @color
|
150
|
-
when Hash
|
151
|
-
|
156
|
+
when Hash
|
157
|
+
[@color[:cyan] || @color[:c],@color[:magenta] || @color[:m],@color[:yellow] || @color[:y],@color[:black] || @color[:k]]
|
158
|
+
when Array
|
159
|
+
@color
|
152
160
|
end
|
153
161
|
|
154
162
|
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,12 @@ class RGhost::Font < RGhost::PsObject #:nodoc:
|
|
34
34
|
|
35
35
|
size= o[:size]
|
36
36
|
str_ret+=case size
|
37
|
-
when Hash
|
38
|
-
|
39
|
-
when
|
37
|
+
when Hash
|
38
|
+
"/#{@name} findfont [ #{size[:width]} 0 0 #{size[:height]} 0 0] makefont setfont "
|
39
|
+
when Array
|
40
|
+
"/#{@name} findfont [ #{size[0]} 0 0 #{size[1]} 0 0] makefont setfont "
|
41
|
+
when Fixnum
|
42
|
+
"/#{@name} findfont #{size} scalefont setfont "
|
40
43
|
end
|
41
44
|
str_ret
|
42
45
|
end
|
@@ -126,11 +126,16 @@ class RGhost::Grid::Base < RGhost::PsObject
|
|
126
126
|
|
127
127
|
def format_field(value,type) #:nodoc:
|
128
128
|
case type
|
129
|
-
when Symbol
|
130
|
-
|
131
|
-
when
|
132
|
-
|
133
|
-
when
|
129
|
+
when Symbol
|
130
|
+
RGhost::Grid::FieldFormat.send(type,value)
|
131
|
+
when String
|
132
|
+
RGhost::Grid::FieldFormat.string(type % value)
|
133
|
+
when NilClass
|
134
|
+
RGhost::Grid::FieldFormat.string(value)
|
135
|
+
when Class
|
136
|
+
type.new(value).gs_format
|
137
|
+
when Proc
|
138
|
+
RGhost::Grid::FieldFormat.string(type.call(value))
|
134
139
|
|
135
140
|
else raise TypeError.new("type=#{type}, value type=#{value.class}")
|
136
141
|
end
|
@@ -207,9 +212,12 @@ class RGhost::Grid::Base < RGhost::PsObject
|
|
207
212
|
# link:images/setstyle03.png
|
208
213
|
def style(type=:border_lines)
|
209
214
|
st=case type
|
210
|
-
when :border_lines
|
211
|
-
|
212
|
-
when :
|
215
|
+
when :border_lines
|
216
|
+
RGhost::Grid::Style::BorderLines.new
|
217
|
+
when :old_forms
|
218
|
+
RGhost::Grid::Style::OldForms.new
|
219
|
+
when :bottom_lines
|
220
|
+
RGhost::Grid::Style::BottomLines.new
|
213
221
|
else raise NameError.new("Why? #{type} ?")
|
214
222
|
end
|
215
223
|
|
@@ -45,9 +45,12 @@ class RGhost::Grid::Rails < RGhost::Grid::Base
|
|
45
45
|
_data.collect do |d|
|
46
46
|
line=@rails_cols.collect do |c|
|
47
47
|
case c[:field_name]
|
48
|
-
when Symbol
|
49
|
-
|
50
|
-
when
|
48
|
+
when Symbol
|
49
|
+
d[c[:field_name]]
|
50
|
+
when String
|
51
|
+
d.instance_eval c[:field_name]
|
52
|
+
when Proc
|
53
|
+
d.instance_eval(&c[:field_name])
|
51
54
|
end
|
52
55
|
end
|
53
56
|
proc_line(line)
|
data/lib/rghost/paper.rb
CHANGED
@@ -87,8 +87,10 @@ class RGhost::Paper < RGhost::PsObject
|
|
87
87
|
|
88
88
|
|
89
89
|
return case RGhost::Config::GS[:unit].new
|
90
|
-
when RGhost::Units::Cm
|
91
|
-
|
90
|
+
when RGhost::Units::Cm
|
91
|
+
(value.to_f*72/2.545).to_i
|
92
|
+
when RGhost::Units::Inch
|
93
|
+
(value.to_f*72).to_i
|
92
94
|
else
|
93
95
|
value
|
94
96
|
end
|
@@ -105,9 +107,10 @@ class RGhost::Paper < RGhost::PsObject
|
|
105
107
|
#end
|
106
108
|
|
107
109
|
case @options[:margin]
|
108
|
-
when Numeric
|
109
|
-
|
110
|
-
|
110
|
+
when Numeric
|
111
|
+
mt=mr=mb=ml=RGhost::Units::parse(@options[:margin])
|
112
|
+
when Array
|
113
|
+
mt=RGhost::Units::parse(@options[:margin][0] || DEFAULT_OPTIONS[:margin_top] )
|
111
114
|
mr=RGhost::Units::parse(@options[:margin][1] || DEFAULT_OPTIONS[:margin_right])
|
112
115
|
mb=RGhost::Units::parse(@options[:margin][2] || DEFAULT_OPTIONS[:margin_bottom])
|
113
116
|
ml=RGhost::Units::parse(@options[:margin][3] || DEFAULT_OPTIONS[:margin_left] )
|
@@ -124,12 +127,11 @@ class RGhost::Paper < RGhost::PsObject
|
|
124
127
|
def format_paper
|
125
128
|
|
126
129
|
case @paper
|
127
|
-
when Symbol
|
128
|
-
|
129
|
-
p=RGhost::Constants::Papers::STANDARD[@paper.to_s.downcase.to_sym]
|
130
|
+
when Symbol
|
131
|
+
p=RGhost::Constants::Papers::STANDARD[@paper.to_s.downcase.to_sym]
|
130
132
|
p.reverse! if @options[:landscape]
|
131
133
|
{:rg => "/pagesize #{to_array( p ) } def\n", :gs => p, :done => true}
|
132
|
-
when Array
|
134
|
+
when Array
|
133
135
|
@paper.reverse! if @options[:landscape]
|
134
136
|
{:rg => "/pagesize #{to_array( @paper.map{|v| to_pt(v) } ) } def\n", :gs => @paper, :done => false}
|
135
137
|
end
|
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
|
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
|
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
|
|
@@ -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
@@ -38,10 +38,14 @@ module RGhost::RubyToPs
|
|
38
38
|
ps_arr=[]
|
39
39
|
arr.each do |a|
|
40
40
|
ps_arr << case a
|
41
|
-
when TrueClass,FalseClass
|
42
|
-
|
43
|
-
when
|
44
|
-
|
41
|
+
when TrueClass,FalseClass
|
42
|
+
to_bool(a)
|
43
|
+
when Numeric
|
44
|
+
a
|
45
|
+
when Proc
|
46
|
+
a.to_s
|
47
|
+
when Array
|
48
|
+
to_array(a)
|
45
49
|
else
|
46
50
|
to_string(a.to_s)
|
47
51
|
end
|
@@ -66,7 +70,8 @@ module RGhost::RubyToPs
|
|
66
70
|
tudo=""
|
67
71
|
s.each do |v|
|
68
72
|
case v
|
69
|
-
when
|
73
|
+
when /^%/
|
74
|
+
tudo << "#{v.gsub(/%/,'')} to_s show "
|
70
75
|
else
|
71
76
|
tudo << "(#{ps_escape(v)}) show "
|
72
77
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rghost
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.6.
|
4
|
+
version: 0.8.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shairon Toledo
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-04-14 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|