contao 0.4.2 → 0.5.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/contao.gemspec +2 -8
- data/lib/contao.rb +1 -54
- data/lib/contao/application.rb +13 -23
- data/lib/contao/commands/help.rb +1 -1
- data/lib/contao/generators/base.rb +1 -3
- data/lib/contao/notifier.rb +3 -3
- data/lib/contao/railtie.rb +11 -0
- data/lib/contao/ui.rb +219 -0
- data/lib/contao/version.rb +1 -1
- data/lib/{contao/tasks → tasks}/contao.rake +18 -19
- data/lib/{contao/tasks → tasks}/whitespace.rake +0 -0
- data/spec/lib/contao/application_spec.rb +6 -8
- data/spec/lib/contao/notifier_spec.rb +15 -15
- data/spec/spec_helper.rb +6 -14
- data/spec/support/filesystem_mock.rb +40 -11
- data/spec/support/stub_rails.rb +29 -0
- metadata +12 -128
- data/lib/contao/coffeescript_compiler.rb +0 -58
- data/lib/contao/compiler.rb +0 -128
- data/lib/contao/javascript_compiler.rb +0 -77
- data/lib/contao/stylesheet_compiler.rb +0 -56
- data/lib/contao/tasks/assets.rake +0 -22
- data/lib/contao/tasks/jasmine.rake +0 -8
- data/lib/guard/assets.rb +0 -117
- data/lib/monkey_patches.rb +0 -1
- data/lib/monkey_patches/compass/urls.rb +0 -81
- data/spec/lib/contao/coffeescript_compiler_spec.rb +0 -85
- data/spec/lib/contao/javascript_compiler_spec.rb +0 -91
- data/spec/lib/contao/stylesheet_compiler_spec.rb +0 -117
- data/spec/lib/contao_spec.rb +0 -62
- data/spec/lib/guard/assets_spec.rb +0 -220
- data/spec/support/compiler_shared_examples.rb +0 -292
- data/spec/support/config_shared_examples.rb +0 -29
@@ -1,292 +0,0 @@
|
|
1
|
-
shared_examples_for "Compiler" do
|
2
|
-
describe "attributes" do
|
3
|
-
it "should have :options as attr_accessor" do
|
4
|
-
subject.should respond_to(:options)
|
5
|
-
subject.should respond_to(:options=)
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "init" do
|
10
|
-
it "should set options" do
|
11
|
-
subject.class.new(foo: :bar).options[:foo].should == :bar
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should set the manifest_path as an instance variable" do
|
15
|
-
subject.instance_variable_get(:@manifest_path).should ==
|
16
|
-
Pathname('/root/my_awesome_project/public/resources/manifest.json')
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "#compile" do
|
21
|
-
before :each do
|
22
|
-
subject.class.any_instance.stub(:prepare_folders)
|
23
|
-
subject.class.any_instance.stub(:compile_assets)
|
24
|
-
subject.class.any_instance.stub(:create_hashed_assets)
|
25
|
-
subject.class.any_instance.stub(:generate_manifest)
|
26
|
-
subject.class.any_instance.stub(:notify)
|
27
|
-
end
|
28
|
-
|
29
|
-
it {should respond_to :compile}
|
30
|
-
|
31
|
-
it "should be accessible at class level" do
|
32
|
-
subject.class.any_instance.should_receive(:compile).once
|
33
|
-
subject.class.compile
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should return self" do
|
37
|
-
subject.compile.should == subject
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should have the following call stack for development" do
|
41
|
-
subject.should_receive(:prepare_folders).once.ordered
|
42
|
-
subject.should_receive(:compile_assets).once.ordered
|
43
|
-
subject.should_receive(:generate_manifest).once.ordered
|
44
|
-
subject.should_receive(:notify).once.ordered
|
45
|
-
|
46
|
-
subject.compile
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should have the following call stack for production" do
|
50
|
-
TechnoGate::Contao.env = :production
|
51
|
-
subject.should_receive(:prepare_folders).once.ordered
|
52
|
-
subject.should_receive(:compile_assets).once.ordered
|
53
|
-
subject.should_receive(:create_hashed_assets).once.ordered
|
54
|
-
subject.should_receive(:notify).once.ordered
|
55
|
-
|
56
|
-
subject.compile
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "#clean", :fakefs do
|
61
|
-
it {should respond_to :clean}
|
62
|
-
|
63
|
-
it "should be accessible at class level" do
|
64
|
-
subject.class.any_instance.should_receive(:clean).once
|
65
|
-
subject.class.clean
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should remove the entire assets_public_path" do
|
69
|
-
stub_filesystem!
|
70
|
-
File.directory?("/root/my_awesome_project/public/resources").should be_true
|
71
|
-
subject.clean
|
72
|
-
File.directory?("/root/my_awesome_project/public/resources").should be_false
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe '#input_from_config_path' do
|
77
|
-
it {should respond_to :input_from_config_path}
|
78
|
-
end
|
79
|
-
|
80
|
-
describe '#output_from_config_path' do
|
81
|
-
it {should respond_to :output_from_config_path}
|
82
|
-
end
|
83
|
-
|
84
|
-
describe '#input_from_options' do
|
85
|
-
it {should respond_to :input_from_options}
|
86
|
-
end
|
87
|
-
|
88
|
-
describe '#output_from_options' do
|
89
|
-
it {should respond_to :output_from_options}
|
90
|
-
end
|
91
|
-
|
92
|
-
describe '#input_path' do
|
93
|
-
it {should respond_to :input_path}
|
94
|
-
|
95
|
-
it "should return whatever in input_from_config_path" do
|
96
|
-
mock('input').tap do |path|
|
97
|
-
subject.stub(:input_from_config_path).and_return path
|
98
|
-
|
99
|
-
subject.send(:input_path).should == path
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should return whatever in input_from_options" do
|
104
|
-
mock('input').tap do |path|
|
105
|
-
subject.stub(:input_from_options).and_return path
|
106
|
-
|
107
|
-
subject.send(:input_path).should == path
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
it "should prefer options over config" do
|
112
|
-
{options: mock('options'), config: mock('config')}.tap do |mocks|
|
113
|
-
subject.stub(:input_from_config_path).and_return mocks[:config]
|
114
|
-
subject.stub(:input_from_options).and_return mocks[:options]
|
115
|
-
|
116
|
-
subject.send(:input_path).should == mocks[:options]
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
describe '#output_path' do
|
122
|
-
it {should respond_to :output_path}
|
123
|
-
|
124
|
-
it "should return whatever in output_from_config_path" do
|
125
|
-
mock('output').tap do |path|
|
126
|
-
subject.stub(:output_from_config_path).and_return path
|
127
|
-
|
128
|
-
subject.send(:output_path).should == path
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
it "should return whatever in output_from_options" do
|
133
|
-
mock('output').tap do |path|
|
134
|
-
subject.stub(:output_from_options).and_return path
|
135
|
-
|
136
|
-
subject.send(:output_path).should == path
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should prefer options over config" do
|
141
|
-
{options: mock('options'), config: mock('config')}.tap do |mocks|
|
142
|
-
subject.stub(:output_from_config_path).and_return mocks[:config]
|
143
|
-
subject.stub(:output_from_options).and_return mocks[:options]
|
144
|
-
|
145
|
-
subject.send(:output_path).should == mocks[:options]
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
describe "#compiler_name" do
|
151
|
-
it {should respond_to :compiler_name}
|
152
|
-
|
153
|
-
it "should not be empty" do
|
154
|
-
subject.send(:compiler_name).should_not be_empty
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
describe "#prepare_folders", :fakefs do
|
159
|
-
it {should respond_to :prepare_folders}
|
160
|
-
|
161
|
-
it "should create the js_path" do
|
162
|
-
subject.send :prepare_folders
|
163
|
-
File.directory?("/root/my_awesome_project/public/resources")
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
describe "#compile_assets" do
|
168
|
-
it {should respond_to :compile_assets}
|
169
|
-
end
|
170
|
-
|
171
|
-
describe "#create_hashed_assets" do
|
172
|
-
it {should respond_to :create_hashed_assets}
|
173
|
-
end
|
174
|
-
|
175
|
-
describe '#create_digest_for_file', :fakefs do
|
176
|
-
before :each do
|
177
|
-
stub_filesystem!
|
178
|
-
|
179
|
-
@file_path = '/root/my_awesome_project/file.something.extension'
|
180
|
-
File.open(@file_path, 'w') do |f|
|
181
|
-
f.write('some data')
|
182
|
-
end
|
183
|
-
|
184
|
-
@digest = Digest::MD5.hexdigest('some data')
|
185
|
-
@digested_file_path = "/root/my_awesome_project/file.something-#{@digest}.extension"
|
186
|
-
end
|
187
|
-
|
188
|
-
it "should be able to create a hashed file" do
|
189
|
-
subject.send(:create_digest_for_file, @file_path)
|
190
|
-
File.exists?(@digested_file_path).should be_true
|
191
|
-
end
|
192
|
-
|
193
|
-
it "should have exactly the same content (a copy of the file)" do
|
194
|
-
subject.send(:create_digest_for_file, @file_path)
|
195
|
-
File.read(@digested_file_path).should == File.read(@file_path)
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
describe '#generate_manifest_for', :fakefs do
|
200
|
-
before :each do
|
201
|
-
stub_filesystem!
|
202
|
-
|
203
|
-
@files = [
|
204
|
-
'/root/my_awesome_project/public/resources/application.js',
|
205
|
-
'/root/my_awesome_project/public/resources/application-d41d8cd98f00b204e9800998ecf8427e.js',
|
206
|
-
'/root/my_awesome_project/public/resources/application.css',
|
207
|
-
'/root/my_awesome_project/public/resources/application-982436e5fe99465e0540d0cf38e7aff4.css',
|
208
|
-
].each {|f| File.open(f, 'w') {|fh| fh.write ""}}
|
209
|
-
|
210
|
-
@manifest_path = '/root/my_awesome_project/public/resources/manifest.json'
|
211
|
-
end
|
212
|
-
|
213
|
-
describe "stylesheets" do
|
214
|
-
it "should a create a JSON manifest" do
|
215
|
-
subject.send(:generate_manifest_for, "stylesheets", "css")
|
216
|
-
|
217
|
-
File.exists?(@manifest_path).should be_true
|
218
|
-
end
|
219
|
-
|
220
|
-
it "should create a JSON manifest with only non-digested files if the env is development" do
|
221
|
-
subject.send(:generate_manifest_for, "stylesheets", "css")
|
222
|
-
|
223
|
-
manifest = JSON.parse(File.read(@manifest_path))
|
224
|
-
manifest.should have_key('stylesheets')
|
225
|
-
manifest['stylesheets'].should include('application.css')
|
226
|
-
manifest['stylesheets'].should_not include('application-982436e5fe99465e0540d0cf38e7aff4.css')
|
227
|
-
end
|
228
|
-
|
229
|
-
it "should create a JSON manifest with only the digested file if the env is production" do
|
230
|
-
TechnoGate::Contao.env = :production
|
231
|
-
subject.send(:generate_manifest_for, "stylesheets", "css")
|
232
|
-
|
233
|
-
manifest = JSON.parse(File.read(@manifest_path))
|
234
|
-
manifest.should have_key('stylesheets')
|
235
|
-
manifest['stylesheets'].should include('application-982436e5fe99465e0540d0cf38e7aff4.css')
|
236
|
-
manifest['stylesheets'].should_not include('application.css')
|
237
|
-
end
|
238
|
-
|
239
|
-
it "should not touch anything present in the manifest" do
|
240
|
-
File.open(@manifest_path, 'w') do |manifest|
|
241
|
-
manifest.write({"javascripts" => [1, 2, 3]}.to_json)
|
242
|
-
end
|
243
|
-
|
244
|
-
subject.send(:generate_manifest_for, "stylesheets", "css")
|
245
|
-
|
246
|
-
manifest = JSON.parse(File.read(@manifest_path))
|
247
|
-
manifest.should have_key('javascripts')
|
248
|
-
manifest["javascripts"].should == [1, 2, 3]
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
describe "javascripts" do
|
253
|
-
|
254
|
-
it "should a create a JSON manifest" do
|
255
|
-
subject.send(:generate_manifest_for, "javascripts", "js")
|
256
|
-
|
257
|
-
File.exists?(@manifest_path).should be_true
|
258
|
-
end
|
259
|
-
|
260
|
-
it "should create a JSON manifest with only non-digested files if the env is development" do
|
261
|
-
subject.send(:generate_manifest_for, "javascripts", "js")
|
262
|
-
|
263
|
-
manifest = JSON.parse(File.read(@manifest_path))
|
264
|
-
manifest.should have_key('javascripts')
|
265
|
-
manifest['javascripts'].should include('application.js')
|
266
|
-
manifest['javascripts'].should_not include('application-d41d8cd98f00b204e9800998ecf8427e.js')
|
267
|
-
end
|
268
|
-
|
269
|
-
it "should create a JSON manifest with only the digested file if the env is production" do
|
270
|
-
TechnoGate::Contao.env = :production
|
271
|
-
subject.send(:generate_manifest_for, "javascripts", "js")
|
272
|
-
|
273
|
-
manifest = JSON.parse(File.read(@manifest_path))
|
274
|
-
manifest.should have_key('javascripts')
|
275
|
-
manifest['javascripts'].should include('application-d41d8cd98f00b204e9800998ecf8427e.js')
|
276
|
-
manifest['javascripts'].should_not include('application.js')
|
277
|
-
end
|
278
|
-
|
279
|
-
it "should not touch anything present in the manifest" do
|
280
|
-
File.open(@manifest_path, 'w') do |manifest|
|
281
|
-
manifest.write({"stylesheets" => [1, 2, 3]}.to_json)
|
282
|
-
end
|
283
|
-
|
284
|
-
subject.send(:generate_manifest_for, "javascripts", "js")
|
285
|
-
|
286
|
-
manifest = JSON.parse(File.read(@manifest_path))
|
287
|
-
manifest.should have_key('stylesheets')
|
288
|
-
manifest["stylesheets"].should == [1, 2, 3]
|
289
|
-
end
|
290
|
-
end
|
291
|
-
end
|
292
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
shared_examples_for "Config" do
|
2
|
-
it_should_behave_like "Singleton"
|
3
|
-
|
4
|
-
it "should be an open struct" do
|
5
|
-
subject.class.superclass.should == OpenStruct
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should have a config as a superclass" do
|
9
|
-
subject.config.class.should == OpenStruct
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "config" do
|
13
|
-
it "should set a configuration variable using a block" do
|
14
|
-
klass.configure do
|
15
|
-
config.foo = :bar
|
16
|
-
end
|
17
|
-
|
18
|
-
klass.instance.config.foo.should == :bar
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should be accessible form the class level" do
|
22
|
-
klass.configure do
|
23
|
-
config.foo = :bar
|
24
|
-
end
|
25
|
-
|
26
|
-
klass.config.foo.should == :bar
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|