slinky 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
data/slinky.gemspec CHANGED
@@ -2,19 +2,21 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: slinky 0.8.0 ruby lib
5
+ # stub: slinky 0.8.1 ruby lib
6
+ # stub: ext/transitive_closure/extconf.rb
6
7
 
7
8
  Gem::Specification.new do |s|
8
9
  s.name = "slinky"
9
- s.version = "0.8.0"
10
+ s.version = "0.8.1"
10
11
 
11
12
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
13
  s.require_paths = ["lib"]
13
14
  s.authors = ["Micah Wylde"]
14
- s.date = "2014-07-19"
15
+ s.date = "2014-11-07"
15
16
  s.description = "A static file server for rich web apps that automatically compiles SASS, HAML, CoffeeScript and more"
16
17
  s.email = "micah@micahw.com"
17
18
  s.executables = ["slinky"]
19
+ s.extensions = ["ext/transitive_closure/extconf.rb"]
18
20
  s.extra_rdoc_files = [
19
21
  "LICENSE.txt",
20
22
  "README.md"
@@ -29,6 +31,8 @@ Gem::Specification.new do |s|
29
31
  "Rakefile",
30
32
  "VERSION",
31
33
  "bin/slinky",
34
+ "ext/transitive_closure/extconf.rb",
35
+ "ext/transitive_closure/transitive_closure.c",
32
36
  "lib/slinky.rb",
33
37
  "lib/slinky/builder.rb",
34
38
  "lib/slinky/compiled_file.rb",
@@ -47,6 +51,7 @@ Gem::Specification.new do |s|
47
51
  "lib/slinky/live_reload.rb",
48
52
  "lib/slinky/manifest.rb",
49
53
  "lib/slinky/proxy_server.rb",
54
+ "lib/slinky/pure_transitive_clsoure.rb",
50
55
  "lib/slinky/runner.rb",
51
56
  "lib/slinky/server.rb",
52
57
  "lib/slinky/templates/error.css",
@@ -75,21 +80,22 @@ Gem::Specification.new do |s|
75
80
  s.add_runtime_dependency(%q<em-proxy>, ["~> 0.1"])
76
81
  s.add_runtime_dependency(%q<rainbow>, ["~> 1.1"])
77
82
  s.add_runtime_dependency(%q<mime-types>, ["~> 1.16"])
78
- s.add_runtime_dependency(%q<yui-compressor>, ["~> 0.12"])
83
+ s.add_runtime_dependency(%q<uglifier>, ["~> 2.5"])
79
84
  s.add_runtime_dependency(%q<listen>, ["~> 2.4"])
80
85
  s.add_runtime_dependency(%q<haml>, ["~> 3.1"])
81
- s.add_runtime_dependency(%q<sass>, ["~> 3.1"])
86
+ s.add_runtime_dependency(%q<sass>, ["~> 3.3"])
82
87
  s.add_runtime_dependency(%q<coffee-script>, ["~> 2.2"])
83
88
  s.add_development_dependency(%q<rspec>, ["~> 2.10"])
84
89
  s.add_development_dependency(%q<yard>, ["~> 0.8"])
85
90
  s.add_development_dependency(%q<bundler>, ["~> 1.5"])
86
91
  s.add_development_dependency(%q<jeweler>, ["~> 1.8"])
87
- s.add_development_dependency(%q<fakefs>, ["~> 0.5"])
92
+ s.add_development_dependency(%q<fakefs>, ["= 0.5.3"])
88
93
  s.add_development_dependency(%q<em-http-request>, ["~> 1.0"])
89
94
  s.add_development_dependency(%q<simplecov>, [">= 0"])
90
95
  s.add_development_dependency(%q<less>, [">= 2.2.0"])
91
96
  s.add_development_dependency(%q<therubyracer>, [">= 0"])
92
97
  s.add_development_dependency(%q<react-jsx>, ["~> 0.8.0"])
98
+ s.add_development_dependency(%q<rake-compiler>, ["~> 0.9.3"])
93
99
  else
94
100
  s.add_dependency(%q<multi_json>, ["~> 1.9.2"])
95
101
  s.add_dependency(%q<eventmachine>, ["~> 1.0"])
@@ -98,21 +104,22 @@ Gem::Specification.new do |s|
98
104
  s.add_dependency(%q<em-proxy>, ["~> 0.1"])
99
105
  s.add_dependency(%q<rainbow>, ["~> 1.1"])
100
106
  s.add_dependency(%q<mime-types>, ["~> 1.16"])
101
- s.add_dependency(%q<yui-compressor>, ["~> 0.12"])
107
+ s.add_dependency(%q<uglifier>, ["~> 2.5"])
102
108
  s.add_dependency(%q<listen>, ["~> 2.4"])
103
109
  s.add_dependency(%q<haml>, ["~> 3.1"])
104
- s.add_dependency(%q<sass>, ["~> 3.1"])
110
+ s.add_dependency(%q<sass>, ["~> 3.3"])
105
111
  s.add_dependency(%q<coffee-script>, ["~> 2.2"])
106
112
  s.add_dependency(%q<rspec>, ["~> 2.10"])
107
113
  s.add_dependency(%q<yard>, ["~> 0.8"])
108
114
  s.add_dependency(%q<bundler>, ["~> 1.5"])
109
115
  s.add_dependency(%q<jeweler>, ["~> 1.8"])
110
- s.add_dependency(%q<fakefs>, ["~> 0.5"])
116
+ s.add_dependency(%q<fakefs>, ["= 0.5.3"])
111
117
  s.add_dependency(%q<em-http-request>, ["~> 1.0"])
112
118
  s.add_dependency(%q<simplecov>, [">= 0"])
113
119
  s.add_dependency(%q<less>, [">= 2.2.0"])
114
120
  s.add_dependency(%q<therubyracer>, [">= 0"])
115
121
  s.add_dependency(%q<react-jsx>, ["~> 0.8.0"])
122
+ s.add_dependency(%q<rake-compiler>, ["~> 0.9.3"])
116
123
  end
117
124
  else
118
125
  s.add_dependency(%q<multi_json>, ["~> 1.9.2"])
@@ -122,21 +129,22 @@ Gem::Specification.new do |s|
122
129
  s.add_dependency(%q<em-proxy>, ["~> 0.1"])
123
130
  s.add_dependency(%q<rainbow>, ["~> 1.1"])
124
131
  s.add_dependency(%q<mime-types>, ["~> 1.16"])
125
- s.add_dependency(%q<yui-compressor>, ["~> 0.12"])
132
+ s.add_dependency(%q<uglifier>, ["~> 2.5"])
126
133
  s.add_dependency(%q<listen>, ["~> 2.4"])
127
134
  s.add_dependency(%q<haml>, ["~> 3.1"])
128
- s.add_dependency(%q<sass>, ["~> 3.1"])
135
+ s.add_dependency(%q<sass>, ["~> 3.3"])
129
136
  s.add_dependency(%q<coffee-script>, ["~> 2.2"])
130
137
  s.add_dependency(%q<rspec>, ["~> 2.10"])
131
138
  s.add_dependency(%q<yard>, ["~> 0.8"])
132
139
  s.add_dependency(%q<bundler>, ["~> 1.5"])
133
140
  s.add_dependency(%q<jeweler>, ["~> 1.8"])
134
- s.add_dependency(%q<fakefs>, ["~> 0.5"])
141
+ s.add_dependency(%q<fakefs>, ["= 0.5.3"])
135
142
  s.add_dependency(%q<em-http-request>, ["~> 1.0"])
136
143
  s.add_dependency(%q<simplecov>, [">= 0"])
137
144
  s.add_dependency(%q<less>, [">= 2.2.0"])
138
145
  s.add_dependency(%q<therubyracer>, [">= 0"])
139
146
  s.add_dependency(%q<react-jsx>, ["~> 0.8.0"])
147
+ s.add_dependency(%q<rake-compiler>, ["~> 0.9.3"])
140
148
  end
141
149
  end
142
150
 
@@ -48,6 +48,13 @@ eos
48
48
  s.include?("color: red;") && s.include?("h1 a")
49
49
  }
50
50
  end
51
+
52
+ it "should not compile partials" do
53
+ src = "body { color: $something; }"
54
+ compiler_test("/compilers/_partial.scss", ".css", src){|s|
55
+ s == ""
56
+ }
57
+ end
51
58
  end
52
59
 
53
60
  context "LessCompiler" do
@@ -33,7 +33,6 @@ describe "Manifest" do
33
33
  m = @mdevel
34
34
  hash1 = m.md5
35
35
  File.open("/src/hello.html", "w+") {|f| f.write("Hell!") }
36
- $stdout.should_receive(:puts).with("Compiled /src/test.haml".foreground(:green)).exactly(2).times
37
36
  m.add_all_by_path(["/src/hello.html"])
38
37
  m.md5.should_not == hash1
39
38
  end
@@ -55,8 +54,8 @@ describe "Manifest" do
55
54
  it "should produce the correct scripts string for devel" do
56
55
  @mdevel.scripts_string.should == [
57
56
  '<script type="text/javascript" src="/l1/test5.js"></script>',
58
- '<script type="text/javascript" src="/l1/l2/test6.js"></script>',
59
57
  '<script type="text/javascript" src="/l1/test2.js"></script>',
58
+ '<script type="text/javascript" src="/l1/l2/test6.js"></script>',
60
59
  '<script type="text/javascript" src="/l1/l2/test3.js"></script>',
61
60
  '<script type="text/javascript" src="/l1/test.js"></script>'].join("\n")
62
61
  end
@@ -156,6 +155,14 @@ describe "Manifest" do
156
155
  mf.find_directives.should == {:slinky_require => ["test2.js", "l2/test3.js"]}
157
156
  end
158
157
 
158
+ it "should properly find depends directives" do
159
+ File.open("/src/depends.sass", "w+") {|f|
160
+ f.write('// slinky_depends("/something.sass")')
161
+ }
162
+ mf = Slinky::ManifestFile.new("/src/depends.sass", "/src/build", @mprod)
163
+ mf.find_directives.should == {:slinky_depends => ["/something.sass"]}
164
+ end
165
+
159
166
  it "should properly determine build_to path" do
160
167
  mf = Slinky::ManifestFile.new("/src/test.haml", "/src/build", @mprod)
161
168
  mf.build_to.should == Pathname.new("/src/build/test.html")
@@ -226,7 +233,7 @@ describe "Manifest" do
226
233
  end
227
234
 
228
235
  it "should build a correct dependency list" do
229
- @mprod.dependency_list.collect{|x| x.source}.should == ["/src/test.haml", "/src/l1/test.sass", "/src/l1/test5.js", "/src/l1/l2/test.txt", "/src/l1/l2/test2.css", "/src/l1/l2/test6.js", "/src/l1/l2/l3/test2.txt", "/src/l1/test2.js", "/src/l1/l2/test3.coffee", "/src/l1/test.js"]
236
+ @mprod.dependency_list.collect{|x| x.source}.should == ["/src/test.haml", "/src/l1/test5.js", "/src/l1/test2.js", "/src/l1/l2/test6.js", "/src/l1/l2/test3.coffee", "/src/l1/test.js", "/src/l1/test.sass", "/src/l1/l2/test.txt", "/src/l1/l2/test2.css", "/src/l1/l2/l3/test2.txt"]
230
237
  end
231
238
 
232
239
  it "should fail if there is a cycle in the dependency graph" do
@@ -245,6 +252,22 @@ describe "Manifest" do
245
252
  f.process
246
253
  end
247
254
 
255
+ it "should handle external depends directives" do
256
+ Dir.mkdir("/external")
257
+ File.open("/external/file.js", "w+"){|f| f.write("Hello!") }
258
+ File.open("/src/l1/test5.coffee", "w+"){|f| f.write("slinky_depends_external('../external/*.js')")}
259
+ manifest = Slinky::Manifest.new("/src", @config, :devel => true)
260
+ f = manifest.find_by_path("l1/test5.js").first
261
+ f.should_not == nil
262
+ f.external_dependencies.should == ["/external/file.js"]
263
+ f.external_dependencies_updated?.should == true
264
+
265
+ $stdout.should_receive(:puts).with(/Compiled \/src\/l1\/test5.coffee/)
266
+ f.process
267
+
268
+ f.external_dependencies_updated?.should == false
269
+ end
270
+
248
271
  it "should handle depends directives with glob patterns" do
249
272
  File.open("/src/l1/test5.coffee", "w+"){|f| f.write("slinky_depends('*.sass')")}
250
273
  File.open("/src/l1/test2.sass", "w+"){|f| f.write("body\n\tcolor: red")}
@@ -257,6 +280,18 @@ describe "Manifest" do
257
280
  f.process
258
281
  end
259
282
 
283
+ it "should handle depends directives with **" do
284
+ File.open("/src/l1/test5.coffee", "w+"){|f| f.write("slinky_depends('/l1/**/*.sass')")}
285
+ File.open("/src/l1/l2/test5.sass", "w+"){|f| f.write("body\n\tcolor: red")}
286
+ manifest = Slinky::Manifest.new("/src", @config, :devel => true)
287
+ f = manifest.find_by_path("l1/test5.js").first
288
+ f.should_not == nil
289
+ $stdout.should_receive(:puts).with(/Compiled \/src\/l1\/test.sass/)
290
+ $stdout.should_receive(:puts).with(/Compiled \/src\/l1\/l2\/test5.sass/)
291
+ $stdout.should_receive(:puts).with(/Compiled \/src\/l1\/test5.coffee/)
292
+ f.process
293
+ end
294
+
260
295
  it "should handle depends directives with infinite loops" do
261
296
  File.open("/src/l1/test5.coffee", "w+"){|f| f.write("slinky_depends('*.sass')")}
262
297
  File.open("/src/l1/test2.sass", "w+"){|f| f.write("/* slinky_depends('*.coffee')")}
@@ -311,7 +346,6 @@ eos
311
346
  end
312
347
 
313
348
  it "should detect new files" do
314
- $stdout.should_receive(:puts).with(/Compiled \/src\/test.haml/)
315
349
  manifest = Slinky::Manifest.new("/src", @config, :devel => true)
316
350
  File.open("/src/l1/cache.coffee", "w+"){|f| f.write("console.log 'hello'")}
317
351
  manifest.add_all_by_path(["/src/l1/cache.coffee"])
@@ -326,7 +360,6 @@ eos
326
360
 
327
361
  it "should handle deletion of files" do
328
362
  File.open("/src/l1/cache.coffee", "w+"){|f| f.write("console.log 'hello'")}
329
- $stdout.should_receive(:puts).with(/Compiled \/src\/test.haml/)
330
363
  manifest = Slinky::Manifest.new("/src", @config, :devel => true)
331
364
  f = manifest.find_by_path("l1/cache.coffee").first
332
365
  f.should_not == nil
@@ -444,6 +477,32 @@ eos
444
477
 
445
478
  File.read("/build/styles.css").include?("IGNORE!!!").should == false
446
479
  end
480
+
481
+ it "should recompile files when files they depend on change" do
482
+ $stdout.should_receive(:puts).with(/Compiled \/src\/.+/).exactly(4).times
483
+
484
+ File.open("/src/l1/depender.scss", "w+"){|f|
485
+ f.write("// slinky_depends('/l1/_dependee.scss')\n")
486
+ f.write("@import \"dependee\";\n")
487
+ f.write("body { color: $bodycolor }\n")
488
+ }
489
+ File.open("/src/l1/_dependee.scss", "w+"){|f|
490
+ f.write("$bodycolor: red;\n")
491
+ }
492
+ mdevel = Slinky::Manifest.new("/src", @config)
493
+
494
+ mf = mdevel.find_by_path("/l1/depender.scss").first
495
+ path = mf.process
496
+ File.read(path).should match /color: red/
497
+
498
+ File.open("/src/l1/_dependee.scss", "w+"){|f|
499
+ f.write("$bodycolor: green;\n")
500
+ }
501
+
502
+ mf = mdevel.find_by_path("/l1/depender.scss").first
503
+ path = mf.process
504
+ File.read(path).should match /color: green/
505
+ end
447
506
  end
448
507
 
449
508
  context "FindByPattern" do
data/spec/slinky_spec.rb CHANGED
@@ -4,6 +4,7 @@ require 'em-http'
4
4
  describe "Slinky" do
5
5
  context "Runner" do
6
6
  it "should output help" do
7
+ $stdout.should_receive(:puts).with(/slinky \d+\.\d+\.\d+/)
7
8
  $stdout.should_receive(:puts).with(/Usage: slinky/)
8
9
  lambda { ::Slinky::Runner.new(["--help"]).run }.should raise_error SystemExit
9
10
  end
@@ -120,6 +121,7 @@ eos
120
121
 
121
122
  it "should accept a port option" do
122
123
  port = 53455
124
+ $stdout.should_receive(:puts).with(/slinky \d+\.\d+\.\d+/)
123
125
  $stdout.should_receive(:puts).with(/Started static file server on port #{port}/)
124
126
  run_for 0.3 do
125
127
  Slinky::Runner.new(["start","--port", port.to_s, "--no-livereload"]).run
@@ -135,6 +137,7 @@ eos
135
137
  end
136
138
 
137
139
  it "should serve files for realz" do
140
+ $stdout.should_receive(:puts).with(/slinky \d+\.\d+\.\d+/)
138
141
  $stdout.should_receive(:puts).with(/Started static file server on port 43453/)
139
142
  @results = []
140
143
  File.open("/src/index.haml", "w+"){|f|
@@ -189,7 +192,7 @@ eos
189
192
  @config = <<eos
190
193
  proxy:
191
194
  "/test1": "http://127.0.0.1:8000"
192
- "/test2": "http://127.0.0.1:7000"
195
+ "/test2": "http://127.0.0.1:7000/"
193
196
  ignore:
194
197
  - script/vendor
195
198
  - script/jquery.js
@@ -214,7 +217,7 @@ eos
214
217
  File.open("/src/slinky.yaml", "w+"){|f| f.write @config}
215
218
  @proxies = {
216
219
  "/test1" => "http://127.0.0.1:8000",
217
- "/test2" => "http://127.0.0.1:7000"
220
+ "/test2" => "http://127.0.0.1:7000/"
218
221
  }
219
222
  @ignores = ["script/vendor", "script/jquery.js"]
220
223
  @pushstates = {
@@ -262,7 +265,7 @@ eos
262
265
  before :each do
263
266
  @config = <<eos
264
267
  proxy:
265
- "/test1": "http://127.0.0.1:8000"
268
+ "/test1": "http://127.0.0.1:8000/"
266
269
  "/test2/": "http://127.0.0.1:7000"
267
270
  eos
268
271
  @cr = Slinky::ConfigReader.new(@config)
@@ -276,7 +279,7 @@ eos
276
279
  @proxies.map{|x|
277
280
  [x[0], x[1].to_s]
278
281
  }.should ==
279
- [["/test1", URI::parse("http://127.0.0.1:8000").to_s],
282
+ [["/test1", URI::parse("http://127.0.0.1:8000/").to_s],
280
283
  ["/test2/", URI::parse("http://127.0.0.1:7000").to_s]]
281
284
  end
282
285
 
@@ -288,7 +291,7 @@ eos
288
291
  it "should find the correct matcher for a request" do
289
292
  p = Slinky::ProxyServer.find_matcher(@proxies, "/test1/this/is/another")
290
293
  p[0].should == "/test1"
291
- p[1].to_s.should == "http://127.0.0.1:8000"
294
+ p[1].to_s.should == "http://127.0.0.1:8000/"
292
295
 
293
296
  p = Slinky::ProxyServer.find_matcher(@proxies, "/test2/whatsgoing.html?something=asdf")
294
297
  p[0].should == "/test2/"
@@ -332,5 +335,19 @@ eos
332
335
  @proxies[0][1].to_s.should == "http://127.0.0.1:6000"
333
336
  @proxies[0][2].should == {"lag" => 1000}
334
337
  end
338
+
339
+ it "should properly rewrite slashes for '/'" do
340
+ config = <<eos
341
+ proxy:
342
+ "/": "http://127.0.0.1:6000/"
343
+ eos
344
+ cr = Slinky::ConfigReader.new(config)
345
+ proxies = Slinky::ProxyServer.process_proxies(cr.proxy)
346
+
347
+ data = "GET /hello HTTP/1.1\r\nHost:127.0.0.1:8000\r\n\r\n\n"
348
+ path = data.match(Slinky::ProxyServer::HTTP_MATCHER)[2]
349
+ p2 = Slinky::ProxyServer.rewrite_path(path, proxies[0])
350
+ p2.should == "/hello"
351
+ end
335
352
  end
336
353
  end
data/spec/spec_helper.rb CHANGED
@@ -76,6 +76,12 @@ module FakeFS
76
76
  end
77
77
 
78
78
  module Slinky
79
+ class Runner
80
+ def version
81
+ "0.8.0"
82
+ end
83
+ end
84
+
79
85
  # The coffee script compiler doesn't work under FakeFS
80
86
  module CoffeeCompiler
81
87
  def CoffeeCompiler::compile s, file
@@ -112,16 +118,10 @@ module Slinky
112
118
  end
113
119
  end
114
120
 
115
- # Compressors don't work under FakeFS
116
- class FakeCompressor
117
- def compress s
118
- s
119
- end
120
- end
121
-
122
121
  class Manifest
123
122
  def compressor_for_product product
124
- FakeCompressor.new
123
+ # Compressors don't work under FakeFS
124
+ lambda{|s| s}
125
125
  end
126
126
  end
127
127
 
@@ -209,8 +209,10 @@ eos
209
209
  File.open("/src/l1/l2/test.txt", "w+"){|f| f.write("hello\n") }
210
210
  File.open("/src/l1/l2/l3/test2.txt", "w+"){|f| f.write("goodbye\n") }
211
211
 
212
- @files = ["test.haml", "l1/test.js", "l1/test.sass", "l1/l2/test2.css", "l1/l2/test.txt", "l1/l2/l3/test2.txt", "l1/test2.js", "l1/l2/test3.coffee", "l1/test5.js", "l1/l2/test6.js"]
213
-
212
+ @files = ["test.haml", "l1/test.js", "l1/test.sass",
213
+ "l1/l2/test2.css", "l1/l2/test.txt", "l1/l2/l3/test2.txt",
214
+ "l1/test2.js", "l1/l2/test3.coffee", "l1/test5.js",
215
+ "l1/l2/test6.js"]
214
216
  end
215
217
 
216
218
  config.after :all do