TwP-webby 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/History.txt +13 -0
  2. data/Manifest.txt +44 -34
  3. data/Rakefile +2 -2
  4. data/bin/webby +33 -0
  5. data/bin/webby-gen +33 -0
  6. data/examples/presentation/content/presentation/s5/bodybg.gif +0 -0
  7. data/examples/presentation/content/presentation/s5/print.css +25 -1
  8. data/examples/webby/content/release-notes/rel-0-9-3/index.txt +47 -0
  9. data/lib/webby/apps/generator.rb +41 -48
  10. data/lib/webby/apps/main.rb +22 -0
  11. data/lib/webby/auto_builder.rb +78 -6
  12. data/lib/webby/builder.rb +9 -9
  13. data/lib/webby/core_ext/kernel.rb +5 -0
  14. data/lib/webby/filters/wiki_words.rb +14 -0
  15. data/lib/webby/helpers/url_helper.rb +6 -0
  16. data/lib/webby/journal.rb +126 -0
  17. data/lib/webby/renderer.rb +11 -6
  18. data/lib/webby/resources/meta_file.rb +8 -5
  19. data/lib/webby/stelan/paginator.rb +2 -2
  20. data/lib/webby/tasks/growl.rake +4 -3
  21. data/lib/webby.rb +3 -10
  22. data/spec/data/outline/basic.out +81 -0
  23. data/spec/data/outline/basic.txt +25 -0
  24. data/spec/data/outline/no_clobber.out +86 -0
  25. data/spec/data/outline/numbering.out +81 -0
  26. data/spec/data/outline/numbering_only.out +21 -0
  27. data/spec/data/outline/toc_range_1.out +66 -0
  28. data/spec/data/outline/toc_range_2.out +55 -0
  29. data/spec/data/outline/toc_style.out +81 -0
  30. data/spec/data/{Sitefile → site/Sitefile} +0 -0
  31. data/spec/data/{content → site/content}/_partial.txt +0 -0
  32. data/spec/data/{content → site/content}/css/coderay.css +0 -0
  33. data/spec/data/{content → site/content}/css/site.css +0 -0
  34. data/spec/data/{content → site/content}/css/tumblog.css +0 -0
  35. data/spec/data/{content → site/content}/images/tumblog/permalink.gif +0 -0
  36. data/spec/data/{content → site/content}/images/tumblog/rss.gif +0 -0
  37. data/spec/data/{content → site/content}/index.txt +0 -0
  38. data/spec/data/{content → site/content}/photos.txt +0 -0
  39. data/spec/data/{content → site/content}/tumblog/200806/the-noble-chicken/index.txt +0 -0
  40. data/spec/data/{content → site/content}/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt +0 -0
  41. data/spec/data/{content → site/content}/tumblog/200807/mad-city-chickens/index.txt +0 -0
  42. data/spec/data/{content → site/content}/tumblog/200807/the-wisdom-of-the-dutch/index.txt +0 -0
  43. data/spec/data/{content → site/content}/tumblog/200807/up-a-tree/index.txt +0 -0
  44. data/spec/data/{content → site/content}/tumblog/index.txt +0 -0
  45. data/spec/data/{content → site/content}/tumblog/rss.txt +0 -0
  46. data/spec/data/{layouts → site/layouts}/default.txt +0 -0
  47. data/spec/data/{layouts → site/layouts}/tumblog/default.txt +0 -0
  48. data/spec/data/{layouts → site/layouts}/tumblog/post.txt +0 -0
  49. data/spec/data/{lib → site/lib}/breadcrumbs.rb +0 -0
  50. data/spec/data/{lib → site/lib}/tumblog_helper.rb +0 -0
  51. data/spec/data/{tasks → site/tasks}/tumblog.rake +0 -0
  52. data/spec/data/{templates → site/templates}/_partial.erb +0 -0
  53. data/spec/data/{templates → site/templates}/atom_feed.erb +0 -0
  54. data/spec/data/{templates → site/templates}/page.erb +0 -0
  55. data/{examples/website → spec/data/site}/templates/presentation.erb +0 -0
  56. data/spec/data/{templates → site/templates}/tumblog/conversation.erb +0 -0
  57. data/spec/data/{templates → site/templates}/tumblog/link.erb +0 -0
  58. data/spec/data/{templates → site/templates}/tumblog/photo.erb +0 -0
  59. data/spec/data/{templates → site/templates}/tumblog/post.erb +0 -0
  60. data/spec/data/{templates → site/templates}/tumblog/quote.erb +0 -0
  61. data/spec/spec_helper.rb +4 -4
  62. data/spec/webby/apps/generator_spec.rb +3 -2
  63. data/spec/webby/filters/basepath_spec.rb +167 -0
  64. data/spec/webby/filters/outline_spec.rb +92 -0
  65. data/spec/webby/renderer_spec.rb +1 -1
  66. data/spec/webby/resources/db_spec.rb +1 -1
  67. data/spec/webby/resources/layout_spec.rb +1 -1
  68. data/spec/webby/resources/meta_file_spec.rb +27 -13
  69. data/spec/webby/resources/page_spec.rb +1 -1
  70. data/spec/webby/resources/resource_spec.rb +1 -1
  71. data/spec/webby/resources_spec.rb +1 -1
  72. data/tasks/gem.rake +93 -32
  73. data/tasks/manifest.rake +3 -4
  74. data/tasks/rubyforge.rake +2 -4
  75. metadata +67 -57
  76. data/lib/webby/stelan/spawner.rb +0 -339
  77. data/lib/webby/tasks/heel.rake +0 -28
  78. data/spec/data/templates/presentation.erb +0 -40
@@ -1,339 +0,0 @@
1
- require 'rbconfig'
2
- require 'thread'
3
- require 'tempfile'
4
-
5
- # :stopdoc:
6
-
7
- # == Synopsis
8
- #
9
- # A class for spawning child processes and ensuring those children continue
10
- # running.
11
- #
12
- # == Details
13
- #
14
- # When a spawner is created it is given the command to run in a child
15
- # process. This child process has +stdin+, +stdout+, and +stderr+ redirected
16
- # to +/dev/null+ (this works even on Windows). When the child dies for any
17
- # reason, the spawner will restart a new child process in the exact same
18
- # manner as the original.
19
- #
20
- class Spawner
21
-
22
- @dev_null = test(?e, "/dev/null") ? "/dev/null" : "NUL:"
23
-
24
- c = ::Config::CONFIG
25
- ruby = File.join(c['bindir'], c['ruby_install_name']) << c['EXEEXT']
26
- @ruby = if system('%s -e exit' % ruby) then ruby
27
- elsif system('ruby -e exit') then 'ruby'
28
- else warn 'no ruby in PATH/CONFIG'
29
- end
30
-
31
- class << self
32
- attr_reader :ruby
33
- attr_reader :dev_null
34
-
35
- def finalizer( cids )
36
- pid = $$
37
- lambda do
38
- break unless pid == $$
39
- cids.kill 'TERM', :all
40
- end # lambda
41
- end # finalizer
42
- end
43
-
44
- # call-seq:
45
- # Spawner.new( command, *args, opts = {} )
46
- #
47
- # Creates a new spawner that will execute the given external _command_ in
48
- # a sub-process. The calling semantics of <code>Kernel::exec</code> are
49
- # used to execute the _command_. Any number of optional _args_ can be
50
- # passed to the _command_.
51
- #
52
- # Available options:
53
- #
54
- # :spawn => the number of child processes to spawn
55
- # :pause => wait time (in seconds) before respawning after termination
56
- # :ruby => the Ruby interpreter to use when spawning children
57
- # :env => a hash for the child process environment
58
- # :stdin => stdin child processes will read from
59
- # :stdout => stdout child processes will write to
60
- # :stderr => stderr child processes will write to
61
- #
62
- # The <code>:env</code> option is used to add environemnt variables to
63
- # child processes when they are spawned.
64
- #
65
- # *Note:* all spawned child processes will use the same stdin, stdout, and
66
- # stderr if they are given in the options. Otherwise they all default to
67
- # <code>/dev/null</code> on *NIX and <code>NUL:</code> on Windows.
68
- #
69
- def initialize( *args )
70
- config = {
71
- :ruby => self.class.ruby,
72
- :spawn => 1,
73
- :pause => 0,
74
- :stdin => self.class.dev_null,
75
- :stdout => self.class.dev_null,
76
- :stderr => self.class.dev_null
77
- }
78
- config.merge! args.pop if Hash === args.last
79
- config[:argv] = args
80
-
81
- raise ArgumentError, 'wrong number of arguments' if args.empty?
82
-
83
- @stop = true
84
- @cids = []
85
- @group = ThreadGroup.new
86
-
87
- @spawn = config.delete(:spawn)
88
- @pause = config.delete(:pause)
89
- @ruby = config.delete(:ruby)
90
-
91
- @tmp = child_program(config)
92
-
93
- class << @cids
94
- # call-seq:
95
- # sync {block}
96
- #
97
- # Executes the given block in a synchronized fashion -- i.e. only a
98
- # single thread can execute at a time. Uses Mutex under the hood.
99
- #
100
- def sync(&b)
101
- @mutex ||= Mutex.new
102
- @mutex.synchronize(&b)
103
- end
104
-
105
- # call-seq:
106
- # kill( signal, num ) => number killed
107
- # kill( signal, :all ) => number killed
108
- #
109
- # Send the _signal_ to a given _num_ of child processes or all child
110
- # processes if <code>:all</code> is given instead of a number. Returns
111
- # the number of child processes killed.
112
- #
113
- def kill( signal, arg )
114
- return if empty?
115
-
116
- ary = sync do
117
- case arg
118
- when :all; self.dup
119
- when Integer; self.slice(0,arg)
120
- else raise ArgumentError end
121
- end
122
-
123
- ary.each do |cid|
124
- begin
125
- Process.kill(signal, cid)
126
- rescue SystemCallError
127
- sync {delete cid}
128
- end
129
- end
130
- ary.length
131
- end # def kill
132
- end # class << @cids
133
-
134
- end # def initialize
135
-
136
- attr_reader :spawn
137
- attr_accessor :pause
138
-
139
- # call-seq:
140
- # spawner.spawn = num
141
- #
142
- # Set the number of child processes to spawn. If the new spawn number is
143
- # less than the current number, then spawner threads will die
144
- #
145
- def spawn=( num )
146
- num = num.abs
147
- diff, @spawn = num - @spawn, num
148
- return unless running?
149
-
150
- if diff > 0
151
- diff.times {_spawn}
152
- elsif diff < 0
153
- @cids.kill 'TERM', diff.abs
154
- end
155
- end
156
-
157
- # call-seq:
158
- # start => self
159
- #
160
- # Spawn the sub-processes.
161
- #
162
- def start
163
- return self if running?
164
- @stop = false
165
-
166
- @cleanup = Spawner.finalizer(@cids)
167
- ObjectSpace.define_finalizer(self, @cleanup)
168
-
169
- @spawn.times {_spawn}
170
- self
171
- end
172
-
173
- # call-seq:
174
- # stop( timeout = 5 ) => self
175
- #
176
- # Stop any spawned sub-processes.
177
- #
178
- def stop( timeout = 5 )
179
- return self unless running?
180
- @stop = true
181
-
182
- @cleanup.call
183
- ObjectSpace.undefine_finalizer(self)
184
-
185
- # the cleanup call sends SIGTERM to all the child processes
186
- # however, some might still be hanging around, so we are going to wait
187
- # for a timeout interval and then send a SIGKILL to any remaining child
188
- # processes
189
- nap_time = 0.05 * timeout # sleep for 5% of the timeout interval
190
- timeout = Time.now + timeout
191
-
192
- until @cids.empty?
193
- sleep nap_time
194
- unless Time.now < timeout
195
- @cids.kill 'KILL', :all
196
- @cids.clear
197
- @group.list.each {|t| t.kill}
198
- break
199
- end
200
- end
201
-
202
- self
203
- end
204
-
205
- # call-seq:
206
- # restart( timeout = 5 )
207
- #
208
- def restart( timeout = 5 )
209
- stop( timeout )
210
- start
211
- end
212
-
213
- # call-seq:
214
- # running?
215
- #
216
- # Returns +true+ if the spawner is currently running; returns +false+
217
- # otherwise.
218
- #
219
- def running?
220
- !@stop
221
- end
222
-
223
- # call-seq:
224
- # join( timeout = nil ) => spawner or nil
225
- #
226
- # The calling thread will suspend execution until all child processes have
227
- # been stopped. Does not return until all spawner threads have exited (the
228
- # child processes have been stopped) or until _timeout seconds have
229
- # passed. If the timeout expires +nil+ will be returned; otherwise the
230
- # spawner is returned.
231
- #
232
- def join( limit = nil )
233
- loop do
234
- t = @group.list.first
235
- break if t.nil?
236
- return nil unless t.join(limit)
237
- end
238
- self
239
- end
240
-
241
-
242
- private
243
-
244
- # call-seq:
245
- # _spawn => thread
246
- #
247
- # Creates a thread that will spawn the sub-process via
248
- # <code>IO::popen</code>. If the sub-process terminates, it will be
249
- # respawned until the +stop+ message is sent to this spawner.
250
- #
251
- # If an Exception is encountered during the spawning process, a message
252
- # will be printed to stderr and the thread will exit.
253
- #
254
- def _spawn
255
- t = Thread.new do
256
- catch(:die) do
257
- loop do
258
- begin
259
- io = IO.popen("#{@ruby} #{@tmp.path}", 'r')
260
- cid = io.gets.to_i
261
-
262
- @cids.sync {@cids << cid} if cid > 0
263
- Process.wait cid
264
- rescue Exception => e
265
- STDERR.puts e.inspect
266
- STDERR.puts e.backtrace.join("\n")
267
- throw :die
268
- ensure
269
- io.close rescue nil
270
- @cids.sync {
271
- @cids.delete cid
272
- throw :die unless @cids.length < @spawn
273
- }
274
- end
275
-
276
- throw :die if @stop
277
- sleep @pause
278
-
279
- end # loop
280
- end # catch(:die)
281
- end # Thread.new
282
-
283
- @group.add t
284
- t
285
- end
286
-
287
- # call-seq:
288
- # child_program( config ) => tempfile
289
- #
290
- # Creates a child Ruby program based on the given _config_ hash. The
291
- # following hash keys are used:
292
- #
293
- # :argv => command and arguments passed to <code>Kernel::exec</code>
294
- # :env => environment variables for the child process
295
- # :cwd => the current working directory to use for the child process
296
- # :stdin => stdin the child process will read from
297
- # :stdout => stdout the child process will write to
298
- # :stderr => stderr the child process will write to
299
- #
300
- def child_program( config )
301
- config = Marshal.dump(config)
302
-
303
- tmp = Tempfile.new(self.class.name.downcase)
304
- tmp.write <<-PROG
305
- begin
306
- config = Marshal.load(#{config.inspect})
307
-
308
- argv = config[:argv]
309
- env = config[:env]
310
- cwd = config[:cwd]
311
- stdin = config[:stdin]
312
- stdout = config[:stdout]
313
- stderr = config[:stderr]
314
-
315
- Dir.chdir cwd if cwd
316
- env.each {|k,v| ENV[k.to_s] = v.to_s} if env
317
- rescue Exception => e
318
- STDERR.warn e
319
- abort
320
- end
321
-
322
- STDOUT.puts Process.pid
323
- STDOUT.flush
324
-
325
- STDIN.reopen stdin
326
- STDOUT.reopen stdout
327
- STDERR.reopen stderr
328
-
329
- exec *argv
330
- PROG
331
-
332
- tmp.close
333
- tmp
334
- end
335
- end # class Spawner
336
-
337
- # :startdoc:
338
-
339
- # EOF
@@ -1,28 +0,0 @@
1
-
2
- namespace :heel do
3
-
4
- desc 'Start the heel server to view website (not for Windows)'
5
- task :start do
6
- sh "heel --root #{SITE.output_dir} --port #{SITE.heel_port} --daemonize"
7
- end
8
-
9
- desc 'Stop the heel server'
10
- task :stop do
11
- sh "heel --kill"
12
- end
13
-
14
- task :autorun do
15
- heel_exe = File.join(Gem.bindir, 'heel')
16
- @heel_spawner = Spawner.new(Spawner.ruby, heel_exe, '--root', SITE.output_dir, '--port', SITE.heel_port.to_s, :pause => 86_400)
17
- @heel_spawner.start
18
- end
19
-
20
- task :autobuild => :autorun do
21
- at_exit {@heel_spawner.stop if defined? @heel_spawner and not @heel_spawner.nil?}
22
- end
23
-
24
- end
25
-
26
- task :autobuild => 'heel:autobuild'
27
-
28
- # EOF
@@ -1,40 +0,0 @@
1
- ---
2
- title: <%= title %>
3
- created_at: <%= Time.now.to_y %>
4
- author: You
5
- company: Company
6
- copyright: Creative Commons
7
- filter:
8
- - erb
9
- - textile
10
- - slides
11
- layout: presentation
12
- ---
13
- h1. Presentation Title
14
-
15
- Clever introductory text that will grab the audience's attention.
16
-
17
-
18
- h1. Title of the First Slide
19
-
20
- A little more build up before really getting into the meat of it.
21
-
22
-
23
- h1. Title of the Second Slide
24
-
25
- Finally, some code!
26
-
27
- <%% uv :lang => 'ruby', :line_numbers => false do -%>
28
- class EnglishMajor
29
- def supercilious
30
- 'behaving or looking as though one thinks one is superior to others'
31
- end
32
- end
33
- <%% end -%>
34
-
35
-
36
- h1. The Final Slide
37
-
38
- And that about sums it up!
39
-
40
- Thanks for visiting