machined 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -8
- data/lib/machined/context.rb +1 -0
- data/lib/machined/environment.rb +9 -0
- data/lib/machined/helpers/asset_tag_helpers.rb +12 -127
- data/lib/machined/helpers/locals_helpers.rb +0 -3
- data/lib/machined/helpers/output_helpers.rb +0 -2
- data/lib/machined/helpers/page_helpers.rb +0 -4
- data/lib/machined/helpers/render_helpers.rb +0 -4
- data/lib/machined/templates/site/pages/index.html.erb +1 -1
- data/lib/machined/version.rb +1 -1
- data/machined.gemspec +15 -14
- data/spec/machined/cli_spec.rb +1 -1
- data/spec/machined/context_spec.rb +3 -7
- data/spec/machined/environment_spec.rb +3 -6
- data/spec/machined/helpers/asset_tag_helpers_spec.rb +19 -46
- data/spec/machined/helpers/locals_helper_spec.rb +19 -29
- data/spec/support/helpers.rb +8 -15
- metadata +168 -72
data/README.md
CHANGED
@@ -12,18 +12,19 @@ Installation
|
|
12
12
|
$ gem install machined
|
13
13
|
```
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
Quick Start
|
16
|
+
-----------
|
17
17
|
|
18
18
|
``` bash
|
19
|
-
$ machined new
|
19
|
+
$ machined new blog
|
20
20
|
```
|
21
21
|
|
22
22
|
This creates a directory with the default Machined project structure. More on that later. Let's start up the Machined server:
|
23
23
|
|
24
24
|
``` bash
|
25
|
-
$ cd
|
26
|
-
$
|
25
|
+
$ cd blog
|
26
|
+
$ bundle install
|
27
|
+
$ bundle exec machined server
|
27
28
|
```
|
28
29
|
|
29
30
|
Now that the server is running, edit your pages, assets, etc. and view the results. Most static site servers need to recompile the _entire_ site each time a request is made. Machined (well really Sprockets) is smart enough to compile only what you request, so developing is super fast.
|
@@ -34,14 +35,13 @@ Deploying a Static Website
|
|
34
35
|
Once you've created your site, it's time to go live. On your production box, you just need to compile the site and let Apache, Nginx, or whatever handle the serving. It'll be fast - damn fast.
|
35
36
|
|
36
37
|
``` bash
|
37
|
-
$
|
38
|
-
$ machined compile --environment production
|
38
|
+
$ bundle exec machined compile --environment production
|
39
39
|
```
|
40
40
|
|
41
41
|
Diving In
|
42
42
|
---------
|
43
43
|
|
44
|
-
|
44
|
+
Read the [full documentation](https://github.com/petebrowne/machined/wiki).
|
45
45
|
|
46
46
|
Copyright
|
47
47
|
---------
|
data/lib/machined/context.rb
CHANGED
data/lib/machined/environment.rb
CHANGED
@@ -157,6 +157,15 @@ module Machined
|
|
157
157
|
end
|
158
158
|
assets.js_compressor = js_compressor if config.compress_js
|
159
159
|
assets.css_compressor = css_compressor if config.compress_css
|
160
|
+
|
161
|
+
# Finally, configure Sprockets::Helpers
|
162
|
+
# match curernt configuration.
|
163
|
+
Sprockets::Helpers.configure do |helpers|
|
164
|
+
helpers.environment = assets
|
165
|
+
helpers.digest = config.digest_assets
|
166
|
+
helpers.prefix = config.assets_url
|
167
|
+
helpers.public_path = config.output_path.to_s
|
168
|
+
end
|
160
169
|
end
|
161
170
|
|
162
171
|
# Handles Rack requests by passing the +env+ to an instance
|
@@ -1,133 +1,18 @@
|
|
1
|
-
require "active_support/concern"
|
2
|
-
|
3
1
|
module Machined
|
4
2
|
module Helpers
|
5
3
|
module AssetTagHelpers
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
# Append extension if necessary.
|
20
|
-
if [:css, :js].include?(kind)
|
21
|
-
source << ".#{kind}" unless source =~ /\.#{kind}$/
|
22
|
-
end
|
23
|
-
|
24
|
-
# If the source points to an asset in the assets
|
25
|
-
# environment use `AssetPath` to generate the full path.
|
26
|
-
machined.assets.resolve(source) do |path|
|
27
|
-
return AssetPath.new(machined, machined.assets.find_asset(path)).to_s
|
28
|
-
end
|
29
|
-
|
30
|
-
# Default to using a basic `FilePath` to generate the
|
31
|
-
# full path.
|
32
|
-
FilePath.new(machined, source, kind).to_s
|
33
|
-
end
|
34
|
-
|
35
|
-
# `FilePath` generates a full path for a regular file
|
36
|
-
# in the output path. It's used by #asset_path to generate
|
37
|
-
# paths when using asset tags like #javascript_include_tag,
|
38
|
-
# #stylesheet_link_tag, and #image_tag
|
39
|
-
class FilePath
|
40
|
-
# A reference to the Machined environment.
|
41
|
-
attr_reader :machined
|
42
|
-
|
43
|
-
# The path from which to generate the full path to the asset.
|
44
|
-
attr_reader :source
|
45
|
-
|
46
|
-
# The expected kind of file (:css, :js, :images).
|
47
|
-
attr_reader :kind
|
48
|
-
|
49
|
-
#
|
50
|
-
def initialize(machined, source, kind)
|
51
|
-
@machined = machined
|
52
|
-
@source = source.to_s
|
53
|
-
@kind = kind
|
54
|
-
end
|
55
|
-
|
56
|
-
# Returns the full path to the asset, complete with
|
57
|
-
# timestamp.
|
58
|
-
def to_s
|
59
|
-
path = rewrite_base_path(source)
|
60
|
-
path = rewrite_timestamp(path)
|
61
|
-
path
|
62
|
-
end
|
63
|
-
|
64
|
-
protected
|
65
|
-
|
66
|
-
# Prepends the base path if the path is not
|
67
|
-
# already an absolute path.
|
68
|
-
def rewrite_base_path(path) # :nodoc:
|
69
|
-
if path =~ %r(^/)
|
70
|
-
path
|
71
|
-
else
|
72
|
-
File.join(base_path, path)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
# Appends an asset timestamp based on the
|
77
|
-
# modification time of the asset.
|
78
|
-
def rewrite_timestamp(path) # :nodoc:
|
79
|
-
if timestamp = mtime(path)
|
80
|
-
"#{path}?#{timestamp.to_i}" unless path =~ /\?\d+$/
|
81
|
-
else
|
82
|
-
path
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
# Returns the expected base path for this asset.
|
87
|
-
def base_path # :nodoc:
|
88
|
-
case kind
|
89
|
-
when :css then "/stylesheets"
|
90
|
-
when :js then "/javascripts"
|
91
|
-
else
|
92
|
-
"/#{kind}"
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
# Returns the mtime for the given path (relative to
|
97
|
-
# the output path). Returns nil if the file doesn't exist.
|
98
|
-
def mtime(path) # :nodoc:
|
99
|
-
output_path = File.join(machined.output_path.to_s, path)
|
100
|
-
File.exist?(output_path) ? File.mtime(output_path) : nil
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
# `AssetPath` generates a full path for an asset
|
105
|
-
# that exists in Machined's `assets` environment.
|
106
|
-
class AssetPath < FilePath
|
107
|
-
attr_reader :asset
|
108
|
-
|
109
|
-
def initialize(machined, asset)
|
110
|
-
@machined = machined
|
111
|
-
@asset = asset
|
112
|
-
@source = digest? ? asset.digest_path : asset.logical_path
|
113
|
-
end
|
114
|
-
|
115
|
-
protected
|
116
|
-
|
117
|
-
def rewrite_timestamp(path)
|
118
|
-
digest? ? path : super
|
119
|
-
end
|
120
|
-
|
121
|
-
def digest?
|
122
|
-
machined.config.digest_assets
|
123
|
-
end
|
124
|
-
|
125
|
-
def base_path
|
126
|
-
machined.assets.config.url
|
127
|
-
end
|
128
|
-
|
129
|
-
def mtime(path)
|
130
|
-
asset.mtime
|
4
|
+
# Override asset_path to also work with the
|
5
|
+
# Padrino::Helpers::AssetTagHelpers API.
|
6
|
+
def asset_path(source, options = {})
|
7
|
+
case source
|
8
|
+
when :css
|
9
|
+
path_to_asset options, :dir => "stylesheets", :ext => "css"
|
10
|
+
when :images
|
11
|
+
path_to_asset options, :dir => "images"
|
12
|
+
when :js
|
13
|
+
path_to_asset options, :dir => "javascripts", :ext => "js"
|
14
|
+
else
|
15
|
+
path_to_asset source, options
|
131
16
|
end
|
132
17
|
end
|
133
18
|
end
|
@@ -1,11 +1,8 @@
|
|
1
|
-
require "active_support/concern"
|
2
1
|
require "active_support/hash_with_indifferent_access"
|
3
2
|
|
4
3
|
module Machined
|
5
4
|
module Helpers
|
6
5
|
module LocalsHelpers
|
7
|
-
extend ActiveSupport::Concern
|
8
|
-
|
9
6
|
# Returns the locals hash. It's actually an instance
|
10
7
|
# of `ActiveSupport::HashWithIndifferentAccess`, so strings
|
11
8
|
# and symbols can be used interchangeably.
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require "active_support/concern"
|
2
1
|
require "active_support/memoizable"
|
3
2
|
require "tilt"
|
4
3
|
|
@@ -9,7 +8,6 @@ Tilt::ERBTemplate.default_output_variable = "@_out_buf"
|
|
9
8
|
module Machined
|
10
9
|
module Helpers
|
11
10
|
module OutputHelpers
|
12
|
-
extend ActiveSupport::Concern
|
13
11
|
extend ActiveSupport::Memoizable
|
14
12
|
|
15
13
|
# A hash of Tilt templates that support
|
@@ -1,12 +1,8 @@
|
|
1
|
-
require "active_support/concern"
|
2
1
|
require "active_support/core_ext/string/inflections"
|
3
2
|
|
4
3
|
module Machined
|
5
4
|
module Helpers
|
6
5
|
module PageHelpers
|
7
|
-
extend ActiveSupport::Concern
|
8
|
-
include LocalsHelpers
|
9
|
-
|
10
6
|
# Returns the context of the given path. This is useful
|
11
7
|
# if you want to get the information from the front matter
|
12
8
|
# of a specific page.
|
@@ -1,12 +1,8 @@
|
|
1
1
|
require "pathname"
|
2
|
-
require "active_support/concern"
|
3
2
|
|
4
3
|
module Machined
|
5
4
|
module Helpers
|
6
5
|
module RenderHelpers
|
7
|
-
extend ActiveSupport::Concern
|
8
|
-
include LocalsHelpers
|
9
|
-
|
10
6
|
# This is the short form of both #render_partial and #render_collection.
|
11
7
|
# It works exactly like #render_partial, except if you pass the
|
12
8
|
# +:collection+ option:
|
data/lib/machined/version.rb
CHANGED
data/machined.gemspec
CHANGED
@@ -7,9 +7,9 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = Machined::VERSION
|
8
8
|
s.authors = ["Pete Browne"]
|
9
9
|
s.email = ["me@petebrowne.com"]
|
10
|
-
s.homepage = ""
|
11
|
-
s.summary =
|
12
|
-
s.description =
|
10
|
+
s.homepage = "https://github.com/petebrowne/machined"
|
11
|
+
s.summary = "A static site generator and Rack server built using Sprockets 2.0"
|
12
|
+
s.description = "Why another static site generator? Machined is for the developers who know and love the asset pipeline of Rails 3.1 and want to develop blazingly fast static websites. It's built from the ground up using Sprockets 2.0."
|
13
13
|
|
14
14
|
s.rubyforge_project = "machined"
|
15
15
|
|
@@ -18,17 +18,18 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_dependency "sprockets",
|
22
|
-
s.add_dependency "sprockets-
|
23
|
-
s.add_dependency "
|
24
|
-
s.add_dependency "
|
25
|
-
s.add_dependency "
|
26
|
-
s.add_dependency "
|
27
|
-
s.add_dependency "
|
28
|
-
s.
|
29
|
-
s.add_development_dependency "
|
30
|
-
s.add_development_dependency "test
|
31
|
-
s.add_development_dependency
|
21
|
+
s.add_dependency "sprockets", "~> 2.0.3"
|
22
|
+
s.add_dependency "sprockets-helpers", "~> 0.2.1"
|
23
|
+
s.add_dependency "sprockets-sass", "~> 0.4.1"
|
24
|
+
s.add_dependency "padrino-helpers", "~> 0.10.5"
|
25
|
+
s.add_dependency "activesupport", "~> 3.1.1"
|
26
|
+
s.add_dependency "i18n", "~> 0.6.0"
|
27
|
+
s.add_dependency "thor", "~> 0.14.6"
|
28
|
+
s.add_dependency "crush", "~> 0.3.3"
|
29
|
+
s.add_development_dependency "rspec", "~> 2.7.0"
|
30
|
+
s.add_development_dependency "rack-test", "~> 0.6.1"
|
31
|
+
s.add_development_dependency "test-construct", "~> 1.2.0"
|
32
|
+
s.add_development_dependency 'unindent', "~> 1.0"
|
32
33
|
s.add_development_dependency "haml"
|
33
34
|
s.add_development_dependency "sass"
|
34
35
|
s.add_development_dependency "slim"
|
data/spec/machined/cli_spec.rb
CHANGED
@@ -3,18 +3,14 @@ require "spec_helper"
|
|
3
3
|
describe Machined::Context do
|
4
4
|
describe "#machined" do
|
5
5
|
it "returns a reference to the Machined environment" do
|
6
|
-
|
7
|
-
context.machined.should be(machined)
|
8
|
-
end
|
6
|
+
context.machined.should be(machined)
|
9
7
|
end
|
10
8
|
end
|
11
9
|
|
12
10
|
describe "#config" do
|
13
11
|
it "returns a reference to the Machined environment's configuration" do
|
14
|
-
|
15
|
-
|
16
|
-
context.config.layout.should == "application"
|
17
|
-
end
|
12
|
+
machined.config.layout = "application"
|
13
|
+
context.config.layout.should == "application"
|
18
14
|
end
|
19
15
|
end
|
20
16
|
end
|
@@ -69,9 +69,8 @@ describe Machined::Environment do
|
|
69
69
|
"world"
|
70
70
|
end
|
71
71
|
end
|
72
|
-
|
73
|
-
|
74
|
-
end
|
72
|
+
|
73
|
+
context.hello.should == "world"
|
75
74
|
end
|
76
75
|
|
77
76
|
it "adds methods defined in the given module to the Context" do
|
@@ -81,9 +80,7 @@ describe Machined::Environment do
|
|
81
80
|
end
|
82
81
|
end
|
83
82
|
machined.helpers helper
|
84
|
-
|
85
|
-
context.hello.should == "world"
|
86
|
-
end
|
83
|
+
context.hello.should == "world"
|
87
84
|
end
|
88
85
|
end
|
89
86
|
|
@@ -1,55 +1,43 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Machined::Helpers::AssetTagHelpers do
|
4
|
-
include Machined::Helpers::AssetTagHelpers
|
5
|
-
|
6
4
|
describe "#asset_path" do
|
7
5
|
context "with URIs" do
|
8
6
|
it "returns URIs untouched" do
|
9
|
-
|
10
|
-
asset_path(:js, "https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js").should ==
|
7
|
+
context.asset_path(:js, "https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js").should ==
|
11
8
|
"https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"
|
12
|
-
asset_path(:js, "http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js").should ==
|
9
|
+
context.asset_path(:js, "http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js").should ==
|
13
10
|
"http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"
|
14
|
-
asset_path(:js, "//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js").should ==
|
11
|
+
context.asset_path(:js, "//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js").should ==
|
15
12
|
"//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"
|
16
13
|
end
|
17
14
|
end
|
18
15
|
|
19
16
|
context "with regular files" do
|
20
17
|
it "returns absolute paths" do
|
21
|
-
|
22
|
-
asset_path(:
|
23
|
-
asset_path(:images, "/path/to/file.jpg").should == "/path/to/file.jpg"
|
18
|
+
context.asset_path(:js, "/path/to/file.js").should == "/path/to/file.js"
|
19
|
+
context.asset_path(:images, "/path/to/file.jpg").should == "/path/to/file.jpg"
|
24
20
|
end
|
25
21
|
|
26
22
|
it "appends the extension for javascripts and stylesheets" do
|
27
|
-
|
28
|
-
asset_path(:
|
29
|
-
asset_path(:
|
30
|
-
asset_path(:images, "/path/to/file").should_not == "/path/to/file.jpg"
|
23
|
+
context.asset_path(:js, "/path/to/file").should == "/path/to/file.js"
|
24
|
+
context.asset_path(:css, "/path/to/file").should == "/path/to/file.css"
|
25
|
+
context.asset_path(:images, "/path/to/file").should_not == "/path/to/file.jpg"
|
31
26
|
end
|
32
27
|
|
33
28
|
it "prepends a base URL if missing" do
|
34
|
-
|
35
|
-
asset_path(:
|
36
|
-
asset_path(:
|
37
|
-
asset_path(:images, "logo.jpg").should == "/images/logo.jpg"
|
29
|
+
context.asset_path(:css, "main").should == "/stylesheets/main.css"
|
30
|
+
context.asset_path(:js, "main").should == "/javascripts/main.js"
|
31
|
+
context.asset_path(:images, "logo.jpg").should == "/images/logo.jpg"
|
38
32
|
end
|
39
33
|
|
40
34
|
it "appends a timestamp if the file exists in the output path" do
|
41
35
|
within_construct do |c|
|
42
|
-
|
43
|
-
|
36
|
+
c.file "public/javascripts/main.js"
|
37
|
+
c.file "public/favicon.ico"
|
44
38
|
|
45
|
-
|
46
|
-
|
47
|
-
mtime2 = Time.now - 60
|
48
|
-
file2.utime mtime2, mtime2
|
49
|
-
|
50
|
-
machined
|
51
|
-
asset_path(:js, "main").should == "/javascripts/main.js?#{mtime1.to_i}"
|
52
|
-
asset_path(:images, "/favicon.ico").should == "/favicon.ico?#{mtime2.to_i}"
|
39
|
+
context.asset_path(:js, "main").should =~ %r(/javascripts/main.js\?\d+)
|
40
|
+
context.asset_path(:images, "/favicon.ico").should =~ %r(/favicon.ico\?\d+)
|
53
41
|
end
|
54
42
|
end
|
55
43
|
end
|
@@ -61,22 +49,9 @@ describe Machined::Helpers::AssetTagHelpers do
|
|
61
49
|
c.file "assets/javascripts/main.js"
|
62
50
|
c.file "assets/stylesheets/main.css"
|
63
51
|
|
64
|
-
|
65
|
-
asset_path(:
|
66
|
-
asset_path(:
|
67
|
-
asset_path(:images, "logo.jpg").should =~ %r(^/assets/logo\.jpg)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
it "appends the timestamp of the asset's mtime" do
|
72
|
-
within_construct do |c|
|
73
|
-
c.file "assets/javascripts/main.js", "//= require dep"
|
74
|
-
file = c.file "assets/javascripts/dep.js"
|
75
|
-
|
76
|
-
mtime = Time.now + 600
|
77
|
-
file.utime mtime, mtime
|
78
|
-
|
79
|
-
asset_path(:js, "main").should == "/assets/main.js?#{mtime.to_i}"
|
52
|
+
context.asset_path(:css, "main").should == "/assets/main.css"
|
53
|
+
context.asset_path(:js, "main").should == "/assets/main.js"
|
54
|
+
context.asset_path(:images, "logo.jpg").should == "/assets/logo.jpg"
|
80
55
|
end
|
81
56
|
end
|
82
57
|
|
@@ -85,9 +60,7 @@ describe Machined::Helpers::AssetTagHelpers do
|
|
85
60
|
c.file "assets/javascrtips/main.js"
|
86
61
|
|
87
62
|
machined :digest_assets => true
|
88
|
-
|
89
|
-
asset = machined.assets["main.js"]
|
90
|
-
asset_path(:js, "main").should == "/assets/main-#{asset.digest}.js"
|
63
|
+
context.asset_path(:js, "main").should =~ %r(/assets/main-[0-9a-f]+.js)
|
91
64
|
end
|
92
65
|
end
|
93
66
|
end
|
@@ -3,51 +3,41 @@ require "spec_helper"
|
|
3
3
|
describe Machined::Helpers::LocalsHelpers do
|
4
4
|
describe "#locals=" do
|
5
5
|
it "sets psuedo local variables" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
context.body.should be_nil
|
10
|
-
end
|
6
|
+
context.locals = { :text => "Hello World", :body => nil }
|
7
|
+
context.text.should == "Hello World"
|
8
|
+
context.body.should be_nil
|
11
9
|
end
|
12
10
|
|
13
11
|
it "responds_to the local variable name" do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
context.respond_to?(:body).should be_true
|
18
|
-
end
|
12
|
+
context.locals = { :text => "Hello World", :body => nil }
|
13
|
+
context.respond_to?(:text).should be_true
|
14
|
+
context.respond_to?(:body).should be_true
|
19
15
|
end
|
20
16
|
|
21
17
|
it "still raises errors if the method doesn't exist" do
|
22
|
-
|
23
|
-
|
24
|
-
context.respond_to?(:not_a_local).should be_false
|
25
|
-
end
|
18
|
+
expect { context.not_a_local }.to raise_error(NoMethodError)
|
19
|
+
context.respond_to?(:not_a_local).should be_false
|
26
20
|
end
|
27
21
|
|
28
22
|
it "clears local variables when set to nil" do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
context.respond_to?(:text).should be_false
|
34
|
-
end
|
23
|
+
context.locals = { :text => "Hello World" }
|
24
|
+
context.locals = nil
|
25
|
+
expect { context.text }.to raise_error(NoMethodError)
|
26
|
+
context.respond_to?(:text).should be_false
|
35
27
|
end
|
36
28
|
end
|
37
29
|
|
38
30
|
describe "#with_locals" do
|
39
31
|
it "temporarily changes the local variables" do
|
40
|
-
|
41
|
-
|
42
|
-
context.with_locals(:layout => false, :body => "...") do
|
43
|
-
context.text.should == "Hello World"
|
44
|
-
context.body.should == "..."
|
45
|
-
context.layout.should be_false
|
46
|
-
end
|
32
|
+
context.locals = { :text => "Hello World", :layout => "main" }
|
33
|
+
context.with_locals(:layout => false, :body => "...") do
|
47
34
|
context.text.should == "Hello World"
|
48
|
-
context.
|
49
|
-
context.
|
35
|
+
context.body.should == "..."
|
36
|
+
context.layout.should be_false
|
50
37
|
end
|
38
|
+
context.text.should == "Hello World"
|
39
|
+
context.layout.should == "main"
|
40
|
+
context.respond_to?(:body).should be_false
|
51
41
|
end
|
52
42
|
end
|
53
43
|
end
|
data/spec/support/helpers.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
1
3
|
module Machined
|
2
4
|
module SpecHelpers
|
3
5
|
# Convenience method for creating a new Machined environment
|
@@ -12,22 +14,13 @@ module Machined
|
|
12
14
|
Machined::Sprocket.new machined, config
|
13
15
|
end
|
14
16
|
|
15
|
-
#
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
# Create the necessary files
|
21
|
-
path = c.directory "context"
|
22
|
-
path.file "machined.css.erb", content
|
17
|
+
# Returns a fresh context, that can be used to test helpers.
|
18
|
+
def context(logical_path = "application.js", options = {})
|
19
|
+
@context ||= begin
|
20
|
+
pathname = options[:pathname] || Pathname.new(File.join("assets", logical_path)).expand_path
|
21
|
+
env = options[:env] || machined.assets
|
23
22
|
|
24
|
-
|
25
|
-
sprocket = create_sprocket
|
26
|
-
sprocket.append_path path
|
27
|
-
|
28
|
-
# Find the asset and yield the context and output
|
29
|
-
asset = sprocket["machined.css"]
|
30
|
-
yield asset.send(:blank_context), asset.to_s
|
23
|
+
env.context_class.new env, logical_path, pathname
|
31
24
|
end
|
32
25
|
end
|
33
26
|
|
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: machined
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- Pete Browne
|
@@ -10,206 +15,297 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2011-
|
18
|
+
date: 2011-11-02 00:00:00 Z
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
|
-
name: sprockets
|
17
21
|
requirement: &id001 !ruby/object:Gem::Requirement
|
18
22
|
none: false
|
19
23
|
requirements:
|
20
24
|
- - ~>
|
21
25
|
- !ruby/object:Gem::Version
|
22
|
-
|
23
|
-
|
24
|
-
|
26
|
+
hash: 9
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
- 0
|
30
|
+
- 3
|
31
|
+
version: 2.0.3
|
32
|
+
name: sprockets
|
25
33
|
version_requirements: *id001
|
34
|
+
prerelease: false
|
35
|
+
type: :runtime
|
26
36
|
- !ruby/object:Gem::Dependency
|
27
|
-
name: sprockets-sass
|
28
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
29
38
|
none: false
|
30
39
|
requirements:
|
31
40
|
- - ~>
|
32
41
|
- !ruby/object:Gem::Version
|
33
|
-
|
34
|
-
|
35
|
-
|
42
|
+
hash: 21
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
- 2
|
46
|
+
- 1
|
47
|
+
version: 0.2.1
|
48
|
+
name: sprockets-helpers
|
36
49
|
version_requirements: *id002
|
50
|
+
prerelease: false
|
51
|
+
type: :runtime
|
37
52
|
- !ruby/object:Gem::Dependency
|
38
|
-
name: padrino-helpers
|
39
53
|
requirement: &id003 !ruby/object:Gem::Requirement
|
40
54
|
none: false
|
41
55
|
requirements:
|
42
56
|
- - ~>
|
43
57
|
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
|
46
|
-
|
58
|
+
hash: 13
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
- 4
|
62
|
+
- 1
|
63
|
+
version: 0.4.1
|
64
|
+
name: sprockets-sass
|
47
65
|
version_requirements: *id003
|
66
|
+
prerelease: false
|
67
|
+
type: :runtime
|
48
68
|
- !ruby/object:Gem::Dependency
|
49
|
-
name: activesupport
|
50
69
|
requirement: &id004 !ruby/object:Gem::Requirement
|
51
70
|
none: false
|
52
71
|
requirements:
|
53
72
|
- - ~>
|
54
73
|
- !ruby/object:Gem::Version
|
55
|
-
|
56
|
-
|
57
|
-
|
74
|
+
hash: 61
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
- 10
|
78
|
+
- 5
|
79
|
+
version: 0.10.5
|
80
|
+
name: padrino-helpers
|
58
81
|
version_requirements: *id004
|
82
|
+
prerelease: false
|
83
|
+
type: :runtime
|
59
84
|
- !ruby/object:Gem::Dependency
|
60
|
-
name: i18n
|
61
85
|
requirement: &id005 !ruby/object:Gem::Requirement
|
62
86
|
none: false
|
63
87
|
requirements:
|
64
88
|
- - ~>
|
65
89
|
- !ruby/object:Gem::Version
|
66
|
-
|
67
|
-
|
68
|
-
|
90
|
+
hash: 1
|
91
|
+
segments:
|
92
|
+
- 3
|
93
|
+
- 1
|
94
|
+
- 1
|
95
|
+
version: 3.1.1
|
96
|
+
name: activesupport
|
69
97
|
version_requirements: *id005
|
98
|
+
prerelease: false
|
99
|
+
type: :runtime
|
70
100
|
- !ruby/object:Gem::Dependency
|
71
|
-
name: thor
|
72
101
|
requirement: &id006 !ruby/object:Gem::Requirement
|
73
102
|
none: false
|
74
103
|
requirements:
|
75
104
|
- - ~>
|
76
105
|
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
|
79
|
-
|
106
|
+
hash: 7
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
- 6
|
110
|
+
- 0
|
111
|
+
version: 0.6.0
|
112
|
+
name: i18n
|
80
113
|
version_requirements: *id006
|
114
|
+
prerelease: false
|
115
|
+
type: :runtime
|
81
116
|
- !ruby/object:Gem::Dependency
|
82
|
-
name: crush
|
83
117
|
requirement: &id007 !ruby/object:Gem::Requirement
|
84
118
|
none: false
|
85
119
|
requirements:
|
86
120
|
- - ~>
|
87
121
|
- !ruby/object:Gem::Version
|
88
|
-
|
89
|
-
|
90
|
-
|
122
|
+
hash: 43
|
123
|
+
segments:
|
124
|
+
- 0
|
125
|
+
- 14
|
126
|
+
- 6
|
127
|
+
version: 0.14.6
|
128
|
+
name: thor
|
91
129
|
version_requirements: *id007
|
130
|
+
prerelease: false
|
131
|
+
type: :runtime
|
92
132
|
- !ruby/object:Gem::Dependency
|
93
|
-
name: rspec
|
94
133
|
requirement: &id008 !ruby/object:Gem::Requirement
|
95
134
|
none: false
|
96
135
|
requirements:
|
97
136
|
- - ~>
|
98
137
|
- !ruby/object:Gem::Version
|
99
|
-
|
100
|
-
|
101
|
-
|
138
|
+
hash: 21
|
139
|
+
segments:
|
140
|
+
- 0
|
141
|
+
- 3
|
142
|
+
- 3
|
143
|
+
version: 0.3.3
|
144
|
+
name: crush
|
102
145
|
version_requirements: *id008
|
146
|
+
prerelease: false
|
147
|
+
type: :runtime
|
103
148
|
- !ruby/object:Gem::Dependency
|
104
|
-
name: rack-test
|
105
149
|
requirement: &id009 !ruby/object:Gem::Requirement
|
106
150
|
none: false
|
107
151
|
requirements:
|
108
152
|
- - ~>
|
109
153
|
- !ruby/object:Gem::Version
|
110
|
-
|
111
|
-
|
112
|
-
|
154
|
+
hash: 19
|
155
|
+
segments:
|
156
|
+
- 2
|
157
|
+
- 7
|
158
|
+
- 0
|
159
|
+
version: 2.7.0
|
160
|
+
name: rspec
|
113
161
|
version_requirements: *id009
|
162
|
+
prerelease: false
|
163
|
+
type: :development
|
114
164
|
- !ruby/object:Gem::Dependency
|
115
|
-
name: test-construct
|
116
165
|
requirement: &id010 !ruby/object:Gem::Requirement
|
117
166
|
none: false
|
118
167
|
requirements:
|
119
168
|
- - ~>
|
120
169
|
- !ruby/object:Gem::Version
|
121
|
-
|
122
|
-
|
123
|
-
|
170
|
+
hash: 5
|
171
|
+
segments:
|
172
|
+
- 0
|
173
|
+
- 6
|
174
|
+
- 1
|
175
|
+
version: 0.6.1
|
176
|
+
name: rack-test
|
124
177
|
version_requirements: *id010
|
178
|
+
prerelease: false
|
179
|
+
type: :development
|
125
180
|
- !ruby/object:Gem::Dependency
|
126
|
-
name: unindent
|
127
181
|
requirement: &id011 !ruby/object:Gem::Requirement
|
128
182
|
none: false
|
129
183
|
requirements:
|
130
184
|
- - ~>
|
131
185
|
- !ruby/object:Gem::Version
|
132
|
-
|
133
|
-
|
134
|
-
|
186
|
+
hash: 31
|
187
|
+
segments:
|
188
|
+
- 1
|
189
|
+
- 2
|
190
|
+
- 0
|
191
|
+
version: 1.2.0
|
192
|
+
name: test-construct
|
135
193
|
version_requirements: *id011
|
194
|
+
prerelease: false
|
195
|
+
type: :development
|
136
196
|
- !ruby/object:Gem::Dependency
|
137
|
-
name: haml
|
138
197
|
requirement: &id012 !ruby/object:Gem::Requirement
|
139
198
|
none: false
|
140
199
|
requirements:
|
141
|
-
- -
|
200
|
+
- - ~>
|
142
201
|
- !ruby/object:Gem::Version
|
143
|
-
|
144
|
-
|
145
|
-
|
202
|
+
hash: 15
|
203
|
+
segments:
|
204
|
+
- 1
|
205
|
+
- 0
|
206
|
+
version: "1.0"
|
207
|
+
name: unindent
|
146
208
|
version_requirements: *id012
|
209
|
+
prerelease: false
|
210
|
+
type: :development
|
147
211
|
- !ruby/object:Gem::Dependency
|
148
|
-
name: sass
|
149
212
|
requirement: &id013 !ruby/object:Gem::Requirement
|
150
213
|
none: false
|
151
214
|
requirements:
|
152
215
|
- - ">="
|
153
216
|
- !ruby/object:Gem::Version
|
217
|
+
hash: 3
|
218
|
+
segments:
|
219
|
+
- 0
|
154
220
|
version: "0"
|
155
|
-
|
156
|
-
prerelease: false
|
221
|
+
name: haml
|
157
222
|
version_requirements: *id013
|
223
|
+
prerelease: false
|
224
|
+
type: :development
|
158
225
|
- !ruby/object:Gem::Dependency
|
159
|
-
name: slim
|
160
226
|
requirement: &id014 !ruby/object:Gem::Requirement
|
161
227
|
none: false
|
162
228
|
requirements:
|
163
229
|
- - ">="
|
164
230
|
- !ruby/object:Gem::Version
|
231
|
+
hash: 3
|
232
|
+
segments:
|
233
|
+
- 0
|
165
234
|
version: "0"
|
166
|
-
|
167
|
-
prerelease: false
|
235
|
+
name: sass
|
168
236
|
version_requirements: *id014
|
237
|
+
prerelease: false
|
238
|
+
type: :development
|
169
239
|
- !ruby/object:Gem::Dependency
|
170
|
-
name: erubis
|
171
240
|
requirement: &id015 !ruby/object:Gem::Requirement
|
172
241
|
none: false
|
173
242
|
requirements:
|
174
243
|
- - ">="
|
175
244
|
- !ruby/object:Gem::Version
|
245
|
+
hash: 3
|
246
|
+
segments:
|
247
|
+
- 0
|
176
248
|
version: "0"
|
177
|
-
|
178
|
-
prerelease: false
|
249
|
+
name: slim
|
179
250
|
version_requirements: *id015
|
251
|
+
prerelease: false
|
252
|
+
type: :development
|
180
253
|
- !ruby/object:Gem::Dependency
|
181
|
-
name: rdiscount
|
182
254
|
requirement: &id016 !ruby/object:Gem::Requirement
|
183
255
|
none: false
|
184
256
|
requirements:
|
185
257
|
- - ">="
|
186
258
|
- !ruby/object:Gem::Version
|
259
|
+
hash: 3
|
260
|
+
segments:
|
261
|
+
- 0
|
187
262
|
version: "0"
|
188
|
-
|
189
|
-
prerelease: false
|
263
|
+
name: erubis
|
190
264
|
version_requirements: *id016
|
265
|
+
prerelease: false
|
266
|
+
type: :development
|
191
267
|
- !ruby/object:Gem::Dependency
|
192
|
-
name: uglifier
|
193
268
|
requirement: &id017 !ruby/object:Gem::Requirement
|
194
269
|
none: false
|
195
270
|
requirements:
|
196
271
|
- - ">="
|
197
272
|
- !ruby/object:Gem::Version
|
273
|
+
hash: 3
|
274
|
+
segments:
|
275
|
+
- 0
|
198
276
|
version: "0"
|
199
|
-
|
200
|
-
prerelease: false
|
277
|
+
name: rdiscount
|
201
278
|
version_requirements: *id017
|
279
|
+
prerelease: false
|
280
|
+
type: :development
|
202
281
|
- !ruby/object:Gem::Dependency
|
203
|
-
name: rake
|
204
282
|
requirement: &id018 !ruby/object:Gem::Requirement
|
205
283
|
none: false
|
206
284
|
requirements:
|
207
285
|
- - ">="
|
208
286
|
- !ruby/object:Gem::Version
|
287
|
+
hash: 3
|
288
|
+
segments:
|
289
|
+
- 0
|
209
290
|
version: "0"
|
291
|
+
name: uglifier
|
292
|
+
version_requirements: *id018
|
293
|
+
prerelease: false
|
210
294
|
type: :development
|
295
|
+
- !ruby/object:Gem::Dependency
|
296
|
+
requirement: &id019 !ruby/object:Gem::Requirement
|
297
|
+
none: false
|
298
|
+
requirements:
|
299
|
+
- - ">="
|
300
|
+
- !ruby/object:Gem::Version
|
301
|
+
hash: 3
|
302
|
+
segments:
|
303
|
+
- 0
|
304
|
+
version: "0"
|
305
|
+
name: rake
|
306
|
+
version_requirements: *id019
|
211
307
|
prerelease: false
|
212
|
-
|
308
|
+
type: :development
|
213
309
|
description: Why another static site generator? Machined is for the developers who know and love the asset pipeline of Rails 3.1 and want to develop blazingly fast static websites. It's built from the ground up using Sprockets 2.0.
|
214
310
|
email:
|
215
311
|
- me@petebrowne.com
|
@@ -269,7 +365,7 @@ files:
|
|
269
365
|
- spec/spec_helper.rb
|
270
366
|
- spec/support/helpers.rb
|
271
367
|
- spec/support/match_paths_matcher.rb
|
272
|
-
homepage:
|
368
|
+
homepage: https://github.com/petebrowne/machined
|
273
369
|
licenses: []
|
274
370
|
|
275
371
|
post_install_message:
|
@@ -282,7 +378,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
282
378
|
requirements:
|
283
379
|
- - ">="
|
284
380
|
- !ruby/object:Gem::Version
|
285
|
-
hash:
|
381
|
+
hash: 3
|
286
382
|
segments:
|
287
383
|
- 0
|
288
384
|
version: "0"
|
@@ -291,14 +387,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
291
387
|
requirements:
|
292
388
|
- - ">="
|
293
389
|
- !ruby/object:Gem::Version
|
294
|
-
hash:
|
390
|
+
hash: 3
|
295
391
|
segments:
|
296
392
|
- 0
|
297
393
|
version: "0"
|
298
394
|
requirements: []
|
299
395
|
|
300
396
|
rubyforge_project: machined
|
301
|
-
rubygems_version: 1.8.
|
397
|
+
rubygems_version: 1.8.5
|
302
398
|
signing_key:
|
303
399
|
specification_version: 3
|
304
400
|
summary: A static site generator and Rack server built using Sprockets 2.0
|