hydeweb 0.1.14 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.md CHANGED
@@ -1,3 +1,15 @@
1
+ v0.2.2 - Jun 16, 2011
2
+ ---------------------
3
+
4
+ ### Added:
5
+ * **Built-in Compass support.**
6
+ * **Enable Sass, SCSS, Haml, Textile and Markdown by default.**
7
+ * Extensions from `_extensions/*rb` will now be loaded.
8
+
9
+ ### Changed:
10
+ * The default `hyde.conf` now comments out the default stuff you don't need to set.
11
+ * Update dependencies to Cuba 2.0, and Hashie 1.0.
12
+
1
13
  v0.1.14 - Jun 04, 2011
2
14
  ----------------------
3
15
 
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
- Hyde
2
- ====
1
+ # [Hyde](http://sinefunc.com/hyde?)
2
+ #### Hyde is a website preprocessor.
3
3
 
4
- Hyde is a website preprocessor.
4
+ http://sinefunc.com/hyde/
5
5
 
6
- http://labs.sinefunc.com/hyde/
6
+ - __HAML, Sass, Compass and more:__ Hyde will let you write in HAML, SCSS,
7
+ Sass, and more by default. It also comes preloaded with
8
+ [Compass](http://compass-style.org).
7
9
 
8
10
  - __Layouts and Partials:__ Hyde lets you define your site's header and footer
9
11
  layouts in a separate file, and even separate snippets of your site
@@ -52,3 +54,22 @@ Here's how you can get started:
52
54
  hyde start # <= Serve via a local web server
53
55
 
54
56
 
57
+ Testing
58
+ -------
59
+
60
+ Run tests:
61
+
62
+ rake test
63
+
64
+ To try it in a different Ruby version, you can use RVM + Bundler to make
65
+ things easier. For instance:
66
+
67
+ rvm use 1.8.7@hyde --create # Create a gemset
68
+ bundle install # Install the needed gems on that set
69
+ rake test
70
+
71
+ Authors
72
+ -------
73
+
74
+ Authored and maintained by Rico Sta. Cruz and Sinefunc, Inc.
75
+ See [sinefunc.com](http://sinefunc.com) for more about our work!
@@ -1,6 +1,6 @@
1
1
  # This is a Hyde site.
2
- # Install the `hydeweb` Ruby gem and type `hyde` for help.
3
- hyde_requirement: 0.1
2
+ # Install Hyde (`gem install hydeweb`) and type `hyde` for help.
3
+ hyde_requirement: 0.2
4
4
 
5
5
  # The folder where the site's source files are kept.
6
6
  site_path: .
@@ -11,25 +11,24 @@ layouts_path: _layouts
11
11
  extensions_path: _extensions
12
12
  partials_path: .
13
13
 
14
- # Files to be excluded from processing
15
- ignore:
16
- - **/*~
17
- - README*
18
- - config.ru
19
- - **/.*
20
- - **/_*
21
-
22
- # Optional options for layout engines
23
- tilt_options:
24
- haml:
25
- :escape_html: true
26
- scss:
27
- :load_paths: [ 'css' ]
28
- :style: :compact
29
- :line_numbers: true
30
-
31
- # Optional settings for doing a build
32
- tilt_build_options:
33
- scss:
34
- :style: :compressed
35
- :line_numbers: false
14
+ ## Files to be excluded from processing.
15
+
16
+ # ignore:
17
+ # - **/*~
18
+
19
+ ## Optional options for layout engines.
20
+
21
+ # tilt_options:
22
+ # haml:
23
+ # escape_html: true
24
+ # scss:
25
+ # load_paths: [ 'css' ]
26
+ # style: :compact
27
+ # line_numbers: true
28
+
29
+ ## Optional settings for doing a build.
30
+
31
+ # tilt_build_options:
32
+ # scss:
33
+ # style: :compressed
34
+ # line_numbers: false
@@ -0,0 +1,8 @@
1
+ require 'compass'
2
+
3
+ opts = Compass.sass_engine_options
4
+
5
+ [:sass, :scss].each do |type|
6
+ Hyde.project.config.tilt_options(type)[:load_paths] ||= Array.new
7
+ Hyde.project.config.tilt_options(type)[:load_paths] += opts[:load_paths]
8
+ end
data/lib/hyde/config.rb CHANGED
@@ -9,13 +9,38 @@ class Hyde
9
9
  # Hyde.project.config.site_path
10
10
  # Hyde.project.config.layouts_path
11
11
  #
12
- class Config < OpenStruct
12
+ class Config
13
13
  DEFAULTS = {
14
14
  :site_path => '.',
15
- :layouts_path => nil,
16
- :extensions_path => nil,
17
- :partials_path => nil,
18
- :output_path => nil
15
+ :layouts_path => '_layouts',
16
+ :extensions_path => '_extensions',
17
+ :partials_path => '_layouts',
18
+ :output_path => '_output',
19
+ :tilt_options => {
20
+ :haml => {
21
+ :escape_html => true
22
+ },
23
+ :sass => {
24
+ :load_paths => ['css', '.'],
25
+ :style => :compact,
26
+ :line_numbers => true
27
+ },
28
+ :scss => {
29
+ :load_paths => ['css', '..'],
30
+ :style => :compact,
31
+ :line_numbers => true
32
+ },
33
+ },
34
+ :tilt_build_options => {
35
+ :scss => {
36
+ :style => :compressed,
37
+ :line_numbers => false
38
+ },
39
+ :sass => {
40
+ :style => :compressed,
41
+ :line_numbers => false
42
+ }
43
+ }
19
44
  }
20
45
 
21
46
  def self.load(config_file)
@@ -24,31 +49,37 @@ class Config < OpenStruct
24
49
 
25
50
  def initialize(options={})
26
51
  # Try to emulate proper .merge behavior in Ruby 1.8
27
- options.each { |k, v| options[k] ||= DEFAULTS[k] if DEFAULTS.keys.include?(k) }
28
- super options
52
+ #DEFAULTS.each { |k, v| options[k] ||= v }
53
+ @table = Hashie::Mash.new
54
+ @table.deep_merge! DEFAULTS
55
+ @table.deep_merge! options
56
+ end
57
+
58
+ # Passthru
59
+ def method_missing(meth, *args, &blk)
60
+ @table.send meth, *args
29
61
  end
30
62
 
31
63
  # Returns tilt options for a given file.
32
64
  # @example tilt_options('index.haml') # { :escape_html => ... }
33
- def tilt_options_for(file, options)
65
+ def tilt_options_for(file, options={})
34
66
  ext = file.split('.').last.downcase
35
67
  opts = tilt_options(ext) || Hash.new
36
- opts = opts.merge(tilt_options(ext, :tilt_build_options) || Hash.new) if options[:build]
37
- opts
68
+ opts = opts.merge(tilt_options(ext, :tilt_build_options)) if options[:build]
69
+
70
+ to_hash opts
38
71
  end
39
72
 
40
73
  # Returns tilt options for a given engine.
41
74
  # @example tilt_options('haml') # { :escape_html => ... }
42
75
  def tilt_options(what, key=:tilt_options)
43
- @table[key] ||= begin
44
- h = Hash.new { |h, k| h[k] = Hash.new }
45
- h['haml'] = { :escape_html => true }
46
- h['scss'] = { :load_path => ['css'] }
47
- h['sass'] = { :load_path => ['css'] }
48
- h
49
- end
50
-
76
+ @table[key] ||= Hash.new
51
77
  @table[key][what.to_s] ||= Hash.new
52
78
  end
79
+
80
+ private
81
+ def to_hash(mash)
82
+ mash.inject(Hash.new) { |h, (k, v)| h[k.to_sym] = v; h }
83
+ end
53
84
  end
54
85
  end
data/lib/hyde/project.rb CHANGED
@@ -42,6 +42,8 @@ class Project
42
42
 
43
43
  validate_version
44
44
  load_extensions
45
+
46
+ require 'hyde/compass_support'
45
47
  end
46
48
 
47
49
  def validate_version
@@ -61,7 +63,10 @@ class Project
61
63
 
62
64
  def load_extensions
63
65
  path = path(:extensions)
64
- Dir[path(:extensions, '*', '*.rb')].each { |f| require f } if path
66
+
67
+ ( Dir[path(:extensions, '*.rb')] +
68
+ Dir[path(:extensions, '*', '*.rb')]
69
+ ).sort.each { |f| require f } if path
65
70
  end
66
71
 
67
72
  def config_file
@@ -103,10 +108,16 @@ class Project
103
108
  def ignored_files
104
109
  specs = [*config.ignore].map { |s| root(s) }
105
110
  specs << config_file
111
+
112
+ # Ignore the standard files
106
113
  [:layouts, :extensions, :partials, :output].each do |aspect|
107
- specs << path(aspect, '**/*') if path(aspect) && path(aspect) != path(:site)
114
+ specs << File.join(config.send(:"#{aspect}_path"), '**/*') if path(aspect) && path(aspect) != path(:site)
108
115
  end
109
- specs.compact.map { |s| Dir[s] }.flatten.uniq
116
+
117
+ # Ignore dotfiles and hyde.conf by default
118
+ specs += %w[.* _* *~ README* /hyde.conf /config.ru]
119
+
120
+ specs.compact.map { |s| glob(s) }.flatten.uniq
110
121
  end
111
122
 
112
123
  def build(&blk)
@@ -119,6 +130,14 @@ class Project
119
130
  end
120
131
 
121
132
  protected
133
+ def glob(str)
134
+ if str[0] == '/'
135
+ Dir[str] + Dir[root(str)] + Dir["#{root(str)}/**"]
136
+ else
137
+ Dir[root("**/#{str}")] + Dir[root("**/#{str}/**")]
138
+ end
139
+ end
140
+
122
141
  def build_cleanup
123
142
  FileUtils.rm_rf '.sass_cache'
124
143
  end
@@ -0,0 +1,7 @@
1
+ class Hyde
2
+ VERSION = "0.2.2"
3
+
4
+ def self.version
5
+ VERSION
6
+ end
7
+ end
data/lib/hyde.rb CHANGED
@@ -2,15 +2,18 @@ $:.push *Dir[File.expand_path('../../vendor/*/lib', __FILE__)]
2
2
 
3
3
  require 'fileutils'
4
4
  require 'ostruct'
5
+ require 'hashie'
5
6
  require 'yaml'
6
7
  require 'tilt'
7
8
  require 'shake'
8
9
 
10
+ # For Compass and such
11
+ Encoding.default_external = 'utf-8' if defined?(::Encoding)
12
+
9
13
  # HTML files as ERB
10
14
  Tilt.mappings['html'] = Tilt.mappings['erb']
11
15
 
12
16
  class Hyde
13
- VERSION = "0.1.14"
14
17
  PREFIX = File.expand_path('../', __FILE__)
15
18
 
16
19
  Error = Class.new(StandardError)
@@ -30,12 +33,10 @@ class Hyde
30
33
  autoload :Partial, "#{PREFIX}/hyde/partial"
31
34
  autoload :Helpers, "#{PREFIX}/hyde/helpers"
32
35
 
36
+ require "#{PREFIX}/hyde/version"
37
+
33
38
  class << self
34
39
  # The latest project.
35
40
  attr_accessor :project
36
-
37
- def version
38
- VERSION
39
- end
40
41
  end
41
42
  end
@@ -1,2 +1 @@
1
- div a {
2
- color: red; }
1
+ div a{color:red}
File without changes
@@ -0,0 +1 @@
1
+ $hi = 1
@@ -0,0 +1 @@
1
+ hyde_requirement: 9000.0
@@ -1,2 +1 @@
1
- div {
2
- color: red; }
1
+ div{color:red}
@@ -1,2 +1 @@
1
- dir {
2
- color: #332211; }
1
+ dir{color:#332211}
@@ -12,5 +12,6 @@ class ExtensionsTest < TestCase
12
12
 
13
13
  test "extensions" do
14
14
  assert $extension_loaded == "aoeu"
15
+ assert $hi == 1
15
16
  end
16
17
  end
@@ -1,9 +1,9 @@
1
1
  require File.expand_path('../../helper', __FILE__)
2
2
 
3
3
  class HydeTest < TestCase
4
- def assert_fixture_works(path)
5
- build_fixture(path) { |control, var|
6
- assert File.exists?(var)
4
+ def assert_fixture_works(path, options={})
5
+ build_fixture(path, options) { |control, var|
6
+ assert File.exists?(var), "#{var} doesn't exist"
7
7
  if read(control) != read(var)
8
8
  flunk "Failed in #{var}\n" +
9
9
  "Control:\n" +
@@ -25,17 +25,24 @@ class HydeTest < TestCase
25
25
  end
26
26
 
27
27
 
28
- def build_fixture(path, &blk)
28
+ def build_fixture(path, options={}, &blk)
29
29
  # Build
30
30
  project = build path
31
31
 
32
- assert \
33
- Dir[project.root('control/**/*')].length ==
34
- Dir[project.root('public/**/*')].length
32
+ options[:control_path] ||= '_control'
33
+ options[:public_path] ||= '_public'
35
34
 
36
- Dir[project.root('control/**/*')].each do |control|
35
+ control_path = project.root(options[:control_path])
36
+ public_path = project.root(options[:public_path])
37
+
38
+ from = Dir["#{control_path}/**/*"].map { |dir| dir.gsub(control_path, '') }.sort
39
+ to = Dir["#{public_path}/**/*"].map { |dir| dir.gsub(public_path, '') }.sort
40
+
41
+ assert_equal from, to, "The build happened to make less files"
42
+
43
+ Dir["#{control_path}/**/*"].each do |control|
37
44
  next unless File.file?(control)
38
- var = control.sub('/control/', '/public/')
45
+ var = control.sub(control_path, public_path)
39
46
  yield control, var
40
47
  end if block_given?
41
48
  end
@@ -46,7 +53,9 @@ class HydeTest < TestCase
46
53
 
47
54
  teardown do
48
55
  # Remove the generated
49
- Dir[fixture('*', 'public')].each { |dir| FileUtils.rm_rf dir }
56
+ ( Dir[fixture('*', 'public')] +
57
+ Dir[fixture('*', '_public')]
58
+ ).each { |dir| FileUtils.rm_rf dir }
50
59
  end
51
60
 
52
61
  test "fixture one" do
@@ -85,6 +94,18 @@ class HydeTest < TestCase
85
94
  assert_fixture_works fixture('build_options')
86
95
  end
87
96
 
97
+ test "fixture empty_config" do
98
+ assert_fixture_works fixture('empty_config'),
99
+ :control_path => '_control',
100
+ :public_path => '_output'
101
+ end
102
+
103
+ test "fixture high_version" do
104
+ assert_fixture_fails(fixture('high_version')) { |e|
105
+ assert e.message.include?('>= 9000')
106
+ }
107
+ end
108
+
88
109
  test "fixture fail_type" do
89
110
  assert_fixture_fails(fixture('fail_type')) { |e|
90
111
  assert e.message.include?('nonexistent')
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: hydeweb
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.14
5
+ version: 0.2.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Rico Sta. Cruz
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-04 00:00:00 +08:00
13
+ date: 2011-06-16 00:00:00 +08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirement: &id002 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
- - - ">="
33
+ - - ~>
34
34
  - !ruby/object:Gem::Version
35
35
  version: 1.2.2
36
36
  type: :runtime
@@ -41,44 +41,99 @@ dependencies:
41
41
  requirement: &id003 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
- - - ">="
44
+ - - ~>
45
45
  - !ruby/object:Gem::Version
46
- version: 1.0.0
46
+ version: 2.0.0
47
47
  type: :runtime
48
48
  version_requirements: *id003
49
49
  - !ruby/object:Gem::Dependency
50
- name: haml
50
+ name: hashie
51
51
  prerelease: false
52
52
  requirement: &id004 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
- - - ">="
55
+ - - ~>
56
56
  - !ruby/object:Gem::Version
57
- version: "0"
58
- type: :development
57
+ version: 1.0.0
58
+ type: :runtime
59
59
  version_requirements: *id004
60
60
  - !ruby/object:Gem::Dependency
61
- name: less
61
+ name: haml
62
62
  prerelease: false
63
63
  requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 3.1.1
69
+ type: :runtime
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: sass
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: 3.1.1
80
+ type: :runtime
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: compass
84
+ prerelease: false
85
+ requirement: &id007 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: 0.11.1
91
+ type: :runtime
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: RedCloth
95
+ prerelease: false
96
+ requirement: &id008 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 4.2.3
102
+ type: :runtime
103
+ version_requirements: *id008
104
+ - !ruby/object:Gem::Dependency
105
+ name: maruku
106
+ prerelease: false
107
+ requirement: &id009 !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ~>
111
+ - !ruby/object:Gem::Version
112
+ version: 0.6.0
113
+ type: :runtime
114
+ version_requirements: *id009
115
+ - !ruby/object:Gem::Dependency
116
+ name: less
117
+ prerelease: false
118
+ requirement: &id010 !ruby/object:Gem::Requirement
64
119
  none: false
65
120
  requirements:
66
121
  - - ">="
67
122
  - !ruby/object:Gem::Version
68
123
  version: "0"
69
124
  type: :development
70
- version_requirements: *id005
125
+ version_requirements: *id010
71
126
  - !ruby/object:Gem::Dependency
72
127
  name: maruku
73
128
  prerelease: false
74
- requirement: &id006 !ruby/object:Gem::Requirement
129
+ requirement: &id011 !ruby/object:Gem::Requirement
75
130
  none: false
76
131
  requirements:
77
132
  - - ">="
78
133
  - !ruby/object:Gem::Version
79
134
  version: "0"
80
135
  type: :development
81
- version_requirements: *id006
136
+ version_requirements: *id011
82
137
  description: Hyde lets you create static websites from a bunch of files written in HAML, Textile, Sass, or any other.
83
138
  email:
84
139
  - rico@sinefunc.com
@@ -94,6 +149,7 @@ files:
94
149
  - bin/hyde01
95
150
  - lib/hyde/cli/helpers.rb
96
151
  - lib/hyde/cli.rb
152
+ - lib/hyde/compass_support.rb
97
153
  - lib/hyde/config.rb
98
154
  - lib/hyde/helpers.rb
99
155
  - lib/hyde/layout.rb
@@ -103,14 +159,17 @@ files:
103
159
  - lib/hyde/project.rb
104
160
  - lib/hyde/server.rb
105
161
  - lib/hyde/set.rb
162
+ - lib/hyde/version.rb
106
163
  - lib/hyde.rb
107
164
  - test/fixture/build_options/control/page.html
108
165
  - test/fixture/build_options/control/style.css
109
166
  - test/fixture/build_options/hyde.conf
110
167
  - test/fixture/build_options/site/page.haml
111
168
  - test/fixture/build_options/site/style.scss
169
+ - test/fixture/empty_config/hyde.conf
112
170
  - test/fixture/extensions/control/index.html
113
171
  - test/fixture/extensions/extensions/a/a.rb
172
+ - test/fixture/extensions/extensions/hi.rb
114
173
  - test/fixture/extensions/hyde.conf
115
174
  - test/fixture/extensions/site/index.haml
116
175
  - test/fixture/fail_type/control/about/index.html
@@ -118,6 +177,7 @@ files:
118
177
  - test/fixture/fail_type/control/index.html
119
178
  - test/fixture/fail_type/hyde.conf
120
179
  - test/fixture/fail_type/site/index.haml
180
+ - test/fixture/high_version/hyde.conf
121
181
  - test/fixture/html/control/index.html
122
182
  - test/fixture/html/hyde.conf
123
183
  - test/fixture/html/site/index.html