slinky 0.8.2 → 0.8.3
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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile +3 -2
- data/VERSION +1 -1
- data/lib/slinky/compiled_file.rb +1 -1
- data/lib/slinky/compilers/sass-compiler.rb +5 -5
- data/lib/slinky/compilers/typescript-compiler.rb +16 -0
- data/lib/slinky/manifest.rb +9 -6
- data/lib/slinky/server.rb +9 -3
- data/slinky.gemspec +14 -10
- data/spec/compilers_spec.rb +69 -27
- data/spec/manifest_spec.rb +34 -24
- data/spec/slinky_spec.rb +5 -4
- data/spec/spec_helper.rb +21 -76
- metadata +23 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1458d69b24daf80c962d71ca9fa6b9fcf366e315
|
4
|
+
data.tar.gz: 7854256d1f1b2710b9df508851997e222ac34e67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 145fcb64b35433b8d45946b87de8ca1e39c306aca7fdbf87c1811c39dbb66433a2eb6a8ad96a2e9ea2930862590a4f7563c2c2d14ebc5e08b8cbd0ae493e08d4
|
7
|
+
data.tar.gz: 89767aa9c0b59c9e36fc47e1d17a51d93803ca32bf78ce1e9ccf04b7d10c14ac81b6ade62fa6616a1b9b2b3b36caff93def213bef37678562b9a275144f83920
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -13,7 +13,7 @@ gem "listen", "~> 2.4"
|
|
13
13
|
|
14
14
|
# compilation support gems
|
15
15
|
gem "haml", "~> 3.1"
|
16
|
-
gem "
|
16
|
+
gem "sassc", "~> 1.8"
|
17
17
|
gem "coffee-script", "~> 2.2"
|
18
18
|
|
19
19
|
group :development do
|
@@ -21,7 +21,7 @@ group :development do
|
|
21
21
|
gem "yard", "~> 0.8"
|
22
22
|
gem "bundler", "~> 1.5"
|
23
23
|
gem "jeweler", "~> 1.8"
|
24
|
-
gem "fakefs", '0.
|
24
|
+
gem "fakefs", '0.6.7', :require => "fakefs/safe"
|
25
25
|
gem "em-http-request", '~> 1.0'
|
26
26
|
gem 'simplecov'
|
27
27
|
# optional compilation gems
|
@@ -29,4 +29,5 @@ group :development do
|
|
29
29
|
gem "therubyracer" # for less
|
30
30
|
gem "react-jsx", '~> 0.8.0'
|
31
31
|
gem "rake-compiler", '~> 0.9.3'
|
32
|
+
gem "typescript-node", "~> 1.6.2"
|
32
33
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.3
|
data/lib/slinky/compiled_file.rb
CHANGED
@@ -25,7 +25,7 @@ module Slinky
|
|
25
25
|
if @compiler.respond_to? :compile
|
26
26
|
compiler_compile path, cb
|
27
27
|
else
|
28
|
-
compile_failed "invalid compiler"
|
28
|
+
compile_failed Exception.new("invalid compiler")
|
29
29
|
cb.call @output_path, nil, nil, "invalid compiler"
|
30
30
|
# compiler_command path, cb
|
31
31
|
end
|
@@ -3,8 +3,8 @@ module Slinky
|
|
3
3
|
Compilers.register_compiler self,
|
4
4
|
:inputs => ["sass", "scss"],
|
5
5
|
:outputs => ["css"],
|
6
|
-
:dependencies => [["
|
7
|
-
:requires => ["
|
6
|
+
:dependencies => [["sassc", "~> 1.8"]],
|
7
|
+
:requires => ["sassc"]
|
8
8
|
|
9
9
|
def SassCompiler::compile s, file
|
10
10
|
syntax = file.end_with?(".sass") ? :sass : :scss
|
@@ -12,9 +12,9 @@ module Slinky
|
|
12
12
|
# This is a partial, don't render it
|
13
13
|
""
|
14
14
|
else
|
15
|
-
sass_engine =
|
16
|
-
|
17
|
-
|
15
|
+
sass_engine = SassC::Engine.new(s,
|
16
|
+
:syntax => syntax,
|
17
|
+
:load_paths => [File.dirname(file)])
|
18
18
|
sass_engine.render
|
19
19
|
end
|
20
20
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Slinky
|
2
|
+
module TypescriptCompiler
|
3
|
+
Compilers.register_compiler self,
|
4
|
+
:inputs => ["ts"],
|
5
|
+
:outputs => ["js"],
|
6
|
+
:dependencies => [["typescript-node", "~> 1.6.0"]],
|
7
|
+
:requires => ["typescript-node"]
|
8
|
+
|
9
|
+
def TypescriptCompiler::compile s, file
|
10
|
+
# Raises an error if node is not available
|
11
|
+
TypeScript::Node.check_node
|
12
|
+
|
13
|
+
TypeScript::Node.compile_file(file, '--target', 'ES5').js
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/slinky/manifest.rb
CHANGED
@@ -139,14 +139,16 @@ module Slinky
|
|
139
139
|
# Finds all the matching manifest files for a particular product.
|
140
140
|
# This does not take into account dependencies.
|
141
141
|
def files_for_product product
|
142
|
-
|
143
|
-
|
144
|
-
|
142
|
+
p = @config.produce[product]
|
143
|
+
|
144
|
+
if p.nil?
|
145
|
+
raise NoSuchProductError.new(
|
146
|
+
"Product '#{product}' has not been configured")
|
145
147
|
end
|
146
148
|
|
147
149
|
type = type_for_product product
|
148
150
|
if type != ".js" && type != ".css"
|
149
|
-
|
151
|
+
raise InvalidConfigError.new("Only .js and .css products are supported")
|
150
152
|
end
|
151
153
|
|
152
154
|
g = dependency_graph.transitive_closure
|
@@ -308,6 +310,7 @@ module Slinky
|
|
308
310
|
end
|
309
311
|
|
310
312
|
def compressor_for_product product
|
313
|
+
require 'sassc'
|
311
314
|
case type_for_product(product)
|
312
315
|
when ".js"
|
313
316
|
# Use UglifyJS
|
@@ -315,7 +318,7 @@ module Slinky
|
|
315
318
|
mangle: false, output: {ascii_only: false})}
|
316
319
|
when ".css"
|
317
320
|
# Use SASS's compressed output
|
318
|
-
lambda{|s|
|
321
|
+
lambda{|s| SassC::Engine.new(s, :syntax => :scss, :style => :compressed).render}
|
319
322
|
end
|
320
323
|
end
|
321
324
|
|
@@ -752,7 +755,7 @@ module Slinky
|
|
752
755
|
# to the build path
|
753
756
|
def build
|
754
757
|
return nil unless should_build
|
755
|
-
|
758
|
+
|
756
759
|
if !File.exists? @build_path
|
757
760
|
FileUtils.mkdir_p(@build_path)
|
758
761
|
end
|
data/lib/slinky/server.rb
CHANGED
@@ -48,8 +48,6 @@ module Slinky
|
|
48
48
|
path += "/index.html"
|
49
49
|
end
|
50
50
|
|
51
|
-
resp.content_type MIME::Types.type_for(path).first.to_s
|
52
|
-
|
53
51
|
if file
|
54
52
|
# They're requesting the source file and we should not
|
55
53
|
# compile it (but still process directives)
|
@@ -61,6 +59,14 @@ module Slinky
|
|
61
59
|
else
|
62
60
|
not_found resp
|
63
61
|
end
|
62
|
+
|
63
|
+
type = MIME::Types.type_for(path).first.to_s
|
64
|
+
if resp.content.encoding.to_s == "UTF-8"
|
65
|
+
type += "; charset=utf-8"
|
66
|
+
end
|
67
|
+
|
68
|
+
resp.content_type type
|
69
|
+
|
64
70
|
resp
|
65
71
|
end
|
66
72
|
|
@@ -116,7 +122,7 @@ module Slinky
|
|
116
122
|
size = File.size(path)
|
117
123
|
_, _, extension = path.match(EXTENSION_REGEX).to_a
|
118
124
|
# File reading code from rack/file.rb
|
119
|
-
File.open
|
125
|
+
File.open(path, "rb") do |file|
|
120
126
|
resp.content = ""
|
121
127
|
while size > 0
|
122
128
|
part = file.read([8192, size].min)
|
data/slinky.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
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.
|
5
|
+
# stub: slinky 0.8.3 ruby lib
|
6
6
|
# stub: ext/transitive_closure/extconf.rb
|
7
7
|
|
8
8
|
Gem::Specification.new do |s|
|
9
9
|
s.name = "slinky"
|
10
|
-
s.version = "0.8.
|
10
|
+
s.version = "0.8.3"
|
11
11
|
|
12
12
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
13
13
|
s.require_paths = ["lib"]
|
14
14
|
s.authors = ["Micah Wylde"]
|
15
|
-
s.date = "
|
15
|
+
s.date = "2016-07-30"
|
16
16
|
s.description = "A static file server for rich web apps that automatically compiles SASS, HAML, CoffeeScript and more"
|
17
17
|
s.email = "micah@micahw.com"
|
18
18
|
s.executables = ["slinky"]
|
@@ -43,6 +43,7 @@ Gem::Specification.new do |s|
|
|
43
43
|
"lib/slinky/compilers/jsx-compiler.rb",
|
44
44
|
"lib/slinky/compilers/less-compiler.rb",
|
45
45
|
"lib/slinky/compilers/sass-compiler.rb",
|
46
|
+
"lib/slinky/compilers/typescript-compiler.rb",
|
46
47
|
"lib/slinky/config_reader.rb",
|
47
48
|
"lib/slinky/em-popen3.rb",
|
48
49
|
"lib/slinky/errors.rb",
|
@@ -66,7 +67,7 @@ Gem::Specification.new do |s|
|
|
66
67
|
]
|
67
68
|
s.homepage = "http://mwylde.github.com/slinky/"
|
68
69
|
s.licenses = ["MIT"]
|
69
|
-
s.rubygems_version = "2.
|
70
|
+
s.rubygems_version = "2.4.5.1"
|
70
71
|
s.summary = "Static file server for javascript apps"
|
71
72
|
|
72
73
|
if s.respond_to? :specification_version then
|
@@ -83,19 +84,20 @@ Gem::Specification.new do |s|
|
|
83
84
|
s.add_runtime_dependency(%q<uglifier>, ["~> 2.5"])
|
84
85
|
s.add_runtime_dependency(%q<listen>, ["~> 2.4"])
|
85
86
|
s.add_runtime_dependency(%q<haml>, ["~> 3.1"])
|
86
|
-
s.add_runtime_dependency(%q<
|
87
|
+
s.add_runtime_dependency(%q<sassc>, ["~> 1.8"])
|
87
88
|
s.add_runtime_dependency(%q<coffee-script>, ["~> 2.2"])
|
88
89
|
s.add_development_dependency(%q<rspec>, ["~> 2.10"])
|
89
90
|
s.add_development_dependency(%q<yard>, ["~> 0.8"])
|
90
91
|
s.add_development_dependency(%q<bundler>, ["~> 1.5"])
|
91
92
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8"])
|
92
|
-
s.add_development_dependency(%q<fakefs>, ["= 0.
|
93
|
+
s.add_development_dependency(%q<fakefs>, ["= 0.6.7"])
|
93
94
|
s.add_development_dependency(%q<em-http-request>, ["~> 1.0"])
|
94
95
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
95
96
|
s.add_development_dependency(%q<less>, [">= 2.2.0"])
|
96
97
|
s.add_development_dependency(%q<therubyracer>, [">= 0"])
|
97
98
|
s.add_development_dependency(%q<react-jsx>, ["~> 0.8.0"])
|
98
99
|
s.add_development_dependency(%q<rake-compiler>, ["~> 0.9.3"])
|
100
|
+
s.add_development_dependency(%q<typescript-node>, ["~> 1.6.2"])
|
99
101
|
else
|
100
102
|
s.add_dependency(%q<multi_json>, ["~> 1.9.2"])
|
101
103
|
s.add_dependency(%q<eventmachine>, ["~> 1.0"])
|
@@ -107,19 +109,20 @@ Gem::Specification.new do |s|
|
|
107
109
|
s.add_dependency(%q<uglifier>, ["~> 2.5"])
|
108
110
|
s.add_dependency(%q<listen>, ["~> 2.4"])
|
109
111
|
s.add_dependency(%q<haml>, ["~> 3.1"])
|
110
|
-
s.add_dependency(%q<
|
112
|
+
s.add_dependency(%q<sassc>, ["~> 1.8"])
|
111
113
|
s.add_dependency(%q<coffee-script>, ["~> 2.2"])
|
112
114
|
s.add_dependency(%q<rspec>, ["~> 2.10"])
|
113
115
|
s.add_dependency(%q<yard>, ["~> 0.8"])
|
114
116
|
s.add_dependency(%q<bundler>, ["~> 1.5"])
|
115
117
|
s.add_dependency(%q<jeweler>, ["~> 1.8"])
|
116
|
-
s.add_dependency(%q<fakefs>, ["= 0.
|
118
|
+
s.add_dependency(%q<fakefs>, ["= 0.6.7"])
|
117
119
|
s.add_dependency(%q<em-http-request>, ["~> 1.0"])
|
118
120
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
119
121
|
s.add_dependency(%q<less>, [">= 2.2.0"])
|
120
122
|
s.add_dependency(%q<therubyracer>, [">= 0"])
|
121
123
|
s.add_dependency(%q<react-jsx>, ["~> 0.8.0"])
|
122
124
|
s.add_dependency(%q<rake-compiler>, ["~> 0.9.3"])
|
125
|
+
s.add_dependency(%q<typescript-node>, ["~> 1.6.2"])
|
123
126
|
end
|
124
127
|
else
|
125
128
|
s.add_dependency(%q<multi_json>, ["~> 1.9.2"])
|
@@ -132,19 +135,20 @@ Gem::Specification.new do |s|
|
|
132
135
|
s.add_dependency(%q<uglifier>, ["~> 2.5"])
|
133
136
|
s.add_dependency(%q<listen>, ["~> 2.4"])
|
134
137
|
s.add_dependency(%q<haml>, ["~> 3.1"])
|
135
|
-
s.add_dependency(%q<
|
138
|
+
s.add_dependency(%q<sassc>, ["~> 1.8"])
|
136
139
|
s.add_dependency(%q<coffee-script>, ["~> 2.2"])
|
137
140
|
s.add_dependency(%q<rspec>, ["~> 2.10"])
|
138
141
|
s.add_dependency(%q<yard>, ["~> 0.8"])
|
139
142
|
s.add_dependency(%q<bundler>, ["~> 1.5"])
|
140
143
|
s.add_dependency(%q<jeweler>, ["~> 1.8"])
|
141
|
-
s.add_dependency(%q<fakefs>, ["= 0.
|
144
|
+
s.add_dependency(%q<fakefs>, ["= 0.6.7"])
|
142
145
|
s.add_dependency(%q<em-http-request>, ["~> 1.0"])
|
143
146
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
144
147
|
s.add_dependency(%q<less>, [">= 2.2.0"])
|
145
148
|
s.add_dependency(%q<therubyracer>, [">= 0"])
|
146
149
|
s.add_dependency(%q<react-jsx>, ["~> 0.8.0"])
|
147
150
|
s.add_dependency(%q<rake-compiler>, ["~> 0.9.3"])
|
151
|
+
s.add_dependency(%q<typescript-node>, ["~> 1.6.2"])
|
148
152
|
end
|
149
153
|
end
|
150
154
|
|
data/spec/compilers_spec.rb
CHANGED
@@ -1,37 +1,41 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
require 'em-http'
|
3
3
|
|
4
|
-
def compiler_test file, ext, src, &test
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
cpath.end_with?(ext).should == true
|
15
|
-
test.call(File.open(cpath).read).should == true
|
16
|
-
called_back = true
|
17
|
-
}
|
4
|
+
def compiler_test file, ext, src, dir = nil, &test
|
5
|
+
FakeFS.without {
|
6
|
+
dir ||= Dir.mktmpdir
|
7
|
+
|
8
|
+
begin
|
9
|
+
path = "#{dir}/#{file}"
|
10
|
+
|
11
|
+
File.open(path, "w+"){|f| f.write(src)}
|
12
|
+
cf = Slinky::Compilers.cfile_for_file(path)
|
13
|
+
called_back = false
|
18
14
|
|
19
|
-
|
15
|
+
$stdout.should_receive(:puts).with("Compiled #{path}".foreground(:green))
|
16
|
+
|
17
|
+
cf.compile{|cpath, _, _, error|
|
18
|
+
error.should == nil
|
19
|
+
cpath.nil?.should == false
|
20
|
+
cpath.end_with?(ext).should == true
|
21
|
+
test.call(File.open(cpath).read).should == true
|
22
|
+
called_back = true
|
23
|
+
}
|
24
|
+
called_back.should == true
|
25
|
+
ensure
|
26
|
+
FileUtils.rm_rf(dir)
|
27
|
+
end
|
28
|
+
}
|
20
29
|
end
|
21
30
|
|
22
31
|
describe "Compilers" do
|
23
|
-
before :each do
|
24
|
-
FileUtils.rm_rf("/compilers") rescue nil
|
25
|
-
FileUtils.mkdir("/compilers")
|
26
|
-
end
|
27
|
-
|
28
32
|
context "SassCompiler" do
|
29
33
|
it "should be able to compile SASS files" do
|
30
34
|
src = <<eos
|
31
35
|
h1
|
32
36
|
color: red
|
33
37
|
eos
|
34
|
-
compiler_test("
|
38
|
+
compiler_test("test.sass", ".css", src){|s|
|
35
39
|
s.include?("color: red;")
|
36
40
|
}
|
37
41
|
end
|
@@ -44,14 +48,14 @@ h1 {
|
|
44
48
|
}
|
45
49
|
}
|
46
50
|
eos
|
47
|
-
compiler_test("
|
51
|
+
compiler_test("test.scss", ".css", src){|s|
|
48
52
|
s.include?("color: red;") && s.include?("h1 a")
|
49
53
|
}
|
50
54
|
end
|
51
55
|
|
52
56
|
it "should not compile partials" do
|
53
57
|
src = "body { color: $something; }"
|
54
|
-
compiler_test("
|
58
|
+
compiler_test("_partial.scss", ".css", src){|s|
|
55
59
|
s == ""
|
56
60
|
}
|
57
61
|
end
|
@@ -66,7 +70,7 @@ eos
|
|
66
70
|
width: percentage(@width);
|
67
71
|
}
|
68
72
|
eos
|
69
|
-
compiler_test("
|
73
|
+
compiler_test("test.less", ".css", src){|s|
|
70
74
|
s.include?("width: 50%;")
|
71
75
|
}
|
72
76
|
end
|
@@ -78,7 +82,7 @@ eos
|
|
78
82
|
test = {do: (x) -> console.log(x)}
|
79
83
|
test.do("Hello, world")
|
80
84
|
eos
|
81
|
-
compiler_test("
|
85
|
+
compiler_test("test.coffee", ".js", src){|s|
|
82
86
|
s.include?("function(x) {")
|
83
87
|
}
|
84
88
|
end
|
@@ -92,7 +96,7 @@ eos
|
|
92
96
|
%title Hello!
|
93
97
|
%body
|
94
98
|
eos
|
95
|
-
compiler_test("
|
99
|
+
compiler_test("test.haml", ".html", src){|s|
|
96
100
|
s.include?("<title>Hello!</title>")
|
97
101
|
}
|
98
102
|
end
|
@@ -107,9 +111,47 @@ eos
|
|
107
111
|
document.getElementById('example')
|
108
112
|
);
|
109
113
|
EOF
|
110
|
-
compiler_test("
|
114
|
+
compiler_test("test.jsx", ".js", src){|s|
|
111
115
|
s.include?("Hello, world!")
|
112
116
|
}
|
113
117
|
end
|
114
118
|
end
|
119
|
+
|
120
|
+
context "TypescriptCompiler" do
|
121
|
+
it "should be able to compile .ts files" do
|
122
|
+
src = <<-EOF
|
123
|
+
function greeter(person: string) {
|
124
|
+
return "Hello, " + person;
|
125
|
+
}
|
126
|
+
|
127
|
+
var user = "Jane User";
|
128
|
+
EOF
|
129
|
+
compiler_test("test.ts", ".js", src){|s|
|
130
|
+
s.include?("function greeter(person)")
|
131
|
+
}
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should be able to reference definition files" do
|
135
|
+
dts = <<-EOF
|
136
|
+
declare var Test: {x: number}
|
137
|
+
EOF
|
138
|
+
|
139
|
+
src = <<-EOF
|
140
|
+
///<reference path="types/my.d.ts">
|
141
|
+
|
142
|
+
console.log(Test.x + 5);
|
143
|
+
EOF
|
144
|
+
|
145
|
+
FakeFS.without {
|
146
|
+
dir = Dir.mktmpdir
|
147
|
+
|
148
|
+
FileUtils.mkdir("#{dir}/types")
|
149
|
+
File.open("#{dir}/types/my.d.ts", "w+"){|f| f.write(dts)}
|
150
|
+
|
151
|
+
compiler_test("test.ts", ".js", src, dir){|s|
|
152
|
+
s.include?("Test.x")
|
153
|
+
}
|
154
|
+
}
|
155
|
+
end
|
156
|
+
end
|
115
157
|
end
|
data/spec/manifest_spec.rb
CHANGED
@@ -132,7 +132,7 @@ describe "Manifest" do
|
|
132
132
|
build_path = mf.process
|
133
133
|
end
|
134
134
|
|
135
|
-
it "should report errors for bad files" do
|
135
|
+
it "should report errors for bad files" do
|
136
136
|
File.open("/src/l1/l2/bad.sass", "w+"){|f|
|
137
137
|
f.write "color: red;"
|
138
138
|
}
|
@@ -479,29 +479,39 @@ eos
|
|
479
479
|
end
|
480
480
|
|
481
481
|
it "should recompile files when files they depend on change" do
|
482
|
-
$stdout.should_receive(:puts).with(/Compiled
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
482
|
+
$stdout.should_receive(:puts).with(/Compiled .+/).exactly(4).times
|
483
|
+
|
484
|
+
# We can't use FakeFS with SassC
|
485
|
+
FakeFS.without do
|
486
|
+
dir = Dir.mktmpdir
|
487
|
+
begin
|
488
|
+
FileUtils.mkdir("#{dir}/l1")
|
489
|
+
File.open("#{dir}/l1/depender.scss", "w+"){|f|
|
490
|
+
f.write("// slinky_depends('/l1/_dependee.scss')\n")
|
491
|
+
f.write("@import \"dependee\";\n")
|
492
|
+
f.write("body { color: $bodycolor }\n")
|
493
|
+
}
|
494
|
+
File.open("#{dir}/l1/_dependee.scss", "w+"){|f|
|
495
|
+
f.write("$bodycolor: red;\n")
|
496
|
+
}
|
497
|
+
|
498
|
+
mdevel = Slinky::Manifest.new(dir, @config)
|
499
|
+
|
500
|
+
mf = mdevel.find_by_path("/l1/depender.scss").first
|
501
|
+
path = mf.process
|
502
|
+
File.read(path).should match /color: red/
|
503
|
+
|
504
|
+
File.open("#{dir}/l1/_dependee.scss", "w+"){|f|
|
505
|
+
f.write("$bodycolor: green;\n")
|
506
|
+
}
|
507
|
+
|
508
|
+
mf = mdevel.find_by_path("/l1/depender.scss").first
|
509
|
+
path = mf.process
|
510
|
+
File.read(path).should match /color: green/
|
511
|
+
ensure
|
512
|
+
FileUtils.rm_rf(dir)
|
513
|
+
end
|
514
|
+
end
|
505
515
|
end
|
506
516
|
end
|
507
517
|
|
data/spec/slinky_spec.rb
CHANGED
@@ -53,7 +53,8 @@ describe "Slinky" do
|
|
53
53
|
|
54
54
|
it "should serve the processed version of static files" do
|
55
55
|
Slinky::Server.manifest = @mdevel
|
56
|
-
@resp.should_receive(:content_type)
|
56
|
+
@resp.should_receive(:content_type)
|
57
|
+
.with("application/javascript; charset=utf-8").at_least(:once)
|
57
58
|
Slinky::Server.process_path @resp, "/l1/test.js"
|
58
59
|
File.read("/src/l1/test.js").match("slinky_require").should_not == nil
|
59
60
|
@resp.content.match("slinky_require").should == nil
|
@@ -83,7 +84,7 @@ eos
|
|
83
84
|
Slinky::Server.config = cr
|
84
85
|
Slinky::Server.manifest = @mdevel
|
85
86
|
$stdout.should_receive(:puts).with("Compiled /src/test.haml".foreground(:green))
|
86
|
-
@resp.should_receive(:content_type).with("text/html").at_least(:once)
|
87
|
+
@resp.should_receive(:content_type).with("text/html; charset=utf-8").at_least(:once)
|
87
88
|
Slinky::Server.process_path @resp, "this/doesnt/exist.html"
|
88
89
|
@resp.content.include?("html").should == true
|
89
90
|
end
|
@@ -98,7 +99,7 @@ eos
|
|
98
99
|
Slinky::Server.config = cr
|
99
100
|
Slinky::Server.manifest = @mdevel
|
100
101
|
@resp.should_receive(:status=).with(404)
|
101
|
-
@resp.should_receive(:content_type).with("text/html").at_least(:once)
|
102
|
+
@resp.should_receive(:content_type).with("text/html; charset=utf-8").at_least(:once)
|
102
103
|
Slinky::Server.process_path @resp, "this/doesnt/exist.html"
|
103
104
|
end
|
104
105
|
|
@@ -114,7 +115,7 @@ eos
|
|
114
115
|
Slinky::Server.config = cr
|
115
116
|
manifest = Slinky::Manifest.new("/src", cr)
|
116
117
|
Slinky::Server.manifest = manifest
|
117
|
-
@resp.should_receive(:content_type).with("text/html").at_least(:once)
|
118
|
+
@resp.should_receive(:content_type).with("text/html; charset=utf-8").at_least(:once)
|
118
119
|
Slinky::Server.process_path @resp, "hello/doesnt/exist.html"
|
119
120
|
@resp.content.include?("goodbye").should == true
|
120
121
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,73 +8,10 @@ require 'bundler/setup'
|
|
8
8
|
require 'rspec'
|
9
9
|
require 'slinky'
|
10
10
|
require 'fakefs/safe'
|
11
|
+
require 'tmpdir'
|
11
12
|
require 'fileutils'
|
12
13
|
require 'open-uri'
|
13
14
|
|
14
|
-
# Requires supporting files with custom matchers and macros, etc,
|
15
|
-
# in ./support/ and its subdirectories.
|
16
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
17
|
-
|
18
|
-
# Monkeypath to fix Tempfile creation in Ruby 2.1
|
19
|
-
# (https://github.com/defunkt/fakefs/pull/227)
|
20
|
-
module FakeFS
|
21
|
-
class Dir
|
22
|
-
if RUBY_VERSION >= '2.1'
|
23
|
-
module Tmpname # :nodoc:
|
24
|
-
module_function
|
25
|
-
|
26
|
-
def tmpdir
|
27
|
-
Dir.tmpdir
|
28
|
-
end
|
29
|
-
|
30
|
-
def make_tmpname(prefix_suffix, n)
|
31
|
-
case prefix_suffix
|
32
|
-
when String
|
33
|
-
prefix = prefix_suffix
|
34
|
-
suffix = ""
|
35
|
-
when Array
|
36
|
-
prefix = prefix_suffix[0]
|
37
|
-
suffix = prefix_suffix[1]
|
38
|
-
else
|
39
|
-
raise ArgumentError, "unexpected prefix_suffix: #{prefix_suffix.inspect}"
|
40
|
-
end
|
41
|
-
t = Time.now.strftime("%Y%m%d")
|
42
|
-
path = "#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
|
43
|
-
path << "-#{n}" if n
|
44
|
-
path << suffix
|
45
|
-
end
|
46
|
-
|
47
|
-
def create(basename, *rest)
|
48
|
-
if opts = Hash.try_convert(rest[-1])
|
49
|
-
opts = opts.dup if rest.pop.equal?(opts)
|
50
|
-
max_try = opts.delete(:max_try)
|
51
|
-
opts = [opts]
|
52
|
-
else
|
53
|
-
opts = []
|
54
|
-
end
|
55
|
-
tmpdir, = *rest
|
56
|
-
if $SAFE > 0 and tmpdir.tainted?
|
57
|
-
tmpdir = '/tmp'
|
58
|
-
else
|
59
|
-
tmpdir ||= tmpdir()
|
60
|
-
end
|
61
|
-
n = nil
|
62
|
-
begin
|
63
|
-
path = File.join(tmpdir, make_tmpname(basename, n))
|
64
|
-
yield(path, n, *opts)
|
65
|
-
rescue Errno::EEXIST
|
66
|
-
n ||= 0
|
67
|
-
n += 1
|
68
|
-
retry if !max_try or n < max_try
|
69
|
-
raise "cannot generate temporary name using `#{basename}' under `#{tmpdir}'"
|
70
|
-
end
|
71
|
-
path
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
15
|
module Slinky
|
79
16
|
class Runner
|
80
17
|
def version
|
@@ -85,10 +22,9 @@ module Slinky
|
|
85
22
|
# The coffee script compiler doesn't work under FakeFS
|
86
23
|
module CoffeeCompiler
|
87
24
|
def CoffeeCompiler::compile s, file
|
88
|
-
FakeFS.
|
89
|
-
|
90
|
-
|
91
|
-
o
|
25
|
+
FakeFS.without {
|
26
|
+
CoffeeScript::compile(s)
|
27
|
+
}
|
92
28
|
end
|
93
29
|
end
|
94
30
|
|
@@ -97,10 +33,20 @@ module Slinky
|
|
97
33
|
class << self
|
98
34
|
alias :old_compile :compile
|
99
35
|
def JSXCompiler::compile s, file
|
100
|
-
FakeFS.
|
101
|
-
|
102
|
-
|
103
|
-
|
36
|
+
FakeFS.without {
|
37
|
+
old_compile(s, file)
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
module SassCompiler
|
44
|
+
class << self
|
45
|
+
alias :old_compile :compile
|
46
|
+
def SassCompiler::compile s, file
|
47
|
+
FakeFS.without {
|
48
|
+
old_compile(s, file)
|
49
|
+
}
|
104
50
|
end
|
105
51
|
end
|
106
52
|
end
|
@@ -110,10 +56,9 @@ module Slinky
|
|
110
56
|
class << self
|
111
57
|
alias :get_old_cfile :get_cfile
|
112
58
|
def get_cfile *args
|
113
|
-
FakeFS.
|
114
|
-
|
115
|
-
|
116
|
-
cfile
|
59
|
+
FakeFS.without {
|
60
|
+
get_old_cfile *args
|
61
|
+
}
|
117
62
|
end
|
118
63
|
end
|
119
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slinky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micah Wylde
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -151,19 +151,19 @@ dependencies:
|
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '3.1'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
154
|
+
name: sassc
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
159
|
+
version: '1.8'
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
166
|
+
version: '1.8'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: coffee-script
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -240,14 +240,14 @@ dependencies:
|
|
240
240
|
requirements:
|
241
241
|
- - '='
|
242
242
|
- !ruby/object:Gem::Version
|
243
|
-
version: 0.
|
243
|
+
version: 0.6.7
|
244
244
|
type: :development
|
245
245
|
prerelease: false
|
246
246
|
version_requirements: !ruby/object:Gem::Requirement
|
247
247
|
requirements:
|
248
248
|
- - '='
|
249
249
|
- !ruby/object:Gem::Version
|
250
|
-
version: 0.
|
250
|
+
version: 0.6.7
|
251
251
|
- !ruby/object:Gem::Dependency
|
252
252
|
name: em-http-request
|
253
253
|
requirement: !ruby/object:Gem::Requirement
|
@@ -332,6 +332,20 @@ dependencies:
|
|
332
332
|
- - "~>"
|
333
333
|
- !ruby/object:Gem::Version
|
334
334
|
version: 0.9.3
|
335
|
+
- !ruby/object:Gem::Dependency
|
336
|
+
name: typescript-node
|
337
|
+
requirement: !ruby/object:Gem::Requirement
|
338
|
+
requirements:
|
339
|
+
- - "~>"
|
340
|
+
- !ruby/object:Gem::Version
|
341
|
+
version: 1.6.2
|
342
|
+
type: :development
|
343
|
+
prerelease: false
|
344
|
+
version_requirements: !ruby/object:Gem::Requirement
|
345
|
+
requirements:
|
346
|
+
- - "~>"
|
347
|
+
- !ruby/object:Gem::Version
|
348
|
+
version: 1.6.2
|
335
349
|
description: A static file server for rich web apps that automatically compiles SASS,
|
336
350
|
HAML, CoffeeScript and more
|
337
351
|
email: micah@micahw.com
|
@@ -364,6 +378,7 @@ files:
|
|
364
378
|
- lib/slinky/compilers/jsx-compiler.rb
|
365
379
|
- lib/slinky/compilers/less-compiler.rb
|
366
380
|
- lib/slinky/compilers/sass-compiler.rb
|
381
|
+
- lib/slinky/compilers/typescript-compiler.rb
|
367
382
|
- lib/slinky/config_reader.rb
|
368
383
|
- lib/slinky/em-popen3.rb
|
369
384
|
- lib/slinky/errors.rb
|
@@ -404,7 +419,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
404
419
|
version: '0'
|
405
420
|
requirements: []
|
406
421
|
rubyforge_project:
|
407
|
-
rubygems_version: 2.
|
422
|
+
rubygems_version: 2.4.5.1
|
408
423
|
signing_key:
|
409
424
|
specification_version: 4
|
410
425
|
summary: Static file server for javascript apps
|