comb 0.0.4 → 0.0.5
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/comb.gemspec +1 -0
- data/lib/comb.rb +24 -3
- data/lib/comb/version.rb +1 -1
- data/test/js/templates/link.html +1 -0
- data/test/js/templates/list.html +5 -0
- data/test/output.js.example +8 -2
- metadata +18 -3
data/comb.gemspec
CHANGED
data/lib/comb.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require_relative 'comb/version'
|
|
2
|
+
require 'json'
|
|
2
3
|
require 'time'
|
|
3
4
|
|
|
4
5
|
class Comb
|
|
@@ -21,7 +22,10 @@ public
|
|
|
21
22
|
mark_start_of_output
|
|
22
23
|
append_require_snippet
|
|
23
24
|
for_each_js_module do |name, code|
|
|
24
|
-
|
|
25
|
+
append_module(name, code)
|
|
26
|
+
end
|
|
27
|
+
for_each_html_template do |name, template|
|
|
28
|
+
append_template(name, template)
|
|
25
29
|
end
|
|
26
30
|
mark_end_of_output
|
|
27
31
|
return_output
|
|
@@ -47,7 +51,15 @@ require.register = function(module, code) {
|
|
|
47
51
|
end
|
|
48
52
|
|
|
49
53
|
def for_each_js_module
|
|
50
|
-
|
|
54
|
+
for_each_file('js') { |name, code| yield name, code }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def for_each_html_template
|
|
58
|
+
for_each_file('html') { |name, template| yield name, template }
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def for_each_file(ext)
|
|
62
|
+
Dir.glob(@path_to_modules + "/**/*.#{ext}").each do |path|
|
|
51
63
|
# get the module 'name' by removing the path and the extension
|
|
52
64
|
name = path.gsub(@path_to_modules, '').gsub(/^\//, '').gsub(/\.js$/, '')
|
|
53
65
|
code = File.open(path) { |f| f.read }
|
|
@@ -55,7 +67,7 @@ require.register = function(module, code) {
|
|
|
55
67
|
end
|
|
56
68
|
end
|
|
57
69
|
|
|
58
|
-
def
|
|
70
|
+
def append_module(name, code)
|
|
59
71
|
@output << (<<-eos
|
|
60
72
|
require.register('#{name}', function() {
|
|
61
73
|
#{indent_code(code)}
|
|
@@ -64,6 +76,15 @@ require.register('#{name}', function() {
|
|
|
64
76
|
).chomp
|
|
65
77
|
end
|
|
66
78
|
|
|
79
|
+
def append_template(name, template)
|
|
80
|
+
@output << (<<-eos
|
|
81
|
+
require.register('#{name}', function() {
|
|
82
|
+
return #{template.gsub("\n", ' ').gsub(/\s+/, ' ' ).strip.to_json}
|
|
83
|
+
})
|
|
84
|
+
eos
|
|
85
|
+
).chomp
|
|
86
|
+
end
|
|
87
|
+
|
|
67
88
|
def indent_code(code)
|
|
68
89
|
code.split("\n").collect { |line| " #{line}" }.join("\n")
|
|
69
90
|
end
|
data/lib/comb/version.rb
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<a href="<%= uri %>"><%= label %></a>
|
data/test/output.js.example
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// generated by comb on
|
|
1
|
+
// generated by comb on 2012-01-04T04:54:10Z
|
|
2
2
|
var require = function(module) {
|
|
3
3
|
return require.registry[module]()
|
|
4
4
|
}
|
|
@@ -34,4 +34,10 @@ require.register('utils/uri', function() {
|
|
|
34
34
|
|
|
35
35
|
return {bestUri: bestUri}
|
|
36
36
|
})
|
|
37
|
-
|
|
37
|
+
require.register('templates/link.html', function() {
|
|
38
|
+
return "<a href=\"<%= uri %>\"><%= label %></a>"
|
|
39
|
+
})
|
|
40
|
+
require.register('templates/list.html', function() {
|
|
41
|
+
return "<ul> <% _(items).each(function(item) { %> <li><%= item %></li> <% } %> </ul>"
|
|
42
|
+
})
|
|
43
|
+
// end of comb output at 2012-01-04T04:54:10Z
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: comb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.5
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,8 +9,19 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
13
|
-
dependencies:
|
|
12
|
+
date: 2012-01-04 00:00:00.000000000Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: json
|
|
16
|
+
requirement: &70182412598740 !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: *70182412598740
|
|
14
25
|
description: Brings file-based module support to client-side JavaScript applications.
|
|
15
26
|
email:
|
|
16
27
|
- ryan@yeahnah.org
|
|
@@ -30,6 +41,8 @@ files:
|
|
|
30
41
|
- test/README
|
|
31
42
|
- test/container.html
|
|
32
43
|
- test/js/app.js
|
|
44
|
+
- test/js/templates/link.html
|
|
45
|
+
- test/js/templates/list.html
|
|
33
46
|
- test/js/utils/date.js
|
|
34
47
|
- test/js/utils/uri.js
|
|
35
48
|
- test/output.js.example
|
|
@@ -61,6 +74,8 @@ test_files:
|
|
|
61
74
|
- test/README
|
|
62
75
|
- test/container.html
|
|
63
76
|
- test/js/app.js
|
|
77
|
+
- test/js/templates/link.html
|
|
78
|
+
- test/js/templates/list.html
|
|
64
79
|
- test/js/utils/date.js
|
|
65
80
|
- test/js/utils/uri.js
|
|
66
81
|
- test/output.js.example
|