rghost 0.7.4 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (447) hide show
  1. data/lib/rghost/border.rb +44 -0
  2. data/lib/rghost/callback.rb +25 -22
  3. data/lib/rghost/circle.rb +102 -0
  4. data/lib/rghost/color.rb +81 -56
  5. data/lib/rghost/constants.rb +599 -589
  6. data/lib/rghost/convert.rb +26 -7
  7. data/lib/rghost/cursor.rb +90 -58
  8. data/lib/rghost/dash.rb +59 -0
  9. data/lib/rghost/document.rb +334 -311
  10. data/lib/rghost/document_callback_facade.rb +64 -0
  11. data/lib/rghost/dsc_entry.rb +12 -12
  12. data/lib/rghost/dynamic_document_callback.rb +6 -18
  13. data/lib/rghost/eps.rb +17 -8
  14. data/lib/rghost/font.rb +19 -23
  15. data/lib/rghost/font_map.rb +40 -0
  16. data/lib/rghost/frame.rb +105 -0
  17. data/lib/rghost/function.rb +19 -21
  18. data/lib/rghost/gif.rb +22 -9
  19. data/lib/rghost/graphic.rb +3 -3
  20. data/lib/rghost/grid/base_grid.rb +218 -0
  21. data/lib/rghost/grid/callback_facade.rb +136 -0
  22. data/lib/rghost/grid/csv_grid.rb +50 -0
  23. data/lib/rghost/{data_grid → grid}/dynamic_callback.rb +2 -2
  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 +70 -0
  29. data/lib/rghost/{data_grid → grid}/static_callback.rb +4 -4
  30. data/lib/rghost/grid/style/border_lines.rb +46 -0
  31. data/lib/rghost/grid/style/bottom_lines.rb +30 -0
  32. data/lib/rghost/grid/style/old_forms.rb +30 -0
  33. data/lib/rghost/grid/style/style.rb +8 -0
  34. data/lib/rghost/gs_alone.rb +7 -5
  35. data/lib/rghost/helpers.rb +4 -4
  36. data/lib/rghost/horizontal_line.rb +35 -19
  37. data/lib/rghost/how_to.rb +75 -0
  38. data/lib/rghost/image.rb +8 -8
  39. data/lib/rghost/jpeg.rb +21 -8
  40. data/lib/rghost/line.rb +66 -17
  41. data/lib/rghost/line_width.rb +19 -8
  42. data/lib/rghost/load.rb +24 -22
  43. data/lib/rghost/newpath.rb +8 -7
  44. data/lib/rghost/paper.rb +100 -41
  45. data/lib/rghost/parse_text.rb +53 -0
  46. data/lib/rghost/point.rb +9 -8
  47. data/lib/rghost/point_with_command.rb +5 -5
  48. data/lib/rghost/polygon.rb +75 -0
  49. data/lib/rghost/ps/AdobeExpert.enc +0 -0
  50. data/lib/rghost/ps/AdobeLatinEncoding.enc +0 -0
  51. data/lib/rghost/ps/Bengali.enc +0 -0
  52. data/lib/rghost/ps/CodePage1250.enc +0 -0
  53. data/lib/rghost/ps/CodePage1251.enc +0 -0
  54. data/lib/rghost/ps/CodePage1252.enc +0 -0
  55. data/lib/rghost/ps/CodePage1253.enc +0 -0
  56. data/lib/rghost/ps/CodePage1254.enc +0 -0
  57. data/lib/rghost/ps/CodePage1256.enc +0 -0
  58. data/lib/rghost/ps/CodePage1257.enc +0 -0
  59. data/lib/rghost/ps/CodePage1258.enc +0 -0
  60. data/lib/rghost/ps/CodePage874.enc +0 -0
  61. data/lib/rghost/ps/Fontmap +5 -0
  62. data/lib/rghost/ps/IsoLatin.enc +0 -0
  63. data/lib/rghost/ps/MacCentralEuropean.enc +0 -0
  64. data/lib/rghost/ps/{MacCyrillice.enc → MacCyrillice.desnc} +0 -0
  65. data/lib/rghost/ps/MacGreek.enc +0 -0
  66. data/lib/rghost/ps/MacHebrew.enc +0 -0
  67. data/lib/rghost/ps/TeX-CorkEncoding.enc +0 -0
  68. data/lib/rghost/ps/TeX-LGR-Greek.enc +0 -0
  69. data/lib/rghost/ps/TeX-T2AModified2Encoding.enc +0 -0
  70. data/lib/rghost/ps/TeX-T2BAdobeEncoding.enc +0 -0
  71. data/lib/rghost/ps/TeX-T2CAdobeEncoding.enc +0 -0
  72. data/lib/rghost/ps/TeX-X2AdobeEncoding.enc +0 -0
  73. data/lib/rghost/ps/TeX-XL2encoding.enc +0 -0
  74. data/lib/rghost/ps/TeXMathExtensionEncoding.enc +0 -0
  75. data/lib/rghost/ps/TeXMathItalicEncoding.enc +0 -0
  76. data/lib/rghost/ps/TeXMathSymbolEncoding.enc +0 -0
  77. data/lib/rghost/ps/US-ASCII.enc +0 -0
  78. data/lib/rghost/ps/UTF-8.enc +0 -0
  79. data/lib/rghost/ps/__datagrid.ps +52 -0
  80. data/lib/rghost/ps/_cusor.ps +46 -0
  81. data/lib/rghost/ps/basic.ps +12 -1
  82. data/lib/rghost/ps/begin_document.ps +1 -0
  83. data/lib/rghost/ps/callbacks.ps +32 -3
  84. data/lib/rghost/ps/code128.font +0 -0
  85. data/lib/rghost/ps/code39.font +0 -0
  86. data/lib/rghost/ps/cursor.ps +77 -13
  87. data/lib/rghost/ps/datagrid.ps +4 -1
  88. data/lib/rghost/ps/developer.ps +237 -0
  89. data/lib/rghost/ps/ean.font +0 -0
  90. data/lib/rghost/ps/eps.ps +0 -0
  91. data/lib/rghost/ps/font.ps +8 -1
  92. data/lib/rghost/ps/frame.ps +16 -0
  93. data/lib/rghost/ps/gif.ps +0 -0
  94. data/lib/rghost/ps/horizontal_line.ps +4 -3
  95. data/lib/rghost/ps/i25.font +0 -0
  96. data/lib/rghost/ps/jpeg.ps +0 -0
  97. data/lib/rghost/ps/paper.ps +0 -0
  98. data/lib/rghost/ps/rectangle.ps +0 -0
  99. data/lib/rghost/ps/rghost_default_template.eps +1532 -0
  100. data/lib/rghost/ps/row.ps +0 -0
  101. data/lib/rghost/ps/show.ps +2 -1
  102. data/lib/rghost/ps/table_callbacks.ps +0 -0
  103. data/lib/rghost/ps/text.ps +63 -0
  104. data/lib/rghost/ps/textarea.ps +1 -1
  105. data/lib/rghost/ps/type.ps +0 -0
  106. data/lib/rghost/ps/unit.ps +0 -0
  107. data/lib/rghost/ps/vertical_line.ps +2 -4
  108. data/lib/rghost/ps/virtual_pages.ps +55 -0
  109. data/lib/rghost/ps_facade.rb +256 -0
  110. data/lib/rghost/ps_object.rb +24 -20
  111. data/lib/rghost/rgengine.so +0 -0
  112. data/lib/rghost/ruby_ghost_config.rb +224 -16
  113. data/lib/rghost/ruby_ghost_engine.rb +32 -55
  114. data/lib/rghost/ruby_ghost_version.rb +8 -0
  115. data/lib/rghost/ruby_to_ps.rb +52 -78
  116. data/lib/rghost/scale.rb +22 -7
  117. data/lib/rghost/shape_content.rb +23 -0
  118. data/lib/rghost/show.rb +77 -20
  119. data/lib/rghost/static_document_callback.rb +3 -7
  120. data/lib/rghost/text.rb +44 -0
  121. data/lib/rghost/text_in.rb +36 -14
  122. data/lib/rghost/textarea.rb +66 -93
  123. data/lib/rghost/units.rb +45 -44
  124. data/lib/rghost/variable.rb +4 -4
  125. data/lib/rghost/vertical_line.rb +27 -19
  126. data/lib/rghost/virtual_pages.rb +42 -0
  127. data/lib/rghost.rb +16 -2
  128. metadata +153 -500
  129. data/lib/rghost/arc.rb +0 -39
  130. data/lib/rghost/barcode.rb +0 -40
  131. data/lib/rghost/data_grid/basic_grid.rb +0 -136
  132. data/lib/rghost/data_grid/csv_grid.rb +0 -27
  133. data/lib/rghost/data_grid/data_grid.rb +0 -14
  134. data/lib/rghost/data_grid/field_format.rb +0 -60
  135. data/lib/rghost/data_grid/grid.rb +0 -18
  136. data/lib/rghost/data_grid/header.rb +0 -111
  137. data/lib/rghost/data_grid/rails_grid.rb +0 -62
  138. data/lib/rghost/data_grid/style/border_lines.rb +0 -47
  139. data/lib/rghost/data_grid/style/bottom_lines.rb +0 -30
  140. data/lib/rghost/data_grid/style/old_forms.rb +0 -30
  141. data/lib/rghost/data_grid/style/style.rb +0 -8
  142. data/lib/rghost/doc/classes/Arc.html +0 -200
  143. data/lib/rghost/doc/classes/Arc.src/M000049.html +0 -18
  144. data/lib/rghost/doc/classes/Arc.src/M000050.html +0 -23
  145. data/lib/rghost/doc/classes/Barcode.html +0 -214
  146. data/lib/rghost/doc/classes/Barcode.src/M000001.html +0 -19
  147. data/lib/rghost/doc/classes/Barcode.src/M000002.html +0 -18
  148. data/lib/rghost/doc/classes/Barcode.src/M000003.html +0 -19
  149. data/lib/rghost/doc/classes/Barcode.src/M000004.html +0 -27
  150. data/lib/rghost/doc/classes/CMYK.html +0 -209
  151. data/lib/rghost/doc/classes/CMYK.src/M000047.html +0 -18
  152. data/lib/rghost/doc/classes/CMYK.src/M000048.html +0 -24
  153. data/lib/rghost/doc/classes/Callback.html +0 -220
  154. data/lib/rghost/doc/classes/Callback.src/M000071.html +0 -21
  155. data/lib/rghost/doc/classes/Callback.src/M000072.html +0 -26
  156. data/lib/rghost/doc/classes/Color.html +0 -175
  157. data/lib/rghost/doc/classes/Color.src/M000028.html +0 -33
  158. data/lib/rghost/doc/classes/Constants/Colors.html +0 -129
  159. data/lib/rghost/doc/classes/Constants/Devices.html +0 -163
  160. data/lib/rghost/doc/classes/Constants/Devices.src/M000168.html +0 -22
  161. data/lib/rghost/doc/classes/Constants/Fonts.html +0 -144
  162. data/lib/rghost/doc/classes/Constants/Papers.html +0 -124
  163. data/lib/rghost/doc/classes/Constants.html +0 -120
  164. data/lib/rghost/doc/classes/Convert.html +0 -189
  165. data/lib/rghost/doc/classes/Convert.src/M000067.html +0 -20
  166. data/lib/rghost/doc/classes/Convert.src/M000068.html +0 -24
  167. data/lib/rghost/doc/classes/Cursor.html +0 -330
  168. data/lib/rghost/doc/classes/Cursor.src/M000031.html +0 -21
  169. data/lib/rghost/doc/classes/Cursor.src/M000032.html +0 -21
  170. data/lib/rghost/doc/classes/Cursor.src/M000033.html +0 -20
  171. data/lib/rghost/doc/classes/Cursor.src/M000034.html +0 -18
  172. data/lib/rghost/doc/classes/Cursor.src/M000035.html +0 -18
  173. data/lib/rghost/doc/classes/Cursor.src/M000036.html +0 -19
  174. data/lib/rghost/doc/classes/Cursor.src/M000037.html +0 -22
  175. data/lib/rghost/doc/classes/Cursor.src/M000038.html +0 -18
  176. data/lib/rghost/doc/classes/Cursor.src/M000039.html +0 -18
  177. data/lib/rghost/doc/classes/DSCEntry.html +0 -173
  178. data/lib/rghost/doc/classes/DSCEntry.src/M000059.html +0 -19
  179. data/lib/rghost/doc/classes/DSCEntry.src/M000060.html +0 -19
  180. data/lib/rghost/doc/classes/DataGrid/BasicGrid.html +0 -343
  181. data/lib/rghost/doc/classes/DataGrid/BasicGrid.src/M000140.html +0 -27
  182. data/lib/rghost/doc/classes/DataGrid/BasicGrid.src/M000141.html +0 -26
  183. data/lib/rghost/doc/classes/DataGrid/BasicGrid.src/M000142.html +0 -22
  184. data/lib/rghost/doc/classes/DataGrid/BasicGrid.src/M000143.html +0 -19
  185. data/lib/rghost/doc/classes/DataGrid/BasicGrid.src/M000144.html +0 -26
  186. data/lib/rghost/doc/classes/DataGrid/BasicGrid.src/M000145.html +0 -34
  187. data/lib/rghost/doc/classes/DataGrid/BasicGrid.src/M000146.html +0 -18
  188. data/lib/rghost/doc/classes/DataGrid/BasicGrid.src/M000147.html +0 -37
  189. data/lib/rghost/doc/classes/DataGrid/BasicGrid.src/M000148.html +0 -26
  190. data/lib/rghost/doc/classes/DataGrid/CSVGrid.html +0 -152
  191. data/lib/rghost/doc/classes/DataGrid/CSVGrid.src/M000139.html +0 -32
  192. data/lib/rghost/doc/classes/DataGrid/DynamicCallback.html +0 -158
  193. data/lib/rghost/doc/classes/DataGrid/DynamicCallback.src/M000149.html +0 -19
  194. data/lib/rghost/doc/classes/DataGrid/FieldFormat/Custom.html +0 -176
  195. data/lib/rghost/doc/classes/DataGrid/FieldFormat/Custom.src/M000136.html +0 -18
  196. data/lib/rghost/doc/classes/DataGrid/FieldFormat/Custom.src/M000137.html +0 -18
  197. data/lib/rghost/doc/classes/DataGrid/FieldFormat/Custom.src/M000138.html +0 -18
  198. data/lib/rghost/doc/classes/DataGrid/FieldFormat.html +0 -216
  199. data/lib/rghost/doc/classes/DataGrid/FieldFormat.src/M000131.html +0 -19
  200. data/lib/rghost/doc/classes/DataGrid/FieldFormat.src/M000132.html +0 -18
  201. data/lib/rghost/doc/classes/DataGrid/FieldFormat.src/M000133.html +0 -23
  202. data/lib/rghost/doc/classes/DataGrid/FieldFormat.src/M000134.html +0 -18
  203. data/lib/rghost/doc/classes/DataGrid/FieldFormat.src/M000135.html +0 -22
  204. data/lib/rghost/doc/classes/DataGrid/Grid.html +0 -148
  205. data/lib/rghost/doc/classes/DataGrid/Grid.src/M000160.html +0 -19
  206. data/lib/rghost/doc/classes/DataGrid/Header.html +0 -367
  207. data/lib/rghost/doc/classes/DataGrid/Header.src/M000150.html +0 -26
  208. data/lib/rghost/doc/classes/DataGrid/Header.src/M000151.html +0 -25
  209. data/lib/rghost/doc/classes/DataGrid/Header.src/M000152.html +0 -24
  210. data/lib/rghost/doc/classes/DataGrid/Header.src/M000153.html +0 -19
  211. data/lib/rghost/doc/classes/DataGrid/Header.src/M000154.html +0 -18
  212. data/lib/rghost/doc/classes/DataGrid/Header.src/M000155.html +0 -18
  213. data/lib/rghost/doc/classes/DataGrid/Header.src/M000156.html +0 -18
  214. data/lib/rghost/doc/classes/DataGrid/Header.src/M000157.html +0 -18
  215. data/lib/rghost/doc/classes/DataGrid/Header.src/M000158.html +0 -19
  216. data/lib/rghost/doc/classes/DataGrid/Header.src/M000159.html +0 -19
  217. data/lib/rghost/doc/classes/DataGrid/RailsGrid.html +0 -234
  218. data/lib/rghost/doc/classes/DataGrid/RailsGrid.src/M000161.html +0 -27
  219. data/lib/rghost/doc/classes/DataGrid/RailsGrid.src/M000162.html +0 -23
  220. data/lib/rghost/doc/classes/DataGrid/RailsGrid.src/M000163.html +0 -18
  221. data/lib/rghost/doc/classes/DataGrid/StaticCallback.html +0 -158
  222. data/lib/rghost/doc/classes/DataGrid/StaticCallback.src/M000164.html +0 -19
  223. data/lib/rghost/doc/classes/DataGrid/Style/BorderLines.html +0 -137
  224. data/lib/rghost/doc/classes/DataGrid/Style/BorderLines.src/M000128.html +0 -55
  225. data/lib/rghost/doc/classes/DataGrid/Style/BottomLines.html +0 -137
  226. data/lib/rghost/doc/classes/DataGrid/Style/BottomLines.src/M000129.html +0 -38
  227. data/lib/rghost/doc/classes/DataGrid/Style/OldForms.html +0 -137
  228. data/lib/rghost/doc/classes/DataGrid/Style/OldForms.src/M000130.html +0 -38
  229. data/lib/rghost/doc/classes/DataGrid/Style.html +0 -113
  230. data/lib/rghost/doc/classes/DataGrid.html +0 -133
  231. data/lib/rghost/doc/classes/Document.html +0 -990
  232. data/lib/rghost/doc/classes/Document.src/M000075.html +0 -32
  233. data/lib/rghost/doc/classes/Document.src/M000076.html +0 -18
  234. data/lib/rghost/doc/classes/Document.src/M000077.html +0 -29
  235. data/lib/rghost/doc/classes/Document.src/M000078.html +0 -33
  236. data/lib/rghost/doc/classes/Document.src/M000079.html +0 -20
  237. data/lib/rghost/doc/classes/Document.src/M000080.html +0 -21
  238. data/lib/rghost/doc/classes/Document.src/M000081.html +0 -18
  239. data/lib/rghost/doc/classes/Document.src/M000082.html +0 -19
  240. data/lib/rghost/doc/classes/Document.src/M000083.html +0 -21
  241. data/lib/rghost/doc/classes/Document.src/M000084.html +0 -22
  242. data/lib/rghost/doc/classes/Document.src/M000085.html +0 -18
  243. data/lib/rghost/doc/classes/Document.src/M000086.html +0 -18
  244. data/lib/rghost/doc/classes/Document.src/M000087.html +0 -18
  245. data/lib/rghost/doc/classes/Document.src/M000088.html +0 -18
  246. data/lib/rghost/doc/classes/Document.src/M000089.html +0 -19
  247. data/lib/rghost/doc/classes/Document.src/M000090.html +0 -18
  248. data/lib/rghost/doc/classes/Document.src/M000091.html +0 -18
  249. data/lib/rghost/doc/classes/Document.src/M000092.html +0 -18
  250. data/lib/rghost/doc/classes/Document.src/M000093.html +0 -18
  251. data/lib/rghost/doc/classes/Document.src/M000094.html +0 -18
  252. data/lib/rghost/doc/classes/Document.src/M000095.html +0 -18
  253. data/lib/rghost/doc/classes/Document.src/M000096.html +0 -18
  254. data/lib/rghost/doc/classes/Document.src/M000097.html +0 -18
  255. data/lib/rghost/doc/classes/Document.src/M000098.html +0 -18
  256. data/lib/rghost/doc/classes/Document.src/M000099.html +0 -18
  257. data/lib/rghost/doc/classes/Document.src/M000100.html +0 -18
  258. data/lib/rghost/doc/classes/Document.src/M000101.html +0 -18
  259. data/lib/rghost/doc/classes/Document.src/M000102.html +0 -18
  260. data/lib/rghost/doc/classes/Document.src/M000103.html +0 -18
  261. data/lib/rghost/doc/classes/Document.src/M000104.html +0 -18
  262. data/lib/rghost/doc/classes/Document.src/M000105.html +0 -18
  263. data/lib/rghost/doc/classes/Document.src/M000106.html +0 -18
  264. data/lib/rghost/doc/classes/Document.src/M000107.html +0 -18
  265. data/lib/rghost/doc/classes/Document.src/M000108.html +0 -18
  266. data/lib/rghost/doc/classes/Document.src/M000109.html +0 -18
  267. data/lib/rghost/doc/classes/Document.src/M000110.html +0 -18
  268. data/lib/rghost/doc/classes/Document.src/M000111.html +0 -20
  269. data/lib/rghost/doc/classes/Document.src/M000112.html +0 -19
  270. data/lib/rghost/doc/classes/Document.src/M000113.html +0 -19
  271. data/lib/rghost/doc/classes/DynamicDocumentCallback.html +0 -175
  272. data/lib/rghost/doc/classes/DynamicDocumentCallback.src/M000022.html +0 -19
  273. data/lib/rghost/doc/classes/Eps.html +0 -168
  274. data/lib/rghost/doc/classes/Eps.src/M000063.html +0 -20
  275. data/lib/rghost/doc/classes/Eps.src/M000064.html +0 -20
  276. data/lib/rghost/doc/classes/Font.html +0 -205
  277. data/lib/rghost/doc/classes/Font.src/M000061.html +0 -22
  278. data/lib/rghost/doc/classes/Font.src/M000062.html +0 -37
  279. data/lib/rghost/doc/classes/Function.html +0 -196
  280. data/lib/rghost/doc/classes/Function.src/M000045.html +0 -27
  281. data/lib/rghost/doc/classes/Function.src/M000046.html +0 -20
  282. data/lib/rghost/doc/classes/GSAlone.html +0 -154
  283. data/lib/rghost/doc/classes/GSAlone.src/M000065.html +0 -19
  284. data/lib/rghost/doc/classes/GSAlone.src/M000066.html +0 -22
  285. data/lib/rghost/doc/classes/Gif.html +0 -148
  286. data/lib/rghost/doc/classes/Gif.src/M000040.html +0 -30
  287. data/lib/rghost/doc/classes/Graphic.html +0 -153
  288. data/lib/rghost/doc/classes/Graphic.src/M000014.html +0 -18
  289. data/lib/rghost/doc/classes/Gray.html +0 -181
  290. data/lib/rghost/doc/classes/Gray.src/M000026.html +0 -18
  291. data/lib/rghost/doc/classes/Gray.src/M000027.html +0 -19
  292. data/lib/rghost/doc/classes/Helpers/HashKeyMethod.html +0 -131
  293. data/lib/rghost/doc/classes/Helpers/HashKeyMethod.src/M000127.html +0 -18
  294. data/lib/rghost/doc/classes/Helpers/HashKeyMethodClass.html +0 -118
  295. data/lib/rghost/doc/classes/Helpers.html +0 -112
  296. data/lib/rghost/doc/classes/HorizontalLine.html +0 -186
  297. data/lib/rghost/doc/classes/HorizontalLine.src/M000023.html +0 -23
  298. data/lib/rghost/doc/classes/Image.html +0 -176
  299. data/lib/rghost/doc/classes/Image.src/M000042.html +0 -20
  300. data/lib/rghost/doc/classes/Image.src/M000043.html +0 -26
  301. data/lib/rghost/doc/classes/Jpeg.html +0 -148
  302. data/lib/rghost/doc/classes/Jpeg.src/M000013.html +0 -28
  303. data/lib/rghost/doc/classes/Line.html +0 -190
  304. data/lib/rghost/doc/classes/Line.src/M000069.html +0 -20
  305. data/lib/rghost/doc/classes/Line.src/M000070.html +0 -19
  306. data/lib/rghost/doc/classes/LineWidth.html +0 -172
  307. data/lib/rghost/doc/classes/LineWidth.src/M000005.html +0 -18
  308. data/lib/rghost/doc/classes/LineWidth.src/M000006.html +0 -18
  309. data/lib/rghost/doc/classes/Load.html +0 -161
  310. data/lib/rghost/doc/classes/Load.src/M000165.html +0 -21
  311. data/lib/rghost/doc/classes/Load.src/M000166.html +0 -34
  312. data/lib/rghost/doc/classes/Load.src/M000167.html +0 -19
  313. data/lib/rghost/doc/classes/NewPath.html +0 -153
  314. data/lib/rghost/doc/classes/NewPath.src/M000041.html +0 -18
  315. data/lib/rghost/doc/classes/Paper.html +0 -213
  316. data/lib/rghost/doc/classes/Paper.src/M000010.html +0 -20
  317. data/lib/rghost/doc/classes/Paper.src/M000011.html +0 -24
  318. data/lib/rghost/doc/classes/Paper.src/M000012.html +0 -20
  319. data/lib/rghost/doc/classes/Point.html +0 -180
  320. data/lib/rghost/doc/classes/Point.src/M000073.html +0 -20
  321. data/lib/rghost/doc/classes/Point.src/M000074.html +0 -18
  322. data/lib/rghost/doc/classes/PointWithCommand.html +0 -150
  323. data/lib/rghost/doc/classes/PointWithCommand.src/M000115.html +0 -22
  324. data/lib/rghost/doc/classes/PsObject.html +0 -269
  325. data/lib/rghost/doc/classes/PsObject.src/M000015.html +0 -25
  326. data/lib/rghost/doc/classes/PsObject.src/M000016.html +0 -18
  327. data/lib/rghost/doc/classes/PsObject.src/M000017.html +0 -18
  328. data/lib/rghost/doc/classes/PsObject.src/M000018.html +0 -18
  329. data/lib/rghost/doc/classes/PsObject.src/M000019.html +0 -21
  330. data/lib/rghost/doc/classes/PsObject.src/M000020.html +0 -19
  331. data/lib/rghost/doc/classes/PsObject.src/M000021.html +0 -18
  332. data/lib/rghost/doc/classes/RGB.html +0 -213
  333. data/lib/rghost/doc/classes/RGB.src/M000024.html +0 -21
  334. data/lib/rghost/doc/classes/RGB.src/M000025.html +0 -25
  335. data/lib/rghost/doc/classes/Rectangle.html +0 -226
  336. data/lib/rghost/doc/classes/Rectangle.src/M000056.html +0 -18
  337. data/lib/rghost/doc/classes/Rectangle.src/M000057.html +0 -24
  338. data/lib/rghost/doc/classes/Rectangle.src/M000058.html +0 -21
  339. data/lib/rghost/doc/classes/RubyGhostConfig.html +0 -144
  340. data/lib/rghost/doc/classes/RubyGhostConfig.src/M000118.html +0 -22
  341. data/lib/rghost/doc/classes/RubyGhostEngine.html +0 -261
  342. data/lib/rghost/doc/classes/RubyGhostEngine.src/M000007.html +0 -24
  343. data/lib/rghost/doc/classes/RubyGhostEngine.src/M000008.html +0 -96
  344. data/lib/rghost/doc/classes/RubyGhostEngine.src/M000009.html +0 -21
  345. data/lib/rghost/doc/classes/RubyToPs.html +0 -272
  346. data/lib/rghost/doc/classes/RubyToPs.src/M000119.html +0 -23
  347. data/lib/rghost/doc/classes/RubyToPs.src/M000120.html +0 -18
  348. data/lib/rghost/doc/classes/RubyToPs.src/M000121.html +0 -18
  349. data/lib/rghost/doc/classes/RubyToPs.src/M000122.html +0 -19
  350. data/lib/rghost/doc/classes/RubyToPs.src/M000123.html +0 -30
  351. data/lib/rghost/doc/classes/RubyToPs.src/M000124.html +0 -18
  352. data/lib/rghost/doc/classes/RubyToPs.src/M000125.html +0 -18
  353. data/lib/rghost/doc/classes/RubyToPs.src/M000126.html +0 -30
  354. data/lib/rghost/doc/classes/Scale.html +0 -153
  355. data/lib/rghost/doc/classes/Scale.src/M000114.html +0 -18
  356. data/lib/rghost/doc/classes/Show.html +0 -203
  357. data/lib/rghost/doc/classes/Show.src/M000052.html +0 -20
  358. data/lib/rghost/doc/classes/Show.src/M000053.html +0 -19
  359. data/lib/rghost/doc/classes/StaticDocumentCallback.html +0 -168
  360. data/lib/rghost/doc/classes/StaticDocumentCallback.src/M000051.html +0 -19
  361. data/lib/rghost/doc/classes/TextArea.html +0 -217
  362. data/lib/rghost/doc/classes/TextArea.src/M000029.html +0 -22
  363. data/lib/rghost/doc/classes/TextArea.src/M000030.html +0 -24
  364. data/lib/rghost/doc/classes/TextIn.html +0 -201
  365. data/lib/rghost/doc/classes/TextIn.src/M000054.html +0 -19
  366. data/lib/rghost/doc/classes/TextIn.src/M000055.html +0 -24
  367. data/lib/rghost/doc/classes/Units/Cm.html +0 -145
  368. data/lib/rghost/doc/classes/Units/Cm.src/M000175.html +0 -19
  369. data/lib/rghost/doc/classes/Units/Inch.html +0 -145
  370. data/lib/rghost/doc/classes/Units/Inch.src/M000174.html +0 -18
  371. data/lib/rghost/doc/classes/Units/PSUnit.html +0 -139
  372. data/lib/rghost/doc/classes/Units/PSUnit.src/M000170.html +0 -18
  373. data/lib/rghost/doc/classes/Units/Unit.html +0 -190
  374. data/lib/rghost/doc/classes/Units/Unit.src/M000171.html +0 -18
  375. data/lib/rghost/doc/classes/Units/Unit.src/M000172.html +0 -19
  376. data/lib/rghost/doc/classes/Units/Unit.src/M000173.html +0 -18
  377. data/lib/rghost/doc/classes/Units.html +0 -166
  378. data/lib/rghost/doc/classes/Units.src/M000169.html +0 -22
  379. data/lib/rghost/doc/classes/Variable.html +0 -152
  380. data/lib/rghost/doc/classes/Variable.src/M000044.html +0 -18
  381. data/lib/rghost/doc/classes/VerticalLine.html +0 -175
  382. data/lib/rghost/doc/classes/VerticalLine.src/M000116.html +0 -23
  383. data/lib/rghost/doc/classes/VerticalLine.src/M000117.html +0 -19
  384. data/lib/rghost/doc/created.rid +0 -1
  385. data/lib/rghost/doc/files/arc_rb.html +0 -109
  386. data/lib/rghost/doc/files/barcode_rb.html +0 -108
  387. data/lib/rghost/doc/files/callback_rb.html +0 -109
  388. data/lib/rghost/doc/files/color_rb.html +0 -110
  389. data/lib/rghost/doc/files/constants_rb.html +0 -108
  390. data/lib/rghost/doc/files/convert_rb.html +0 -107
  391. data/lib/rghost/doc/files/cursor_rb.html +0 -110
  392. data/lib/rghost/doc/files/data_grid/basic_grid_rb.html +0 -108
  393. data/lib/rghost/doc/files/data_grid/csv_grid_rb.html +0 -108
  394. data/lib/rghost/doc/files/data_grid/data_grid_rb.html +0 -116
  395. data/lib/rghost/doc/files/data_grid/dynamic_callback_rb.html +0 -108
  396. data/lib/rghost/doc/files/data_grid/field_format_rb.html +0 -109
  397. data/lib/rghost/doc/files/data_grid/grid_rb.html +0 -108
  398. data/lib/rghost/doc/files/data_grid/header_rb.html +0 -113
  399. data/lib/rghost/doc/files/data_grid/rails_grid_rb.html +0 -108
  400. data/lib/rghost/doc/files/data_grid/static_callback_rb.html +0 -109
  401. data/lib/rghost/doc/files/data_grid/style/border_lines_rb.html +0 -101
  402. data/lib/rghost/doc/files/data_grid/style/bottom_lines_rb.html +0 -101
  403. data/lib/rghost/doc/files/data_grid/style/old_forms_rb.html +0 -101
  404. data/lib/rghost/doc/files/data_grid/style/style_rb.html +0 -110
  405. data/lib/rghost/doc/files/document_rb.html +0 -150
  406. data/lib/rghost/doc/files/dsc_entry_rb.html +0 -108
  407. data/lib/rghost/doc/files/dynamic_document_callback_rb.html +0 -108
  408. data/lib/rghost/doc/files/eps_rb.html +0 -108
  409. data/lib/rghost/doc/files/font_rb.html +0 -110
  410. data/lib/rghost/doc/files/function_rb.html +0 -108
  411. data/lib/rghost/doc/files/gif_rb.html +0 -114
  412. data/lib/rghost/doc/files/graphic_rb.html +0 -113
  413. data/lib/rghost/doc/files/gs_alone_rb.html +0 -101
  414. data/lib/rghost/doc/files/helpers_rb.html +0 -101
  415. data/lib/rghost/doc/files/horizontal_line_rb.html +0 -109
  416. data/lib/rghost/doc/files/image_rb.html +0 -108
  417. data/lib/rghost/doc/files/jpeg_rb.html +0 -112
  418. data/lib/rghost/doc/files/line_rb.html +0 -109
  419. data/lib/rghost/doc/files/line_width_rb.html +0 -108
  420. data/lib/rghost/doc/files/load_rb.html +0 -108
  421. data/lib/rghost/doc/files/newpath_rb.html +0 -113
  422. data/lib/rghost/doc/files/paper_rb.html +0 -112
  423. data/lib/rghost/doc/files/point_rb.html +0 -109
  424. data/lib/rghost/doc/files/point_with_command_rb.html +0 -109
  425. data/lib/rghost/doc/files/ps_object_rb.html +0 -107
  426. data/lib/rghost/doc/files/rectangle_rb.html +0 -110
  427. data/lib/rghost/doc/files/rghost_rb.html +0 -109
  428. data/lib/rghost/doc/files/ruby_ghost_config_rb.html +0 -109
  429. data/lib/rghost/doc/files/ruby_ghost_engine_rb.html +0 -111
  430. data/lib/rghost/doc/files/ruby_to_ps_rb.html +0 -107
  431. data/lib/rghost/doc/files/scale_rb.html +0 -108
  432. data/lib/rghost/doc/files/show_rb.html +0 -109
  433. data/lib/rghost/doc/files/static_document_callback_rb.html +0 -109
  434. data/lib/rghost/doc/files/text_in_rb.html +0 -110
  435. data/lib/rghost/doc/files/textarea_rb.html +0 -111
  436. data/lib/rghost/doc/files/units_rb.html +0 -109
  437. data/lib/rghost/doc/files/variable_rb.html +0 -108
  438. data/lib/rghost/doc/files/version_rb.html +0 -101
  439. data/lib/rghost/doc/files/vertical_line_rb.html +0 -110
  440. data/lib/rghost/doc/fr_class_index.html +0 -93
  441. data/lib/rghost/doc/fr_file_index.html +0 -81
  442. data/lib/rghost/doc/fr_method_index.html +0 -201
  443. data/lib/rghost/doc/index.html +0 -24
  444. data/lib/rghost/ps/functions.ps +0 -646
  445. data/lib/rghost/rectangle.rb +0 -39
  446. data/lib/rghost/rghost.rb +0 -3
  447. data/lib/rghost/version.rb +0 -9
@@ -0,0 +1,218 @@
1
+ require 'enumerator'
2
+ # RGhost::Grid::Base is a helper object to create a tabular
3
+ # representations, composed of rows, columns and a title. This
4
+ # prototype used to join the common attributes for data grids. To use
5
+ # a Grid you must first setup the columns, then load the data.
6
+ #
7
+ # Example:
8
+ # grid=Grid::Matrix.new
9
+ # grid.column :title => "Code", :width => 1
10
+ # grid.column :title => "Name", :width => 3, :align => :center
11
+ # grid.column :title => "Date", :width => 3, :align => :center
12
+ #
13
+ # Note that both the width and align of the last two columns are
14
+ # identical. To avoid repetition, you can specify a default width upon
15
+ # creating the DataGrid::Grid object. Any columns that do not specify
16
+ # an explicit width and align property will inherit the defaults.
17
+ #
18
+ # Example:
19
+ #
20
+ # grid=Grid::Matrix.new :width => 3, :align => :center
21
+ # grid.column :title => "Code", :width => 1 #:width => 1, :align => :center
22
+ # grid.column :title => "Name" #:width => 3, :align => :center
23
+ # grid.column :title => "Date" #:width => 3, :align => :center
24
+ #
25
+ # The actual content needs to be passed in as an array of arrays
26
+ #
27
+ # values=[
28
+ # [1,"Name 1", Time.now],
29
+ # [2,"Name 2", Time.now],
30
+ # [3,"Name 3", Time.now],
31
+ # [4,"Name 4", Time.now],
32
+ # [5,"Name 5", Time.now]
33
+ # ]
34
+ #
35
+ # Bind the content to the grid:
36
+ # grid.data(values)
37
+ # Add the Grid to a document
38
+ # d=Document.new
39
+ # d.set grid
40
+ #
41
+ class RGhost::Grid::Base < RGhost::PsObject
42
+ attr_reader :header
43
+ attr_accessor :column_padding
44
+ include RGhost::RubyToPs
45
+ include RGhost::Grid::CallbackFacade
46
+
47
+ #===Options
48
+ #* <tt>:headings</tt> - To disable headers set this attribute to false.
49
+ #* <tt>:column_padding</tt> - Padding between column content and its edge.
50
+ #* <tt>:width</tt> - Width for all columns.
51
+ #* <tt>:align</tt> - Align for all data(:left, :center and :right).
52
+ #* <tt>:title_align</tt> - Align for all the header's name(:left, :center and :right).
53
+ def initialize(options={})
54
+
55
+ @header=RGhost::Grid::Header.new( (options[:headings] == false)?false:true )
56
+ @header.default_options(options)
57
+ @callbacks=RGhost::PsObject.new
58
+ @column_padding= options[:column_padding] || 0.1
59
+ @record_count=1
60
+ @data=[]
61
+ @data[0]=[]
62
+ @data_index=0
63
+ @max_stack=RGhost::Config::GS[:stack_elements]
64
+ end
65
+
66
+
67
+ # Defines properties of a column. Parameters are the same as for new,
68
+ # plus some additional ones like :format.
69
+ # * <tt>:format</tt> - Format of the data. You can format data in four
70
+ # different ways with Rghost, passing in a Symbol
71
+ # a String a Class or Proc.
72
+ #
73
+ # ==== :format Parameters type
74
+ # * Symbol - Searches for a method defined as Grid::FieldFormat::method_name
75
+ # :format => :eurodate
76
+ # * Class - A class that inherits Grid::FieldFormat::Custom with a overridden format method.
77
+ # :format => MyFormat
78
+ # * String - Formats using the same parameters used in sprintf
79
+ # :format => "%0.2f"
80
+ # * Proc - A block. In the example a text limited to 9 characters.
81
+ # :format => lambda {|s| s.gsub(/^(.{9}).*$/,'\1...')}
82
+ # ====Customizing formats
83
+ # Replace spaces with a double dash.
84
+ # class MyFormat < DataGrid::FieldFormat::Custom
85
+ # def format
86
+ # @value.to_s.gsub(/ /,'--')
87
+ # end
88
+ # end
89
+ #
90
+ # Using
91
+ #
92
+ # grid.column :title => "Name", :format => MyFormat
93
+ #
94
+ # Below, the columns with their proper formats.
95
+ #
96
+ # grid.column :title => "Code",:format => "(%d)", :width => 1
97
+ # grid.column :title => "Name", :format => MyFormat
98
+ # grid.column :title => "Date", :format => lambda {|date| date.strftime("%d/%m/%Y") }
99
+ # values=[
100
+ # [1,"Name 1", Time.now],
101
+ # [2,"Name 2", Time.now],
102
+ # [3,"Name 3", Time.now],
103
+ # [4,"Name 4", Time.now],
104
+ # [5,"Name 5", Time.now]
105
+ # ]
106
+ # grid.data(values)
107
+ # Add the Grid to a document
108
+ #
109
+ # d=Document.new
110
+ # d.set grid
111
+ # link:images/format01.png
112
+ def col(title="", options={})
113
+ if title.is_a? Hash
114
+ @header.col(title[:title],title)
115
+ else
116
+ @header.col(title[:title],options)
117
+ end
118
+ end
119
+ #Alias for col
120
+ def column(title="", options={})
121
+ col(title,options)
122
+
123
+ end
124
+
125
+ def format_field(value,type) #:nodoc:
126
+ case type
127
+ when Symbol: RGhost::Grid::FieldFormat.send(type,value)
128
+ when String: RGhost::Grid::FieldFormat.string(type % value)
129
+ when NilClass: RGhost::Grid::FieldFormat.string(value)
130
+ when Class: type.new(value).gs_format
131
+ when Proc: RGhost::Grid::FieldFormat.string(type.call(value))
132
+
133
+ else raise TypeError.new("type=#{type}, value type=#{value.class}")
134
+ end
135
+
136
+ end
137
+ def width
138
+ @header.size
139
+ end
140
+ def proc_line(line) #:nodoc:
141
+ h=@header.data_types
142
+ rec=[]
143
+ line.each_with_index do |v,i|
144
+ #puts "#{i} == #{h[i]} = #{v}, #{format_field(v,h[i])}"
145
+ rec << format_field(v,h[i])
146
+ end
147
+ @data[@data_index] << "[#{rec}]\n"
148
+
149
+
150
+ if @record_count == @max_stack
151
+ @record_count=0
152
+ @data_index+=1
153
+ @data[@data_index]=[]
154
+ end
155
+ @record_count+=1
156
+
157
+
158
+ end
159
+ #Defines data to grid processor.
160
+ def data(data)
161
+
162
+ end
163
+ public
164
+
165
+ def ps
166
+
167
+
168
+ grid_names=[]
169
+ p=RGhost::PsObject.new
170
+ p.set RGhost::Variable.new(:col_padding,RGhost::Units::parse(@column_padding))
171
+ @data.each do |ary|
172
+ r=(rand*99999).to_i
173
+ p.raw "/data#{r}[\n#{ary.join}\n] def"
174
+ grid_names << r
175
+ end
176
+ p.raw "#{@header.ps} #{@callbacks}"
177
+
178
+ g=RGhost::Graphic.new do
179
+ raw :before_table_create
180
+ raw grid_names.map{|m| " data#{m} table_proc \n" }.join
181
+ raw :after_table_create
182
+ end
183
+ p.set g
184
+ p.raw :nrdp
185
+ p
186
+
187
+
188
+ end
189
+
190
+ # Grid has 3 preset styles :bottom_lines, :border_lines and
191
+ # old_forms. To set any of them, use:
192
+ #
193
+ # grid.style(:border_lines)
194
+ #
195
+ # :border_lines - instance of Grid::Style::BorderLines
196
+ #
197
+ # link:images/setstyle01.png
198
+ #
199
+ # :bottom_lines - instance of Grid::Style::BottomLines
200
+ #
201
+ # link:images/setstyle02.png
202
+ #
203
+ # :old_forms - instance of Grid::Style::OldForms
204
+ #
205
+ # link:images/setstyle03.png
206
+ def style(type=:border_lines)
207
+ st=case type
208
+ when :border_lines: RGhost::Grid::Style::BorderLines.new
209
+ when :old_forms: RGhost::Grid::Style::OldForms.new
210
+ when :bottom_lines: RGhost::Grid::Style::BottomLines.new
211
+ else raise NameError.new("Why? #{type} ?")
212
+ end
213
+
214
+ st.set_style(self)
215
+
216
+ end
217
+
218
+ end
@@ -0,0 +1,136 @@
1
+
2
+ module RGhost::Grid
3
+ # The callbacks for the grid are defined here. Let's see them in action.
4
+ # ===Grid::CallbackFacade examples
5
+ # grid=Grid::Matrix.new :column_padding => 1
6
+ # grid.column :title => "Id", :width => 1
7
+ # grid.column :title => "Name", :width => 3, :align => :center
8
+ # grid.column :title => "Date", :width => 3, :align => :right, :title_align => :center, :format => lambda{|v| v.strftime("%d/%m/%Y")}
9
+ # values=('A'..'E').to_a.map{|v| [v,"Name #{v}", Time.now]}
10
+ #
11
+ # even_row:
12
+ # grid.even_row do
13
+ # background_row(:size => grid.width)
14
+ # end
15
+ # link:images/grid01.png
16
+ #
17
+ # Now before_row to create a top and bottom line:
18
+ # grid.before_row do
19
+ # horizontal_line(:top, :size => grid.width )
20
+ # horizontal_line(:bottom, :size => grid.width)
21
+ # end
22
+ #
23
+ # link:images/grid02.png
24
+ #
25
+ # before_column:
26
+ # grid.before_column do
27
+ # vertical_line_row
28
+ # end
29
+ #
30
+ # link:images/grid03.png
31
+ #
32
+ # after_column:
33
+ # grid.after_column { vertical_line_row }
34
+ #
35
+ #
36
+ # link:images/grid04.png
37
+ #
38
+ # Moving to the header
39
+ # grid.header.before_create do
40
+ # horizontal_line(:top, :size => grid.width)
41
+ # end
42
+ #
43
+ # link:images/grid05.png
44
+ #
45
+ # Finishing the grid lines:
46
+ # grid.header.before_column do
47
+ # vertical_line_row
48
+ # end
49
+ #
50
+ #
51
+ # grid.header.after_column do
52
+ # vertical_line_row
53
+ # end
54
+ #
55
+ # link:images/grid06.png
56
+ #
57
+ # Now a adding a bold font to the header
58
+ # grid.header.before_create do
59
+ # horizontal_line(:top, :size => grid.width)
60
+ # use_tag :bold
61
+ # end
62
+ #
63
+ # link:images/grid07.png
64
+ #
65
+ # Oops. Not quite what we expected, the entire grid used bold
66
+ # face. We need to use a header callback to reset the font.
67
+ #
68
+ # grid.header.after_create do
69
+ # use_tag :normal
70
+ # end
71
+ #
72
+ # link:images/grid08.png
73
+ #
74
+ # Don't forget
75
+ #
76
+ # doc=Document.new
77
+ # doc.set grid
78
+ module CallbackFacade
79
+
80
+ # Executes before processing row. Responds to :only and :except
81
+ # options.
82
+ def before_row(options={},&block)
83
+ new_dynamic_callback(:before_row,options,&block)
84
+ end
85
+
86
+ # Executes on creating an odd rows. Responds to :only and :except
87
+ # options.
88
+ def odd_row(options={},&block)
89
+ new_dynamic_callback(:odd_row,options,&block)
90
+ end
91
+
92
+ # Executes upon creating even rows. Responds to :only and :except
93
+ # options.
94
+ def even_row(options={},&block)
95
+ new_dynamic_callback(:even_row,options,&block)
96
+ end
97
+
98
+ # Executes before creating a column. Responds to :only and :except
99
+ # options.
100
+ def before_column(options={},&block)
101
+ new_dynamic_callback(:before_column,options,&block)
102
+ end
103
+
104
+ # Executes after a column was created. Responds to :only and
105
+ # :except options.
106
+ def after_column(options={},&block)
107
+ new_dynamic_callback(:after_column,options,&block)
108
+ end
109
+
110
+ # Executes when creating an odd column. Responds to :only and
111
+ # :except options.
112
+ def odd_column(options={},&block)
113
+ new_dynamic_callback(:odd_column,options,&block)
114
+ end
115
+
116
+ # Executes upon creating an even column. Responds to :only and
117
+ # :except options.
118
+ def even_column(options={},&block)
119
+ new_dynamic_callback(:even_column,options,&block)
120
+ end
121
+
122
+
123
+ private
124
+
125
+ def new_dynamic_callback(name,options={},&block)
126
+ @callbacks.set RGhost::Callback.new(name,options,&block)
127
+ end
128
+ def new_static_callback(name,&block)
129
+
130
+ callback_body= RGhost::PsFacade.new(&block)
131
+ @callbacks.set RGhost::Function.new(name,callback_body)
132
+ end
133
+
134
+
135
+ end
136
+ end
@@ -0,0 +1,50 @@
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)}
36
+ proc_line(l)
37
+ first=false
38
+
39
+ next
40
+ else
41
+
42
+ proc_line(l)
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+
49
+
50
+ end
@@ -1,6 +1,6 @@
1
1
  require "callback"
2
- #Callbacks Din�micos a n�vel de Grid
3
- class DataGrid::DynamicCallback < Callback
2
+ #Callbacks Din�micos a n�vel de Grid
3
+ class RGhost::Grid::DynamicCallback < RGhost::Callback
4
4
  ACCEPT=[:before_row, :after_row, :even_row,
5
5
  :odd_row, :before_column, :after_column, :even_column, :odd_column]
6
6
 
@@ -0,0 +1,43 @@
1
+ $LOAD_PATH << File.dirname(__FILE__)+File::SEPARATOR+"../"
2
+
3
+ require 'ps_object'
4
+
5
+ require '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 'grid/header'
3
+ require 'grid/callback_facade'
4
+ require 'grid/style/style'
5
+ require 'grid/base_grid'
6
+ require 'grid/rails_grid'
7
+ require 'grid/matrix'
8
+ require 'grid/csv_grid'
9
+ require 'grid/dynamic_callback'
10
+ require 'grid/static_callback'
11
+ require 'grid/field_format'
12
+ end
13
+
14
+
15
+
@@ -0,0 +1,120 @@
1
+ $LOAD_PATH << File.dirname(__FILE__)+File::SEPARATOR+"../"
2
+ require "ps_object"
3
+ require "ruby_to_ps"
4
+ require "variable"
5
+ require "units"
6
+ require "function"
7
+ require "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 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,70 @@
1
+ require '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: d[c[:field_name]]
49
+ when String: d.instance_eval c[:field_name]
50
+ when Proc: d.instance_eval(&c[:field_name])
51
+ end
52
+ end
53
+ proc_line(line)
54
+ end
55
+ end
56
+
57
+ def col(field_name, options={}) #:nodoc:
58
+ super(options[:title],options)
59
+ @rails_cols||=[]
60
+ owf=options.dup #from options with field
61
+ owf[:field_name]||=field_name
62
+ @rails_cols << owf
63
+
64
+ end
65
+
66
+ def column(field_name, options={}) #:nodoc:
67
+ col(field_name,options)
68
+ end
69
+
70
+ end
@@ -1,13 +1,13 @@
1
1
  require "ps_object"
2
2
  require "function"
3
- #Callbacks est�ticos a n�vel de Grid
4
- class DataGrid::StaticCallback < Function
3
+
4
+ class RGhost::Grid::StaticCallback < RGhost::Function
5
5
  ACCEPT=[:before_table_create, :after_table_create]
6
-
6
+
7
7
  def initialize(name,&block)
8
8
  raise NameError.new("#{name} no accept in #{self.class}") unless ACCEPT.include? name
9
9
  super(name,&block)
10
10
  end
11
-
11
+
12
12
  end
13
13