awestruct 0.5.3 → 0.5.4.beta1
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/lib/awestruct/cli/init.rb +35 -34
- data/lib/awestruct/cli/invoker.rb +4 -4
- data/lib/awestruct/cli/manifest.rb +57 -55
- data/lib/awestruct/cli/options.rb +11 -0
- data/lib/awestruct/config.rb +17 -14
- data/lib/awestruct/deploy/base_deploy.rb +13 -7
- data/lib/awestruct/deploy/github_pages_deploy.rb +14 -9
- data/lib/awestruct/engine.rb +17 -12
- data/lib/awestruct/extensions/intense_debate.rb +1 -1
- data/lib/awestruct/extensions/minify.rb +1 -1
- data/lib/awestruct/extensions/pipeline.rb +2 -2
- data/lib/awestruct/extensions/relative.rb +7 -1
- data/lib/awestruct/frameworks/base_Gemfile +5 -1
- data/lib/awestruct/frameworks/bootstrap/base_layout.html.haml +2 -2
- data/lib/awestruct/handler_chains.rb +2 -2
- data/lib/awestruct/handlers/asciidoctor_handler.rb +22 -4
- data/lib/awestruct/handlers/base_tilt_handler.rb +34 -10
- data/lib/awestruct/handlers/file_handler.rb +8 -12
- data/lib/awestruct/handlers/front_matter_handler.rb +1 -1
- data/lib/awestruct/handlers/interpolation_handler.rb +1 -6
- data/lib/awestruct/handlers/tilt_handler.rb +1 -7
- data/lib/awestruct/handlers/verbatim_file_handler.rb +12 -0
- data/lib/awestruct/scm/git.rb +14 -0
- data/lib/awestruct/version.rb +1 -1
- data/man/awestruct.1 +14 -3
- data/spec/asciidoc_handler_spec.rb +43 -40
- data/spec/awestruct/scm/git_spec.rb +29 -0
- data/spec/config_spec.rb +8 -2
- data/spec/engine_spec.rb +31 -9
- data/spec/erb_handler_spec.rb +33 -31
- data/spec/front_matter_handler_spec.rb +17 -6
- data/spec/github_pages_deploy_spec.rb +13 -7
- data/spec/haml_handler_spec.rb +62 -59
- data/spec/interpolation_handler_spec.rb +4 -8
- data/spec/javascript_handler_spec.rb +16 -13
- data/spec/minify_spec.rb +3 -1
- data/spec/mustache_handler_spec.rb +11 -7
- data/spec/options_spec.rb +20 -11
- data/spec/page_loader_spec.rb +3 -1
- data/spec/page_loader_spec_for_layouts.rb +3 -1
- data/spec/redirect_handler_spec.rb +21 -17
- data/spec/slim_handler_spec.rb +51 -49
- data/spec/support/shared_handler_example.rb +12 -8
- data/spec/test-data/front-matter-file-utf8.txt +5 -0
- data/spec/test-data/handlers/haml-error.html.haml +4 -0
- data/spec/test-data/handlers/hello.bogus +1 -0
- data/spec/tilt_handler_spec.rb +70 -3
- metadata +16 -25
data/lib/awestruct/cli/init.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'awestruct/cli/manifest'
|
2
|
+
require 'awestruct/cli/options'
|
2
3
|
require 'sass'
|
3
4
|
require 'sass/plugin'
|
4
5
|
|
@@ -11,61 +12,61 @@ module Awestruct
|
|
11
12
|
end
|
12
13
|
|
13
14
|
BASE_MANIFEST = Manifest.new {
|
14
|
-
mkdir(
|
15
|
-
mkdir(
|
16
|
-
mkdir(
|
17
|
-
copy_file(
|
18
|
-
copy_file(
|
19
|
-
copy_file(
|
20
|
-
copy_file(
|
21
|
-
mkdir(
|
15
|
+
mkdir('_config')
|
16
|
+
mkdir('_layouts')
|
17
|
+
mkdir('_ext')
|
18
|
+
copy_file('_ext/pipeline.rb', Init.framework_path('base_pipeline.rb'))
|
19
|
+
copy_file('.awestruct_ignore', Init.framework_path('base_awestruct_ignore'))
|
20
|
+
copy_file('Rakefile', Init.framework_path('base_Rakefile'))
|
21
|
+
copy_file('Gemfile', Init.framework_path('base_Gemfile'))
|
22
|
+
mkdir('stylesheets')
|
22
23
|
}
|
23
24
|
|
24
|
-
def initialize(
|
25
|
-
@dir
|
25
|
+
def initialize(opts = Awestruct::CLI::Options.new, framework = 'compass', scaffold = true)
|
26
|
+
@dir = dir
|
26
27
|
@framework = framework
|
27
|
-
@scaffold
|
28
|
+
@scaffold = scaffold
|
28
29
|
end
|
29
30
|
|
30
31
|
def run()
|
31
|
-
manifest = Manifest.new(
|
32
|
+
manifest = Manifest.new(BASE_MANIFEST)
|
32
33
|
scaffold_name = @framework
|
33
34
|
lib = nil
|
34
35
|
case @framework
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
36
|
+
when 'compass'
|
37
|
+
scaffold_name = 'blueprint'
|
38
|
+
when 'bootstrap'
|
39
|
+
lib = 'bootstrap-sass'
|
40
|
+
when 'foundation'
|
41
|
+
lib = 'zurb-foundation'
|
42
|
+
when '960'
|
43
|
+
lib = 'ninesixty'
|
43
44
|
end
|
44
45
|
require lib unless lib.nil?
|
45
|
-
manifest.install_compass(
|
46
|
-
if (
|
47
|
-
manifest.copy_file(
|
48
|
-
manifest.copy_file(
|
49
|
-
base_index = framework_path(
|
46
|
+
manifest.install_compass(@framework)
|
47
|
+
if (@scaffold)
|
48
|
+
manifest.copy_file('_config/site.yml', framework_path('base_site.yml'), :overwrite => true)
|
49
|
+
manifest.copy_file('_layouts/base.html.haml', framework_path('base_layout.html.haml', scaffold_name))
|
50
|
+
base_index = framework_path('base_index.html.haml', scaffold_name)
|
50
51
|
if File.file? base_index
|
51
|
-
manifest.copy_file(
|
52
|
+
manifest.copy_file('index.html.haml', base_index)
|
52
53
|
else
|
53
|
-
manifest.copy_file(
|
54
|
+
manifest.copy_file('index.html.haml', framework_path('base_index.html.haml'))
|
54
55
|
end
|
55
56
|
|
56
|
-
humans_txt = framework_path(
|
57
|
+
humans_txt = framework_path('humans.txt')
|
57
58
|
if File.file? humans_txt
|
58
|
-
manifest.copy_file(
|
59
|
+
manifest.copy_file('humans.txt', humans_txt, :overwrite => true)
|
59
60
|
end
|
60
61
|
|
61
|
-
manifest.touch_file(
|
62
|
-
manifest.add_requires(
|
62
|
+
manifest.touch_file('_config/site.yml')
|
63
|
+
manifest.add_requires('_ext/pipeline.rb', [lib]) unless lib.nil?
|
63
64
|
if scaffold_name == 'foundation'
|
64
|
-
manifest.remove_file(
|
65
|
-
manifest.remove_file(
|
65
|
+
manifest.remove_file('index.html')
|
66
|
+
manifest.remove_file('MIT-LICENSE.txt')
|
66
67
|
end
|
67
68
|
end
|
68
|
-
manifest.perform(
|
69
|
+
manifest.perform(@dir)
|
69
70
|
end
|
70
71
|
|
71
72
|
def framework_path(path, framework = nil)
|
@@ -82,13 +82,13 @@ module Awestruct
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def setup_config()
|
85
|
-
@config = Awestruct::Config.new(
|
86
|
-
@config.track_dependencies = true if ( options.auto )
|
87
|
-
@config.verbose = true if ( options.verbose )
|
85
|
+
@config = Awestruct::Config.new( @options )
|
86
|
+
@config.track_dependencies = true if ( @options.auto )
|
87
|
+
@config.verbose = true if ( @options.verbose )
|
88
88
|
end
|
89
89
|
|
90
90
|
def invoke_init()
|
91
|
-
Awestruct::CLI::Init.new( Dir.pwd, options.framework, options.scaffold ).run
|
91
|
+
Awestruct::CLI::Init.new( Dir.pwd, @options.framework, @options.scaffold ).run
|
92
92
|
end
|
93
93
|
|
94
94
|
def invoke_script()
|
@@ -15,6 +15,7 @@ class Compass::AppIntegration::StandAlone::Installer
|
|
15
15
|
def write_configuration_files(config_file = nil)
|
16
16
|
# no!
|
17
17
|
end
|
18
|
+
|
18
19
|
def finalize(opts={})
|
19
20
|
$LOG.info <<-END.gsub(/^ {6}/, '')
|
20
21
|
|
@@ -35,25 +36,26 @@ end
|
|
35
36
|
|
36
37
|
module Awestruct
|
37
38
|
module CLI
|
39
|
+
#noinspection RubyResolve
|
38
40
|
class Manifest
|
39
41
|
|
40
42
|
attr_reader :parent
|
41
43
|
attr_reader :steps
|
42
44
|
|
43
|
-
def initialize(parent=nil
|
45
|
+
def initialize(parent=nil, &block)
|
44
46
|
@parent = parent
|
45
47
|
@steps = []
|
46
48
|
instance_eval &block if block
|
47
49
|
end
|
48
50
|
|
49
51
|
def mkdir(path)
|
50
|
-
steps << MkDir.new(
|
52
|
+
steps << MkDir.new(path)
|
51
53
|
end
|
52
54
|
|
53
55
|
def copy_file(path, input_path, opts = {})
|
54
|
-
steps << CopyFile.new(
|
56
|
+
steps << CopyFile.new(path, input_path, opts)
|
55
57
|
end
|
56
|
-
|
58
|
+
|
57
59
|
def touch_file(path)
|
58
60
|
steps << TouchFile.new(path)
|
59
61
|
end
|
@@ -74,7 +76,7 @@ module Awestruct
|
|
74
76
|
parent.perform(dir) if parent
|
75
77
|
steps.each do |step|
|
76
78
|
begin
|
77
|
-
step.perform(
|
79
|
+
step.perform(dir)
|
78
80
|
rescue => e
|
79
81
|
$LOG.error e if $LOG.error?
|
80
82
|
$LOG.error e.backtrace.join("\n") if $LOG.error?
|
@@ -85,7 +87,7 @@ module Awestruct
|
|
85
87
|
def unperform(dir)
|
86
88
|
steps.each do |step|
|
87
89
|
begin
|
88
|
-
step.unperform(
|
90
|
+
step.unperform(dir)
|
89
91
|
rescue => e
|
90
92
|
$LOG.error e if $LOG.error?
|
91
93
|
$LOG.error e.backtrace.join("\n") if $LOG.error?
|
@@ -104,47 +106,47 @@ module Awestruct
|
|
104
106
|
end
|
105
107
|
|
106
108
|
def perform(dir)
|
107
|
-
p = File.join(
|
108
|
-
if
|
109
|
+
p = File.join(dir, @path)
|
110
|
+
if File.exist?(p)
|
109
111
|
$LOG.error "Exists: #{p}" if $LOG.error?
|
110
112
|
return
|
111
113
|
end
|
112
|
-
|
114
|
+
unless File.directory?(File.dirname(p))
|
113
115
|
$LOG.error "Does not exist: #{File.dirname(p)}" if $LOG.error?
|
114
116
|
return
|
115
117
|
end
|
116
118
|
$LOG.info "Create directory: #{p}" if $LOG.info?
|
117
|
-
FileUtils.mkdir(
|
119
|
+
FileUtils.mkdir(p)
|
118
120
|
end
|
119
121
|
|
120
122
|
def unperform(dir)
|
121
|
-
p = File.join(
|
122
|
-
|
123
|
+
p = File.join(dir, @path)
|
124
|
+
unless File.exist?(p)
|
123
125
|
$LOG.error "Does not exist: #{p}" if $LOG.error?
|
124
126
|
return
|
125
127
|
end
|
126
|
-
|
128
|
+
unless File.directory?(p)
|
127
129
|
$LOG.error "Not a directory: #{p}" if $LOG.error?
|
128
130
|
return
|
129
131
|
end
|
130
|
-
if
|
132
|
+
if Dir.entries(p) != 2
|
131
133
|
$LOG.error "Not empty: #{p}" if $LOG.error?
|
132
134
|
return
|
133
135
|
end
|
134
136
|
$LOG.info "Remove: #{p}" if $LOG.info?
|
135
|
-
FileUtils.rmdir(
|
137
|
+
FileUtils.rmdir(p)
|
136
138
|
end
|
137
139
|
end
|
138
|
-
|
140
|
+
|
139
141
|
class TouchFile
|
140
142
|
def initialize(path)
|
141
143
|
@path = path
|
142
144
|
end
|
143
|
-
|
145
|
+
|
144
146
|
def perform(dir)
|
145
147
|
FileUtils.touch(File.join(dir, @path))
|
146
148
|
end
|
147
|
-
|
149
|
+
|
148
150
|
def unperform(dir)
|
149
151
|
#nothing
|
150
152
|
end
|
@@ -154,16 +156,16 @@ module Awestruct
|
|
154
156
|
def initialize(path)
|
155
157
|
@path = path
|
156
158
|
end
|
157
|
-
|
159
|
+
|
158
160
|
def perform(dir)
|
159
|
-
FileUtils.rm(
|
161
|
+
FileUtils.rm(File.join(dir, @path), :force => true)
|
160
162
|
end
|
161
|
-
|
163
|
+
|
162
164
|
def unperform(dir)
|
163
165
|
#nothing
|
164
166
|
end
|
165
167
|
end
|
166
|
-
|
168
|
+
|
167
169
|
# Adds a requires for each library in libs to the
|
168
170
|
# top of the file specified by path
|
169
171
|
class AddRequires
|
@@ -171,20 +173,20 @@ module Awestruct
|
|
171
173
|
@path = path
|
172
174
|
@libs = libs
|
173
175
|
end
|
174
|
-
|
176
|
+
|
175
177
|
def perform(dir)
|
176
178
|
file = File.join(dir, @path)
|
177
|
-
File.
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
new.write old.read
|
179
|
+
old_lines = File.read file
|
180
|
+
FileUtils.rm(file)
|
181
|
+
|
182
|
+
File.open(file, 'w') do |new|
|
183
|
+
@libs.each do |lib|
|
184
|
+
new.write "require '#{lib}'\n"
|
184
185
|
end
|
186
|
+
new.write old_lines
|
185
187
|
end
|
186
188
|
end
|
187
|
-
|
189
|
+
|
188
190
|
def unperform(dir)
|
189
191
|
#nothing
|
190
192
|
end
|
@@ -192,23 +194,23 @@ module Awestruct
|
|
192
194
|
|
193
195
|
class CopyFile
|
194
196
|
def initialize(path, input_path, opts = {})
|
195
|
-
@path
|
197
|
+
@path = path
|
196
198
|
@input_path = input_path
|
197
|
-
@overwrite
|
199
|
+
@overwrite = opts[:overwrite]
|
198
200
|
end
|
199
201
|
|
200
|
-
def perform(dir
|
201
|
-
p = File.join(
|
202
|
-
if !@overwrite && File.exist?(
|
202
|
+
def perform(dir)
|
203
|
+
p = File.join(dir, @path)
|
204
|
+
if !@overwrite && File.exist?(p)
|
203
205
|
$LOG.error "Exists: #{p}" if $LOG.error?
|
204
206
|
return
|
205
207
|
end
|
206
|
-
|
207
|
-
$LOG.error "No directory: #{File.dirname(
|
208
|
+
unless File.directory?(File.dirname(p))
|
209
|
+
$LOG.error "No directory: #{File.dirname(p)}" if $LOG.error?
|
208
210
|
return
|
209
211
|
end
|
210
212
|
$LOG.info "Create file: #{p}" if $LOG.info?
|
211
|
-
File.open(
|
213
|
+
File.open(p, 'w') { |f| f.write(File.read(@input_path)) }
|
212
214
|
end
|
213
215
|
|
214
216
|
def unperform(dir)
|
@@ -216,13 +218,13 @@ module Awestruct
|
|
216
218
|
end
|
217
219
|
|
218
220
|
def notunperform(dir)
|
219
|
-
p = File.join(
|
220
|
-
|
221
|
+
p = File.join(@dir, p)
|
222
|
+
unless File.exist?(p)
|
221
223
|
$LOG.error "Does not exist: #{p}" if $LOG.error?
|
222
224
|
return
|
223
225
|
end
|
224
226
|
$LOG.info "Remove: #{p}" if $LOG.info?
|
225
|
-
FileUtils.rm(
|
227
|
+
FileUtils.rm(p)
|
226
228
|
end
|
227
229
|
|
228
230
|
end
|
@@ -233,19 +235,19 @@ module Awestruct
|
|
233
235
|
end
|
234
236
|
|
235
237
|
def perform(dir)
|
236
|
-
Compass.configuration.sass_dir
|
237
|
-
Compass.configuration.css_dir
|
238
|
-
Compass.configuration.images_dir
|
239
|
-
|
240
|
-
cmd = Compass::Commands::CreateProject.new(
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
238
|
+
Compass.configuration.sass_dir = 'stylesheets'
|
239
|
+
Compass.configuration.css_dir = '_site/stylesheets'
|
240
|
+
Compass.configuration.images_dir = 'images'
|
241
|
+
|
242
|
+
cmd = Compass::Commands::CreateProject.new(dir, {
|
243
|
+
:framework => @framework,
|
244
|
+
:project_type => :stand_alone,
|
245
|
+
:css_dir => '_site/stylesheets',
|
246
|
+
:sass_dir => 'stylesheets',
|
247
|
+
:images_dir => 'images',
|
248
|
+
:fonts_dir => 'fonts',
|
249
|
+
:javascripts_dir => 'javascripts',
|
250
|
+
})
|
249
251
|
cmd.perform
|
250
252
|
end
|
251
253
|
|
@@ -21,6 +21,8 @@ module Awestruct
|
|
21
21
|
attr_accessor :deploy
|
22
22
|
attr_accessor :script
|
23
23
|
attr_accessor :verbose
|
24
|
+
attr_accessor :source_dir
|
25
|
+
attr_accessor :output_dir
|
24
26
|
|
25
27
|
def initialize()
|
26
28
|
@generate = nil
|
@@ -37,6 +39,8 @@ module Awestruct
|
|
37
39
|
@deploy = false
|
38
40
|
@script = nil
|
39
41
|
@verbose = false
|
42
|
+
@source_dir = Dir.pwd
|
43
|
+
@output_dir = File.expand_path '_site'
|
40
44
|
end
|
41
45
|
|
42
46
|
def self.parse!(args)
|
@@ -98,6 +102,13 @@ module Awestruct
|
|
98
102
|
#opts.on( '--run SCRIPT', 'Invoke a script after initialization' ) do |script|
|
99
103
|
# self.script = script
|
100
104
|
#end
|
105
|
+
opts.on( '--source-dir DIR', 'Location of sources (default: .' ) do |source_dir|
|
106
|
+
self.source_dir = File.expand_path source_dir
|
107
|
+
end
|
108
|
+
|
109
|
+
opts.on( '--output-dir DIR', 'Location to output generated site (default: _site' ) do |output_dir|
|
110
|
+
self.output_dir = File.expand_path output_dir
|
111
|
+
end
|
101
112
|
|
102
113
|
opts.separator ''
|
103
114
|
opts.separator "Common options:"
|
data/lib/awestruct/config.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'awestruct/cli/options'
|
1
2
|
|
2
3
|
module Awestruct
|
3
4
|
|
@@ -18,22 +19,24 @@ module Awestruct
|
|
18
19
|
attr_accessor :stylesheets_dir
|
19
20
|
|
20
21
|
attr_accessor :verbose
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@
|
31
|
-
|
32
|
-
|
33
|
-
@
|
22
|
+
attr_accessor :options
|
23
|
+
|
24
|
+
def initialize(opts = Awestruct::CLI::Options.new)
|
25
|
+
@dir = Pathname.new( opts.source_dir )
|
26
|
+
@layouts_dir = Pathname.new( File.join(@dir, '_layouts') )
|
27
|
+
@config_dir = Pathname.new( File.join(@dir, '_config') )
|
28
|
+
@input_dir = Pathname.new( File.join(@dir, '') )
|
29
|
+
@output_dir = Pathname.new( opts.output_dir )
|
30
|
+
@extension_dir = Pathname.new( File.join(@dir, '_ext') )
|
31
|
+
@skin_dir = Pathname.new( File.join(@dir, '_skin') )
|
32
|
+
@tmp_dir = Pathname.new( File.join(@dir, '_tmp') )
|
33
|
+
|
34
|
+
@images_dir = Pathname.new( File.join(@dir, 'images') )
|
35
|
+
@stylesheets_dir = Pathname.new( File.join(@dir, 'stylesheets') )
|
36
|
+
@options = opts
|
34
37
|
|
35
38
|
# Dir[] doesn't like empty list
|
36
|
-
ignore_file = File.join(dir, ".awestruct_ignore")
|
39
|
+
ignore_file = File.join(@dir, ".awestruct_ignore")
|
37
40
|
if File.exists?(ignore_file)
|
38
41
|
ignore_stmts = IO.read(ignore_file).each_line.map(&:strip)
|
39
42
|
end
|
@@ -1,22 +1,28 @@
|
|
1
1
|
require 'awestruct/deployers'
|
2
|
-
|
2
|
+
Dir[ File.join( File.dirname(__FILE__), '..', 'scm' '*.rb' ) ].each do |f|
|
3
|
+
begin
|
4
|
+
require f
|
5
|
+
rescue LoadError => e
|
6
|
+
raise e 'Something horribly, horribly wrong has happened'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
3
10
|
|
4
11
|
module Awestruct
|
5
12
|
module Deploy
|
6
13
|
class Base
|
7
|
-
UNCOMMITTED_CHANGES =
|
14
|
+
UNCOMMITTED_CHANGES = 'You have uncommitted changes in the working branch. Please commit or stash them.'
|
8
15
|
def run(deploy_config)
|
9
16
|
if deploy_config['uncommitted'] == true
|
10
17
|
publish_site
|
11
18
|
else
|
12
|
-
|
19
|
+
scm = deploy_config['scm'] || 'git'
|
20
|
+
#require "awestruct/scm/#{scm}"
|
21
|
+
scm_class = Object.const_get('Awestruct').const_get('Scm').const_get(scm.slice(0, 1).capitalize + scm.slice(1..-1))
|
22
|
+
scm_class.new.uncommitted_changes?(deploy_config['source_dir']) ? existing_changes() : publish_site()
|
13
23
|
end
|
14
24
|
end
|
15
25
|
|
16
|
-
def git
|
17
|
-
@git ||= ::Git.open('.')
|
18
|
-
end
|
19
|
-
|
20
26
|
def publish_site
|
21
27
|
$LOG.error( "#{self.class.name}#publish_site not implemented." ) if $LOG.error?
|
22
28
|
end
|