hydeweb 0.0.1.pre5 → 0.0.2.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/VERSION +1 -1
- data/bin/hyde +5 -0
- data/data/new_site/README.md +1 -1
- data/data/new_site/{_config.yml → hyde.conf} +6 -0
- data/docs/ExtendingHyde.md +9 -0
- data/docs/GettingStarted.md +2 -0
- data/lib/hyde/clicommand.rb +5 -4
- data/lib/hyde/project.rb +31 -8
- data/lib/hyde/renderer.rb +1 -1
- data/lib/hyde/renderers.rb +10 -4
- data/lib/hyde.rb +17 -1
- data/test/test_all_fixtures.rb +4 -4
- data/test/test_utils.rb +2 -2
- metadata +7 -5
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2.pre
|
data/bin/hyde
CHANGED
data/data/new_site/README.md
CHANGED
@@ -8,7 +8,7 @@ Instructions
|
|
8
8
|
------------
|
9
9
|
|
10
10
|
1. Make sure Ruby (>= v1.8) is installed.
|
11
|
-
2. Install the hydeweb gem: `gem install hydeweb`
|
11
|
+
2. Install the hydeweb gem: `gem install hydeweb --pre`
|
12
12
|
3. Build the site HTML files by typing: `hyde build`
|
13
13
|
|
14
14
|
You may also type `hyde serve` to serve the files in a local web server.
|
data/lib/hyde/clicommand.rb
CHANGED
@@ -11,6 +11,7 @@ module Hyde
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.help
|
14
|
+
log "Usage: hyde #{self.to_s.downcase.split(':')[-1]}"
|
14
15
|
log "No help for this command."
|
15
16
|
end
|
16
17
|
|
@@ -19,12 +20,12 @@ module Hyde
|
|
19
20
|
end
|
20
21
|
|
21
22
|
def self.project
|
22
|
-
|
23
|
-
Hyde
|
24
|
-
|
25
|
-
ostream << "No Hyde config file found. (looking for: hyde.conf, _config.yml)\n"
|
23
|
+
if $project.nil?
|
24
|
+
log "Error: Hyde config file not found. (looking for: hyde.conf, _config.yml)"
|
25
|
+
log "Run this command in a Hyde project directory.\nTo start a new Hyde project, type `hyde create <name>`"
|
26
26
|
exit
|
27
27
|
end
|
28
|
+
$project
|
28
29
|
end
|
29
30
|
|
30
31
|
def self.desc(str)
|
data/lib/hyde/project.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
module Hyde
|
2
|
+
# TODO: This class is growing... time to refactor
|
2
3
|
class Project
|
3
4
|
include Hyde::Utils
|
4
5
|
|
@@ -24,26 +25,47 @@ module Hyde
|
|
24
25
|
@config = OStruct.new defaults
|
25
26
|
@root, @config_file = find_root_from root
|
26
27
|
@config.merge! YAML::load_file(@config_file) if File.exists? @config_file
|
28
|
+
load_extensions
|
27
29
|
end
|
28
30
|
|
29
31
|
def find_root_from(start)
|
30
|
-
|
32
|
+
check = File.expand_path(start)
|
31
33
|
ret = nil
|
32
34
|
while ret.nil?
|
33
35
|
# See if any of these files exist
|
34
36
|
['_config.yml', 'hyde.conf'].each do |config_name|
|
35
|
-
config_file = File.join(
|
36
|
-
ret ||= [
|
37
|
+
config_file = File.join(check, config_name)
|
38
|
+
ret ||= [check, config_file] if File.exists? config_file
|
37
39
|
end
|
38
40
|
|
39
41
|
# Traverse back (die if we reach the root)
|
40
|
-
|
41
|
-
|
42
|
-
raise NoRootError if
|
42
|
+
old_check = check
|
43
|
+
check = File.expand_path(File.join(check, '..'))
|
44
|
+
raise NoRootError if check == old_check
|
43
45
|
end
|
44
46
|
ret
|
45
47
|
end
|
46
48
|
|
49
|
+
def load_extensions
|
50
|
+
@config.gems.each do |gem|
|
51
|
+
require gem
|
52
|
+
end
|
53
|
+
|
54
|
+
ext_roots = Dir[root :extensions, '*'].select { |d| File.directory? d }
|
55
|
+
ext_roots.each do |dir|
|
56
|
+
ext = File.basename(dir)
|
57
|
+
|
58
|
+
# Try extensions/name/name.rb
|
59
|
+
# Try extensions/name/lib/name.rb
|
60
|
+
ext_files = [
|
61
|
+
File.join(dir, "#{ext}.rb"),
|
62
|
+
File.join(dir, 'lib', "#{ext}.rb")
|
63
|
+
]
|
64
|
+
ext_files.reject! { |f| not File.exists? f }
|
65
|
+
require ext_files[0] if ext_files[0]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
47
69
|
def method_missing(meth, *args, &blk)
|
48
70
|
raise NoMethodError, "No method `#{meth}`" unless @config.include?(meth)
|
49
71
|
@config.send meth
|
@@ -82,7 +104,7 @@ module Hyde
|
|
82
104
|
mfile << rendered
|
83
105
|
mfile.close
|
84
106
|
rescue RenderError => e
|
85
|
-
ostream << " *** Error: #{e.
|
107
|
+
ostream << " *** Error: #{e.to_s}".gsub("\n", "\n *** ") << "\n"
|
86
108
|
end
|
87
109
|
end
|
88
110
|
rescue NoGemError => e
|
@@ -131,7 +153,8 @@ module Hyde
|
|
131
153
|
{ 'layouts_path' => 'layouts',
|
132
154
|
'extensions_path' => 'extensions',
|
133
155
|
'site_path' => 'site',
|
134
|
-
'output_path' => 'public'
|
156
|
+
'output_path' => 'public',
|
157
|
+
'gems' => []
|
135
158
|
}
|
136
159
|
end
|
137
160
|
|
data/lib/hyde/renderer.rb
CHANGED
data/lib/hyde/renderers.rb
CHANGED
@@ -3,8 +3,12 @@ module Hyde
|
|
3
3
|
class Haml < Renderer::Parsable
|
4
4
|
def evaluate(scope, data={}, &block)
|
5
5
|
require_lib 'haml'
|
6
|
-
|
7
|
-
|
6
|
+
begin
|
7
|
+
@engine = ::Haml::Engine.new(markup, {})
|
8
|
+
@engine.render scope, data, &block
|
9
|
+
rescue ::Haml::SyntaxError => e
|
10
|
+
raise Hyde::RenderError.new(e.message, :line => e.line)
|
11
|
+
end
|
8
12
|
end
|
9
13
|
end
|
10
14
|
|
@@ -12,7 +16,6 @@ module Hyde
|
|
12
16
|
def evaluate(scope, data={}, &block)
|
13
17
|
require_lib 'erb'
|
14
18
|
@engine = ::ERB.new markup
|
15
|
-
# So that we can yield!
|
16
19
|
eval("self", scope).eval_block @engine.src, &block
|
17
20
|
end
|
18
21
|
end
|
@@ -24,7 +27,10 @@ module Hyde
|
|
24
27
|
@engine = ::Less::Engine.new(File.open(filename))
|
25
28
|
@engine.to_css
|
26
29
|
rescue ::Less::SyntaxError => e
|
27
|
-
|
30
|
+
matches = /^on line ([0-9]+): (.*)$/.match(e.message)
|
31
|
+
line = matches[1]
|
32
|
+
message = matches[2]
|
33
|
+
raise Hyde::RenderError.new(message, :line => line)
|
28
34
|
end
|
29
35
|
end
|
30
36
|
end
|
data/lib/hyde.rb
CHANGED
@@ -15,8 +15,24 @@ module Hyde
|
|
15
15
|
autoload :TemplateHelpers,"#{prefix}/hyde/template_helpers"
|
16
16
|
|
17
17
|
Error = Class.new(::StandardError)
|
18
|
-
RenderError = Class.new(Error)
|
19
18
|
NoGemError = Class.new(Error)
|
20
19
|
NotFound = Class.new(Error)
|
21
20
|
NoRootError = Class.new(Error)
|
21
|
+
|
22
|
+
class RenderError < Error
|
23
|
+
attr_accessor :message
|
24
|
+
attr_accessor :line
|
25
|
+
|
26
|
+
def initialize(msg, *args)
|
27
|
+
@message = msg
|
28
|
+
a = args.inject({}) { |a, i| a.merge! i if i.is_a? Hash; a }
|
29
|
+
@line = a[:line] if a[:line]
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_s
|
33
|
+
@line ?
|
34
|
+
"line #{@line}: #{@message}" :
|
35
|
+
"#{@message}"
|
36
|
+
end
|
37
|
+
end
|
22
38
|
end
|
data/test/test_all_fixtures.rb
CHANGED
@@ -18,23 +18,23 @@ class TestAllFixtures < Test::Unit::TestCase
|
|
18
18
|
|
19
19
|
def self.all_sites
|
20
20
|
@@sites ||= Dir["#{@@root}/*"] \
|
21
|
-
.
|
21
|
+
.select { |f| File.directory? f } \
|
22
22
|
.map { |f| File.basename(f) }
|
23
23
|
end
|
24
24
|
|
25
25
|
all_sites.each do |site|
|
26
26
|
describe "Test `#{site}`" do
|
27
|
-
should "Build
|
27
|
+
should "Build #{site} properly and have identical files to the control" do
|
28
28
|
@project = Hyde::Project.new File.join(@@root, site)
|
29
29
|
@project.build
|
30
30
|
|
31
31
|
unknown_root = @project.root :site
|
32
32
|
control_root = @project.root 'www_control'
|
33
33
|
|
34
|
-
if not
|
34
|
+
if not File.directory? control_root
|
35
35
|
flunk "No www_control"
|
36
36
|
else
|
37
|
-
@project.files.
|
37
|
+
@project.files.select { |f| File.directory? f }.each do |path|
|
38
38
|
unknown = File.open(File.join(unknown_root, path)).read
|
39
39
|
control = File.open(File.join(control_root, path)).read
|
40
40
|
|
data/test/test_utils.rb
CHANGED
@@ -15,8 +15,8 @@ class TestUtils < Test::Unit::TestCase
|
|
15
15
|
|
16
16
|
should "force_file_open" do
|
17
17
|
f = force_file_open File.join(@pwd, 'bbb/ccc/test.txt')
|
18
|
-
assert
|
19
|
-
assert
|
18
|
+
assert File.directory? 'bbb'
|
19
|
+
assert File.directory? 'bbb/ccc'
|
20
20
|
assert File.exists? 'bbb/ccc/test.txt'
|
21
21
|
end
|
22
22
|
end
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
- pre
|
10
|
+
version: 0.0.2.pre
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Rico Sta. Cruz
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-
|
19
|
+
date: 2010-05-01 00:00:00 +08:00
|
20
20
|
default_executable: hyde
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -80,9 +80,11 @@ files:
|
|
80
80
|
- bin/hyde
|
81
81
|
- data/new_site/.gitignore
|
82
82
|
- data/new_site/README.md
|
83
|
-
- data/new_site/
|
83
|
+
- data/new_site/hyde.conf
|
84
84
|
- data/new_site/layouts/default.haml
|
85
85
|
- data/new_site/site/index.html.haml
|
86
|
+
- docs/ExtendingHyde.md
|
87
|
+
- docs/GettingStarted.md
|
86
88
|
- lib/hyde.rb
|
87
89
|
- lib/hyde/clicommand.rb
|
88
90
|
- lib/hyde/clicommands.rb
|