zassets 0.2.3 → 0.2.4
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 +5 -5
- data/features/builder/build.feature +1 -1
- data/features/builder/manifest.feature +1 -1
- data/features/cli/default_action.feature +5 -0
- data/features/cli/usage.feature +1 -1
- data/features/config/file.feature +1 -1
- data/features/engines/coffee.feature +1 -1
- data/features/engines/sass.feature +1 -1
- data/features/step_definitions/builder_steps.rb +7 -1
- data/lib/zassets.rb +1 -1
- data/lib/zassets/{compiler.rb → builder.rb} +4 -4
- data/lib/zassets/cli.rb +32 -32
- data/lib/zassets/config.rb +2 -2
- data/lib/zassets/version.rb +1 -1
- data/spec/zassets/{compiler_spec.rb → builder_spec.rb} +15 -15
- data/spec/zassets/cli_spec.rb +81 -65
- data/spec/zassets/config_spec.rb +4 -4
- metadata +6 -5
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
z'assets - standalone asset pipeline
|
2
2
|
====================================
|
3
3
|
|
4
|
-
z'assets is a tool based on [Sprockets][] for serving and
|
4
|
+
z'assets is a tool based on [Sprockets][] for serving and building
|
5
5
|
web assets. When serving over HTTP (intended for a development
|
6
|
-
environment),
|
6
|
+
environment), transpilation through various preprocessors will happen on
|
7
7
|
the fly. For production environment all specified assets are built as
|
8
8
|
files in a directory tree similar to their sources, except filenames
|
9
9
|
will include a hash to help caching.
|
@@ -33,8 +33,8 @@ directory:
|
|
33
33
|
- 'assets/styles'
|
34
34
|
- 'assets/scripts'
|
35
35
|
public_path: 'public'
|
36
|
-
|
37
|
-
|
36
|
+
build_path: 'public/assets'
|
37
|
+
build:
|
38
38
|
- 'main.css'
|
39
39
|
|
40
40
|
Then you can launch development HTTP server with the following
|
@@ -44,7 +44,7 @@ command:
|
|
44
44
|
|
45
45
|
And build your assets:
|
46
46
|
|
47
|
-
zassets
|
47
|
+
zassets build
|
48
48
|
|
49
49
|
You can override some config options using command line arguments,
|
50
50
|
the complete list is printed on the standard output on
|
data/features/cli/usage.feature
CHANGED
@@ -4,7 +4,7 @@ end
|
|
4
4
|
|
5
5
|
|
6
6
|
When /^I build$/ do
|
7
|
-
run_simple 'zassets
|
7
|
+
run_simple 'zassets build'
|
8
8
|
end
|
9
9
|
|
10
10
|
|
@@ -33,3 +33,9 @@ Then /^the built file "([^"]*)" should match \/([^\/]*)\/$/ do |path, content|
|
|
33
33
|
IO.read(Dir[path].first).should =~ regexp
|
34
34
|
end
|
35
35
|
end
|
36
|
+
|
37
|
+
Then /^it should build$/ do
|
38
|
+
prep_for_fs_check do
|
39
|
+
File.exist?('public/assets/manifest.json').should be_true
|
40
|
+
end
|
41
|
+
end
|
data/lib/zassets.rb
CHANGED
@@ -3,7 +3,7 @@ require 'coffee_script'
|
|
3
3
|
|
4
4
|
module ZAssets
|
5
5
|
autoload :CLI, 'zassets/cli'
|
6
|
-
autoload :
|
6
|
+
autoload :Builder, 'zassets/builder'
|
7
7
|
autoload :Config, 'zassets/config'
|
8
8
|
autoload :MemoryFile, 'zassets/memory_file'
|
9
9
|
autoload :Server, 'zassets/server'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'sprockets'
|
2
2
|
|
3
3
|
module ZAssets
|
4
|
-
class
|
4
|
+
class Builder
|
5
5
|
MANIFEST_FILENAME = 'manifest.json'
|
6
6
|
|
7
7
|
attr_writer :manifest
|
@@ -10,8 +10,8 @@ module ZAssets
|
|
10
10
|
@config = config
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
manifest.compile(@config[:
|
13
|
+
def build
|
14
|
+
manifest.compile(@config[:build])
|
15
15
|
end
|
16
16
|
|
17
17
|
def manifest
|
@@ -19,7 +19,7 @@ module ZAssets
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def manifest_path
|
22
|
-
[@config[:
|
22
|
+
[@config[:build_path], MANIFEST_FILENAME].join '/'
|
23
23
|
end
|
24
24
|
|
25
25
|
def environment
|
data/lib/zassets/cli.rb
CHANGED
@@ -2,17 +2,44 @@ require 'optparse'
|
|
2
2
|
|
3
3
|
module ZAssets
|
4
4
|
class CLI
|
5
|
-
|
5
|
+
ACTIONS = %w(build serve)
|
6
|
+
|
7
|
+
attr_reader :options, :action
|
6
8
|
|
7
9
|
def initialize(args, stdout = $stdout)
|
8
10
|
@stdout = stdout
|
9
|
-
@
|
11
|
+
@action = :build
|
12
|
+
args_parse! args
|
13
|
+
end
|
14
|
+
|
15
|
+
def config
|
16
|
+
@config ||= Config.new @options
|
17
|
+
end
|
18
|
+
|
19
|
+
def run
|
20
|
+
case @action
|
21
|
+
when :serve
|
22
|
+
server.run
|
23
|
+
when :build
|
24
|
+
builder.build
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def builder
|
29
|
+
@builder ||= Builder.new config
|
30
|
+
end
|
31
|
+
|
32
|
+
def server
|
33
|
+
@server ||= Server.new config
|
10
34
|
end
|
11
35
|
|
36
|
+
|
37
|
+
private
|
38
|
+
|
12
39
|
def args_parse!(args)
|
13
40
|
options = {}
|
14
41
|
parser = OptionParser.new do |o|
|
15
|
-
o.banner = "Usage: #{File.basename $0} [options]
|
42
|
+
o.banner = "Usage: #{File.basename $0} [options] [build|serve]"
|
16
43
|
|
17
44
|
o.on '-v', '--verbose', 'Enable verbose mode' do |v|
|
18
45
|
options[:verbose] = v
|
@@ -53,35 +80,8 @@ module ZAssets
|
|
53
80
|
exit 64
|
54
81
|
end
|
55
82
|
|
56
|
-
|
57
|
-
|
58
|
-
else
|
59
|
-
@stdout.puts parser
|
60
|
-
exit 64
|
61
|
-
end
|
62
|
-
|
63
|
-
options
|
64
|
-
end
|
65
|
-
|
66
|
-
def config
|
67
|
-
@config ||= Config.new @options
|
68
|
-
end
|
69
|
-
|
70
|
-
def run
|
71
|
-
case config[:action]
|
72
|
-
when :serve
|
73
|
-
server.run
|
74
|
-
when :compile
|
75
|
-
compiler.compile
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def compiler
|
80
|
-
@compiler ||= Compiler.new config
|
81
|
-
end
|
82
|
-
|
83
|
-
def server
|
84
|
-
@server ||= Server.new config
|
83
|
+
@options = options
|
84
|
+
@action = args.last.to_sym if args.last && ACTIONS.include?(args.last)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
data/lib/zassets/config.rb
CHANGED
data/lib/zassets/version.rb
CHANGED
@@ -1,38 +1,38 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module ZAssets
|
4
|
-
describe
|
5
|
-
let(:config)
|
6
|
-
subject(:
|
4
|
+
describe Builder do
|
5
|
+
let(:config) { Config.new }
|
6
|
+
subject(:builder) { Builder.new(config) }
|
7
7
|
|
8
|
-
describe '#
|
8
|
+
describe '#build' do
|
9
9
|
it 'compiles the manifest' do
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
builder.manifest = double('manifest')
|
11
|
+
builder.manifest.should_receive :compile
|
12
|
+
builder.build
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
describe '#manifest' do
|
17
17
|
it 'builds a sprockets manifest' do
|
18
18
|
Sprockets::Manifest.should_receive(:new).with(
|
19
|
-
|
20
|
-
|
19
|
+
builder.environment,
|
20
|
+
builder.manifest_path
|
21
21
|
)
|
22
|
-
|
22
|
+
builder.manifest
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'returns the sprockets manifest' do
|
26
26
|
manifest = double('manifest')
|
27
27
|
Sprockets::Manifest.stub(:new) { manifest }
|
28
|
-
|
28
|
+
builder.manifest.should == manifest
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
describe '#manifest_path' do
|
33
33
|
it 'returns the manifest file path' do
|
34
|
-
|
35
|
-
config[:
|
34
|
+
builder.manifest_path.should == File.join(
|
35
|
+
config[:build_path],
|
36
36
|
'manifest.json'
|
37
37
|
)
|
38
38
|
end
|
@@ -41,13 +41,13 @@ module ZAssets
|
|
41
41
|
describe '#environment' do
|
42
42
|
it 'builds a sprockets env' do
|
43
43
|
SprocketsEnv.should_receive(:new).with(config)
|
44
|
-
|
44
|
+
builder.environment
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'returns the sprockets env' do
|
48
48
|
environment = double('environment')
|
49
49
|
SprocketsEnv.stub(:new) { environment }
|
50
|
-
|
50
|
+
builder.environment.should == environment
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
data/spec/zassets/cli_spec.rb
CHANGED
@@ -5,78 +5,94 @@ module ZAssets
|
|
5
5
|
let(:args) { ['serve'] }
|
6
6
|
subject(:cli) { CLI.new(args) }
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
context 'option arguments parsing ' do
|
15
|
-
def with_option(option, value = nil)
|
16
|
-
if value
|
17
|
-
CLI.new [option, value, *args]
|
18
|
-
else
|
19
|
-
CLI.new [option, *args]
|
8
|
+
describe '#initialize' do
|
9
|
+
context 'action arguments parsing' do
|
10
|
+
it 'parses the action' do
|
11
|
+
cli.action.should == :serve
|
20
12
|
end
|
21
|
-
end
|
22
13
|
|
23
|
-
|
24
|
-
|
25
|
-
end
|
14
|
+
context 'when action is not provided' do
|
15
|
+
let(:args) { [] }
|
26
16
|
|
27
|
-
|
28
|
-
|
17
|
+
it 'defaults to build' do
|
18
|
+
cli.action.should == :build
|
19
|
+
end
|
20
|
+
end
|
29
21
|
end
|
30
22
|
|
31
|
-
|
32
|
-
with_option(
|
33
|
-
|
23
|
+
context 'option arguments parsing ' do
|
24
|
+
def with_option(option, value = nil)
|
25
|
+
if value
|
26
|
+
CLI.new [option, value, *args]
|
27
|
+
else
|
28
|
+
CLI.new [option, *args]
|
29
|
+
end
|
30
|
+
end
|
34
31
|
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
it 'parses the -v option' do
|
33
|
+
with_option('-v').options[:verbose].should be_true
|
34
|
+
end
|
38
35
|
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
it 'parses the -c option' do
|
37
|
+
with_option('-c', 'config').options[:config_file].should == 'config'
|
38
|
+
end
|
42
39
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
subject(:cli) { CLI.new(args, output) }
|
40
|
+
it 'parses the -o option' do
|
41
|
+
with_option('-o', '::0').options[:host].should == '::0'
|
42
|
+
end
|
47
43
|
|
48
|
-
it '
|
49
|
-
|
50
|
-
cli
|
51
|
-
rescue SystemExit
|
52
|
-
end
|
53
|
-
output.string.should =~ /\AUsage: /
|
44
|
+
it 'parses the -p option' do
|
45
|
+
with_option('-p', '9393').options[:port].should == '9393'
|
54
46
|
end
|
55
47
|
|
56
|
-
it '
|
57
|
-
|
48
|
+
it 'parses the -s option' do
|
49
|
+
with_option('-s', 'thin').options[:server].should == 'thin'
|
58
50
|
end
|
59
|
-
end
|
60
51
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
52
|
+
context '-h option' do
|
53
|
+
let(:args) { ['-h'] }
|
54
|
+
let(:output) { StringIO.new }
|
55
|
+
subject(:cli) { CLI.new(args, output) }
|
56
|
+
|
57
|
+
it 'prints the usage help' do
|
58
|
+
begin
|
59
|
+
cli
|
60
|
+
rescue SystemExit
|
61
|
+
end
|
62
|
+
output.string.should =~ /\AUsage: /
|
63
|
+
end
|
65
64
|
|
66
|
-
|
67
|
-
|
68
|
-
cli
|
69
|
-
rescue SystemExit
|
65
|
+
it 'exits' do
|
66
|
+
lambda { cli }.should raise_error SystemExit
|
70
67
|
end
|
71
|
-
output.string.chomp.should == VERSION
|
72
68
|
end
|
73
69
|
|
74
|
-
|
75
|
-
|
70
|
+
context '-V option' do
|
71
|
+
let(:args) { ['-V'] }
|
72
|
+
let(:output) { StringIO.new }
|
73
|
+
subject(:cli) { CLI.new(args, output) }
|
74
|
+
|
75
|
+
it 'prints the version' do
|
76
|
+
begin
|
77
|
+
cli
|
78
|
+
rescue SystemExit
|
79
|
+
end
|
80
|
+
output.string.chomp.should == VERSION
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'exits' do
|
84
|
+
lambda { cli }.should raise_error SystemExit
|
85
|
+
end
|
76
86
|
end
|
77
87
|
end
|
78
88
|
end
|
79
89
|
|
90
|
+
describe '#action' do
|
91
|
+
it 'return the current action' do
|
92
|
+
cli.action.should == args.last.to_sym
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
80
96
|
describe '#config' do
|
81
97
|
it 'builds a config' do
|
82
98
|
Config.should_receive(:new).with(cli.options)
|
@@ -100,28 +116,28 @@ module ZAssets
|
|
100
116
|
end
|
101
117
|
end
|
102
118
|
|
103
|
-
context '
|
104
|
-
let(:args) { ['
|
119
|
+
context 'build action' do
|
120
|
+
let(:args) { ['build'] }
|
105
121
|
|
106
|
-
it 'runs the
|
107
|
-
|
108
|
-
cli.stub(:
|
109
|
-
|
122
|
+
it 'runs the builder' do
|
123
|
+
builder = double('builder')
|
124
|
+
cli.stub(:builder) { builder }
|
125
|
+
builder.should_receive :build
|
110
126
|
cli.run
|
111
127
|
end
|
112
128
|
end
|
113
129
|
end
|
114
130
|
|
115
|
-
describe '#
|
116
|
-
it 'builds a
|
117
|
-
|
118
|
-
cli.
|
131
|
+
describe '#builder' do
|
132
|
+
it 'builds a builder' do
|
133
|
+
Builder.should_receive(:new).with(cli.config)
|
134
|
+
cli.builder
|
119
135
|
end
|
120
136
|
|
121
|
-
it 'returns the
|
122
|
-
|
123
|
-
|
124
|
-
cli.
|
137
|
+
it 'returns the builder' do
|
138
|
+
builder = double('builder')
|
139
|
+
Builder.stub(:new) { builder }
|
140
|
+
cli.builder.should == builder
|
125
141
|
end
|
126
142
|
end
|
127
143
|
|
data/spec/zassets/config_spec.rb
CHANGED
@@ -67,12 +67,12 @@ module ZAssets
|
|
67
67
|
config.default_options[:public_path].should == 'public'
|
68
68
|
end
|
69
69
|
|
70
|
-
it 'sets
|
71
|
-
config.default_options[:
|
70
|
+
it 'sets build_path to public/assets directory' do
|
71
|
+
config.default_options[:build_path].should == 'public/assets'
|
72
72
|
end
|
73
73
|
|
74
|
-
it 'sets
|
75
|
-
config.default_options[:
|
74
|
+
it 'sets build empty' do
|
75
|
+
config.default_options[:build].should == []
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zassets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -189,6 +189,7 @@ files:
|
|
189
189
|
- bin/zassets
|
190
190
|
- features/builder/build.feature
|
191
191
|
- features/builder/manifest.feature
|
192
|
+
- features/cli/default_action.feature
|
192
193
|
- features/cli/usage.feature
|
193
194
|
- features/cli/version.feature
|
194
195
|
- features/config/file.feature
|
@@ -208,8 +209,8 @@ files:
|
|
208
209
|
- features/support/env_cucumber-doc_string.rb
|
209
210
|
- features/support/env_server.rb
|
210
211
|
- lib/zassets.rb
|
212
|
+
- lib/zassets/builder.rb
|
211
213
|
- lib/zassets/cli.rb
|
212
|
-
- lib/zassets/compiler.rb
|
213
214
|
- lib/zassets/config.rb
|
214
215
|
- lib/zassets/exceptions.rb
|
215
216
|
- lib/zassets/memory_file.rb
|
@@ -223,8 +224,8 @@ files:
|
|
223
224
|
- spec/spec_helper.rb
|
224
225
|
- spec/support/fixtures_helpers.rb
|
225
226
|
- spec/zassets-plugins-dummy.rb
|
227
|
+
- spec/zassets/builder_spec.rb
|
226
228
|
- spec/zassets/cli_spec.rb
|
227
|
-
- spec/zassets/compiler_spec.rb
|
228
229
|
- spec/zassets/config_spec.rb
|
229
230
|
- spec/zassets/memory_file_spec.rb
|
230
231
|
- spec/zassets/server_spec.rb
|
@@ -253,7 +254,7 @@ rubyforge_project:
|
|
253
254
|
rubygems_version: 1.8.23
|
254
255
|
signing_key:
|
255
256
|
specification_version: 3
|
256
|
-
summary: zassets-0.2.
|
257
|
+
summary: zassets-0.2.4
|
257
258
|
test_files:
|
258
259
|
- spec/fixtures/assets/app.js
|
259
260
|
- spec/fixtures/config/zassets.yaml
|
@@ -262,8 +263,8 @@ test_files:
|
|
262
263
|
- spec/spec_helper.rb
|
263
264
|
- spec/support/fixtures_helpers.rb
|
264
265
|
- spec/zassets-plugins-dummy.rb
|
266
|
+
- spec/zassets/builder_spec.rb
|
265
267
|
- spec/zassets/cli_spec.rb
|
266
|
-
- spec/zassets/compiler_spec.rb
|
267
268
|
- spec/zassets/config_spec.rb
|
268
269
|
- spec/zassets/memory_file_spec.rb
|
269
270
|
- spec/zassets/server_spec.rb
|