gorgyrella 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (233) hide show
  1. data/.bzr/README +3 -0
  2. data/.bzr/branch/branch.conf +2 -0
  3. data/.bzr/branch/format +1 -0
  4. data/.bzr/branch/last-revision +1 -0
  5. data/.bzr/branch/tags +0 -0
  6. data/.bzr/branch-format +1 -0
  7. data/.bzr/checkout/conflicts +1 -0
  8. data/.bzr/checkout/dirstate +0 -0
  9. data/.bzr/checkout/format +1 -0
  10. data/.bzr/checkout/merge-hashes +33 -0
  11. data/.bzr/repository/format +1 -0
  12. data/.bzr/repository/indices/7433d7509bfad4e7de61716fd159a28e.iix +0 -0
  13. data/.bzr/repository/indices/7433d7509bfad4e7de61716fd159a28e.rix +0 -0
  14. data/.bzr/repository/indices/7433d7509bfad4e7de61716fd159a28e.six +5 -0
  15. data/.bzr/repository/indices/7433d7509bfad4e7de61716fd159a28e.tix +0 -0
  16. data/.bzr/repository/indices/747331f41951a7f9509b3190e9082de2.iix +0 -0
  17. data/.bzr/repository/indices/747331f41951a7f9509b3190e9082de2.rix +0 -0
  18. data/.bzr/repository/indices/747331f41951a7f9509b3190e9082de2.six +5 -0
  19. data/.bzr/repository/indices/747331f41951a7f9509b3190e9082de2.tix +0 -0
  20. data/.bzr/repository/indices/94ae76525de86acde2f4722e88fec764.iix +0 -0
  21. data/.bzr/repository/indices/94ae76525de86acde2f4722e88fec764.rix +0 -0
  22. data/.bzr/repository/indices/94ae76525de86acde2f4722e88fec764.six +5 -0
  23. data/.bzr/repository/indices/94ae76525de86acde2f4722e88fec764.tix +0 -0
  24. data/.bzr/repository/indices/ae5f61661ebb8f30600ce7443b2ea000.iix +0 -0
  25. data/.bzr/repository/indices/ae5f61661ebb8f30600ce7443b2ea000.rix +0 -0
  26. data/.bzr/repository/indices/ae5f61661ebb8f30600ce7443b2ea000.six +5 -0
  27. data/.bzr/repository/indices/ae5f61661ebb8f30600ce7443b2ea000.tix +0 -0
  28. data/.bzr/repository/indices/e34ba77fcb41bb254463c3c177123bb1.iix +0 -0
  29. data/.bzr/repository/indices/e34ba77fcb41bb254463c3c177123bb1.rix +0 -0
  30. data/.bzr/repository/indices/e34ba77fcb41bb254463c3c177123bb1.six +5 -0
  31. data/.bzr/repository/indices/e34ba77fcb41bb254463c3c177123bb1.tix +0 -0
  32. data/.bzr/repository/indices/e409e77b2da885ef4e5bc5089a04e60e.iix +0 -0
  33. data/.bzr/repository/indices/e409e77b2da885ef4e5bc5089a04e60e.rix +0 -0
  34. data/.bzr/repository/indices/e409e77b2da885ef4e5bc5089a04e60e.six +5 -0
  35. data/.bzr/repository/indices/e409e77b2da885ef4e5bc5089a04e60e.tix +0 -0
  36. data/.bzr/repository/indices/fa740d26e5ddc0570df1ec65a7a2af1c.iix +0 -0
  37. data/.bzr/repository/indices/fa740d26e5ddc0570df1ec65a7a2af1c.rix +0 -0
  38. data/.bzr/repository/indices/fa740d26e5ddc0570df1ec65a7a2af1c.six +5 -0
  39. data/.bzr/repository/indices/fa740d26e5ddc0570df1ec65a7a2af1c.tix +0 -0
  40. data/.bzr/repository/obsolete_packs/24b89e5a96bc1f03a7ce1a200ab48dc9.iix +0 -0
  41. data/.bzr/repository/obsolete_packs/24b89e5a96bc1f03a7ce1a200ab48dc9.pack +0 -0
  42. data/.bzr/repository/obsolete_packs/24b89e5a96bc1f03a7ce1a200ab48dc9.rix +0 -0
  43. data/.bzr/repository/obsolete_packs/24b89e5a96bc1f03a7ce1a200ab48dc9.six +5 -0
  44. data/.bzr/repository/obsolete_packs/24b89e5a96bc1f03a7ce1a200ab48dc9.tix +0 -0
  45. data/.bzr/repository/obsolete_packs/3ed72fa820dea2da6169d4361433a5f3.iix +0 -0
  46. data/.bzr/repository/obsolete_packs/3ed72fa820dea2da6169d4361433a5f3.pack +0 -0
  47. data/.bzr/repository/obsolete_packs/3ed72fa820dea2da6169d4361433a5f3.rix +0 -0
  48. data/.bzr/repository/obsolete_packs/3ed72fa820dea2da6169d4361433a5f3.six +5 -0
  49. data/.bzr/repository/obsolete_packs/3ed72fa820dea2da6169d4361433a5f3.tix +0 -0
  50. data/.bzr/repository/obsolete_packs/acd9bdd28baefb868bf64371dde19d2b.iix +0 -0
  51. data/.bzr/repository/obsolete_packs/acd9bdd28baefb868bf64371dde19d2b.pack +0 -0
  52. data/.bzr/repository/obsolete_packs/acd9bdd28baefb868bf64371dde19d2b.rix +0 -0
  53. data/.bzr/repository/obsolete_packs/acd9bdd28baefb868bf64371dde19d2b.six +5 -0
  54. data/.bzr/repository/obsolete_packs/acd9bdd28baefb868bf64371dde19d2b.tix +0 -0
  55. data/.bzr/repository/obsolete_packs/c408af011313ac56380f5716caffaf43.iix +0 -0
  56. data/.bzr/repository/obsolete_packs/c408af011313ac56380f5716caffaf43.pack +0 -0
  57. data/.bzr/repository/obsolete_packs/c408af011313ac56380f5716caffaf43.rix +0 -0
  58. data/.bzr/repository/obsolete_packs/c408af011313ac56380f5716caffaf43.six +5 -0
  59. data/.bzr/repository/obsolete_packs/c408af011313ac56380f5716caffaf43.tix +0 -0
  60. data/.bzr/repository/obsolete_packs/cf2fbd7a25e9ab28e03fe483b1232f54.iix +0 -0
  61. data/.bzr/repository/obsolete_packs/cf2fbd7a25e9ab28e03fe483b1232f54.pack +0 -0
  62. data/.bzr/repository/obsolete_packs/cf2fbd7a25e9ab28e03fe483b1232f54.rix +0 -0
  63. data/.bzr/repository/obsolete_packs/cf2fbd7a25e9ab28e03fe483b1232f54.six +5 -0
  64. data/.bzr/repository/obsolete_packs/cf2fbd7a25e9ab28e03fe483b1232f54.tix +0 -0
  65. data/.bzr/repository/obsolete_packs/fedc9930335a072ae735da013bf94c74.iix +0 -0
  66. data/.bzr/repository/obsolete_packs/fedc9930335a072ae735da013bf94c74.pack +0 -0
  67. data/.bzr/repository/obsolete_packs/fedc9930335a072ae735da013bf94c74.rix +0 -0
  68. data/.bzr/repository/obsolete_packs/fedc9930335a072ae735da013bf94c74.six +5 -0
  69. data/.bzr/repository/obsolete_packs/fedc9930335a072ae735da013bf94c74.tix +0 -0
  70. data/.bzr/repository/pack-names +0 -0
  71. data/.bzr/repository/packs/7433d7509bfad4e7de61716fd159a28e.pack +0 -0
  72. data/.bzr/repository/packs/747331f41951a7f9509b3190e9082de2.pack +0 -0
  73. data/.bzr/repository/packs/94ae76525de86acde2f4722e88fec764.pack +0 -0
  74. data/.bzr/repository/packs/ae5f61661ebb8f30600ce7443b2ea000.pack +0 -0
  75. data/.bzr/repository/packs/e34ba77fcb41bb254463c3c177123bb1.pack +0 -0
  76. data/.bzr/repository/packs/e409e77b2da885ef4e5bc5089a04e60e.pack +0 -0
  77. data/.bzr/repository/packs/fa740d26e5ddc0570df1ec65a7a2af1c.pack +0 -0
  78. data/.bzrignore +5 -0
  79. data/History.txt +4 -0
  80. data/LICENSE +619 -0
  81. data/README.txt +27 -0
  82. data/Rakefile +59 -0
  83. data/bin/gorgyrella +6 -0
  84. data/gorgyrella-manual-0-0-1.pdf +0 -0
  85. data/gorgyrella.gemspec +36 -0
  86. data/lib/gorgyrella/builder.rb +49 -0
  87. data/lib/gorgyrella/composer.rb +79 -0
  88. data/lib/gorgyrella/formatters/coderay.rb +28 -0
  89. data/lib/gorgyrella/formatters/pygments.rb +35 -0
  90. data/lib/gorgyrella/formatters/pygments_guess_lexer.py +9 -0
  91. data/lib/gorgyrella/formatters/ultraviolet.rb +35 -0
  92. data/lib/gorgyrella/gorgyrella.rb +9 -0
  93. data/lib/gorgyrella/parser.rb +637 -0
  94. data/lib/gorgyrella/parser.rl +133 -0
  95. data/lib/gorgyrella.rb +46 -0
  96. data/lib/webby/gorgyrella_helper.rb +31 -0
  97. data/spec/builder_spec.rb +7 -0
  98. data/spec/composer_spec.rb +70 -0
  99. data/spec/data/coderay.css +126 -0
  100. data/spec/data/example-python.html +24 -0
  101. data/spec/data/example-ruby.html +30 -0
  102. data/spec/data/pygments.css +59 -0
  103. data/spec/data/test.py +21 -0
  104. data/spec/data/test.rb +13 -0
  105. data/spec/data/ultraviolet/css/active4d.css +114 -0
  106. data/spec/data/ultraviolet/css/all_hallows_eve.css +72 -0
  107. data/spec/data/ultraviolet/css/amy.css +147 -0
  108. data/spec/data/ultraviolet/css/blackboard.css +88 -0
  109. data/spec/data/ultraviolet/css/brilliance_black.css +605 -0
  110. data/spec/data/ultraviolet/css/brilliance_dull.css +599 -0
  111. data/spec/data/ultraviolet/css/cobalt.css +149 -0
  112. data/spec/data/ultraviolet/css/dawn.css +121 -0
  113. data/spec/data/ultraviolet/css/eiffel.css +121 -0
  114. data/spec/data/ultraviolet/css/espresso_libre.css +109 -0
  115. data/spec/data/ultraviolet/css/idle.css +62 -0
  116. data/spec/data/ultraviolet/css/iplastic.css +80 -0
  117. data/spec/data/ultraviolet/css/lazy.css +73 -0
  118. data/spec/data/ultraviolet/css/mac_classic.css +123 -0
  119. data/spec/data/ultraviolet/css/magicwb_amiga.css +104 -0
  120. data/spec/data/ultraviolet/css/pastels_on_dark.css +188 -0
  121. data/spec/data/ultraviolet/css/slush_poppies.css +85 -0
  122. data/spec/data/ultraviolet/css/spacecadet.css +51 -0
  123. data/spec/data/ultraviolet/css/sunburst.css +180 -0
  124. data/spec/data/ultraviolet/css/twilight.css +137 -0
  125. data/spec/data/ultraviolet/css/zenburnesque.css +91 -0
  126. data/spec/data/unmarked.rb +32 -0
  127. data/spec/gorgyrella_spec.rb +7 -0
  128. data/spec/parser_spec.rb +73 -0
  129. data/spec/spec_helper.rb +13 -0
  130. data/spec/tmp/example-python-processed-coderay.html +31 -0
  131. data/spec/tmp/example-python-processed-pygments.html +31 -0
  132. data/spec/tmp/example-python-processed-ultraviolet.html +31 -0
  133. data/spec/tmp/example-ruby-processed-coderay.html +31 -0
  134. data/spec/tmp/example-ruby-processed-pygments.html +37 -0
  135. data/spec/tmp/example-ruby-processed-ultraviolet.html +33 -0
  136. data/tasks/ann.rake +80 -0
  137. data/tasks/bones.rake +20 -0
  138. data/tasks/gem.rake +201 -0
  139. data/tasks/git.rake +40 -0
  140. data/tasks/notes.rake +27 -0
  141. data/tasks/post_load.rake +34 -0
  142. data/tasks/rdoc.rake +51 -0
  143. data/tasks/rubyforge.rake +55 -0
  144. data/tasks/setup.rb +292 -0
  145. data/tasks/spec.rake +54 -0
  146. data/tasks/svn.rake +47 -0
  147. data/tasks/test.rake +40 -0
  148. data/tasks/zentest.rake +36 -0
  149. data/webby/.DS_Store +0 -0
  150. data/webby/README.txt +6 -0
  151. data/webby/Sitefile +24 -0
  152. data/webby/content/css/blueprint/ie.css +26 -0
  153. data/webby/content/css/blueprint/plugins/buttons/icons/cross.png +0 -0
  154. data/webby/content/css/blueprint/plugins/buttons/icons/key.png +0 -0
  155. data/webby/content/css/blueprint/plugins/buttons/icons/tick.png +0 -0
  156. data/webby/content/css/blueprint/plugins/buttons/readme.txt +32 -0
  157. data/webby/content/css/blueprint/plugins/buttons/screen.css +97 -0
  158. data/webby/content/css/blueprint/plugins/fancy-type/readme.txt +14 -0
  159. data/webby/content/css/blueprint/plugins/fancy-type/screen.css +71 -0
  160. data/webby/content/css/blueprint/plugins/link-icons/icons/doc.png +0 -0
  161. data/webby/content/css/blueprint/plugins/link-icons/icons/email.png +0 -0
  162. data/webby/content/css/blueprint/plugins/link-icons/icons/external.png +0 -0
  163. data/webby/content/css/blueprint/plugins/link-icons/icons/feed.png +0 -0
  164. data/webby/content/css/blueprint/plugins/link-icons/icons/im.png +0 -0
  165. data/webby/content/css/blueprint/plugins/link-icons/icons/pdf.png +0 -0
  166. data/webby/content/css/blueprint/plugins/link-icons/icons/visited.png +0 -0
  167. data/webby/content/css/blueprint/plugins/link-icons/icons/xls.png +0 -0
  168. data/webby/content/css/blueprint/plugins/link-icons/readme.txt +18 -0
  169. data/webby/content/css/blueprint/plugins/link-icons/screen.css +40 -0
  170. data/webby/content/css/blueprint/plugins/rtl/readme.txt +10 -0
  171. data/webby/content/css/blueprint/plugins/rtl/screen.css +109 -0
  172. data/webby/content/css/blueprint/print.css +30 -0
  173. data/webby/content/css/blueprint/screen.css +251 -0
  174. data/webby/content/css/blueprint/src/forms.css +49 -0
  175. data/webby/content/css/blueprint/src/grid.css +212 -0
  176. data/webby/content/css/blueprint/src/grid.png +0 -0
  177. data/webby/content/css/blueprint/src/ie.css +59 -0
  178. data/webby/content/css/blueprint/src/print.css +85 -0
  179. data/webby/content/css/blueprint/src/reset.css +38 -0
  180. data/webby/content/css/blueprint/src/typography.css +105 -0
  181. data/webby/content/css/pygments.txt +6 -0
  182. data/webby/content/css/site.css +78 -0
  183. data/webby/content/gorgyrella-manual.erb +33 -0
  184. data/webby/content/index.txt +15 -0
  185. data/webby/layouts/book.txt +29 -0
  186. data/webby/layouts/default.txt +27 -0
  187. data/webby/layouts/two_column.txt +25 -0
  188. data/webby/layouts/web.txt +42 -0
  189. data/webby/output/.cairn +0 -0
  190. data/webby/output/css/blueprint/ie.css +26 -0
  191. data/webby/output/css/blueprint/plugins/buttons/icons/cross.png +0 -0
  192. data/webby/output/css/blueprint/plugins/buttons/icons/key.png +0 -0
  193. data/webby/output/css/blueprint/plugins/buttons/icons/tick.png +0 -0
  194. data/webby/output/css/blueprint/plugins/buttons/readme.txt +32 -0
  195. data/webby/output/css/blueprint/plugins/buttons/screen.css +97 -0
  196. data/webby/output/css/blueprint/plugins/fancy-type/readme.txt +14 -0
  197. data/webby/output/css/blueprint/plugins/fancy-type/screen.css +71 -0
  198. data/webby/output/css/blueprint/plugins/link-icons/icons/doc.png +0 -0
  199. data/webby/output/css/blueprint/plugins/link-icons/icons/email.png +0 -0
  200. data/webby/output/css/blueprint/plugins/link-icons/icons/external.png +0 -0
  201. data/webby/output/css/blueprint/plugins/link-icons/icons/feed.png +0 -0
  202. data/webby/output/css/blueprint/plugins/link-icons/icons/im.png +0 -0
  203. data/webby/output/css/blueprint/plugins/link-icons/icons/pdf.png +0 -0
  204. data/webby/output/css/blueprint/plugins/link-icons/icons/visited.png +0 -0
  205. data/webby/output/css/blueprint/plugins/link-icons/icons/xls.png +0 -0
  206. data/webby/output/css/blueprint/plugins/link-icons/readme.txt +18 -0
  207. data/webby/output/css/blueprint/plugins/link-icons/screen.css +40 -0
  208. data/webby/output/css/blueprint/plugins/rtl/readme.txt +10 -0
  209. data/webby/output/css/blueprint/plugins/rtl/screen.css +109 -0
  210. data/webby/output/css/blueprint/print.css +30 -0
  211. data/webby/output/css/blueprint/screen.css +251 -0
  212. data/webby/output/css/blueprint/src/forms.css +49 -0
  213. data/webby/output/css/blueprint/src/grid.css +212 -0
  214. data/webby/output/css/blueprint/src/grid.png +0 -0
  215. data/webby/output/css/blueprint/src/ie.css +59 -0
  216. data/webby/output/css/blueprint/src/print.css +85 -0
  217. data/webby/output/css/blueprint/src/reset.css +38 -0
  218. data/webby/output/css/blueprint/src/typography.css +105 -0
  219. data/webby/output/css/pygments.css +59 -0
  220. data/webby/output/css/site.css +62 -0
  221. data/webby/output/gorgyrella-manual.aux +17 -0
  222. data/webby/output/gorgyrella-manual.erb +51 -0
  223. data/webby/output/gorgyrella-manual.log +271 -0
  224. data/webby/output/gorgyrella-manual.out +2 -0
  225. data/webby/output/gorgyrella-manual.pdf +0 -0
  226. data/webby/output/gorgyrella-manual.tex +191 -0
  227. data/webby/output/index.html +41 -0
  228. data/webby/rsync-exclude +7 -0
  229. data/webby/tasks/latex.rake +14 -0
  230. data/webby/templates/article.erb +15 -0
  231. data/webby/templates/book.erb +16 -0
  232. data/webby/templates/page.erb +12 -0
  233. metadata +313 -0
@@ -0,0 +1,133 @@
1
+ module Gorgyrella
2
+ class Parser
3
+ %%{
4
+ machine gorgyrella_parser;
5
+
6
+ action raise_error {
7
+ context = data[p - 30, 60].pack("c*") rescue
8
+ context ||= data[p - 10, 20].pack("c*") rescue
9
+ context ||= data[p-10, 10].pack("c*")
10
+ context ||= "not available"
11
+ raise "an error occurred parsing character " + p.to_s + " code: " + data[p].to_s + " chr: ->" + data[p, 1].pack("c*") + "<- \ncontext: " + context
12
+ }
13
+
14
+ action s {
15
+ start = p
16
+ }
17
+
18
+ action l {
19
+ text = data[start, p - start].pack("c*").strip
20
+ }
21
+
22
+ action reset_vars {
23
+ filename = nil
24
+ section = nil
25
+ format = nil
26
+ language = nil
27
+ command = nil
28
+ }
29
+
30
+ action process_command {
31
+ case command
32
+ when :include
33
+ builder.append_section(
34
+ :command => 'include',
35
+ :file => filename,
36
+ :section => section,
37
+ :format => format,
38
+ :language => language
39
+ )
40
+ when :export
41
+ builder.append_section(:section => section, :language => language)
42
+ when :end
43
+ builder.append_section
44
+ else
45
+ raise command
46
+ end
47
+ }
48
+
49
+ action start_line {
50
+ location = "start"
51
+ line_start_pos = p
52
+ }
53
+
54
+ action finish_line {
55
+ current_line_text = data[line_start_pos, p - line_start_pos].pack("c*")
56
+ line_data << [p, cs, current_line_text]
57
+ }
58
+
59
+ action trace {
60
+ $stdout.write "\nchar #{ sprintf("%03d", p)} #{data[p, 1].pack("c*")} state #{cs} #{location}"
61
+ }
62
+
63
+ ws = [ \t];
64
+ eol = "\n" | "\r\n";
65
+
66
+ identifier = (alpha (alpha | '.' | '_' | '-')*) >s %l;
67
+ string = '"' . (any - '"' - eol)* >s %l . '"'; # token STRING: '\'([^\\n\'\\\\]|\\\\.)*\'|"([^\\n"\\\\]|\\\\.)*"'
68
+ number = digit+ >s %l;
69
+
70
+ filename = string %{filename = text } ;
71
+ section = (identifier|string|number) %{section = text} ;
72
+ format= identifier %{format = text} ;
73
+ language = identifier %{language = text} ;
74
+
75
+ section_format_language = (section) | (section ws+ format) | (section ws+ format ws+ language) ;
76
+
77
+ include_section = 'include' ws+ filename ws+ section_format_language;
78
+ export_section = 'export' ws+ section (ws+ language)?;
79
+ end_section = 'end' ws*;
80
+
81
+ command =
82
+ include_section >{location = 'include command'} >reset_vars %{ command = :include } |
83
+ export_section >{location = 'export command'} >reset_vars %{ command = :export } |
84
+ end_section >{location = 'end command'} %{ command = :end }
85
+ ;
86
+
87
+ starter = ("###"|'%%%'|'///') . " @";
88
+
89
+ non_starter = [^#%/] - eol;
90
+ false_start_hash = '#'{1,2} . ([^#] - eol) ;
91
+ false_start_percent = '%'{1,2} . ([^%] - eol) ;
92
+ followed_by_zlen = ('%'{1,3} | '#' {1,3}) . eol;
93
+ no_at = ("###"|'%%%'|'///') . ' ' . [^@];
94
+ more_than_three = ("####"|'%%%%'|'////');
95
+
96
+ not_starter = non_starter | false_start_hash | false_start_percent | no_at | followed_by_zlen | more_than_three;
97
+
98
+ statement = (ws* . starter . command %process_command) ;
99
+ junk = (ws* . not_starter . (any - eol)* ) ;
100
+
101
+ line = (statement | junk | zlen) >start_line . eol %finish_line %{ builder.append_line(current_line_text.chomp) unless location =~ /command/ } ;
102
+ document := line* $!raise_error;
103
+
104
+ }%%
105
+
106
+ %% write data;
107
+
108
+ ### @export "run-machine"
109
+ def self.run_machine(data, test_mode = false)
110
+ # puts "Running the state machine with input #{data}..."
111
+ data += "\n\n"
112
+ data = data.unpack("c*") if data.is_a?(String)
113
+
114
+ line_counter = 0
115
+ line_data = []
116
+
117
+ builder = Builder.new
118
+
119
+ eof = -1
120
+
121
+ %% write init;
122
+ %% write exec;
123
+
124
+
125
+ if test_mode
126
+ [builder, line_data]
127
+ else
128
+ builder
129
+ end
130
+ end
131
+ ### @end
132
+ end
133
+ end
data/lib/gorgyrella.rb ADDED
@@ -0,0 +1,46 @@
1
+ module Gorgyrella
2
+ # :stopdoc:
3
+ VERSION = '0.0.1'
4
+ LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
5
+ PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
6
+ # :startdoc:
7
+
8
+ # Returns the version string for the library.
9
+ #
10
+ def self.version
11
+ VERSION
12
+ end
13
+
14
+ # Returns the library path for the module. If any arguments are given,
15
+ # they will be joined to the end of the libray path using
16
+ # <tt>File.join</tt>.
17
+ #
18
+ def self.libpath( *args )
19
+ args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
20
+ end
21
+
22
+ # Returns the lpath for the module. If any arguments are given,
23
+ # they will be joined to the end of the path using
24
+ # <tt>File.join</tt>.
25
+ #
26
+ def self.path( *args )
27
+ args.empty? ? PATH : ::File.join(PATH, args.flatten)
28
+ end
29
+
30
+ # Utility method used to require all files ending in .rb that lie in the
31
+ # directory below this file that has the same name as the filename passed
32
+ # in. Optionally, a specific _directory_ name can be passed in such that
33
+ # the _filename_ does not have to be equivalent to the directory.
34
+ #
35
+ def self.require_all_libs_relative_to( fname, dir = nil )
36
+ dir ||= ::File.basename(fname, '.*')
37
+ search_me = ::File.expand_path(
38
+ ::File.join(::File.dirname(fname), dir, '**', '*.rb'))
39
+
40
+ Dir.glob(search_me).sort.each {|rb| require rb}
41
+ end
42
+
43
+ end # module Gorgyrella
44
+
45
+ Gorgyrella.require_all_libs_relative_to(__FILE__)
46
+ Gorgyrella.require_all_libs_relative_to(__FILE__, "webby")
@@ -0,0 +1,31 @@
1
+ begin
2
+ require "webby"
3
+
4
+ module Webby::Helpers
5
+ module GorgyrellaHelper
6
+ def gorg(filename, section = "1", format = nil, language = nil)
7
+ if !File.exist?(filename)
8
+ filename = File.join(Webby.site.content_dir, @page.dir, filename)
9
+ end
10
+
11
+ Gorgyrella.render_section(filename, section, format, language)
12
+ end
13
+
14
+ # LaTeX Helpers
15
+ def gorgl(filename, section = "1", format = "latex", language = nil)
16
+ gorg(filename, section, format, language)
17
+ end
18
+
19
+ def pygments_latex_styles(style = 'default')
20
+ command = "pygmentize -S #{style} -f latex"
21
+ $pygments_latex_styles_cache ||= IO.popen(command).read
22
+ end
23
+ end
24
+
25
+ register(GorgyrellaHelper)
26
+ end
27
+
28
+ puts "GorgyrellaHelper registered with Webby."
29
+ rescue LoadError
30
+ puts "Webby not available, GorgyrellaHelper not registered."
31
+ end
@@ -0,0 +1,7 @@
1
+ require File.join(File.dirname(__FILE__), %w[spec_helper])
2
+
3
+ describe Gorgyrella::Builder, "" do
4
+ it "should description" do
5
+
6
+ end
7
+ end
@@ -0,0 +1,70 @@
1
+ require File.join(File.dirname(__FILE__), %w[spec_helper])
2
+
3
+ describe Gorgyrella::Composer, "Pygments" do
4
+ it "should create a HTML file including python code" do
5
+ comp = Gorgyrella::Composer.new('Pygments')
6
+
7
+ File.open("spec/tmp/example-python-processed-pygments.html", "w") do |f|
8
+ f.write comp.process("spec/data/example-python.html")
9
+ end
10
+ end
11
+
12
+ it "should create a HTML file including ruby code" do
13
+ comp = Gorgyrella::Composer.new('Pygments')
14
+
15
+ File.open("spec/tmp/example-ruby-processed-pygments.html", "w") do |f|
16
+ f.write comp.process("spec/data/example-ruby.html")
17
+ end
18
+ end
19
+ end
20
+
21
+ describe Gorgyrella::Composer, "Coderay" do
22
+ it "should create a HTML file including python code" do
23
+ comp = Gorgyrella::Composer.new
24
+
25
+ File.open("spec/tmp/example-python-processed-coderay.html", "w") do |f|
26
+ f.write comp.process("spec/data/example-python.html")
27
+ end
28
+ end
29
+
30
+ it "should create a HTML file including ruby code" do
31
+ comp = Gorgyrella::Composer.new
32
+
33
+ File.open("spec/tmp/example-ruby-processed-coderay.html", "w") do |f|
34
+ f.write comp.process("spec/data/example-ruby.html")
35
+ end
36
+ end
37
+ end
38
+
39
+ describe Gorgyrella::Composer, "Ultraviolet" do
40
+ it "should create a HTML file including python code" do
41
+ comp = Gorgyrella::Composer.new("Ultraviolet")
42
+
43
+ File.open("spec/tmp/example-python-processed-ultraviolet.html", "w") do |f|
44
+ f.write comp.process("spec/data/example-python.html")
45
+ end
46
+ end
47
+
48
+ it "should create a HTML file including ruby code" do
49
+ comp = Gorgyrella::Composer.new("Ultraviolet")
50
+
51
+ File.open("spec/tmp/example-ruby-processed-ultraviolet.html", "w") do |f|
52
+ f.write comp.process("spec/data/example-ruby.html")
53
+ end
54
+ end
55
+ end
56
+
57
+ describe Gorgyrella::Composer, "render_include" do
58
+ it "should be able to call directly" do
59
+ comp = Gorgyrella::Composer.new
60
+ comp.render_include("spec/data/test.py", "Closing", "text").should eql(%{
61
+ if __name__=='__main__':
62
+ print "my name is main"
63
+ a = MyClass()
64
+ })
65
+ end
66
+
67
+ it "should be able to call directly for latex" do
68
+ Gorgyrella.render_section("spec/data/test.py", "Closing", "latex", "python").should eql(%{\\begin{Verbatim}[commandchars=@\\[\\]]\n@PYay[if] __name__@PYbe[==]@PYaB[']@PYaB[__main__]@PYaB[']:\n @PYay[print] @PYaB[\"]@PYaB[my name is main]@PYaB[\"]\n a @PYbe[=] MyClass()\n\\end{Verbatim}\n})
69
+ end
70
+ end
@@ -0,0 +1,126 @@
1
+ .CodeRay {
2
+ background-color: #f8f8f8;
3
+ border: 1px solid silver;
4
+ font-family: 'Courier New', 'Terminal', monospace;
5
+ color: #000;
6
+ }
7
+ .CodeRay pre { margin: 0px }
8
+
9
+ div.CodeRay { }
10
+
11
+ span.CodeRay { white-space: pre; border: 0px; padding: 2px }
12
+
13
+ table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px }
14
+ table.CodeRay td { padding: 2px 4px; vertical-align: top }
15
+
16
+ .CodeRay .line_numbers, .CodeRay .no {
17
+ background-color: #def;
18
+ color: gray;
19
+ text-align: right;
20
+ }
21
+ .CodeRay .line_numbers tt { font-weight: bold }
22
+ .CodeRay .no { padding: 0px 4px }
23
+ .CodeRay .code { width: 100% }
24
+
25
+ ol.CodeRay { font-size: 10pt }
26
+ ol.CodeRay li { white-space: pre }
27
+
28
+ .CodeRay .code pre { overflow: auto }
29
+
30
+ .CodeRay .debug { color:white ! important; background:blue ! important; }
31
+
32
+ .CodeRay .af { color:#00C }
33
+ .CodeRay .an { color:#007 }
34
+ .CodeRay .at { color:#f08 }
35
+ .CodeRay .av { color:#700 }
36
+ .CodeRay .aw { color:#C00 }
37
+ .CodeRay .bi { color:#509; font-weight:bold }
38
+ .CodeRay .c { color:#888; }
39
+
40
+ .CodeRay .ch { color:#04D }
41
+ .CodeRay .ch .k { color:#04D }
42
+ .CodeRay .ch .dl { color:#039 }
43
+
44
+ .CodeRay .cl { color:#B06; font-weight:bold }
45
+ .CodeRay .co { color:#036; font-weight:bold }
46
+ .CodeRay .cr { color:#0A0 }
47
+ .CodeRay .cv { color:#369 }
48
+ .CodeRay .df { color:#099; font-weight:bold }
49
+ .CodeRay .di { color:#088; font-weight:bold }
50
+ .CodeRay .dl { color:black }
51
+ .CodeRay .do { color:#970 }
52
+ .CodeRay .dt { color:#34b }
53
+ .CodeRay .ds { color:#D42; font-weight:bold }
54
+ .CodeRay .e { color:#666; font-weight:bold }
55
+ .CodeRay .en { color:#800; font-weight:bold }
56
+ .CodeRay .er { color:#F00; background-color:#FAA }
57
+ .CodeRay .ex { color:#F00; font-weight:bold }
58
+ .CodeRay .fl { color:#60E; font-weight:bold }
59
+ .CodeRay .fu { color:#06B; font-weight:bold }
60
+ .CodeRay .gv { color:#d70; font-weight:bold }
61
+ .CodeRay .hx { color:#058; font-weight:bold }
62
+ .CodeRay .i { color:#00D; font-weight:bold }
63
+ .CodeRay .ic { color:#B44; font-weight:bold }
64
+
65
+ .CodeRay .il { background: #eee; color: black }
66
+ .CodeRay .il .il { background: #ddd }
67
+ .CodeRay .il .il .il { background: #ccc }
68
+ .CodeRay .il .idl { font-weight: bold; color: #777 }
69
+
70
+ .CodeRay .im { color:#f00; }
71
+ .CodeRay .in { color:#B2B; font-weight:bold }
72
+ .CodeRay .iv { color:#33B }
73
+ .CodeRay .la { color:#970; font-weight:bold }
74
+ .CodeRay .lv { color:#963 }
75
+ .CodeRay .oc { color:#40E; font-weight:bold }
76
+ .CodeRay .of { color:#000; font-weight:bold }
77
+ .CodeRay .op { }
78
+ .CodeRay .pc { color:#038; font-weight:bold }
79
+ .CodeRay .pd { color:#369; font-weight:bold }
80
+ .CodeRay .pp { color:#579; }
81
+ .CodeRay .ps { color:#00C; font-weight: bold; }
82
+ .CodeRay .pt { color:#349; font-weight:bold }
83
+ .CodeRay .r, .kw { color:#080; font-weight:bold }
84
+
85
+ .CodeRay .ke { color: #808; }
86
+ .CodeRay .ke .dl { color: #606; }
87
+ .CodeRay .ke .ch { color: #80f; }
88
+ .CodeRay .vl { color: #088; }
89
+
90
+ .CodeRay .rx { background-color:#fff0ff }
91
+ .CodeRay .rx .k { color:#808 }
92
+ .CodeRay .rx .dl { color:#404 }
93
+ .CodeRay .rx .mod { color:#C2C }
94
+ .CodeRay .rx .fu { color:#404; font-weight: bold }
95
+
96
+ .CodeRay .s { background-color:#fff0f0; color: #D20; }
97
+ .CodeRay .s .s { background-color:#ffe0e0 }
98
+ .CodeRay .s .s .s { background-color:#ffd0d0 }
99
+ .CodeRay .s .k { }
100
+ .CodeRay .s .ch { color: #b0b; }
101
+ .CodeRay .s .dl { color: #710; }
102
+
103
+ .CodeRay .sh { background-color:#f0fff0; color:#2B2 }
104
+ .CodeRay .sh .k { }
105
+ .CodeRay .sh .dl { color:#161 }
106
+
107
+ .CodeRay .sy { color:#A60 }
108
+ .CodeRay .sy .k { color:#A60 }
109
+ .CodeRay .sy .dl { color:#630 }
110
+
111
+ .CodeRay .ta { color:#070 }
112
+ .CodeRay .tf { color:#070; font-weight:bold }
113
+ .CodeRay .ts { color:#D70; font-weight:bold }
114
+ .CodeRay .ty { color:#339; font-weight:bold }
115
+ .CodeRay .v { color:#036 }
116
+ .CodeRay .xt { color:#444 }
117
+
118
+ .CodeRay .ins { background: #afa; }
119
+ .CodeRay .del { background: #faa; }
120
+ .CodeRay .chg { color: #aaf; background: #007; }
121
+ .CodeRay .head { color: #f8f; background: #505 }
122
+
123
+ .CodeRay .ins .ins { color: #080; font-weight:bold }
124
+ .CodeRay .del .del { color: #800; font-weight:bold }
125
+ .CodeRay .chg .chg { color: #66f; }
126
+ .CodeRay .head .head { color: #f4f; }
@@ -0,0 +1,24 @@
1
+ <html>
2
+ <head>
3
+ <link rel="stylesheet" href="../data/pygments.css" type="text/css" media="all" charset="utf-8">
4
+ <link rel="stylesheet" href="../data/coderay.css" type="text/css" media="all" charset="utf-8">
5
+ <link rel="stylesheet" href="../data/ultraviolet/css/amy.css" type="text/css" media="all" charset="utf-8">
6
+ </head>
7
+ <body>
8
+ <p>Here's a test.</p>
9
+ ### @include "spec/data/test.py" "Closing"
10
+ ### @end
11
+
12
+ <p>Another test as raw text.</p>
13
+ <pre>
14
+ ### @include "spec/data/test.py" "Beginning Preamble" text
15
+ ### @end
16
+ </pre>
17
+
18
+ <p>And again with html format</p>
19
+ <pre>
20
+ ### @include "spec/data/test.py" "Main Function" html
21
+ ### @end
22
+ </pre>
23
+ </body>
24
+ </html>
@@ -0,0 +1,30 @@
1
+ <html>
2
+ <head>
3
+ <link rel="stylesheet" href="../data/pygments.css" type="text/css" media="all" charset="utf-8">
4
+ <link rel="stylesheet" href="../data/coderay.css" type="text/css" media="all" charset="utf-8">
5
+ <link rel="stylesheet" href="../data/ultraviolet/css/amy.css" type="text/css" media="all" charset="utf-8">
6
+ </head>
7
+ <body>
8
+ <p>Here's a test.</p>
9
+ ### @include "spec/data/test.rb" "Closing"
10
+ ### @end
11
+
12
+ <p>Another test as raw text.</p>
13
+ <pre>
14
+ ### @include "spec/data/test.rb" "Beginning Preamble" text
15
+ ### @end
16
+ </pre>
17
+
18
+ <p>And again with html format</p>
19
+ <pre>
20
+ ### @include "spec/data/test.rb" "Main Function" html
21
+ ### @end
22
+ </pre>
23
+
24
+ <p>And again to trigger cache</p>
25
+ <pre>
26
+ ### @include "spec/data/test.rb" "Main Function" html
27
+ ### @end
28
+ </pre>
29
+ </body>
30
+ </html>
@@ -0,0 +1,59 @@
1
+ .c { color: #0099FF; font-style: italic } /* Comment */
2
+ .err { color: #AA0000; background-color: #FFAAAA } /* Error */
3
+ .k { color: #006699; font-weight: bold } /* Keyword */
4
+ .o { color: #555555 } /* Operator */
5
+ .cm { color: #0099FF; font-style: italic } /* Comment.Multiline */
6
+ .cp { color: #009999 } /* Comment.Preproc */
7
+ .c1 { color: #0099FF; font-style: italic } /* Comment.Single */
8
+ .cs { color: #0099FF; font-weight: bold; font-style: italic } /* Comment.Special */
9
+ .gd { background-color: #FFCCCC; border: 1px solid #CC0000 } /* Generic.Deleted */
10
+ .ge { font-style: italic } /* Generic.Emph */
11
+ .gr { color: #FF0000 } /* Generic.Error */
12
+ .gh { color: #003300; font-weight: bold } /* Generic.Heading */
13
+ .gi { background-color: #CCFFCC; border: 1px solid #00CC00 } /* Generic.Inserted */
14
+ .go { color: #AAAAAA } /* Generic.Output */
15
+ .gp { color: #000099; font-weight: bold } /* Generic.Prompt */
16
+ .gs { font-weight: bold } /* Generic.Strong */
17
+ .gu { color: #003300; font-weight: bold } /* Generic.Subheading */
18
+ .gt { color: #99CC66 } /* Generic.Traceback */
19
+ .kc { color: #006699; font-weight: bold } /* Keyword.Constant */
20
+ .kd { color: #006699; font-weight: bold } /* Keyword.Declaration */
21
+ .kp { color: #006699 } /* Keyword.Pseudo */
22
+ .kr { color: #006699; font-weight: bold } /* Keyword.Reserved */
23
+ .kt { color: #007788; font-weight: bold } /* Keyword.Type */
24
+ .m { color: #FF6600 } /* Literal.Number */
25
+ .s { color: #CC3300 } /* Literal.String */
26
+ .na { color: #330099 } /* Name.Attribute */
27
+ .nb { color: #336666 } /* Name.Builtin */
28
+ .nc { color: #00AA88; font-weight: bold } /* Name.Class */
29
+ .no { color: #336600 } /* Name.Constant */
30
+ .nd { color: #9999FF } /* Name.Decorator */
31
+ .ni { color: #999999; font-weight: bold } /* Name.Entity */
32
+ .ne { color: #CC0000; font-weight: bold } /* Name.Exception */
33
+ .nf { color: #CC00FF } /* Name.Function */
34
+ .nl { color: #9999FF } /* Name.Label */
35
+ .nn { color: #00CCFF; font-weight: bold } /* Name.Namespace */
36
+ .nt { color: #330099; font-weight: bold } /* Name.Tag */
37
+ .nv { color: #003333 } /* Name.Variable */
38
+ .ow { color: #000000; font-weight: bold } /* Operator.Word */
39
+ .w { color: #bbbbbb } /* Text.Whitespace */
40
+ .mf { color: #FF6600 } /* Literal.Number.Float */
41
+ .mh { color: #FF6600 } /* Literal.Number.Hex */
42
+ .mi { color: #FF6600 } /* Literal.Number.Integer */
43
+ .mo { color: #FF6600 } /* Literal.Number.Oct */
44
+ .sb { color: #CC3300 } /* Literal.String.Backtick */
45
+ .sc { color: #CC3300 } /* Literal.String.Char */
46
+ .sd { color: #CC3300; font-style: italic } /* Literal.String.Doc */
47
+ .s2 { color: #CC3300 } /* Literal.String.Double */
48
+ .se { color: #CC3300; font-weight: bold } /* Literal.String.Escape */
49
+ .sh { color: #CC3300 } /* Literal.String.Heredoc */
50
+ .si { color: #AA0000 } /* Literal.String.Interpol */
51
+ .sx { color: #CC3300 } /* Literal.String.Other */
52
+ .sr { color: #33AAAA } /* Literal.String.Regex */
53
+ .s1 { color: #CC3300 } /* Literal.String.Single */
54
+ .ss { color: #FFCC33 } /* Literal.String.Symbol */
55
+ .bp { color: #336666 } /* Name.Builtin.Pseudo */
56
+ .vc { color: #003333 } /* Name.Variable.Class */
57
+ .vg { color: #003333 } /* Name.Variable.Global */
58
+ .vi { color: #003333 } /* Name.Variable.Instance */
59
+ .il { color: #FF6600 } /* Literal.Number.Integer.Long */
data/spec/data/test.py ADDED
@@ -0,0 +1,21 @@
1
+ ### @export "Import" python
2
+ from collections import *
3
+
4
+ ### @export "Beginning Preamble" python
5
+
6
+ class MyClass:
7
+ def __init__(self):
8
+ pass
9
+
10
+ ### @export "Main Function" python
11
+ def main(self, args):
12
+ pass
13
+
14
+ ### @export "Closing" python
15
+
16
+ if __name__=='__main__':
17
+ print "my name is main"
18
+ a = MyClass()
19
+
20
+ ### @end
21
+ # this should not show up
data/spec/data/test.rb ADDED
@@ -0,0 +1,13 @@
1
+ ### @export "Beginning Preamble"
2
+ class MyClass
3
+ ### @export "Main Function"
4
+ def main(args)
5
+ puts "hi!"
6
+ end
7
+ ### @end
8
+ end
9
+ ### @export "Closing"
10
+ __END__
11
+
12
+ ### @end
13
+ # this should not show up
@@ -0,0 +1,114 @@
1
+ pre.active4d .DiffHeader {
2
+ background-color: #656565;
3
+ color: #FFFFFF;
4
+ }
5
+ pre.active4d .Operator {
6
+ }
7
+ pre.active4d .InheritedClass {
8
+ }
9
+ pre.active4d .TypeName {
10
+ color: #21439C;
11
+ }
12
+ pre.active4d .Number {
13
+ color: #A8017E;
14
+ }
15
+ pre.active4d .EmbeddedSource {
16
+ background-color: #ECF1FF;
17
+ }
18
+ pre.active4d {
19
+ background-color: #FFFFFF;
20
+ color: #000000;
21
+ }
22
+ pre.active4d .DiffInsertedLine {
23
+ background-color: #98FF9A;
24
+ color: #000000;
25
+ }
26
+ pre.active4d .LibraryVariable {
27
+ color: #A535AE;
28
+ }
29
+ pre.active4d .Storage {
30
+ color: #FF5600;
31
+ }
32
+ pre.active4d .InterpolatedEntity {
33
+ font-weight: bold;
34
+ color: #66CCFF;
35
+ }
36
+ pre.active4d .line-numbers {
37
+ background-color: #BAD6FD;
38
+ color: #000000;
39
+ }
40
+ pre.active4d .LocalVariable {
41
+ font-weight: bold;
42
+ color: #6392FF;
43
+ }
44
+ pre.active4d .DiffLineRange {
45
+ background-color: #1B63FF;
46
+ color: #FFFFFF;
47
+ }
48
+ pre.active4d .BlockComment {
49
+ color: #D33435;
50
+ }
51
+ pre.active4d .TagName {
52
+ color: #016CFF;
53
+ }
54
+ pre.active4d .FunctionArgument {
55
+ }
56
+ pre.active4d .BuiltInConstant {
57
+ color: #A535AE;
58
+ }
59
+ pre.active4d .LineComment {
60
+ color: #D33535;
61
+ }
62
+ pre.active4d .DiffDeletedLine {
63
+ background-color: #FF7880;
64
+ color: #000000;
65
+ }
66
+ pre.active4d .NamedConstant {
67
+ color: #B7734C;
68
+ }
69
+ pre.active4d .CommandMethod {
70
+ font-weight: bold;
71
+ color: #45AE34;
72
+ }
73
+ pre.active4d .TableField {
74
+ color: #0BB600;
75
+ }
76
+ pre.active4d .PlainXmlText {
77
+ color: #000000;
78
+ }
79
+ pre.active4d .Invalid {
80
+ background-color: #990000;
81
+ color: #FFFFFF;
82
+ }
83
+ pre.active4d .LibraryClassType {
84
+ color: #A535AE;
85
+ }
86
+ pre.active4d .TagAttribute {
87
+ color: #963DFF;
88
+ }
89
+ pre.active4d .Keyword {
90
+ font-weight: bold;
91
+ color: #006699;
92
+ }
93
+ pre.active4d .UserDefinedConstant {
94
+ }
95
+ pre.active4d .String {
96
+ color: #666666;
97
+ }
98
+ pre.active4d .DiffUnchangedLine {
99
+ color: #5E5E5E;
100
+ }
101
+ pre.active4d .TagContainer {
102
+ color: #7A7A7A;
103
+ }
104
+ pre.active4d .FunctionName {
105
+ color: #21439C;
106
+ }
107
+ pre.active4d .Variable {
108
+ font-weight: bold;
109
+ color: #0053FF;
110
+ }
111
+ pre.active4d .DateTimeLiteral {
112
+ font-weight: bold;
113
+ color: #66CCFF;
114
+ }