hydeweb 0.0.1.pre5 → 0.0.2.pre

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/README.md CHANGED
@@ -18,12 +18,12 @@ To do
18
18
  -----
19
19
 
20
20
  - partials support
21
- - extensions support
22
21
  - _meta.yml
23
22
 
24
23
  Done:
25
24
 
26
25
  - hyde build
26
+ - extensions support
27
27
  - hyde gen
28
28
  - more renderers
29
29
  - less
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1.pre5
1
+ 0.0.2.pre
data/bin/hyde CHANGED
@@ -6,6 +6,11 @@ require 'optparse'
6
6
  require 'rubygems'
7
7
  require 'hyde'
8
8
 
9
+ # This will load the extensions
10
+ begin
11
+ $project = Hyde::Project.new
12
+ rescue Hyde::NoRootError; end
13
+
9
14
  if ARGV.size == 0
10
15
  Hyde::CLICommands::Help.run
11
16
  exit
@@ -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.
@@ -15,3 +15,9 @@ extensions_path: extensions
15
15
 
16
16
  # The folder where the HTML files are to be built when typing `hyde build`.
17
17
  output_path: public
18
+
19
+ # Put any custom gems here.
20
+ # gems:
21
+ # - hyde-rst
22
+ # - hyde-minify
23
+ # - hyde-zip
@@ -0,0 +1,9 @@
1
+ Extending Hyde
2
+ ==============
3
+
4
+ Adding commands
5
+ ---------------
6
+
7
+ Adding parsers
8
+ --------------
9
+
@@ -0,0 +1,2 @@
1
+ Getting started
2
+ ===============
@@ -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
- begin
23
- Hyde::Project.new
24
- rescue NoRootError
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
- root = File.expand_path(start)
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(root, config_name)
36
- ret ||= [root, config_file] if File.exists? config_file
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
- old_root = root
41
- root = File.expand_path(File.join(root, '..'))
42
- raise NoRootError if root == old_root
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.message}".gsub("\n", "\n *** ") << "\n"
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
@@ -48,7 +48,7 @@ module Hyde
48
48
  scope_object.instance_eval do
49
49
  def eval_block(src, &block)
50
50
  # This will let you eval something, and `yield` within that block.
51
- eval src
51
+ eval src, &block
52
52
  end
53
53
  extend Hyde::TemplateHelpers
54
54
  end
@@ -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
- @engine = ::Haml::Engine.new(markup, {})
7
- @engine.render scope, data, &block
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
- raise Hyde::RenderError, e.message
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
@@ -18,23 +18,23 @@ class TestAllFixtures < Test::Unit::TestCase
18
18
 
19
19
  def self.all_sites
20
20
  @@sites ||= Dir["#{@@root}/*"] \
21
- .reject { |f| not Dir.exists? f } \
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 it properly and have identical files to the control" do
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 Dir.exists? control_root
34
+ if not File.directory? control_root
35
35
  flunk "No www_control"
36
36
  else
37
- @project.files.reject { |f| not Dir.exists? f }.each do |path|
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 Dir.exists? 'bbb'
19
- assert Dir.exists? 'bbb/ccc'
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
- - 1
9
- - pre5
10
- version: 0.0.1.pre5
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-04-30 00:00:00 +08:00
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/_config.yml
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