ember 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +15 -0
- data/bin/ember +47 -0
- data/doc/api/classes/Ember.html +61 -0
- data/doc/api/classes/Ember/Template.html +396 -0
- data/doc/api/classes/Ember/Template/Program.html +497 -0
- data/doc/api/created.rid +1 -0
- data/doc/api/css/main.css +263 -0
- data/doc/api/css/panel.css +383 -0
- data/doc/api/css/reset.css +53 -0
- data/doc/api/files/LICENSE.html +76 -0
- data/doc/api/files/lib/ember/template_rb.html +66 -0
- data/doc/api/files/lib/ember_rb.html +63 -0
- data/doc/api/i/arrows.png +0 -0
- data/doc/api/i/results_bg.png +0 -0
- data/doc/api/i/tree_bg.png +0 -0
- data/doc/api/index.html +14 -0
- data/doc/api/js/jquery-1.3.2.min.js +19 -0
- data/doc/api/js/jquery-effect.js +593 -0
- data/doc/api/js/main.js +22 -0
- data/doc/api/js/searchdoc.js +605 -0
- data/doc/api/panel/index.html +63 -0
- data/doc/api/panel/search_index.js +1 -0
- data/doc/api/panel/tree.js +1 -0
- data/doc/example.erb +2 -0
- data/doc/example.txt +2 -0
- data/doc/history.erb +9 -0
- data/doc/index.erb +11 -0
- data/doc/index.xhtml +758 -0
- data/doc/intro.erb +79 -0
- data/doc/setup.erb +29 -0
- data/doc/usage.erb +249 -0
- data/lib/ember.rb +16 -0
- data/lib/ember/template.rb +586 -0
- data/rakefile +14 -0
- data/test/ember.rb +17 -0
- data/test/ember/template.rb +141 -0
- metadata +109 -0
data/rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2009 Suraj N. Kurapati
|
3
|
+
# See the LICENSE file for details.
|
4
|
+
#++
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
gem 'inochi', '~> 1'
|
8
|
+
require 'inochi'
|
9
|
+
|
10
|
+
Inochi.rake :Ember,
|
11
|
+
:test_with => :dfect,
|
12
|
+
:rubyforge_project => 'sunaku',
|
13
|
+
:upload_target => File.expand_path('~/www/lib/ember/'),
|
14
|
+
:upload_delete => true
|
data/test/ember.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
unless Ember.const_defined? :INOCHI
|
2
|
+
fail "#{Ember} must have INOCHI constant"
|
3
|
+
end
|
4
|
+
|
5
|
+
Ember::INOCHI.each do |param, value|
|
6
|
+
const = param.to_s.upcase
|
7
|
+
|
8
|
+
unless Ember.const_defined? const
|
9
|
+
fail "#{Ember} must have #{const} constant"
|
10
|
+
end
|
11
|
+
|
12
|
+
unless Ember.const_get(const) == value
|
13
|
+
fail "#{Ember}'s #{const} constant must be provided by Inochi"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
puts "Inochi establishment tests passed!"
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require 'dfect/mini'
|
2
|
+
require 'inochi/util/combo'
|
3
|
+
|
4
|
+
describe "A template" do
|
5
|
+
it "renders single & multi-line comments as nothing" do
|
6
|
+
WHITESPACE.each_join do |s|
|
7
|
+
render("<%##{s}an#{s}eRuby#{s}comment#{s}%>").must_equal("")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it "renders directives with whitespace-only bodies as nothing" do
|
12
|
+
WHITESPACE.each_join do |s|
|
13
|
+
OPERATIONS.each do |o|
|
14
|
+
render("<%#{o}#{s}%>").must_equal("")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "renders escaped directives in unescaped form" do
|
20
|
+
render("<%%%>").must_equal("<%%>")
|
21
|
+
|
22
|
+
render("<%% %>").must_equal("<% %>")
|
23
|
+
|
24
|
+
lambda { render("<% %%>") }.
|
25
|
+
must_raise(SyntaxError, "the trailing delimiter must not be unescaped")
|
26
|
+
|
27
|
+
render("<%%%%>").must_equal("<%%%>",
|
28
|
+
"the trailing delimiter must not be unescaped")
|
29
|
+
|
30
|
+
WHITESPACE.each_join do |s|
|
31
|
+
body = "#{s}an#{s}eRuby#{s}directive#{s}"
|
32
|
+
|
33
|
+
OPERATIONS.each do |o|
|
34
|
+
render("<%%#{o}#{body}%>").must_equal("<%#{o}#{body}%>")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "renders whitespace surrounding vocal directives correctly" do
|
40
|
+
o = rand.to_s
|
41
|
+
i = "<%= #{o} %>"
|
42
|
+
|
43
|
+
WHITESPACE.each_join do |s|
|
44
|
+
(BLANK + NEWLINES).enumeration do |a, b|
|
45
|
+
render("a#{a}#{s}#{i}#{b}#{s}b").must_equal("a#{a}#{s}#{o}#{b}#{s}b")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it "renders whitespace surrounding silent directives correctly" do
|
51
|
+
i = '<%%>'
|
52
|
+
o = ''
|
53
|
+
|
54
|
+
SPACES.each_join do |s|
|
55
|
+
NEWLINES.each do |n|
|
56
|
+
# without preceding newline
|
57
|
+
render("a#{s}#{i}#{n}b").must_equal("a#{o}b")
|
58
|
+
|
59
|
+
# with preceding newline
|
60
|
+
render("a#{n}#{s}#{i}#{n}b").must_equal("a#{n}#{o}b")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def render input, options = {}
|
68
|
+
Ember::Template.new(input, options).render
|
69
|
+
end
|
70
|
+
|
71
|
+
BLANK = [''] # the empty string
|
72
|
+
NEWLINES = ["\n", "\r\n"]
|
73
|
+
SPACES = [' ', "\t"]
|
74
|
+
WHITESPACE = SPACES + NEWLINES
|
75
|
+
OPERATIONS = [nil, '=', '#', *WHITESPACE]
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "A program compiled from a template" do
|
79
|
+
it "has the same number of lines as its input, regardless of template options" do
|
80
|
+
(BLANK + NEWLINES).each do |s|
|
81
|
+
test_num_lines s
|
82
|
+
test_num_lines "hello#{s}world"
|
83
|
+
|
84
|
+
OPERATIONS.each do |o|
|
85
|
+
test_num_lines "<%#{o}hello#{s}world%>"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
##
|
93
|
+
# Checks that the given input template is compiled into the same
|
94
|
+
# number of lines of Ruby code for all possible template options.
|
95
|
+
#
|
96
|
+
def test_num_lines input
|
97
|
+
num_input_lines = count_lines(input)
|
98
|
+
|
99
|
+
OPTIONS.each_combo do |options|
|
100
|
+
template = Ember::Template.new(input, options)
|
101
|
+
program = template.program
|
102
|
+
|
103
|
+
count_lines(program).must_equal num_input_lines, "template program compiled with #{options.inspect} has different number of lines for input #{input.inspect}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
##
|
108
|
+
# Counts the number of lines in the given string.
|
109
|
+
#
|
110
|
+
def count_lines string
|
111
|
+
string.to_s.scan(/$/).length
|
112
|
+
end
|
113
|
+
|
114
|
+
OPTIONS = [:shorthand, :infer_end, :unindent]
|
115
|
+
|
116
|
+
##
|
117
|
+
# Invokes the given block, passing in an options hash
|
118
|
+
# for Ember::Template, for every possible combination.
|
119
|
+
#
|
120
|
+
def OPTIONS.each_combo
|
121
|
+
raise ArgumentError unless block_given?
|
122
|
+
|
123
|
+
combinations do |flags|
|
124
|
+
yield Hash[ *flags.map {|f| [f, true] }.flatten ]
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
class Array
|
130
|
+
##
|
131
|
+
# Invokes the given block, passing in the result
|
132
|
+
# of Array#join, for every possible combination.
|
133
|
+
#
|
134
|
+
def each_join
|
135
|
+
raise ArgumentError unless block_given?
|
136
|
+
|
137
|
+
permutations do |combo|
|
138
|
+
yield combo.join
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ember
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Suraj N. Kurapati
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-05-04 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: inochi
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "1"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: inochi
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "1"
|
34
|
+
version:
|
35
|
+
description: eRuby template processor
|
36
|
+
email: sunaku@gmail.com
|
37
|
+
executables:
|
38
|
+
- ember
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
43
|
+
files:
|
44
|
+
- rakefile
|
45
|
+
- test/ember.rb
|
46
|
+
- test/ember/template.rb
|
47
|
+
- lib/ember.rb
|
48
|
+
- lib/ember/template.rb
|
49
|
+
- bin/ember
|
50
|
+
- LICENSE
|
51
|
+
- doc/intro.erb
|
52
|
+
- doc/setup.erb
|
53
|
+
- doc/example.txt
|
54
|
+
- doc/example.erb
|
55
|
+
- doc/index.xhtml
|
56
|
+
- doc/api/classes/Ember.html
|
57
|
+
- doc/api/classes/Ember/Template/Program.html
|
58
|
+
- doc/api/classes/Ember/Template.html
|
59
|
+
- doc/api/panel/search_index.js
|
60
|
+
- doc/api/panel/tree.js
|
61
|
+
- doc/api/panel/index.html
|
62
|
+
- doc/api/js/searchdoc.js
|
63
|
+
- doc/api/js/jquery-effect.js
|
64
|
+
- doc/api/js/jquery-1.3.2.min.js
|
65
|
+
- doc/api/js/main.js
|
66
|
+
- doc/api/files/LICENSE.html
|
67
|
+
- doc/api/files/lib/ember_rb.html
|
68
|
+
- doc/api/files/lib/ember/template_rb.html
|
69
|
+
- doc/api/css/main.css
|
70
|
+
- doc/api/css/reset.css
|
71
|
+
- doc/api/css/panel.css
|
72
|
+
- doc/api/i/arrows.png
|
73
|
+
- doc/api/i/tree_bg.png
|
74
|
+
- doc/api/i/results_bg.png
|
75
|
+
- doc/api/created.rid
|
76
|
+
- doc/api/index.html
|
77
|
+
- doc/usage.erb
|
78
|
+
- doc/history.erb
|
79
|
+
- doc/index.erb
|
80
|
+
has_rdoc: true
|
81
|
+
homepage: http://snk.tuxfamily.org/lib/ember
|
82
|
+
licenses: []
|
83
|
+
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: "0"
|
94
|
+
version:
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: "0"
|
100
|
+
version:
|
101
|
+
requirements: []
|
102
|
+
|
103
|
+
rubyforge_project: sunaku
|
104
|
+
rubygems_version: 1.3.2
|
105
|
+
signing_key:
|
106
|
+
specification_version: 3
|
107
|
+
summary: eRuby template processor
|
108
|
+
test_files: []
|
109
|
+
|