machined 0.7.1 → 0.8.0
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/Rakefile +2 -2
- data/bin/machined +3 -3
- data/lib/machined.rb +17 -17
- data/lib/machined/cli.rb +35 -35
- data/lib/machined/context.rb +4 -4
- data/lib/machined/environment.rb +57 -31
- data/lib/machined/helpers/asset_tag_helpers.rb +4 -4
- data/lib/machined/helpers/locals_helpers.rb +1 -1
- data/lib/machined/helpers/output_helpers.rb +15 -15
- data/lib/machined/helpers/page_helpers.rb +1 -1
- data/lib/machined/helpers/render_helpers.rb +16 -16
- data/lib/machined/index.rb +1 -1
- data/lib/machined/initializable.rb +9 -11
- data/lib/machined/processors/front_matter_processor.rb +2 -2
- data/lib/machined/processors/layout_processor.rb +1 -1
- data/lib/machined/server.rb +2 -2
- data/lib/machined/sprocket.rb +4 -4
- data/lib/machined/static_compiler.rb +2 -2
- data/lib/machined/templates/site/Gemfile.tt +4 -4
- data/lib/machined/templates/site/config.ru +1 -1
- data/lib/machined/templates/site/machined.rb +2 -2
- data/lib/machined/templates/site/views/layouts/application.html.erb +2 -2
- data/lib/machined/utils.rb +3 -3
- data/lib/machined/version.rb +1 -1
- data/machined.gemspec +29 -31
- data/spec/machined/cli_spec.rb +56 -56
- data/spec/machined/context_spec.rb +6 -6
- data/spec/machined/environment_spec.rb +94 -94
- data/spec/machined/helpers/asset_tag_helpers_spec.rb +42 -42
- data/spec/machined/helpers/locals_helper_spec.rb +17 -17
- data/spec/machined/helpers/output_helpers_spec.rb +27 -27
- data/spec/machined/helpers/page_helpers_spec.rb +32 -32
- data/spec/machined/helpers/render_helpers_spec.rb +42 -42
- data/spec/machined/initializable_spec.rb +9 -9
- data/spec/machined/processors/front_matter_processor_spec.rb +7 -7
- data/spec/machined/processors/layout_processor_spec.rb +19 -19
- data/spec/machined/server_spec.rb +36 -36
- data/spec/machined/sprocket_spec.rb +15 -15
- data/spec/machined/utils_spec.rb +14 -14
- data/spec/spec_helper.rb +7 -7
- data/spec/support/be_fresh_matcher.rb +2 -2
- data/spec/support/helpers.rb +6 -6
- metadata +177 -301
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'pathname'
|
2
2
|
|
3
3
|
module Machined
|
4
4
|
module Helpers
|
@@ -7,9 +7,9 @@ module Machined
|
|
7
7
|
# It works exactly like #render_partial, except if you pass the
|
8
8
|
# +:collection+ option:
|
9
9
|
#
|
10
|
-
# <%= render
|
10
|
+
# <%= render 'ad', :collection => advertisements %>
|
11
11
|
# # is the same as:
|
12
|
-
# <%= render_collection advertisements,
|
12
|
+
# <%= render_collection advertisements, 'ad' %>
|
13
13
|
#
|
14
14
|
def render(partial, options = {})
|
15
15
|
if collection = options.delete(:collection)
|
@@ -24,9 +24,9 @@ module Machined
|
|
24
24
|
# of Rails' partial rendering, where the individual objects
|
25
25
|
# will be set as local variables based on the name of the partial:
|
26
26
|
#
|
27
|
-
# <%= render_collection advertisements,
|
27
|
+
# <%= render_collection advertisements, 'ad' %>
|
28
28
|
#
|
29
|
-
# This will render the
|
29
|
+
# This will render the 'ad' template and pass the local variable
|
30
30
|
# +ad+ to the template for display. An iteration counter will automatically
|
31
31
|
# be made available to the template with a name of the form
|
32
32
|
# +partial_name_counter+. In the case of the example above, the
|
@@ -51,21 +51,21 @@ module Machined
|
|
51
51
|
#
|
52
52
|
# == Some Examples
|
53
53
|
#
|
54
|
-
# <%= render_partial
|
54
|
+
# <%= render_partial 'account' %>
|
55
55
|
#
|
56
56
|
# This will look for a template in the views paths with the name
|
57
|
-
#
|
58
|
-
# template files, like
|
57
|
+
# 'account' or '_account'. The files can be any processable Tilt
|
58
|
+
# template files, like '.erb', '.md', or '.haml' - or just plain '.html'.
|
59
59
|
#
|
60
|
-
# <%= render_partial
|
60
|
+
# <%= render_partial 'account', :locals => { :account => buyer } %>
|
61
61
|
#
|
62
|
-
# This will set `buyer` as a local variable named
|
62
|
+
# This will set `buyer` as a local variable named 'account'. This can
|
63
63
|
# actually be written a few different ways:
|
64
64
|
#
|
65
|
-
# <%= render_partial
|
65
|
+
# <%= render_partial 'account', :account => buyer %>
|
66
66
|
# # Leftover options are assumed to be locals.
|
67
|
-
# <%= render_partial
|
68
|
-
# # The local variable name
|
67
|
+
# <%= render_partial 'account', :object => buyer %>
|
68
|
+
# # The local variable name 'account' is inferred.
|
69
69
|
#
|
70
70
|
# As mentioned above, any options that are not used by #render_partial
|
71
71
|
# are assumed to be locals when the +:locals+ option is not set.
|
@@ -74,11 +74,11 @@ module Machined
|
|
74
74
|
# where the local variable name will be inferred from the partial name.
|
75
75
|
# This can be overridden with the +:as+ option:
|
76
76
|
#
|
77
|
-
# <%= render_partial
|
77
|
+
# <%= render_partial 'account', :object => buyer, :as => 'user' %>
|
78
78
|
#
|
79
79
|
# This is equivalent to:
|
80
80
|
#
|
81
|
-
# <%= render_partial
|
81
|
+
# <%= render_partial 'account', :locals => { :user => buyer } %>
|
82
82
|
#
|
83
83
|
def render_partial(partial, options = {})
|
84
84
|
template = resolve_partial partial
|
@@ -110,7 +110,7 @@ module Machined
|
|
110
110
|
|
111
111
|
# Attempts to find a view with the given path,
|
112
112
|
# while also looking for a version with a partial-style
|
113
|
-
# name (prefixed with an
|
113
|
+
# name (prefixed with an '_').
|
114
114
|
def resolve_partial(path) # :nodoc:
|
115
115
|
path = Pathname.new path
|
116
116
|
path.absolute? and return path
|
data/lib/machined/index.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'active_support/concern'
|
2
2
|
|
3
3
|
module Machined
|
4
4
|
# Initializable is a minimal version of
|
@@ -9,7 +9,7 @@ module Machined
|
|
9
9
|
#
|
10
10
|
# If they move Rails::Initializable into ActiveSupport
|
11
11
|
# I'll remove this module and use theirs. Right now,
|
12
|
-
# I don't want to `require
|
12
|
+
# I don't want to `require 'rails'` if I don't have to.
|
13
13
|
module Initializable
|
14
14
|
extend ActiveSupport::Concern
|
15
15
|
|
@@ -57,16 +57,14 @@ module Machined
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
initializer.run self, *args
|
67
|
-
end
|
68
|
-
@initializers_run = true
|
60
|
+
# Run each initializer with the given args
|
61
|
+
# yielded to each initializer's block.
|
62
|
+
def run_initializers(*args)
|
63
|
+
return if @initializers_run
|
64
|
+
self.class.initializers.each do |initializer|
|
65
|
+
initializer.run self, *args
|
69
66
|
end
|
67
|
+
@initializers_run = true
|
70
68
|
end
|
71
69
|
end
|
72
70
|
end
|
data/lib/machined/server.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'rack'
|
2
2
|
|
3
3
|
module Machined
|
4
4
|
class Server
|
@@ -18,7 +18,7 @@ module Machined
|
|
18
18
|
# should handle the request and then...let it
|
19
19
|
# handle it.
|
20
20
|
def call(env)
|
21
|
-
refresh if machined.config.environment ==
|
21
|
+
refresh if machined.config.environment == 'development'
|
22
22
|
response = @url_map.call(env)
|
23
23
|
response = @files.call(env) if response.first == 404
|
24
24
|
response
|
data/lib/machined/sprocket.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'ostruct'
|
2
|
+
require 'sprockets'
|
3
|
+
require 'sprockets-sass'
|
4
4
|
|
5
5
|
module Machined
|
6
6
|
class Sprocket < Sprockets::Environment
|
7
7
|
# Default options for a Machined sprocket.
|
8
8
|
DEFAULT_OPTIONS = {
|
9
|
-
:root =>
|
9
|
+
:root => '.',
|
10
10
|
:assets => false,
|
11
11
|
:compile => true
|
12
12
|
}.freeze
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'fileutils'
|
2
2
|
|
3
3
|
module Machined
|
4
4
|
class StaticCompiler
|
@@ -32,7 +32,7 @@ module Machined
|
|
32
32
|
|
33
33
|
# Determines if we should precompile the asset
|
34
34
|
# with the given url. By default, we skip over any
|
35
|
-
# files that begin with
|
35
|
+
# files that begin with '_', like partials.
|
36
36
|
def compile?(url)
|
37
37
|
File.basename(url) !~ /^_/
|
38
38
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
source :rubygems
|
2
2
|
|
3
|
-
gem
|
3
|
+
gem 'machined', '<%= Machined::VERSION %>'
|
4
4
|
|
5
|
-
gem
|
6
|
-
gem
|
5
|
+
gem 'sass', '~> 3.1'
|
6
|
+
gem 'coffee-script', '~> 2.2'
|
7
7
|
|
8
8
|
group :production do
|
9
|
-
gem
|
9
|
+
gem 'uglifier', '~> 1.0'
|
10
10
|
end
|
@@ -1,2 +1,2 @@
|
|
1
|
-
require
|
1
|
+
require 'machined'
|
2
2
|
run Machined::Environment.new
|
@@ -3,8 +3,8 @@
|
|
3
3
|
<head lang="en">
|
4
4
|
<meta charset="utf-8">
|
5
5
|
<title><%= title %></title>
|
6
|
-
<%= stylesheet_link_tag
|
7
|
-
<%= javascript_include_tag
|
6
|
+
<%= stylesheet_link_tag 'application' %>
|
7
|
+
<%= javascript_include_tag 'application' %>
|
8
8
|
</head>
|
9
9
|
<body>
|
10
10
|
<%= yield %>
|
data/lib/machined/utils.rb
CHANGED
data/lib/machined/version.rb
CHANGED
data/machined.gemspec
CHANGED
@@ -1,43 +1,41 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path(
|
3
|
-
require
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'machined/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
6
|
+
s.name = 'machined'
|
7
7
|
s.version = Machined::VERSION
|
8
|
-
s.authors = [
|
9
|
-
s.email = [
|
10
|
-
s.homepage =
|
11
|
-
s.summary =
|
8
|
+
s.authors = ['Pete Browne']
|
9
|
+
s.email = ['me@petebrowne.com']
|
10
|
+
s.homepage = 'https://github.com/petebrowne/machined'
|
11
|
+
s.summary = 'A static site generator and Rack server built using Sprockets 2.0'
|
12
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
|
-
s.rubyforge_project =
|
14
|
+
s.rubyforge_project = 'machined'
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.require_paths = [
|
19
|
+
s.require_paths = ['lib']
|
20
20
|
|
21
|
-
s.add_dependency
|
22
|
-
s.add_dependency
|
23
|
-
s.add_dependency
|
24
|
-
s.add_dependency
|
25
|
-
s.add_dependency
|
26
|
-
s.add_dependency
|
27
|
-
s.add_dependency
|
28
|
-
s.add_dependency
|
29
|
-
s.
|
30
|
-
s.add_development_dependency
|
31
|
-
s.add_development_dependency
|
32
|
-
s.add_development_dependency
|
33
|
-
s.add_development_dependency
|
34
|
-
s.add_development_dependency
|
35
|
-
s.add_development_dependency
|
36
|
-
s.add_development_dependency
|
37
|
-
s.add_development_dependency
|
38
|
-
s.add_development_dependency
|
39
|
-
s.add_development_dependency
|
40
|
-
s.add_development_dependency
|
41
|
-
s.add_development_dependency "jquery-rails"
|
42
|
-
s.add_development_dependency "rake"
|
21
|
+
s.add_dependency 'sprockets', '~> 2.4.0'
|
22
|
+
s.add_dependency 'sprockets-helpers', '~> 0.4.0'
|
23
|
+
s.add_dependency 'sprockets-sass', '~> 0.8.0'
|
24
|
+
s.add_dependency 'padrino-helpers', '~> 0.10.5'
|
25
|
+
s.add_dependency 'activesupport', '~> 3.2.3'
|
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.9.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'
|
33
|
+
s.add_development_dependency 'sprockets-plugin', '~> 0.2.1'
|
34
|
+
s.add_development_dependency 'haml'
|
35
|
+
s.add_development_dependency 'sass'
|
36
|
+
s.add_development_dependency 'slim'
|
37
|
+
s.add_development_dependency 'erubis'
|
38
|
+
s.add_development_dependency 'rdiscount'
|
39
|
+
s.add_development_dependency 'uglifier'
|
40
|
+
s.add_development_dependency 'rake'
|
43
41
|
end
|
data/spec/machined/cli_spec.rb
CHANGED
@@ -1,44 +1,44 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Machined::CLI do
|
4
|
-
describe
|
5
|
-
it
|
4
|
+
describe '#compile' do
|
5
|
+
it 'compiles the site' do
|
6
6
|
machined.should_receive(:compile)
|
7
|
-
Machined::Environment.should_receive(:new).with(:root =>
|
8
|
-
machined_cli
|
7
|
+
Machined::Environment.should_receive(:new).with(:root => '.', :output_path => 'public', :environment => 'production', :config_path => 'machined.rb').and_return(machined)
|
8
|
+
machined_cli 'compile -e production'
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
describe
|
13
|
-
it
|
12
|
+
describe '#new' do
|
13
|
+
it 'creates a machined site directory' do
|
14
14
|
within_construct do |c|
|
15
|
-
machined_cli
|
16
|
-
File.directory?(
|
15
|
+
machined_cli 'new my_site'
|
16
|
+
File.directory?('my_site').should be_true
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
20
|
+
it 'creates source directories' do
|
21
21
|
within_construct do |c|
|
22
|
-
machined_cli
|
23
|
-
File.directory?(
|
24
|
-
File.directory?(
|
25
|
-
File.directory?(
|
26
|
-
File.directory?(
|
27
|
-
File.directory?(
|
22
|
+
machined_cli 'new my_site'
|
23
|
+
File.directory?('my_site/pages').should be_true
|
24
|
+
File.directory?('my_site/views').should be_true
|
25
|
+
File.directory?('my_site/assets/images').should be_true
|
26
|
+
File.directory?('my_site/assets/javascripts').should be_true
|
27
|
+
File.directory?('my_site/assets/stylesheets').should be_true
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
it
|
31
|
+
it 'creates an output path' do
|
32
32
|
within_construct do |c|
|
33
|
-
machined_cli
|
34
|
-
File.directory?(
|
33
|
+
machined_cli 'new my_site'
|
34
|
+
File.directory?('my_site/public').should be_true
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
it
|
38
|
+
it 'creates an default index page' do
|
39
39
|
within_construct do |c|
|
40
|
-
machined_cli
|
41
|
-
File.read(
|
40
|
+
machined_cli 'new my_site'
|
41
|
+
File.read('my_site/pages/index.html.erb').should == <<-CONTENT.unindent
|
42
42
|
---
|
43
43
|
title: Home Page
|
44
44
|
---
|
@@ -50,15 +50,15 @@ describe Machined::CLI do
|
|
50
50
|
|
51
51
|
it 'creates a default layout' do
|
52
52
|
within_construct do |c|
|
53
|
-
machined_cli
|
54
|
-
File.read(
|
53
|
+
machined_cli 'new my_site'
|
54
|
+
File.read('my_site/views/layouts/application.html.erb').should == <<-CONTENT.unindent
|
55
55
|
<!doctype html>
|
56
56
|
<html>
|
57
57
|
<head lang="en">
|
58
58
|
<meta charset="utf-8">
|
59
59
|
<title><%= title %></title>
|
60
|
-
<%= stylesheet_link_tag
|
61
|
-
<%= javascript_include_tag
|
60
|
+
<%= stylesheet_link_tag 'application' %>
|
61
|
+
<%= javascript_include_tag 'application' %>
|
62
62
|
</head>
|
63
63
|
<body>
|
64
64
|
<%= yield %>
|
@@ -68,46 +68,46 @@ describe Machined::CLI do
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
it
|
71
|
+
it 'creates a default javascript file' do
|
72
72
|
within_construct do |c|
|
73
|
-
machined_cli
|
74
|
-
File.exist?(
|
73
|
+
machined_cli 'new my_site'
|
74
|
+
File.exist?('my_site/assets/javascripts/application.js.coffee').should be_true
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
-
it
|
78
|
+
it 'creates a default stylesheet file' do
|
79
79
|
within_construct do |c|
|
80
|
-
machined_cli
|
81
|
-
File.exist?(
|
80
|
+
machined_cli 'new my_site'
|
81
|
+
File.exist?('my_site/assets/stylesheets/application.css.scss').should be_true
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
-
it
|
85
|
+
it 'creates a default Gemfile' do
|
86
86
|
within_construct do |c|
|
87
|
-
machined_cli
|
88
|
-
File.read(
|
87
|
+
machined_cli 'new my_site'
|
88
|
+
File.read('my_site/Gemfile').should == <<-CONTENT.unindent
|
89
89
|
source :rubygems
|
90
90
|
|
91
|
-
gem
|
91
|
+
gem 'machined', '#{Machined::VERSION}'
|
92
92
|
|
93
|
-
gem
|
94
|
-
gem
|
93
|
+
gem 'sass', '~> 3.1'
|
94
|
+
gem 'coffee-script', '~> 2.2'
|
95
95
|
|
96
96
|
group :production do
|
97
|
-
gem
|
97
|
+
gem 'uglifier', '~> 1.0'
|
98
98
|
end
|
99
99
|
CONTENT
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
-
it
|
103
|
+
it 'creates a default config file' do
|
104
104
|
within_construct do |c|
|
105
|
-
machined_cli
|
106
|
-
File.read(
|
107
|
-
require
|
105
|
+
machined_cli 'new my_site'
|
106
|
+
File.read('my_site/machined.rb').should == <<-CONTENT.unindent
|
107
|
+
require 'bundler'
|
108
108
|
Bundler.require :default, config.environment.to_sym
|
109
109
|
|
110
|
-
if config.environment ==
|
110
|
+
if config.environment == 'production'
|
111
111
|
# Compress javascripts and stylesheets
|
112
112
|
config.compress = true
|
113
113
|
|
@@ -125,29 +125,29 @@ describe Machined::CLI do
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
-
it
|
128
|
+
it 'creates a default rackup file' do
|
129
129
|
within_construct do |c|
|
130
|
-
machined_cli
|
131
|
-
File.read(
|
132
|
-
require
|
130
|
+
machined_cli 'new my_site'
|
131
|
+
File.read('my_site/config.ru').should == <<-CONTENT.unindent
|
132
|
+
require 'machined'
|
133
133
|
run Machined::Environment.new
|
134
134
|
CONTENT
|
135
135
|
end
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
|
-
describe
|
140
|
-
it
|
139
|
+
describe '#server' do
|
140
|
+
it 'should start a Rack server' do
|
141
141
|
app = machined
|
142
|
-
Machined::Environment.should_receive(:new).with(:root =>
|
143
|
-
Rack::Server.should_receive(:start).with(hash_including(:app => app, :environment =>
|
144
|
-
machined_cli
|
142
|
+
Machined::Environment.should_receive(:new).with(:root => '.', :output_path => 'site', :environment => 'production', :config_path => 'machined.rb').and_return(app)
|
143
|
+
Rack::Server.should_receive(:start).with(hash_including(:app => app, :environment => 'production', :Port => 5000))
|
144
|
+
machined_cli 'server -o site -e production -p 5000'
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
|
-
describe
|
149
|
-
it
|
150
|
-
output = machined_cli
|
148
|
+
describe '#version' do
|
149
|
+
it 'prints out the current version number' do
|
150
|
+
output = machined_cli 'version'
|
151
151
|
output.strip.should == Machined::VERSION
|
152
152
|
end
|
153
153
|
end
|