bonsai 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/benchmark/associations.rb +1 -1
- data/bonsai.gemspec +3 -2
- data/lib/bonsai.rb +4 -13
- data/lib/bonsai/exporter.rb +5 -10
- data/lib/bonsai/page.rb +7 -8
- data/lib/bonsai/sitemap.rb +8 -0
- data/lib/bonsai/template.rb +7 -7
- data/spec/bonsai/exporter_spec.rb +1 -1
- data/spec/bonsai/generate_spec.rb +2 -2
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +1 -1
- metadata +3 -3
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.5
|
data/benchmark/associations.rb
CHANGED
@@ -2,7 +2,7 @@ require 'lib/bonsai'
|
|
2
2
|
require 'benchmark'
|
3
3
|
|
4
4
|
Bonsai.root_dir = File.dirname(__FILE__) + "/../spec/support"
|
5
|
-
Bonsai.
|
5
|
+
Bonsai.config = { :enable_logging => false }
|
6
6
|
|
7
7
|
page = Bonsai::Page.find("about-us/history")
|
8
8
|
|
data/bonsai.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bonsai}
|
8
|
-
s.version = "1.1.
|
8
|
+
s.version = "1.1.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ben Schwarz"]
|
12
|
-
s.date = %q{2010-02-
|
12
|
+
s.date = %q{2010-02-15}
|
13
13
|
s.default_executable = %q{bonsai}
|
14
14
|
s.description = %q{A static site generator that uses the best toolset available}
|
15
15
|
s.email = %q{ben.schwarz@gmail.com}
|
@@ -114,6 +114,7 @@ Gem::Specification.new do |s|
|
|
114
114
|
"spec/support/templates/partials/inserted.mustache",
|
115
115
|
"vendor/yui-compressor/yuicompressor-2.4.2.jar"
|
116
116
|
]
|
117
|
+
s.has_rdoc = false
|
117
118
|
s.homepage = %q{http://github.com/benschwarz/bonsai}
|
118
119
|
s.post_install_message = %q{
|
119
120
|
|
data/lib/bonsai.rb
CHANGED
@@ -5,13 +5,8 @@ require 'logger'
|
|
5
5
|
$LOAD_PATH << "#{File.dirname(__FILE__)}/bonsai"
|
6
6
|
|
7
7
|
module Bonsai
|
8
|
-
@@root_dir = nil
|
9
|
-
@@config = { :enable_logging => true }
|
10
|
-
|
11
8
|
class << self
|
12
|
-
|
13
|
-
@@root_dir || Dir.pwd
|
14
|
-
end
|
9
|
+
attr_accessor :root_dir, :config
|
15
10
|
|
16
11
|
def root_dir=(path)
|
17
12
|
unless is_a_bonsai?(path)
|
@@ -19,7 +14,7 @@ module Bonsai
|
|
19
14
|
exit 0
|
20
15
|
end
|
21
16
|
|
22
|
-
|
17
|
+
@root_dir = path
|
23
18
|
|
24
19
|
Exporter.path = "#{path}/output"
|
25
20
|
Page.path = "#{path}/content"
|
@@ -27,15 +22,11 @@ module Bonsai
|
|
27
22
|
end
|
28
23
|
|
29
24
|
def log(message)
|
30
|
-
puts message if
|
25
|
+
puts message if config[:enable_logging]
|
31
26
|
end
|
32
27
|
|
33
28
|
def config
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
def configure(&block)
|
38
|
-
yield @@config
|
29
|
+
@config || { :enable_logging => true }
|
39
30
|
end
|
40
31
|
|
41
32
|
def version
|
data/lib/bonsai/exporter.rb
CHANGED
@@ -3,11 +3,9 @@ require 'less'
|
|
3
3
|
|
4
4
|
module Bonsai
|
5
5
|
class Exporter
|
6
|
-
@@path = "output"
|
7
|
-
|
8
6
|
class << self
|
9
|
-
|
10
|
-
def path
|
7
|
+
attr_accessor :path
|
8
|
+
def path; @path || "output"; end
|
11
9
|
|
12
10
|
def process!
|
13
11
|
setup
|
@@ -66,15 +64,12 @@ module Bonsai
|
|
66
64
|
|
67
65
|
readme = <<-README
|
68
66
|
This site was built using Bonsai (http://tinytree.info)
|
69
|
-
|
70
|
-
To make changes to the site using Bonsai you will require the original source files.
|
71
|
-
Please contact the author of your site for details.
|
72
67
|
|
73
|
-
|
74
|
-
|
68
|
+
To make changes to the site you will require the original source files.
|
69
|
+
Please contact the author of your site for details.
|
75
70
|
README
|
76
71
|
|
77
|
-
File.open("#{path}/ABOUT-THIS-SITE
|
72
|
+
File.open("#{path}/ABOUT-THIS-SITE", "w") {|file| file.write(readme) }
|
78
73
|
end
|
79
74
|
|
80
75
|
def copy_assets
|
data/lib/bonsai/page.rb
CHANGED
@@ -11,19 +11,18 @@ end
|
|
11
11
|
|
12
12
|
module Bonsai
|
13
13
|
class Page
|
14
|
-
class NotFound < StandardError; end;
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
def
|
19
|
-
def path=(path); @@path = path; end
|
14
|
+
class NotFound < StandardError; end;
|
15
|
+
class << self
|
16
|
+
attr_accessor :path, :pages
|
17
|
+
|
18
|
+
def pages; @pages || {} end
|
20
19
|
|
21
20
|
def all(dir_path = path, pattern = "*/**")
|
22
21
|
Dir["#{dir_path}/#{pattern}/*.yml"].map {|p| Page.new p }
|
23
22
|
end
|
24
23
|
|
25
24
|
def find(permalink)
|
26
|
-
|
25
|
+
pages[permalink] ||= find!(permalink)
|
27
26
|
end
|
28
27
|
|
29
28
|
private
|
@@ -202,7 +201,7 @@ module Bonsai
|
|
202
201
|
end
|
203
202
|
|
204
203
|
def web_path(path)
|
205
|
-
path.gsub(
|
204
|
+
path.gsub(self.class.path, '').gsub(/\/\d+\./, '/')
|
206
205
|
end
|
207
206
|
end
|
208
207
|
end
|
data/lib/bonsai/sitemap.rb
CHANGED
@@ -25,6 +25,14 @@ module Bonsai
|
|
25
25
|
end
|
26
26
|
|
27
27
|
template.render
|
28
|
+
rescue NoMethodError
|
29
|
+
Bonsai.log <<-HELP
|
30
|
+
! Can't write sitemap. Check that `site.yml` looks something like this:
|
31
|
+
|
32
|
+
#{File.read(File.dirname(__FILE__) + "/templates/site.yml")}
|
33
|
+
HELP
|
34
|
+
|
35
|
+
exit
|
28
36
|
end
|
29
37
|
end
|
30
38
|
end
|
data/lib/bonsai/template.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
module Bonsai
|
2
|
-
class Template
|
3
|
-
@@path = "templates"
|
4
|
-
|
2
|
+
class Template
|
5
3
|
class NotFound < StandardError; end
|
6
4
|
|
5
|
+
# Class methods
|
7
6
|
class << self
|
8
|
-
|
9
|
-
|
10
|
-
def path
|
11
|
-
|
7
|
+
attr_accessor :path
|
8
|
+
|
9
|
+
def path
|
10
|
+
@path || "templates"
|
12
11
|
end
|
13
12
|
|
14
13
|
def find(name)
|
@@ -22,6 +21,7 @@ module Bonsai
|
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
24
|
+
# Instance methods
|
25
25
|
attr_reader :path
|
26
26
|
|
27
27
|
def initialize(path)
|
@@ -120,7 +120,7 @@ describe Bonsai::Exporter do
|
|
120
120
|
end
|
121
121
|
|
122
122
|
it "should write a readme file to explain how the site was generated" do
|
123
|
-
File.exists?("#{Bonsai::Exporter.path}/ABOUT-THIS-SITE
|
123
|
+
File.exists?("#{Bonsai::Exporter.path}/ABOUT-THIS-SITE").should be_true
|
124
124
|
end
|
125
125
|
|
126
126
|
describe "asset compression" do
|
@@ -37,8 +37,8 @@ describe Bonsai::Generate do
|
|
37
37
|
File.exists?("#{@path}/site.yml").should be_true
|
38
38
|
end
|
39
39
|
|
40
|
-
it "should generate
|
41
|
-
Dir.glob("#{@path}/**/*", File::FNM_DOTMATCH).select{|f| File.file?(f) }.size.should ==
|
40
|
+
it "should generate 21 files" do
|
41
|
+
Dir.glob("#{@path}/**/*", File::FNM_DOTMATCH).select{|f| File.file?(f) }.size.should == 21
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should generate 15 directories" do
|
data/spec/spec.opts
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -5,7 +5,7 @@ require 'spec'
|
|
5
5
|
require 'spec/autorun'
|
6
6
|
|
7
7
|
Spec::Runner.configure do |config|
|
8
|
-
Bonsai.
|
8
|
+
Bonsai.config = { :enable_logging => false }
|
9
9
|
|
10
10
|
BONSAI_PATH = "#{File.dirname(__FILE__)}/support" unless defined? BONSAI_PATH
|
11
11
|
Bonsai.root_dir = BONSAI_PATH
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bonsai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Schwarz
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-15 00:00:00 +11:00
|
13
13
|
default_executable: bonsai
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -226,7 +226,7 @@ files:
|
|
226
226
|
- spec/support/templates/demo-template.mustache
|
227
227
|
- spec/support/templates/partials/inserted.mustache
|
228
228
|
- vendor/yui-compressor/yuicompressor-2.4.2.jar
|
229
|
-
has_rdoc:
|
229
|
+
has_rdoc: false
|
230
230
|
homepage: http://github.com/benschwarz/bonsai
|
231
231
|
licenses: []
|
232
232
|
|