stitch-rb 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/compile.rb +1 -1
- data/examples/lib/jquery.js +1 -1
- data/examples/lib/lib.coffee +3 -0
- data/lib/stitch.rb +5 -4
- data/lib/stitch/compilers/tmpl.rb +11 -0
- data/lib/stitch/dependency.rb +44 -0
- data/lib/stitch/package.rb +5 -1
- data/lib/stitch/version.rb +1 -1
- metadata +5 -2
data/examples/compile.rb
CHANGED
data/examples/lib/jquery.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
// A dependency
|
1
|
+
// A dependency - jquery.js
|
data/lib/stitch.rb
CHANGED
@@ -2,8 +2,9 @@ require "json"
|
|
2
2
|
require "stitch/version"
|
3
3
|
|
4
4
|
module Stitch
|
5
|
-
autoload :Compiler,
|
6
|
-
autoload :Package,
|
7
|
-
autoload :
|
8
|
-
autoload :
|
5
|
+
autoload :Compiler, "stitch/compiler"
|
6
|
+
autoload :Package, "stitch/package"
|
7
|
+
autoload :Dependency, "stitch/dependency"
|
8
|
+
autoload :Source, "stitch/source"
|
9
|
+
autoload :Server, "stitch/server"
|
9
10
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Stitch
|
2
|
+
class TmplCompiler < Compiler
|
3
|
+
extensions :tmpl
|
4
|
+
|
5
|
+
def compile(path)
|
6
|
+
content = File.read(path)
|
7
|
+
%{var template = jQuery.template(#{content.to_json});
|
8
|
+
module.exports = (function(data){ return jQuery.tmpl(template, data); });}
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
module Stitch
|
4
|
+
class Dependency
|
5
|
+
class << self
|
6
|
+
def from_path(path, result = [])
|
7
|
+
path = Pathname.new(path)
|
8
|
+
|
9
|
+
if path.directory?
|
10
|
+
path.children.each do |child|
|
11
|
+
from_path(child, result)
|
12
|
+
end
|
13
|
+
else
|
14
|
+
dependency = self.new(path)
|
15
|
+
result << dependency if dependency.valid?
|
16
|
+
end
|
17
|
+
result
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_reader :path
|
22
|
+
|
23
|
+
def initialize(path)
|
24
|
+
@path = Pathname.new(path)
|
25
|
+
end
|
26
|
+
|
27
|
+
def ext
|
28
|
+
path.extname
|
29
|
+
end
|
30
|
+
|
31
|
+
def compile
|
32
|
+
compiler.compile(path)
|
33
|
+
end
|
34
|
+
|
35
|
+
def valid?
|
36
|
+
!!compiler
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
def compiler
|
41
|
+
Compiler.for_extension(ext)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/stitch/package.rb
CHANGED
@@ -20,7 +20,11 @@ module Stitch
|
|
20
20
|
|
21
21
|
protected
|
22
22
|
def compile_dependencies
|
23
|
-
@dependencies.map {|path|
|
23
|
+
@dependencies.map {|path|
|
24
|
+
Dependency.from_path(path)
|
25
|
+
}.flatten.map { |dep|
|
26
|
+
dep.compile
|
27
|
+
}.join("\n")
|
24
28
|
end
|
25
29
|
|
26
30
|
def compile_sources
|
data/lib/stitch/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: stitch-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Alex MacCaw
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-07-
|
13
|
+
date: 2011-07-19 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -33,11 +33,14 @@ files:
|
|
33
33
|
- examples/app/controllers/controller.coffee
|
34
34
|
- examples/compile.rb
|
35
35
|
- examples/lib/jquery.js
|
36
|
+
- examples/lib/lib.coffee
|
36
37
|
- lib/stitch-rb.rb
|
37
38
|
- lib/stitch.rb
|
38
39
|
- lib/stitch/compiler.rb
|
39
40
|
- lib/stitch/compilers/coffeescript.rb
|
40
41
|
- lib/stitch/compilers/javascript.rb
|
42
|
+
- lib/stitch/compilers/tmpl.rb
|
43
|
+
- lib/stitch/dependency.rb
|
41
44
|
- lib/stitch/package.rb
|
42
45
|
- lib/stitch/server.rb
|
43
46
|
- lib/stitch/source.rb
|