zenweb 2.18.0 → 2.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,3 +1,13 @@
1
+ === 2.18.1 / 2009-06-23
2
+
3
+ * 1 minor enhancement:
4
+
5
+ * Switched to minitest
6
+
7
+ * 1 bug fix:
8
+
9
+ * HAHA! 1.9 fixes!
10
+
1
11
  === 2.18.0 / 2009-06-23
2
12
 
3
13
  * 1 major enhancement:
@@ -29,18 +29,18 @@ class HeaderRenderer < GenericRenderer
29
29
  if header then
30
30
  placed = false
31
31
 
32
- content.each { | line |
32
+ content.each_line { | line |
33
33
 
34
- push(line)
34
+ push(line)
35
35
 
36
- if (line =~ /<BODY/i) then
37
- push(header)
38
- placed = true
39
- end
36
+ if (line =~ /<BODY/i) then
37
+ push(header)
38
+ placed = true
39
+ end
40
40
  }
41
41
 
42
42
  unless placed then
43
- unshift(header) unless placed
43
+ unshift(header) unless placed
44
44
  end
45
45
  else
46
46
  push(content)
@@ -57,25 +57,24 @@ class RelativeRenderer < GenericRenderer
57
57
 
58
58
  def render(content)
59
59
  if $Uri_Implemented then
60
- content.each { | line |
60
+ content.each_line { | line |
61
+ line.gsub!(%r%(href=\")([^\"]+)(\")%i) { |url|
62
+ front = $1
63
+ oldurl = $2
64
+ back = $3
65
+ newurl = convert(oldurl)
61
66
 
62
- line.gsub!(%r%(href=\")([^\"]+)(\")%i) { |url|
63
- front = $1
64
- oldurl = $2
65
- back = $3
66
- newurl = convert(oldurl)
67
+ front + newurl + back
68
+ }
67
69
 
68
- front + newurl + back
69
- }
70
-
71
- push(line)
70
+ push(line)
72
71
  }
73
72
 
74
73
  return self.result
75
74
  else
76
75
  return content
77
76
  end
78
- end
77
+ end
79
78
 
80
79
  def convert(u)
81
80
 
@@ -43,12 +43,15 @@ class StupidRenderer < GenericRenderer
43
43
  if methodname then
44
44
  method = self.method(methodname)
45
45
 
46
- content.each { |line|
47
- line = method.call(line)
48
- push(line)
46
+ content.each_line { |line|
47
+ line = method.call(line)
48
+ push(line)
49
49
  }
50
50
  else
51
- @result = content.to_a
51
+ @result = []
52
+ content.each_line { |line|
53
+ @result << line
54
+ }
52
55
  end
53
56
 
54
57
 
@@ -28,28 +28,28 @@ class TocRenderer < GenericRenderer
28
28
  def render(content)
29
29
 
30
30
  toc = [
31
- "** <A NAME=\"0\">Contents:</A>\n",
32
- "\n",
33
- "+ <A HREF=\"\#0\">Contents</A>\n" ]
31
+ "** <A NAME=\"0\">Contents:</A>\n",
32
+ "\n",
33
+ "+ <A HREF=\"\#0\">Contents</A>\n" ]
34
34
  count = 1
35
35
 
36
- content.each { | line |
36
+ content.each_line { | line |
37
37
  if line =~ /^(\*\*+)\s+(.*)/ then
38
- header = $1
39
- text = $2
38
+ header = $1
39
+ text = $2
40
40
 
41
- text = text.sub(/:$/, '')
41
+ text = text.sub(/:$/, '')
42
42
 
43
- level = header.length - 2
43
+ level = header.length - 2
44
44
 
45
- toc.push(("\t" * level) + "+ <A HREF=\"\##{count}\">#{text}</A>\n")
45
+ toc.push(("\t" * level) + "+ <A HREF=\"\##{count}\">#{text}</A>\n")
46
46
 
47
- push "#{header} <A NAME=\"#{count}\">#{text}</A>\n"
48
- # " [<A HREF=\"\#0\">toc</A>]\n"
47
+ push "#{header} <A NAME=\"#{count}\">#{text}</A>\n"
48
+ # " [<A HREF=\"\#0\">toc</A>]\n"
49
49
 
50
- count += 1
50
+ count += 1
51
51
  else
52
- push line
52
+ push line
53
53
  end
54
54
  }
55
55
 
@@ -57,5 +57,4 @@ class TocRenderer < GenericRenderer
57
57
 
58
58
  return self.result
59
59
  end
60
-
61
60
  end
data/lib/ZenWeb.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/local/bin/ruby -w
2
2
 
3
- require 'ftools' # for File::* below
3
+ require 'fileutils'
4
4
 
5
5
  $TESTING = FALSE unless defined? $TESTING
6
6
 
@@ -67,7 +67,7 @@ process.
67
67
 
68
68
  class ZenWebsite
69
69
 
70
- VERSION = '2.18.0'
70
+ VERSION = '2.18.1'
71
71
 
72
72
  attr_reader :datadir, :htmldir, :sitemap
73
73
  attr_reader :documents if $TESTING
@@ -120,7 +120,7 @@ class ZenWebsite
120
120
  puts "Generating website..." unless $TESTING
121
121
  force = false
122
122
  unless (test(?d, self.htmldir)) then
123
- File::makedirs(self.htmldir)
123
+ FileUtils.mkdir_p self.htmldir
124
124
  else
125
125
  # NOTE: It would be better to know what was changed and only
126
126
  # rerender them and their previous and current immediate
@@ -349,7 +349,7 @@ class ZenDocument
349
349
  dir = File.dirname(path)
350
350
 
351
351
  unless (test(?d, dir)) then
352
- File::makedirs(dir)
352
+ FileUtils.mkdir_p dir
353
353
  end
354
354
 
355
355
  content = self.renderContent
data/test/test_zenweb.rb CHANGED
@@ -6,8 +6,9 @@ require 'ZenWeb'
6
6
  require 'ZenWeb/SitemapRenderer'
7
7
  require 'ZenWeb/TocRenderer'
8
8
  require 'ZenWeb/StupidRenderer'
9
+ require 'ZenWeb/FooterRenderer'
9
10
 
10
- require 'test/unit/testcase'
11
+ require 'minitest/autorun'
11
12
 
12
13
  # TODO: get rid of all calls to renderContent
13
14
 
@@ -74,7 +75,7 @@ else
74
75
  alias :shutupwhile :shutupwhile_18
75
76
  end
76
77
 
77
- class ZenTestCase < Test::Unit::TestCase # ZenTest SKIP
78
+ class ZenTestCase < MiniTest::Unit::TestCase # ZenTest SKIP
78
79
 
79
80
  def setup
80
81
  $stderr.puts name if $DEBUG
@@ -123,12 +124,10 @@ class TestZenWebsite < ZenTestCase
123
124
  def util_initialize(sitemap_url, data_dir, html_dir, should_fail=true)
124
125
  if (should_fail) then
125
126
  assert_raises(ArgumentError, "Must throw an ArgumentError") {
126
- ZenWebsite.new(sitemap_url, data_dir, html_dir)
127
+ ZenWebsite.new(sitemap_url, data_dir, html_dir)
127
128
  }
128
129
  else
129
- assert_nothing_raised("Must not throw any exceptions") {
130
- ZenWebsite.new(sitemap_url, data_dir, html_dir)
131
- }
130
+ ZenWebsite.new(sitemap_url, data_dir, html_dir)
132
131
  end
133
132
  end
134
133
 
@@ -136,7 +135,7 @@ class TestZenWebsite < ZenTestCase
136
135
  assert(test(?f, path),
137
136
  "File '#{path}' must exist")
138
137
  file = IO.readlines(path).join('')
139
- assert_not_nil(file.index(expected),
138
+ refute_nil(file.index(expected),
140
139
  "File '#{path}' must have correct content")
141
140
  end
142
141
 
@@ -167,7 +166,7 @@ class TestZenWebsite < ZenTestCase
167
166
  end
168
167
 
169
168
  def test_index
170
- assert_not_nil(@web.sitemap,
169
+ refute_nil(@web.sitemap,
171
170
  "index accessor must return the sitemap")
172
171
  assert_nil(@web["doesn't exist"],
173
172
  "index accessor must return nil for bad urls")
@@ -193,12 +192,12 @@ class TestZenWebsite < ZenTestCase
193
192
  documents = @web.documents
194
193
  assert_kind_of(Hash, documents)
195
194
  assert(documents.size > 0, "Documents better not be empty")
196
- assert_not_nil(documents["/SiteMap.html"], "SiteMap must exist")
195
+ refute_nil(documents["/SiteMap.html"], "SiteMap must exist")
197
196
  end
198
197
 
199
198
  def test_htmldir
200
199
  htmldir = @web.htmldir
201
- assert_not_nil(htmldir, "htmldir must be initialized")
200
+ refute_nil(htmldir, "htmldir must be initialized")
202
201
  assert_instance_of(String, htmldir)
203
202
  end
204
203
 
@@ -224,15 +223,11 @@ class TestZenDocument < ZenTestCase
224
223
  end
225
224
 
226
225
  def test_initialize_good_url
227
- assert_nothing_raised {
228
- ZenDocument.new("/Something.html", @web)
229
- }
226
+ ZenDocument.new("/Something.html", @web)
230
227
  end
231
228
 
232
229
  def test_initialize_missing_ext
233
- assert_nothing_raised {
234
- ZenDocument.new("/Something", @web)
235
- }
230
+ ZenDocument.new("/Something", @web)
236
231
  end
237
232
 
238
233
  def test_initialize_missing_slash
@@ -366,7 +361,7 @@ class TestZenDocument < ZenTestCase
366
361
  def test_parent
367
362
  parent = @doc.parent
368
363
 
369
- assert_not_nil(parent,
364
+ refute_nil(parent,
370
365
  "Parent must not be nil")
371
366
 
372
367
  assert_equal("/index.html", parent.url,
@@ -410,7 +405,7 @@ class TestZenDocument < ZenTestCase
410
405
  assert(newpages.size == oldpages.size + 1,
411
406
  "Page must grow the list of subpages")
412
407
  found = newpages.find {|p| p == url }
413
- assert_not_nil(found, "Page must be contained in new list")
408
+ refute_nil(found, "Page must be contained in new list")
414
409
  end
415
410
 
416
411
  def test_addSubpage_same
@@ -426,7 +421,7 @@ class TestZenDocument < ZenTestCase
426
421
 
427
422
  def test_content
428
423
  content = @doc.content
429
- assert_not_nil(content, "Content must not be nil")
424
+ refute_nil(content, "Content must not be nil")
430
425
  assert_instance_of(String, content)
431
426
  end
432
427
 
@@ -434,7 +429,7 @@ class TestZenDocument < ZenTestCase
434
429
  orig_content = @doc.content
435
430
  @doc.content = "blah"
436
431
  new_content = @doc.content
437
- assert_not_nil(new_content, "Content must not be nil")
432
+ refute_nil(new_content, "Content must not be nil")
438
433
  assert_instance_of(String, new_content)
439
434
  assert_equal("blah", new_content)
440
435
  end
@@ -455,13 +450,13 @@ class TestZenDocument < ZenTestCase
455
450
 
456
451
  def test_htmldir # same as TestZenWebsite#test_htmldir since it's a delegate
457
452
  htmldir = @doc.htmldir
458
- assert_not_nil(htmldir, "htmldir must be initialized")
453
+ refute_nil(htmldir, "htmldir must be initialized")
459
454
  assert_instance_of(String, htmldir)
460
455
  end
461
456
 
462
457
  def test_index
463
458
  result = @doc["renderers"]
464
- assert_not_nil(result, "renderers must exist for document")
459
+ refute_nil(result, "renderers must exist for document")
465
460
  assert_instance_of(Array, result)
466
461
  end
467
462
 
@@ -469,20 +464,20 @@ class TestZenDocument < ZenTestCase
469
464
  newrenderers = ["Something"]
470
465
  @doc["renderers"] = newrenderers
471
466
  metadata = @doc.metadata
472
- assert_not_nil(metadata, "metadata must not be nil")
467
+ refute_nil(metadata, "metadata must not be nil")
473
468
  assert_instance_of(Metadata, metadata)
474
469
  result = metadata["renderers"]
475
- assert_not_nil(result, "renderers must exist in sitemap")
470
+ refute_nil(result, "renderers must exist in sitemap")
476
471
  assert_instance_of(Array, result)
477
- assert_not_nil(result.find {|x| x == "Something"})
472
+ refute_nil(result.find {|x| x == "Something"})
478
473
  end
479
474
 
480
475
  def test_metadata
481
476
  metadata = @doc.metadata
482
- assert_not_nil(metadata, "metadata must not be nil")
477
+ refute_nil(metadata, "metadata must not be nil")
483
478
  assert_instance_of(Metadata, metadata)
484
479
  result = metadata["renderers"]
485
- assert_not_nil(result, "renderers must exist in sitemap")
480
+ refute_nil(result, "renderers must exist in sitemap")
486
481
  assert_instance_of(Array, result)
487
482
  end
488
483
 
@@ -496,21 +491,21 @@ class TestZenDocument < ZenTestCase
496
491
  # it.
497
492
 
498
493
  assert_equal('', @doc.content)
499
- assert_not_nil(@doc.metadata, 'metadata should always be non-nil')
494
+ refute_nil(@doc.metadata, 'metadata should always be non-nil')
500
495
  assert(@doc.content.length > 0, 'file should be parsed now')
501
496
  assert_equal(69, @doc['key4'])
502
497
  end
503
498
 
504
499
  def test_url
505
500
  url = @doc.url
506
- assert_not_nil(url, "Each document must know it's url")
501
+ refute_nil(url, "Each document must know it's url")
507
502
  assert_kind_of(String, url)
508
503
  assert_equal(@url, url)
509
504
  end
510
505
 
511
506
  def test_website
512
507
  website = @doc.website
513
- assert_not_nil(website, "Each document must know of it's website")
508
+ refute_nil(website, "Each document must know of it's website")
514
509
  assert_kind_of(ZenWebsite, website)
515
510
  end
516
511
  end
@@ -562,7 +557,7 @@ class TestZenSitemap < TestZenDocument
562
557
  # def test_renderContent
563
558
  # expected = "<H2>There are 6 pages in this website.</H2>\n<HR CLASS=\"thick\">\n\n<UL>\n <LI><A HREF=\"/index.html\">My Website: Subtitle</A></LI>\n <LI><A HREF=\"/SiteMap.html\">Sitemap: There are 6 pages in this website.</A></LI>\n <LI><A HREF=\"/Something.html\">Something</A></LI>\n <LI><A HREF=\"/~ryand/index.html\">Ryan's Homepage: Version 2.0</A></LI>\n <UL>\n <LI><A HREF=\"/~ryand/blah.html\">blah</A></LI>\n <LI><A HREF=\"/~ryand/stuff/index.html\">my stuff</A></LI>\n </UL>\n</UL>"
564
559
  #
565
- # assert_not_nil(@content.index(expected) > 0,
560
+ # refute_nil(@content.index(expected) > 0,
566
561
  # "Must render some form of HTML")
567
562
  # end
568
563
  end
@@ -792,7 +787,7 @@ class TestFileAttachmentRenderer < ZenRendererTest
792
787
  dir = File.dirname(path)
793
788
 
794
789
  unless (test(?d, dir)) then
795
- File::makedirs(dir)
790
+ FileUtils.mkdir_p dir
796
791
  end
797
792
  end
798
793
 
@@ -870,7 +865,7 @@ class TestHtmlTemplateRenderer < ZenRendererTest
870
865
 
871
866
  def test_render_html_and_head
872
867
  @content = @doc.renderContent
873
- assert_not_nil(@content.index("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">
868
+ refute_nil(@content.index("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">
874
869
  <HTML>
875
870
  <HEAD>
876
871
  <TITLE>Ryan\'s Homepage: Version 2.0</TITLE>
@@ -897,7 +892,7 @@ class TestHtmlTemplateRenderer < ZenRendererTest
897
892
  @content = @doc.renderContent
898
893
  expected = "\n<HR CLASS=\"thick\">\n\n<P class=\"navbar\">\n<A HREF=\"../SiteMap.html\">Sitemap</A> || <A HREF=\"../index.html\">My Website</A>\n / Ryan's Homepage</P>\n\n<P>This is my footer, jive turkey</P></BODY>\n</HTML>\n"
899
894
 
900
- assert_not_nil(@content.index(expected),
895
+ refute_nil(@content.index(expected),
901
896
  "Must render the HTML footer")
902
897
  end
903
898
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zenweb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.18.0
4
+ version: 2.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
metadata.gz.sig CHANGED
Binary file