lunks_rghost 0.8.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. data/lib/rghost/border.rb +44 -0
  2. data/lib/rghost/callback.rb +58 -0
  3. data/lib/rghost/circle.rb +102 -0
  4. data/lib/rghost/color.rb +175 -0
  5. data/lib/rghost/constants.rb +626 -0
  6. data/lib/rghost/convert.rb +43 -0
  7. data/lib/rghost/cursor.rb +124 -0
  8. data/lib/rghost/dash.rb +59 -0
  9. data/lib/rghost/document.rb +546 -0
  10. data/lib/rghost/document_callback_facade.rb +64 -0
  11. data/lib/rghost/dsc_entry.rb +20 -0
  12. data/lib/rghost/dynamic_document_callback.rb +15 -0
  13. data/lib/rghost/eps.rb +31 -0
  14. data/lib/rghost/font.rb +48 -0
  15. data/lib/rghost/font_map.rb +54 -0
  16. data/lib/rghost/frame.rb +105 -0
  17. data/lib/rghost/function.rb +38 -0
  18. data/lib/rghost/gif.rb +41 -0
  19. data/lib/rghost/graphic.rb +26 -0
  20. data/lib/rghost/grid/base_grid.rb +228 -0
  21. data/lib/rghost/grid/callback_facade.rb +136 -0
  22. data/lib/rghost/grid/csv_grid.rb +51 -0
  23. data/lib/rghost/grid/dynamic_callback.rb +12 -0
  24. data/lib/rghost/grid/field_format.rb +43 -0
  25. data/lib/rghost/grid/grid.rb +15 -0
  26. data/lib/rghost/grid/header.rb +120 -0
  27. data/lib/rghost/grid/matrix.rb +10 -0
  28. data/lib/rghost/grid/rails_grid.rb +74 -0
  29. data/lib/rghost/grid/static_callback.rb +13 -0
  30. data/lib/rghost/grid/style/border_lines.rb +44 -0
  31. data/lib/rghost/grid/style/bottom_lines.rb +28 -0
  32. data/lib/rghost/grid/style/old_forms.rb +28 -0
  33. data/lib/rghost/grid/style/style.rb +8 -0
  34. data/lib/rghost/gs_alone.rb +25 -0
  35. data/lib/rghost/helpers.rb +13 -0
  36. data/lib/rghost/horizontal_line.rb +45 -0
  37. data/lib/rghost/how_to.rb +75 -0
  38. data/lib/rghost/image.rb +29 -0
  39. data/lib/rghost/jpeg.rb +39 -0
  40. data/lib/rghost/line.rb +89 -0
  41. data/lib/rghost/line_width.rb +28 -0
  42. data/lib/rghost/load.rb +43 -0
  43. data/lib/rghost/newpath.rb +19 -0
  44. data/lib/rghost/paper.rb +147 -0
  45. data/lib/rghost/parse_text.rb +53 -0
  46. data/lib/rghost/pdf_security.rb +36 -0
  47. data/lib/rghost/point.rb +23 -0
  48. data/lib/rghost/point_with_command.rb +17 -0
  49. data/lib/rghost/polygon.rb +75 -0
  50. data/lib/rghost/ps/AdobeExpert.enc +258 -0
  51. data/lib/rghost/ps/AdobeLatinEncoding.enc +258 -0
  52. data/lib/rghost/ps/Bengali.enc +386 -0
  53. data/lib/rghost/ps/CodePage1250.enc +258 -0
  54. data/lib/rghost/ps/CodePage1251.enc +258 -0
  55. data/lib/rghost/ps/CodePage1252.enc +258 -0
  56. data/lib/rghost/ps/CodePage1253.enc +258 -0
  57. data/lib/rghost/ps/CodePage1254.enc +258 -0
  58. data/lib/rghost/ps/CodePage1256.enc +258 -0
  59. data/lib/rghost/ps/CodePage1257.enc +258 -0
  60. data/lib/rghost/ps/CodePage1258.enc +258 -0
  61. data/lib/rghost/ps/CodePage874.enc +258 -0
  62. data/lib/rghost/ps/Fontmap +5 -0
  63. data/lib/rghost/ps/IsoLatin.enc +352 -0
  64. data/lib/rghost/ps/MacCentralEuropean.enc +258 -0
  65. data/lib/rghost/ps/MacCyrillice.desnc +258 -0
  66. data/lib/rghost/ps/MacGreek.enc +258 -0
  67. data/lib/rghost/ps/MacHebrew.enc +258 -0
  68. data/lib/rghost/ps/TeX-CorkEncoding.enc +258 -0
  69. data/lib/rghost/ps/TeX-LGR-Greek.enc +258 -0
  70. data/lib/rghost/ps/TeX-T2AModified2Encoding.enc +258 -0
  71. data/lib/rghost/ps/TeX-T2BAdobeEncoding.enc +258 -0
  72. data/lib/rghost/ps/TeX-T2CAdobeEncoding.enc +258 -0
  73. data/lib/rghost/ps/TeX-X2AdobeEncoding.enc +258 -0
  74. data/lib/rghost/ps/TeX-XL2encoding.enc +258 -0
  75. data/lib/rghost/ps/TeXMathExtensionEncoding.enc +258 -0
  76. data/lib/rghost/ps/TeXMathItalicEncoding.enc +258 -0
  77. data/lib/rghost/ps/TeXMathSymbolEncoding.enc +258 -0
  78. data/lib/rghost/ps/US-ASCII.enc +258 -0
  79. data/lib/rghost/ps/UTF-8.enc +3 -0
  80. data/lib/rghost/ps/_cusor.ps +46 -0
  81. data/lib/rghost/ps/basic.ps +25 -0
  82. data/lib/rghost/ps/begin_document.ps +8 -0
  83. data/lib/rghost/ps/callbacks.ps +175 -0
  84. data/lib/rghost/ps/code128.font +344 -0
  85. data/lib/rghost/ps/code39.font +195 -0
  86. data/lib/rghost/ps/cursor.ps +106 -0
  87. data/lib/rghost/ps/datagrid.ps +55 -0
  88. data/lib/rghost/ps/developer.ps +237 -0
  89. data/lib/rghost/ps/ean.font +150 -0
  90. data/lib/rghost/ps/eps.ps +42 -0
  91. data/lib/rghost/ps/font.ps +38 -0
  92. data/lib/rghost/ps/frame.ps +16 -0
  93. data/lib/rghost/ps/gif.ps +150 -0
  94. data/lib/rghost/ps/horizontal_line.ps +4 -0
  95. data/lib/rghost/ps/i25.font +103 -0
  96. data/lib/rghost/ps/jpeg.ps +122 -0
  97. data/lib/rghost/ps/link.ps +22 -0
  98. data/lib/rghost/ps/paper.ps +8 -0
  99. data/lib/rghost/ps/rect_link.ps +17 -0
  100. data/lib/rghost/ps/rectangle.ps +5 -0
  101. data/lib/rghost/ps/rghost_default_template.eps +1532 -0
  102. data/lib/rghost/ps/row.ps +4 -0
  103. data/lib/rghost/ps/show.ps +21 -0
  104. data/lib/rghost/ps/table_callbacks.ps +96 -0
  105. data/lib/rghost/ps/text.ps +63 -0
  106. data/lib/rghost/ps/textarea.ps +11 -0
  107. data/lib/rghost/ps/type.ps +1 -0
  108. data/lib/rghost/ps/unit.ps +3 -0
  109. data/lib/rghost/ps/vertical_line.ps +12 -0
  110. data/lib/rghost/ps/virtual_pages.ps +55 -0
  111. data/lib/rghost/ps_facade.rb +253 -0
  112. data/lib/rghost/ps_object.rb +55 -0
  113. data/lib/rghost/rectangle_link.rb +65 -0
  114. data/lib/rghost/rgengine.so +0 -0
  115. data/lib/rghost/ruby_ghost_config.rb +252 -0
  116. data/lib/rghost/ruby_ghost_engine.rb +174 -0
  117. data/lib/rghost/ruby_ghost_version.rb +8 -0
  118. data/lib/rghost/ruby_to_ps.rb +78 -0
  119. data/lib/rghost/scale.rb +29 -0
  120. data/lib/rghost/shape_content.rb +23 -0
  121. data/lib/rghost/show.rb +88 -0
  122. data/lib/rghost/static_document_callback.rb +18 -0
  123. data/lib/rghost/text.rb +44 -0
  124. data/lib/rghost/text_in.rb +51 -0
  125. data/lib/rghost/text_link_in.rb +42 -0
  126. data/lib/rghost/textarea.rb +88 -0
  127. data/lib/rghost/units.rb +82 -0
  128. data/lib/rghost/variable.rb +12 -0
  129. data/lib/rghost/vertical_line.rb +37 -0
  130. data/lib/rghost/virtual_pages.rb +42 -0
  131. data/lib/rghost.rb +18 -0
  132. metadata +181 -0
@@ -0,0 +1,51 @@
1
+
2
+ # Grid::CSV allows you to import data from a csv file.
3
+
4
+ # ===Example
5
+ #
6
+ # grid=Grid::CSV.new :width => 2
7
+ # grid.column :title => "User", :align => :right
8
+ # grid.column :title => "Password", :format => lambda{|v| (v.to_s == "x") ? "Yes" : "No"}
9
+ # grid.column :title => "UID", :width => 1
10
+ # grid.column :title => "GID"
11
+ # grid.column :title => "Gecos", :width => 2.5
12
+ # grid.column :title => "Home Dir", :width => 4
13
+ # grid.column :title => "Shell"
14
+ # grid.style :bottom_lines
15
+ # grid.data("/etc/passwd",/:/)
16
+ #
17
+ # link:images/csvgrid01.png
18
+ #
19
+ class RGhost::Grid::CSV < RGhost::Grid::Base
20
+ # Pass in path to file and the record separator:
21
+ # grid.data("/mydir/myfile.csv", ';')
22
+ # You can use a regular expression for record separator:
23
+ # grid.data("/mydir/myfile.csv", /[^\w]/)
24
+
25
+ def data(filepath,col_sep=';')
26
+ _data=filepath
27
+ first=true
28
+ _data=File.open(_data) if _data.is_a? String
29
+ _data.each do |line|
30
+ l=line.split(Regexp.new(col_sep)) if col_sep.is_a?(String)
31
+ l=line.split(col_sep) if col_sep.is_a?(Regexp)
32
+ if first
33
+ v=l.size-@header.titles.size
34
+ #v.times{@header.titles << "tt"}
35
+ #l.each {|h| col(h)} if @header.titles.size == 0
36
+ l.each {|h| col("")} if @header.titles.size == 0
37
+ proc_line(l)
38
+ first=false
39
+
40
+ next
41
+ else
42
+
43
+ proc_line(l)
44
+ end
45
+ end
46
+
47
+ end
48
+
49
+
50
+
51
+ end
@@ -0,0 +1,12 @@
1
+ require "rghost/callback"
2
+ #Dynamic Callbacks
3
+ class RGhost::Grid::DynamicCallback < RGhost::Callback
4
+ ACCEPT=[:before_row, :after_row, :even_row,
5
+ :odd_row, :before_column, :after_column, :even_column, :odd_column]
6
+
7
+ def initialize(name,options={},&block)
8
+ raise NameError.new("#{name} no accept in #{self.class}") unless ACCEPT.include? name
9
+ super(name,options,&block)
10
+ end
11
+
12
+ end
@@ -0,0 +1,43 @@
1
+ $LOAD_PATH << File.dirname(__FILE__)+File::SEPARATOR+"../"
2
+
3
+ require 'rghost/ps_object'
4
+
5
+ require 'rghost/ruby_to_ps'
6
+
7
+ module RGhost::Grid
8
+ module FieldFormat
9
+ extend RGhost::RubyToPs
10
+ #Format Time/Date to %d/%m/%Y
11
+ def self.eurodate(value)
12
+
13
+ string(value.strftime("%d/%m/%Y"))
14
+ end
15
+ #Cut all blank spaces
16
+ def self.no_space(value)
17
+ string(value.to_s.gsub(/\s/,''))
18
+ end
19
+
20
+ def self.string(value)
21
+ to_string(value)
22
+ end
23
+
24
+ end
25
+ end
26
+ #Prototype to override format method.
27
+ class RGhost::Grid::FieldFormat::Custom
28
+
29
+ def initialize(value)
30
+ @value=value
31
+ end
32
+
33
+ def gs_format
34
+ RGhost::Grid::FieldFormat.string(self.format)
35
+ end
36
+
37
+ def format
38
+ @value.to_s
39
+ end
40
+
41
+ end
42
+
43
+
@@ -0,0 +1,15 @@
1
+ module RGhost::Grid
2
+ require 'rghost/grid/header'
3
+ require 'rghost/grid/callback_facade'
4
+ require 'rghost/grid/style/style'
5
+ require 'rghost/grid/base_grid'
6
+ require 'rghost/grid/rails_grid'
7
+ require 'rghost/grid/matrix'
8
+ require 'rghost/grid/csv_grid'
9
+ require 'rghost/grid/dynamic_callback'
10
+ require 'rghost/grid/static_callback'
11
+ require 'rghost/grid/field_format'
12
+ end
13
+
14
+
15
+
@@ -0,0 +1,120 @@
1
+ $LOAD_PATH << File.dirname(__FILE__)+File::SEPARATOR+"../"
2
+ require "rghost/ps_object"
3
+ require "rghost/ruby_to_ps"
4
+ require "rghost/variable"
5
+ require "rghost/units"
6
+ require "rghost/function"
7
+ require "rghost/callback"
8
+
9
+ # Grid's Header.
10
+ # You can get a header instance using:
11
+ # grid=Grid::Rails.new
12
+ # grid.header
13
+ #
14
+ # You can also define callbacks:
15
+ #
16
+ # grid.header.before_column :only => [1,2] do
17
+ # use_tag :span
18
+ # end
19
+ #
20
+ class RGhost::Grid::Header < RGhost::PsObject
21
+ include RGhost::RubyToPs
22
+
23
+ DEFAULT_OPTIONS={:width => 4, :align => :center, :title_align => nil, :header_width => nil, :format => :string}
24
+ attr_reader :data_types, :titles, :size
25
+
26
+ def initialize(headings=true,options={},&block) #:nodoc:
27
+ @header=RGhost::PsObject.new
28
+ @data_types=[]
29
+ @options=[]
30
+ @titles=[]
31
+ @header.set RGhost::Variable.new(:new_page?,true)
32
+ @default_options=DEFAULT_OPTIONS.merge(options)
33
+ @header.set RGhost::Variable.new(:headings?,headings)
34
+ @size=0
35
+ instance_eval(&block) if block
36
+
37
+ end
38
+
39
+ def ps
40
+
41
+ p,h=format_header
42
+ @header.set RGhost::Variable.new(:header_titles,to_array(@titles))
43
+ @header.set RGhost::Variable.new(:table_params," [\n #{p}] \n")
44
+ @header.set RGhost::Variable.new(:table_header," [\n #{h}] \n")
45
+
46
+
47
+ @header
48
+ end
49
+
50
+ def col(name="", options={}) #:nodoc:
51
+
52
+ opts=@default_options.merge(options)
53
+ @size+=opts[:width]
54
+ @data_types << opts[:format]
55
+ @options << opts
56
+ @titles << ps_escape(name.to_s)
57
+
58
+ end
59
+
60
+ def default_options(opts) #:nodoc:
61
+ @default_options.merge!(opts)
62
+
63
+ end
64
+
65
+ def column(name,options={}) #:nodoc:
66
+ col(name,options)
67
+ end
68
+
69
+ def next_column(name,options={}) #:nodoc:
70
+ col(name,options)
71
+ end
72
+
73
+ def before_create(&block)
74
+ #@header.set RGhost::Function.new(:before_header_create, &block )
75
+ new_static_callback(:before_header_create,&block)
76
+ end
77
+
78
+
79
+ def after_create(&block)
80
+ #@header.set RGhost::Function.new(:after_header_create, &block )
81
+ new_static_callback(:after_header_create,&block)
82
+ end
83
+
84
+ def before_column(options={},&block)
85
+ @header.set RGhost::Callback.new(:before_column_header, options,&block)
86
+
87
+ end
88
+
89
+ def after_column(options={},&block)
90
+ @header.set RGhost::Callback.new(:after_column_header,options,&block)
91
+
92
+ end
93
+
94
+ private
95
+ def new_static_callback(name,&block)
96
+
97
+ callback_body= RGhost::PsFacade.new(&block)
98
+ @header.set RGhost::Function.new(name,callback_body)
99
+ end
100
+ def format_header
101
+ p='' #params
102
+ h='' #params_head
103
+ o=@options.dup
104
+ o.each do |v|
105
+ v[:title_align]||=v[:align]
106
+ v[:header_width]||=v[:width]
107
+ p << "[ #{RGhost::Units::parse(v[:width])} /st_#{v[:align]}]\n "
108
+ h << "[ #{RGhost::Units::parse(v[:header_width])} /st_#{v[:title_align]}]\n "
109
+ end
110
+
111
+ return p,h
112
+
113
+ end
114
+
115
+
116
+ end
117
+
118
+
119
+
120
+
@@ -0,0 +1,10 @@
1
+ # Implements data method for Grid::Base. You can consult the examples at Grid::Base.
2
+ class RGhost::Grid::Matrix < RGhost::Grid::Base
3
+
4
+ def data(_data)
5
+ _data.each{|d| proc_line(d) }
6
+
7
+ end
8
+
9
+ end
10
+
@@ -0,0 +1,74 @@
1
+ require 'rghost/ps_object'
2
+ #
3
+ # Grid::Rails mapps grid columns to ActiveRecord attributes. For
4
+ # example, let's take a Calls class to represent telephone calls.
5
+ #
6
+ # ===Example
7
+ # rails_grid=Grid::Rails.new(:align => :center, :width => 3)
8
+ #
9
+ # Mapping, first the attribute name then the already known optionsName
10
+ # rails_grid.column :mobile, :title => "Mobile", :align => :right
11
+ # rails_grid.column :duration, :title => "Duration",:width => 3
12
+ # rails_grid.column :start, :title => "Start", :format => :eurodate
13
+ # rails_grid.column :called, :title => "Number", :align => :right, :title_align => :center
14
+ # Load data
15
+ # calls = Call.find(:all, :limit => 5000)
16
+ # rails_grid.data(calls)
17
+ # ====Relationships
18
+ # You can also use attributes of associated objects, via a block or
19
+ # string. For example consider Accounts and Customers
20
+ # relationship. Let's produce a grid od all Customers plus some data
21
+ # reffering to the first account the customer had created.
22
+ #
23
+ # class Accounts < ActiveRecord::Base
24
+ # belongs_to :customer
25
+ # end
26
+ # class Customers < ActiveRecord::Base
27
+ # has_many :accounts
28
+ # end
29
+ #
30
+ # c = Customers.find(:all, :include => :accounts )
31
+ #
32
+ # Using a block
33
+ # g=Grid::Rails.new :width => 4
34
+ # g.column :id, :title => "Customer id"
35
+ # g.column :name, :title => "Name", :width => 6
36
+ # g.column :created_on, :title => "Date ", :format => lambda{|d| d.strftime("%m/%d/%Y") }
37
+ # g.column lambda { accounts.first.login }, :title => "Login"
38
+ # g.column lambda { accounts.first.type }, :title => "Account Type"
39
+ # g.data(c)
40
+ # Or a String
41
+ # g.column 'accounts.first.login', :title => Login"
42
+ class RGhost::Grid::Rails < RGhost::Grid::Base
43
+ #The parameter +_data+ is an Array of ActiveRecord::Base objects.
44
+ def data(_data)
45
+ _data.collect do |d|
46
+ line=@rails_cols.collect do |c|
47
+ case c[:field_name]
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])
54
+ end
55
+ end
56
+ proc_line(line)
57
+ end
58
+ end
59
+
60
+ def col(field_name, options={}) #:nodoc:
61
+ super(options[:title],options)
62
+
63
+ @rails_cols||=[]
64
+ owf=options.dup #from options with field
65
+ owf[:field_name]||=field_name
66
+ @rails_cols << owf
67
+
68
+ end
69
+
70
+ def column(field_name, options={}) #:nodoc:
71
+ col(field_name,options)
72
+ end
73
+
74
+ end
@@ -0,0 +1,13 @@
1
+ require "rghost/ps_object"
2
+ require "rghost/function"
3
+
4
+ class RGhost::Grid::StaticCallback < RGhost::Function
5
+ ACCEPT=[:before_table_create, :after_table_create]
6
+
7
+ def initialize(name,&block)
8
+ raise NameError.new("#{name} no accept in #{self.class}") unless ACCEPT.include? name
9
+ super(name,&block)
10
+ end
11
+
12
+ end
13
+
@@ -0,0 +1,44 @@
1
+ class RGhost::Grid::Style::BorderLines
2
+
3
+ def set_style(grid)
4
+
5
+ grid.before_row do |b|
6
+
7
+ b.horizontal_line(:top, :size => grid.width)
8
+ b.horizontal_line(:bottom, :size => grid.width)
9
+ end
10
+
11
+ grid.before_column :only => 0 do |b|
12
+ b.vertical_line_row
13
+ end
14
+
15
+ grid.after_column do |c|
16
+ c.vertical_line_row
17
+ end
18
+
19
+
20
+ grid.header.before_create do |c|
21
+ c.line_width(0)
22
+ c.use_tag :bold
23
+ c.horizontal_line(:top, :size => grid.width)
24
+ c.horizontal_line(:bottom,:size => grid.width)
25
+ end
26
+
27
+ grid.header.after_create {|a| a.use_tag :normal }
28
+
29
+
30
+ grid.header.before_column :only => 0 do |h|
31
+ h.vertical_line_row
32
+ end
33
+
34
+ grid.header.after_column do |h|
35
+ h.vertical_line_row
36
+ end
37
+
38
+
39
+
40
+
41
+ end
42
+
43
+
44
+ end
@@ -0,0 +1,28 @@
1
+ class RGhost::Grid::Style::BottomLines
2
+
3
+ def set_style(grid)
4
+
5
+ size=grid.header.size
6
+ grid.before_row do |b|
7
+ b.horizontal_line(:bottom,:size => grid.width)
8
+
9
+ end
10
+
11
+ grid.header.before_create do |h|
12
+ h.line_width(0)
13
+ h.horizontal_line(:bottom,:size => grid.width)
14
+ h.use_tag :bold
15
+ end
16
+
17
+ grid.header.after_create {|h| h.use_tag :normal }
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+ end
26
+
27
+
28
+ end
@@ -0,0 +1,28 @@
1
+ class RGhost::Grid::Style::OldForms
2
+
3
+ def set_style(grid)
4
+
5
+ size=grid.header.size
6
+ grid.odd_row do |o|
7
+ o.background_row(:size => size)
8
+
9
+ end
10
+
11
+ grid.header.before_create do |h|
12
+ h.line_width(0)
13
+ h.background_row(:size => size, :color => RGhost::ShapeContent::DEFAULT_OPTIONS[:color] )
14
+ h.use_tag :bold
15
+ end
16
+
17
+ grid.header.after_create {|h| h.use_tag :normal }
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+ end
26
+
27
+
28
+ end
@@ -0,0 +1,8 @@
1
+
2
+ module RGhost::Grid
3
+ module Style
4
+ require 'rghost/grid/style/border_lines'
5
+ require 'rghost/grid/style/old_forms'
6
+ require 'rghost/grid/style/bottom_lines'
7
+ end
8
+ end
@@ -0,0 +1,25 @@
1
+ class RGhost::GSAlone #:nodoc:
2
+
3
+ def initialize(params,debug=false)
4
+ @params=params.dup
5
+ @params[0]=" "
6
+ @debug=debug
7
+ end
8
+
9
+ def run
10
+ cmd=@params.join(" ")
11
+ #puts File.exists?(RGhost::Config::GS[:path].to_s)
12
+ unless File.exists?(RGhost::Config::GS[:path].to_s)
13
+ RGhost::Config.config_platform
14
+ end
15
+ r=system(RGhost::Config::GS[:path]+cmd)
16
+
17
+ puts RGhost::Config::GS[:path]+cmd if @debug
18
+ #puts r
19
+ r
20
+ end
21
+
22
+
23
+
24
+ end
25
+
@@ -0,0 +1,13 @@
1
+ module RGhost::UnlessHelpers #:nodoc:
2
+ module HashKeyMethod #:nodoc:
3
+ def method_missing(method, *args)
4
+ self[method.to_sym]
5
+ end
6
+ end
7
+
8
+ class HashKeyMethodClass < Hash #:nodoc:
9
+ include HashKeyMethod
10
+ end
11
+
12
+
13
+ end
@@ -0,0 +1,45 @@
1
+ require "rghost/ps_object"
2
+ require "rghost/units"
3
+ #Creates horizontal line on the current row.
4
+ class RGhost::HorizontalLine < RGhost::PsObject
5
+
6
+ DEFAULT_OPTIONS={:start_in => :limit_left, :size => :area_x,
7
+ :border => RGhost::Border::DEFAULT_OPTIONS
8
+
9
+ }
10
+
11
+ #Examples
12
+ #
13
+ #Drawing line on middle
14
+ #
15
+ # doc.show "Foo Bar"
16
+ # doc.horizontal_line :middle
17
+ #
18
+ #link:images/horizontal_line01.png
19
+ #
20
+ #Drawing line on bottom and customizing border attributes
21
+ #
22
+ # doc.show "Foo Bar"
23
+ # doc.horizontal_line :bottom, :border => {:dash => [1,2,2,2], :color => :red}
24
+ #
25
+ #link:images/horizontal_line02.png
26
+ #
27
+ #Specifies size and where will start of line
28
+ #
29
+ # doc.show "Foo Bar"
30
+ # doc.horizontal_line :top, :start_in => 2, :size => 5, :border => {:dash => [1,2,2,2], :color => :red}
31
+ #
32
+ #link:images/horizontal_line03.png
33
+
34
+
35
+ def initialize(valign=:middle,options={})
36
+ @options=DEFAULT_OPTIONS.dup.merge(options)
37
+ start_in= RGhost::Units::parse(@options[:start_in])
38
+ size= RGhost::Units::parse(@options[:size])
39
+ border=RGhost::Border.new(@options[:border])
40
+ super("gsave #{border.ps } #{start_in} #{size} horizontal_line_#{valign} grestore")
41
+ #super("#{start_in} #{size} horizontal_line_#{valign}")
42
+
43
+ end
44
+
45
+ end
@@ -0,0 +1,75 @@
1
+ #=Ruby Ghostscript engine - Document Builder
2
+ #==About
3
+ #RubyGhost (RGhost) is a library for document developers wanting a quick and easy
4
+ #way to generate pdf files. Notable features include: inserting images,
5
+ #vector drawing , font suppoort , EPS template support and multiple output formats.
6
+ #RGhost acts as Ruby a wrapper over the Ghostscript engine enriched by predefined
7
+ #set Postscript(ps) functions. For example:
8
+ #
9
+ #Ruby code you'll write:
10
+ #
11
+ # h=HorizontalLine.new :middle, :start_in => 3, :size => 2
12
+ #
13
+ #gets translated to the following Postscript function. Note how this is not actually
14
+ #raw Postscript, instead it makes use of a set of predefined functions shipped with Rghost.
15
+ #
16
+ # 3 unit 2 unit exch gsave current_row row_height sqrt add moveto 0 rlineto stroke grestore
17
+ #
18
+ #Unless embarking into deep Postscript wizardry you don't need to be aware of this fact.
19
+ #Basically RGhost is a helper for creating of Postscript documents.
20
+ #The resulting Postscript document is rendered to the target format (usually pdf but not just)
21
+ #by invoking Ghostscript the free Postscript interpreter. Ghostscript settings very
22
+ #a lot depending on your platform. Initially RGhost was developed for *nix environments
23
+ #where Ghostscript is (almost always) native and used as a printing filter (CUPS, LPRng etc)
24
+ #and also as a document format converter. So it became necessary to make an interface
25
+ #between Ruby and Ghostscript in two ways:
26
+ #
27
+ #* gsapi - based on the exchange of data between Ruby and Ghostscript via rgengine.so using gslib.so.8 or gslib-esp.so.8
28
+ #* gsparams - In this mode RGhost just pass parameters to the Ghostscript framework.1.1 Files
29
+ #
30
+ #During the conversion of the postscript code to the desired format 4 files are created, 3 of them being temporary.
31
+ #
32
+ #====Input
33
+ #The input file is a pure postscript file with a .rgin extension that will be automatically removed after the conversion process, even if errors show up.
34
+ #
35
+ #====Errors
36
+ #Using a .rgerr extension, its content are the errors generated by ghostscript. It'll be deleted after the conversion. The content of the file is available on the errors variable of the RubyGhostEngine class.
37
+ #
38
+ #====Log
39
+ #The log file is set using the option :logfile of the RubyGhostEngine class, appending all logs to it. Disabled by default.
40
+ #
41
+ #====Output
42
+ #The output files will have the extension passed to the RGhost::Document#render method. For multi page formats it will return an array of files. These files aren't deleted automatically, meaning that the developer will have to deal with them.
43
+ #====Author
44
+ #Shairon Toledo shairon.toledo(at)gmail.com http://www.hashcode.eti.br Brazil Jun/2008
45
+ #====Thanks
46
+ #Dee Zsombor[http://deezsombor.com] and Mereghost
47
+ #
48
+ #==Installation and Setup
49
+ #====Ghostscript
50
+ #You need to have ESP Ghostscript 8.xx or GNU Ghostscript 8.xx installed
51
+ #
52
+ #=====Non-coupled installation: *gsparams* (recommended)
53
+ #This is the simplest setup, you'll have to dowload and install the Ghostscript framework(http://www.cs.wisc.edu/~ghost/).
54
+ #Rhgost will invoke the ghostscript interpreter in the background to generate the desired output.
55
+ #
56
+ #===== Coupled installation: *gslib* (Linux only)
57
+ #You can use the native ghostrcipt interface via the gs-esp and libgs-esp8 (libgs-esp.so) packages. This may be already set up for you on Linux or you'll have to compile ghostscript
58
+ #=====Installation via remote gem
59
+ # gem install rghost
60
+ #
61
+ #=====Rails plugin installation
62
+ #Gets last version in RubyForge[http://rubyforge.org/frs/?group_id=3796&release_id=18301] unpack on RAILS_ROOT/lib
63
+ #====Setup
64
+ #Look at RGhost::Config
65
+ #==Namespace
66
+ #You can work either full namespace of including RGhost module.
67
+ #=====Full namespace
68
+ # doc=RGhost::Document.new
69
+ #=====Including module RGhost
70
+ # include RGhost
71
+ # doc=Document.new
72
+
73
+ class RGhost::HowTo
74
+
75
+ end
@@ -0,0 +1,29 @@
1
+ require "rghost/ps_object"
2
+ #Super class of GIF and JPEG.
3
+ class RGhost::Image < RGhost::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
+ #Facade method for load image by file extension. Uses Eps, Gif and Jpeg class. Accepts gif, jpeg, jpg and eps
13
+ def self.for(path,options={})
14
+
15
+ clazz=case path
16
+ when /gif$/i
17
+ RGhost::Gif
18
+ when /jpe?g$/i
19
+ RGhost::Jpeg
20
+ when /(eps|template)$/i
21
+ RGhost::Eps
22
+ else raise NameError.new("Unsupported format")
23
+ end
24
+
25
+ clazz.new(path,options)
26
+ end
27
+
28
+
29
+ end
@@ -0,0 +1,39 @@
1
+ require "rghost/ps_object"
2
+ require "rghost/graphic"
3
+ require "rghost/cursor"
4
+ require "rghost/variable"
5
+ require "rghost/image"
6
+ #Loads JPEG image from file
7
+ #===Examples
8
+ # doc=Document.new
9
+ # doc.set Jpeg.new "../public/images/button.jpg", :x => 10, :y => 3
10
+ #Using Image.for facade
11
+ # doc.set Image.for "../public/images/button.jpg", :x => 10, :y => 3
12
+ #Using PsFacade or Document
13
+ # doc.image "images/button.jpg", :x => 10, :y => 3
14
+ #Using Zoom of the 200 percent
15
+ # doc.image "images/button.jpg", :zoom => 200
16
+ #===Options
17
+ #
18
+ #* <tt>:x and :y</tt> - Coordinates to position.
19
+ #* <tt>:rotate</tt> - Angle to image rotation if there is one.
20
+ #* <tt>:zoom</tt> - Resize proportionally the image
21
+ class RGhost::Jpeg < RGhost::Image
22
+
23
+
24
+
25
+ def ps
26
+ #x=Units::parse( @options[:x] )
27
+ #y=Units::parse( @options[:y] )
28
+
29
+ g=RGhost::Graphic.new
30
+ g.set RGhost::Cursor.translate(@options)
31
+ #set Cursor.translate()
32
+ g.set RGhost::Cursor.rotate(@options[:rotate])
33
+ g.set RGhost::Variable.new(:zoom,@options[:zoom]/100.0)
34
+ g.set RGhost::PsObject.new("(#{@file}) viewJPEG")
35
+ g.ps
36
+
37
+ end
38
+
39
+ end