rghost 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/Manifest.txt +101 -0
- data/README.txt +3 -0
- data/Rakefile +93 -0
- data/lib/rghost.rb +3 -0
- data/lib/rghost/arc.rb +39 -0
- data/lib/rghost/barcode.rb +40 -0
- data/lib/rghost/callback.rb +55 -0
- data/lib/rghost/color.rb +118 -0
- data/lib/rghost/constants.rb +616 -0
- data/lib/rghost/convert.rb +24 -0
- data/lib/rghost/cursor.rb +82 -0
- data/lib/rghost/data_grid/basic_grid.rb +136 -0
- data/lib/rghost/data_grid/csv_grid.rb +27 -0
- data/lib/rghost/data_grid/data_grid.rb +14 -0
- data/lib/rghost/data_grid/dynamic_callback.rb +12 -0
- data/lib/rghost/data_grid/field_format.rb +60 -0
- data/lib/rghost/data_grid/grid.rb +18 -0
- data/lib/rghost/data_grid/header.rb +111 -0
- data/lib/rghost/data_grid/rails_grid.rb +37 -0
- data/lib/rghost/data_grid/static_callback.rb +13 -0
- data/lib/rghost/data_grid/style/border_lines.rb +47 -0
- data/lib/rghost/data_grid/style/bottom_lines.rb +30 -0
- data/lib/rghost/data_grid/style/old_forms.rb +30 -0
- data/lib/rghost/data_grid/style/style.rb +8 -0
- data/lib/rghost/document.rb +380 -0
- data/lib/rghost/dsc_entry.rb +20 -0
- data/lib/rghost/dynamic_document_callback.rb +27 -0
- data/lib/rghost/eps.rb +22 -0
- data/lib/rghost/font.rb +52 -0
- data/lib/rghost/function.rb +36 -0
- data/lib/rghost/gif.rb +28 -0
- data/lib/rghost/graphic.rb +28 -0
- data/lib/rghost/gs_alone.rb +17 -0
- data/lib/rghost/helpers.rb +13 -0
- data/lib/rghost/horizontal_line.rb +29 -0
- data/lib/rghost/image.rb +26 -0
- data/lib/rghost/jpeg.rb +26 -0
- data/lib/rghost/line.rb +40 -0
- data/lib/rghost/line_width.rb +17 -0
- data/lib/rghost/load.rb +37 -0
- data/lib/rghost/newpath.rb +20 -0
- data/lib/rghost/paper.rb +88 -0
- data/lib/rghost/point.rb +22 -0
- data/lib/rghost/point_with_command.rb +17 -0
- data/lib/rghost/ps/basic.ps +14 -0
- data/lib/rghost/ps/begin_document.ps +7 -0
- data/lib/rghost/ps/callbacks.ps +146 -0
- data/lib/rghost/ps/code128.font +344 -0
- data/lib/rghost/ps/code39.font +195 -0
- data/lib/rghost/ps/cursor.ps +41 -0
- data/lib/rghost/ps/datagrid.ps +52 -0
- data/lib/rghost/ps/ean.font +150 -0
- data/lib/rghost/ps/eps.ps +42 -0
- data/lib/rghost/ps/font.ps +31 -0
- data/lib/rghost/ps/functions.ps +646 -0
- data/lib/rghost/ps/gif.ps +150 -0
- data/lib/rghost/ps/horizontal_line.ps +3 -0
- data/lib/rghost/ps/i25.font +103 -0
- data/lib/rghost/ps/jpeg.ps +122 -0
- data/lib/rghost/ps/paper.ps +8 -0
- data/lib/rghost/ps/rectangle.ps +5 -0
- data/lib/rghost/ps/row.ps +4 -0
- data/lib/rghost/ps/show.ps +20 -0
- data/lib/rghost/ps/table_callbacks.ps +96 -0
- data/lib/rghost/ps/textarea.ps +11 -0
- data/lib/rghost/ps/type.ps +1 -0
- data/lib/rghost/ps/unit.ps +3 -0
- data/lib/rghost/ps/vertical_line.ps +14 -0
- data/lib/rghost/ps_object.rb +51 -0
- data/lib/rghost/rectangle.rb +39 -0
- data/lib/rghost/rgengine.so +0 -0
- data/lib/rghost/rghost.rb +3 -0
- data/lib/rghost/ruby_ghost_config.rb +25 -0
- data/lib/rghost/ruby_ghost_engine.rb +175 -0
- data/lib/rghost/ruby_to_ps.rb +92 -0
- data/lib/rghost/scale.rb +14 -0
- data/lib/rghost/show.rb +31 -0
- data/lib/rghost/static_document_callback.rb +22 -0
- data/lib/rghost/text_in.rb +29 -0
- data/lib/rghost/textarea.rb +115 -0
- data/lib/rghost/units.rb +81 -0
- data/lib/rghost/variable.rb +12 -0
- data/lib/rghost/version.rb +9 -0
- data/lib/rghost/vertical_line.rb +29 -0
- data/scripts/txt2html +67 -0
- data/setup.rb +1585 -0
- data/test/test_helper.rb +2 -0
- data/test/test_rghost.rb +11 -0
- data/website/index.html +11 -0
- data/website/index.txt +30 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +129 -0
- data/website/template.rhtml +48 -0
- metadata +145 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
require "ps_object"
|
2
|
+
#Especifica uma entradas DSC (Document Structuring Conventions)
|
3
|
+
class DSCEntry < PsObject
|
4
|
+
#Nova inst�ncia de DSCEntry
|
5
|
+
# DSCEntry.new do |entry|
|
6
|
+
# entry << "BoundingBox: 0 0 612 792"
|
7
|
+
# entry << "Pages: 45"
|
8
|
+
# entry << "BeginSetup"
|
9
|
+
# end
|
10
|
+
def initialize
|
11
|
+
|
12
|
+
yield @entries=[]
|
13
|
+
end
|
14
|
+
|
15
|
+
def ps
|
16
|
+
@entries.map{|e| "%%#{e}\n"}.to_s
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "callback"
|
2
|
+
#Callbacks din�micos para a classe Document.
|
3
|
+
class DynamicDocumentCallback < Callback
|
4
|
+
ACCEPT=[:before_page_create,
|
5
|
+
:after_page_create,
|
6
|
+
:odd_pages,
|
7
|
+
:even_pages
|
8
|
+
]
|
9
|
+
#Nova inst�ncia de DynamicDocumentCallback
|
10
|
+
# dc=DynamicDocumentCallback.new(:before_page_create, :except => [1,2]) do
|
11
|
+
# set HorizontalLine.new
|
12
|
+
# end
|
13
|
+
#Usando only
|
14
|
+
# dc=DynamicDocumentCallback.new(:before_page_create, :only => [1,2]) do
|
15
|
+
# set HorizontalLine.new
|
16
|
+
# end
|
17
|
+
def initialize(name,options={},&block)
|
18
|
+
raise NameError.new("#{name} no accept in #{self.class}") unless ACCEPT.include? name
|
19
|
+
super(name,options,&block)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
#c= DynamicDocumentCallback.new(:before_page_create, :except => [1,2], :only => [3,4]) do
|
25
|
+
# set HorizontalLine.new
|
26
|
+
#end
|
27
|
+
#puts c.ps
|
data/lib/rghost/eps.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "ps_object"
|
2
|
+
#Chama as diretivas de carregamento de um EPS
|
3
|
+
class Eps < PsObject
|
4
|
+
#Nova inst�ncia de EPS
|
5
|
+
# eps=Eps.new("/local/tamplates/myform.eps", :x=> 5, :y=> 10, :rotate => 45)
|
6
|
+
def initialize(eps_path,options={:x=>0, :y=> 0, :rotate => 0})
|
7
|
+
super("")
|
8
|
+
@options=options
|
9
|
+
@path=eps_path
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
def ps
|
14
|
+
|
15
|
+
"BeginEPSF \n #{Cursor.translate(@options)} \n\t(#{@path}) run \nEndEPSF\n ";
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
end
|
data/lib/rghost/font.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require "ps_object"
|
2
|
+
require "constants"
|
3
|
+
require "helpers"
|
4
|
+
|
5
|
+
#Carrega uma determida fonte no dispositivo corrente
|
6
|
+
class Font < PsObject
|
7
|
+
DEFAULT_OPTONS={ :size=> 8, :name => "Helvetica", :encoding => true }
|
8
|
+
include Constants::Fonts
|
9
|
+
|
10
|
+
attr_reader :name
|
11
|
+
#Nova inst�ncia de Font. Encoding true usa ISOLatin1Encoding.
|
12
|
+
# #uso de fonte escal�vel
|
13
|
+
# d=Font.new(:name => "Times", :size => 10, :encoding => true)
|
14
|
+
# #fonte distorcida
|
15
|
+
# d=Font.new(:name => "Monospace", :size => [10,30])
|
16
|
+
def initialize(options)
|
17
|
+
|
18
|
+
@options=DEFAULT_OPTONS.dup.merge(options)
|
19
|
+
@options.default ""
|
20
|
+
@name=@options[:name].to_s
|
21
|
+
@name+="-encoding" if @options[:encoding]
|
22
|
+
end
|
23
|
+
|
24
|
+
def ps
|
25
|
+
o=@options
|
26
|
+
str_ret=""
|
27
|
+
if o[:barcode]
|
28
|
+
bc=Barcode.new(o[:barcode])
|
29
|
+
@name=bc.font_name
|
30
|
+
o[:encoding]=false
|
31
|
+
end
|
32
|
+
if o[:encoding] #define enconding
|
33
|
+
str_ret="/#{o[:name]} encoding_font\n"+
|
34
|
+
"/#{o[:name]}-encoding exch definefont pop\n"
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
size= o[:size]
|
39
|
+
str_ret+=case size
|
40
|
+
when Hash: "/#{@name} findfont [ #{size[:width]} 0 0 #{size[:height]} 0 0] makefont setfont "
|
41
|
+
when Array: "/#{@name} findfont [ #{size[0]} 0 0 #{size[1]} 0 0] makefont setfont "
|
42
|
+
when Fixnum: "/#{@name} findfont #{size} scalefont setfont "
|
43
|
+
end
|
44
|
+
str_ret
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "ps_object"
|
2
|
+
|
3
|
+
#Cria fun��es na pilha Postscript
|
4
|
+
class Function < PsObject
|
5
|
+
|
6
|
+
attr_reader :name
|
7
|
+
#Nova inst�ncia de Function.
|
8
|
+
#
|
9
|
+
# f=Function.new(:sum, " 20 10 add")
|
10
|
+
#Passando um PsObject
|
11
|
+
# font=Font.new(:size => 12)
|
12
|
+
# f=Function.new(:font12, font)
|
13
|
+
#Por Bloco
|
14
|
+
# Function.new(:font_bold) do
|
15
|
+
# set Font.new(:name => "Times-Bold", :size => 9)
|
16
|
+
# end
|
17
|
+
def initialize(name,body_function=nil,&block)
|
18
|
+
if block
|
19
|
+
super(&block)
|
20
|
+
|
21
|
+
else
|
22
|
+
|
23
|
+
super("")
|
24
|
+
end
|
25
|
+
@name=name
|
26
|
+
@body_function=body_function
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def ps
|
31
|
+
@body_function||=super
|
32
|
+
|
33
|
+
"\n/#{@name}{\n#{@body_function}\n} bind def \n"
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/lib/rghost/gif.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require "ps_object"
|
2
|
+
require "graphic"
|
3
|
+
require "cursor"
|
4
|
+
require "variable"
|
5
|
+
require "image"
|
6
|
+
require "function"
|
7
|
+
require "scale"
|
8
|
+
# Carrega uma imagem no formato GIF
|
9
|
+
# i=Gif.new("/junk/any.gif", :y=> 5,:x => 8, :zoom=> 200)
|
10
|
+
class Gif < Image
|
11
|
+
|
12
|
+
def ps
|
13
|
+
s=@options[:zoom]/100.0
|
14
|
+
|
15
|
+
g=Graphic.new
|
16
|
+
|
17
|
+
params=Function.new(:gif_params)
|
18
|
+
params.set Cursor.translate(@options)
|
19
|
+
params.set Cursor.rotate(@options[:rotate])
|
20
|
+
params.set Scale.new(s,s)
|
21
|
+
|
22
|
+
g.set params
|
23
|
+
g.set PsObject.new("(#{@file}) viewGIF")
|
24
|
+
g
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "ps_object"
|
2
|
+
require "cursor"
|
3
|
+
require "color"
|
4
|
+
require "point"
|
5
|
+
require "point"
|
6
|
+
require "line_width"
|
7
|
+
#Condiciona em um bloco gr�fico(gsave-grestore). Defini��es gr�ficas v�lidas apenas para o escopo do bloco n�o interferindo nos demais gr�ficos.
|
8
|
+
# doc=Document.new
|
9
|
+
# doc.graphic do
|
10
|
+
# set LineWidth.new(0)
|
11
|
+
# set Line.lineto(5,7)
|
12
|
+
# end
|
13
|
+
class Graphic < PsObject
|
14
|
+
|
15
|
+
def ps
|
16
|
+
"gsave #{super} grestore"
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "ps_object"
|
2
|
+
require "units"
|
3
|
+
#Cria uma linha horizontal na faixa corrente com alinhamento vertical variando em
|
4
|
+
#
|
5
|
+
# :top # topo da faixa
|
6
|
+
# :middle # meio da faixa
|
7
|
+
# :bottom # base da faixa
|
8
|
+
class HorizontalLine < PsObject
|
9
|
+
|
10
|
+
DEFAULT_OPTIONS={:start_in => :limit_left, :size => :area_x}
|
11
|
+
#Nova inst�ncia de HorizontalLine.
|
12
|
+
#
|
13
|
+
#No meio da faixa come�ando de limit_left da p�gina com tamanho da area_x
|
14
|
+
# h=HorizontalLine.new
|
15
|
+
#Iniciando da posi��o 3 at� a 5, no topo
|
16
|
+
# h=HorizontalLine.new(:top, :start_in => 3, :size => 2)
|
17
|
+
#Em um Document
|
18
|
+
# d=Document.new
|
19
|
+
# d.set HorizontalLine.new(:bottom)
|
20
|
+
def initialize(valign=:middle,options={})
|
21
|
+
@options=DEFAULT_OPTIONS.dup.merge(options)
|
22
|
+
start_in=Units::parse(@options[:start_in])
|
23
|
+
size=Units::parse(@options[:size])
|
24
|
+
|
25
|
+
super("#{start_in} #{size} horizontal_line_#{valign}")
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/lib/rghost/image.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require "ps_object"
|
2
|
+
#SuperClass de GIF e JPEG.
|
3
|
+
class Image < PsObject
|
4
|
+
DEFAULT_OPTIONS={:x=> :limit_left, :y=> 1, :zoom => 100, :rotate => 0}
|
5
|
+
|
6
|
+
def initialize(image_path,options={})
|
7
|
+
super("")
|
8
|
+
@options=DEFAULT_OPTIONS.dup.merge(options)
|
9
|
+
@file=image_path
|
10
|
+
end
|
11
|
+
|
12
|
+
#Cria uma imagem pela extens�o. Aceita gif, jpeg, jpg e eps
|
13
|
+
def Image.for(path,options={})
|
14
|
+
|
15
|
+
clazz=case path
|
16
|
+
when /gif$/i: Gif
|
17
|
+
when /jpe?g$/i: Jpeg
|
18
|
+
when /(eps|template)$/i :Eps
|
19
|
+
else raise NameError.new("Format not supported")
|
20
|
+
end
|
21
|
+
|
22
|
+
clazz.new(path,options)
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
end
|
data/lib/rghost/jpeg.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require "ps_object"
|
2
|
+
require "graphic"
|
3
|
+
require "cursor"
|
4
|
+
require "variable"
|
5
|
+
require "image"
|
6
|
+
# Carrega uma imagem no formato Jpeg
|
7
|
+
# i=Jpeg.new("/junk/any.jpg", :y=> 15,:x => 3, :rotate => 90)
|
8
|
+
class Jpeg < Image
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
def ps
|
13
|
+
#x=Units::parse( @options[:x] )
|
14
|
+
#y=Units::parse( @options[:y] )
|
15
|
+
|
16
|
+
g=Graphic.new
|
17
|
+
g.set Cursor.translate(@options)
|
18
|
+
#set Cursor.translate()
|
19
|
+
g.set Cursor.rotate(@options[:rotate])
|
20
|
+
g.set Variable.new(:zoom,@options[:zoom]/100.0)
|
21
|
+
g.set PsObject.new("(#{@file}) viewJPEG")
|
22
|
+
g
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/lib/rghost/line.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require "ps_object"
|
2
|
+
require "point"
|
3
|
+
|
4
|
+
#Define lineto ou rlineto
|
5
|
+
class Line < PsObject
|
6
|
+
DEFAULT_POINT={:x => :limit_left , :y => :current_row}
|
7
|
+
|
8
|
+
#Desenha a linha do ponto correte ao ponto informado
|
9
|
+
# d=Document.new
|
10
|
+
# d.set Cursor.moveto(:x=> 2, :y=> 7)
|
11
|
+
# d.set Line.lineto(:x => 10, :y => 2) #uma linha diagonal para baixo
|
12
|
+
def Line.lineto(point={})
|
13
|
+
|
14
|
+
Line.make_command(:lineto,point)
|
15
|
+
|
16
|
+
end
|
17
|
+
#Desenha a linha do ponto correte ao ponto relativo informado.
|
18
|
+
# d=Document.new
|
19
|
+
# d.set Cursor.moveto(:x=> 2, :y=> 7)
|
20
|
+
# d.set Line.rlineto(:x => 10, :y => 2) #uma linha diagonal para cima
|
21
|
+
def Line.rlineto(point={})
|
22
|
+
Line.make_command(:rlineto,point)
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
private
|
28
|
+
def Line.make_command(command,point={})
|
29
|
+
|
30
|
+
p=DEFAULT_POINT.dup.merge(point)
|
31
|
+
p=Point.new(p[:x],p[:y])
|
32
|
+
PsObject.new "#{p.ps}#{command}"
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "ps_object"
|
2
|
+
#Define a largura da borda. Valor 1 � o padr�o Postscript mas a mais fina � 0
|
3
|
+
class LineWidth < PsObject
|
4
|
+
#Nova inst�ncia de LineWidth
|
5
|
+
# d=Document.new
|
6
|
+
# d.before_page_create do
|
7
|
+
# set LineWidth.new(0)
|
8
|
+
# end
|
9
|
+
def initialize(value=1)
|
10
|
+
@value=value
|
11
|
+
end
|
12
|
+
|
13
|
+
def ps
|
14
|
+
"#{@value} setlinewidth "
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/lib/rghost/load.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require "ps_object"
|
2
|
+
module Load
|
3
|
+
|
4
|
+
def Load.library(name, type=:ps)
|
5
|
+
#PsObject.new File.open(File.dirname(__FILE__)+File::SEPARATOR+type.to_s+File::SEPARATOR+name.to_s+"."+type.to_s).readlines.join("")
|
6
|
+
|
7
|
+
PsObject.new("(#{name.to_s.downcase}.#{type}) runlibfile\n")
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
def Load.rg_enviroment
|
12
|
+
PsObject.new do
|
13
|
+
raw Load.library(:basic)
|
14
|
+
raw Load.library(:cursor)
|
15
|
+
raw Load.library(:rectangle)
|
16
|
+
raw Load.library(:font)
|
17
|
+
raw Load.library(:textarea)
|
18
|
+
raw Load.library(:horizontal_line)
|
19
|
+
raw Load.library(:vertical_line)
|
20
|
+
raw Load.library(:callbacks)
|
21
|
+
raw Load.library(:show)
|
22
|
+
raw Load.library(:eps)
|
23
|
+
raw Load.library(:jpeg)
|
24
|
+
raw Load.library(:gif)
|
25
|
+
raw Load.library(:begin_document)
|
26
|
+
raw Load.library(:datagrid)
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def Load.binary(path)
|
32
|
+
File.open(path).readlines.join
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|