sitebuilder 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.0.4
2
+ 2009-12-13:added spike of how to use erb and semantictext gem
3
+ 2009-12-13:added explicit runtime dependency on semantictext
4
+ == 0.0.3
5
+ 2009-12-11:updated gem development dependencies to reflect dependency on mocha
1
6
  == 0.0.2
2
7
  2009-12-06:fixed warning: "already initialized constant"
3
8
 
data/README.rdoc CHANGED
@@ -11,9 +11,10 @@ a subdirectory of a destination directory.
11
11
  * No action should change the source directory or its contents.
12
12
 
13
13
  === How to use it
14
- * Just a core object model & tests right now... needs to be completed.
15
14
  * Install with:
16
15
  gem install sitebuilder
16
+ * Basic operation can be seen in demo.rdoc
17
+ * Just a core object model & tests right now... needs to be completed.
17
18
  * *rdoc* http://www.greenbarsoft.co.uk/software/sitebuilder/rdoc/
18
19
  * *source* http://github.com/dafydd/sitebuilder
19
20
  * To build me, set an environment variable called *SANDBOX* to the directory above your sitebuilder directory. The tests need this pathname to access test data.
data/TODO.rdoc CHANGED
@@ -1,6 +1,7 @@
1
1
  == todo
2
2
  * make template action - with erb and semantictext
3
3
  * merge a text formatter into template action
4
+ * work out how to map file paths to URLs
4
5
  * make copy action
5
6
  * make index action
6
7
  * work out how to handle cross references
@@ -0,0 +1,42 @@
1
+ require 'sitebuilder'
2
+ require 'rubygems'
3
+ require 'semantictext'
4
+ require 'erb'
5
+
6
+ class Document
7
+ attr_reader :content
8
+ def initialize(c)
9
+ @content=c
10
+ end
11
+ end
12
+
13
+ def mapit(src, tmpl, dst)
14
+ template = ''
15
+ File.open(tmpl) do |f|
16
+ f.readlines.each {|l| template += l }
17
+ end
18
+ content = ''
19
+ File.open(src) do |c|
20
+ c.readlines.each {|l| content += l }
21
+ end
22
+ e = ERB.new template
23
+ document = Document.new(content)
24
+ File.open(dst,'w') do |f|
25
+ f.puts e.result(binding)
26
+ end
27
+ end
28
+ templatepath = File.join(ENV['SANDBOX'],'sitebuilder','examples','homepage','template.rhtml')
29
+ swapout = File.join(ENV['SANDBOX'],'sitebuilder','examples','homepage','source')
30
+ replace = File.join(ENV['SANDBOX'],'sitebuilder','examples','homepage','dest')
31
+
32
+ s = SiteBuilder::SiteGenerator.new(swapout,replace)
33
+ s.add_action('.art') do |s,r|
34
+ mapit(s.path,templatepath,File.join(r,s.extnless+'.html'))
35
+ end
36
+
37
+ s.add_action('.idx') {|s,r| `cp #{s.path} #{r}`; puts "index template #{s.path}\n\t\t #{r}"}
38
+ s.add_action('.png') {|s,r| `cp #{s.path} #{r}`; puts "png copy #{s.path}\n\t\t #{r}"}
39
+ s.add_action('.css') {|s,r| `cp #{s.path} #{r}`; puts "css copy #{s.path}\n\t\t #{r}"}
40
+
41
+ SiteBuilder::DirEntry.new(swapout).traverse(s)
42
+
data/doc/demo.rdoc ADDED
@@ -0,0 +1,66 @@
1
+ == Sample output
2
+
3
+ If using sitebuilder from a gem, remember to "require 'rubygems'"...
4
+
5
+ demo.script(main):001:0> require 'sitebuilder'
6
+ => true
7
+ demo.script(main):002:0> require 'rubygems'
8
+ => true
9
+ demo.script(main):003:0> require 'erb'
10
+ => true
11
+ demo.script(main):004:0>
12
+ demo.script(main):005:0* class Document
13
+ demo.script(main):006:1> attr_reader :content
14
+ demo.script(main):007:1> def initialize(c)
15
+ demo.script(main):008:2> @content=c
16
+ demo.script(main):009:2> end
17
+ demo.script(main):010:1> end
18
+ => nil
19
+ demo.script(main):011:0>
20
+ demo.script(main):012:0* def mapit(src, tmpl, dst)
21
+ demo.script(main):013:1> template = ''
22
+ demo.script(main):014:1> File.open(tmpl) do |f|
23
+ demo.script(main):015:2* f.readlines.each {|l| template += l }
24
+ demo.script(main):016:2> end
25
+ demo.script(main):017:1> content = ''
26
+ demo.script(main):018:1> File.open(src) do |c|
27
+ demo.script(main):019:2* c.readlines.each {|l| content += l }
28
+ demo.script(main):020:2> end
29
+ demo.script(main):021:1> e = ERB.new template
30
+ demo.script(main):022:1> document = Document.new(content)
31
+ demo.script(main):023:1> File.open(dst,'w') do |f|
32
+ demo.script(main):024:2* f.puts e.result(binding)
33
+ demo.script(main):025:2> end
34
+ demo.script(main):026:1> end
35
+ => nil
36
+ demo.script(main):027:0> templatepath = File.join(ENV['SANDBOX'],'sitebuilder','examples','homepage','template.rhtml')
37
+ => "/Users/daf/macbook/workspace/sitebuilder/examples/homepage/template.rhtml"
38
+ demo.script(main):028:0> swapout = File.join(ENV['SANDBOX'],'sitebuilder','examples','homepage','source')
39
+ => "/Users/daf/macbook/workspace/sitebuilder/examples/homepage/source"
40
+ demo.script(main):029:0> replace = File.join(ENV['SANDBOX'],'sitebuilder','examples','homepage','dest')
41
+ => "/Users/daf/macbook/workspace/sitebuilder/examples/homepage/dest"
42
+ demo.script(main):030:0>
43
+ demo.script(main):031:0* s = SiteBuilder::SiteGenerator.new(swapout,replace)
44
+ => #<SiteBuilder::SiteGenerator:0x6bf300 @actions={}, @replace="/Users/daf/macbook/workspace/sitebuilder/examples/homepage/dest", @swapout="/Users/daf/macbook/workspace/sitebuilder/examples/homepage/source">
45
+ demo.script(main):032:0> s.add_action('.art') do |s,r|
46
+ demo.script(main):033:1* mapit(s.path,templatepath,File.join(r,s.extnless+'.html'))
47
+ demo.script(main):034:1> end
48
+ => #<Proc:0x006a8aec@/Users/daf/macbook/workspace/sitebuilder/doc/demo.script:32>
49
+ demo.script(main):035:0>
50
+ demo.script(main):036:0* s.add_action('.idx') {|s,r| `cp #{s.path} #{r}`; puts "index template #{s.path}\n\t\t #{r}"}
51
+ => #<Proc:0x006908fc@/Users/daf/macbook/workspace/sitebuilder/doc/demo.script:36>
52
+ demo.script(main):037:0> s.add_action('.png') {|s,r| `cp #{s.path} #{r}`; puts "png copy #{s.path}\n\t\t #{r}"}
53
+ => #<Proc:0x0067a174@/Users/daf/macbook/workspace/sitebuilder/doc/demo.script:37>
54
+ demo.script(main):038:0> s.add_action('.css') {|s,r| `cp #{s.path} #{r}`; puts "css copy #{s.path}\n\t\t #{r}"}
55
+ => #<Proc:0x0064aca8@/Users/daf/macbook/workspace/sitebuilder/doc/demo.script:38>
56
+ demo.script(main):039:0>
57
+ demo.script(main):040:0* SiteBuilder::DirEntry.new(swapout).traverse(s)
58
+ css copy /Users/daf/macbook/workspace/sitebuilder/examples/homepage/source/homepage.css
59
+ /Users/daf/macbook/workspace/sitebuilder/examples/homepage/dest
60
+ => #<Dir:0x6403d4>
61
+ demo.script(main):041:0>
62
+ demo.script(main):042:0* demo.script(main):042:0>
63
+
64
+
65
+ Sitebuilder 0.0.3
66
+
data/doc/demo.script ADDED
@@ -0,0 +1,41 @@
1
+ require 'sitebuilder'
2
+ require 'rubygems'
3
+ require 'erb'
4
+
5
+ class Document
6
+ attr_reader :content
7
+ def initialize(c)
8
+ @content=c
9
+ end
10
+ end
11
+
12
+ def mapit(src, tmpl, dst)
13
+ template = ''
14
+ File.open(tmpl) do |f|
15
+ f.readlines.each {|l| template += l }
16
+ end
17
+ content = ''
18
+ File.open(src) do |c|
19
+ c.readlines.each {|l| content += l }
20
+ end
21
+ e = ERB.new template
22
+ document = Document.new(content)
23
+ File.open(dst,'w') do |f|
24
+ f.puts e.result(binding)
25
+ end
26
+ end
27
+ templatepath = File.join(ENV['SANDBOX'],'sitebuilder','examples','homepage','template.rhtml')
28
+ swapout = File.join(ENV['SANDBOX'],'sitebuilder','examples','homepage','source')
29
+ replace = File.join(ENV['SANDBOX'],'sitebuilder','examples','homepage','dest')
30
+
31
+ s = SiteBuilder::SiteGenerator.new(swapout,replace)
32
+ s.add_action('.art') do |s,r|
33
+ mapit(s.path,templatepath,File.join(r,s.extnless+'.html'))
34
+ end
35
+
36
+ s.add_action('.idx') {|s,r| `cp #{s.path} #{r}`; puts "index template #{s.path}\n\t\t #{r}"}
37
+ s.add_action('.png') {|s,r| `cp #{s.path} #{r}`; puts "png copy #{s.path}\n\t\t #{r}"}
38
+ s.add_action('.css') {|s,r| `cp #{s.path} #{r}`; puts "css copy #{s.path}\n\t\t #{r}"}
39
+
40
+ SiteBuilder::DirEntry.new(swapout).traverse(s)
41
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sitebuilder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dafydd Rees
@@ -9,9 +9,19 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-11 00:00:00 +00:00
12
+ date: 2009-12-13 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: semantictext
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.2.2
24
+ version:
15
25
  - !ruby/object:Gem::Dependency
16
26
  name: mocha
17
27
  type: :development
@@ -32,11 +42,13 @@ extra_rdoc_files:
32
42
  - CHANGELOG.rdoc
33
43
  - COPYING
34
44
  - README.rdoc
45
+ - doc/demo.rdoc
35
46
  - TODO.rdoc
36
47
  files:
48
+ - doc/complex.script
49
+ - doc/demo.script
37
50
  - lib/sitebuilder/array.rb
38
51
  - lib/sitebuilder/filesystem.rb
39
- - lib/sitebuilder/gen.rb
40
52
  - lib/sitebuilder/sitegenerator.rb
41
53
  - lib/sitebuilder/string.rb
42
54
  - lib/sitebuilder.rb
@@ -47,6 +59,7 @@ files:
47
59
  - CHANGELOG.rdoc
48
60
  - COPYING
49
61
  - README.rdoc
62
+ - doc/demo.rdoc
50
63
  - TODO.rdoc
51
64
  has_rdoc: true
52
65
  homepage: http://www.greenbarsoft.co.uk/software/sitebuilder
@@ -1,16 +0,0 @@
1
- #!/usr/bin/ruby
2
- require 'sitebuilder/sitegenerator'
3
- module SiteBuilder
4
-
5
- swapout = File.join(ENV['SANDBOX'],'sitebuilder','examples','homepage','source')
6
- replace = File.join(ENV['SANDBOX'],'sitebuilder','examples','homepage','dest')
7
-
8
- s = SiteGenerator.new(swapout,replace)
9
- s.add_action('.art') {|s,r| `cp #{s.path} #{r}`; puts "article template #{s.path}\n\t\t #{r}"}
10
- s.add_action('.idx') {|s,r| `cp #{s.path} #{r}`; puts "index template #{s.path}\n\t\t #{r}"}
11
- s.add_action('.png') {|s,r| `cp #{s.path} #{r}`; puts "png copy #{s.path}\n\t\t #{r}"}
12
- s.add_action('.css') {|s,r| `cp #{s.path} #{r}`; puts "css copy #{s.path}\n\t\t #{r}"}
13
-
14
- DirEntry.new(swapout).traverse(s)
15
-
16
- end