ember 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/ember +3 -55
- data/lib/ember.rb +4 -1
- data/lib/ember/inochi.rb +2 -2
- data/lib/ember/template.rb +5 -3
- data/man/man1/ember.1.gz +0 -0
- data/man/man1/ember.1.html +805 -0
- metadata +9 -41
- data/HISTORY +0 -79
- data/INSTALL +0 -31
- data/MANUAL +0 -25
- data/README +0 -54
- data/THEORY +0 -151
- data/USAGE +0 -250
- data/doc/ann.xml +0 -93
- data/doc/api/Ember.html +0 -436
- data/doc/api/Ember/Template.html +0 -774
- data/doc/api/Ember/Template/Program.html +0 -877
- data/doc/api/Ember/Template/Program/Statement.html +0 -181
- data/doc/api/_index.html +0 -139
- data/doc/api/class_list.html +0 -36
- data/doc/api/css/common.css +0 -1
- data/doc/api/css/full_list.css +0 -50
- data/doc/api/css/style.css +0 -273
- data/doc/api/file.LICENSE.html +0 -73
- data/doc/api/file_list.html +0 -38
- data/doc/api/frames.html +0 -13
- data/doc/api/index.html +0 -73
- data/doc/api/js/app.js +0 -111
- data/doc/api/js/full_list.js +0 -117
- data/doc/api/js/jquery.js +0 -19
- data/doc/api/method_list.html +0 -179
- data/doc/api/top-level-namespace.html +0 -87
- data/doc/ember.png +0 -0
- data/doc/ember.svg +0 -784
- data/doc/example.erb +0 -2
- data/doc/example.txt +0 -2
- data/doc/index.html +0 -2295
- data/inochi.opts +0 -31
- data/test/combinatorics.rb +0 -188
- data/test/ember/template_test.rb +0 -137
- data/test/runner +0 -25
- data/test/test_helper.rb +0 -5
data/inochi.opts
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# Location where project documentation will be uploaded by `inochi pub:doc`.
|
3
|
-
# This value can utilize any remote/destination syntax supported by `rsync`.
|
4
|
-
#
|
5
|
-
:pub_doc_target: ~/www/lib/ember
|
6
|
-
|
7
|
-
##
|
8
|
-
# Options for the `rsync` command used to upload this project's documentation.
|
9
|
-
#
|
10
|
-
:pub_doc_options: --verbose --compress --archive --update --delete
|
11
|
-
|
12
|
-
##
|
13
|
-
# Arbitrary Ruby code that will configure this project's RubyGem before it
|
14
|
-
# is built by `inochi gem`. This code has access to a local variable named
|
15
|
-
# `gem` which holds a Gem::Specification object representing this project.
|
16
|
-
#
|
17
|
-
# @example
|
18
|
-
#
|
19
|
-
# :gem_spec_logic: |
|
20
|
-
# # show the Inochi-provided specification for this project's RubyGem
|
21
|
-
# puts gem
|
22
|
-
#
|
23
|
-
# # add files that are outside this project directory to the RubyGem
|
24
|
-
# gem.files += FileList['/some/outside/**/*.files']
|
25
|
-
#
|
26
|
-
# # omit some files in this project's directory from the RubyGem
|
27
|
-
# gem.files.exclude '{some*files,in_this,project/**/directory}'
|
28
|
-
#
|
29
|
-
# # and so on... anything is possible! use your imagination!
|
30
|
-
#
|
31
|
-
:gem_spec_logic: |
|
data/test/combinatorics.rb
DELETED
@@ -1,188 +0,0 @@
|
|
1
|
-
# Simple combinatorics library for Ruby 1.8, 1.9, and (hopefully) beyond.
|
2
|
-
#
|
3
|
-
# (the ISC license)
|
4
|
-
#
|
5
|
-
# Copyright 2007 Suraj N. Kurapati <sunaku@gmail.com>
|
6
|
-
#
|
7
|
-
# Permission to use, copy, modify, and/or distribute this software for any
|
8
|
-
# purpose with or without fee is hereby granted, provided that the above
|
9
|
-
# copyright notice and this permission notice appear in all copies.
|
10
|
-
#
|
11
|
-
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
12
|
-
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
13
|
-
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
14
|
-
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
15
|
-
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
16
|
-
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
17
|
-
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
18
|
-
#
|
19
|
-
class Array
|
20
|
-
unless method_defined? :enumeration
|
21
|
-
##
|
22
|
-
# Returns all possible enumerations made from
|
23
|
-
# sample_size number of items from this list.
|
24
|
-
#
|
25
|
-
# @param [Integer] sample_size
|
26
|
-
# The length of each enumeration.
|
27
|
-
#
|
28
|
-
# @param [Proc] sampler
|
29
|
-
# If given, each enumeration is passed to this block.
|
30
|
-
#
|
31
|
-
def enumeration(sample_size = self.length, &sampler)
|
32
|
-
return [] if sample_size < 1
|
33
|
-
|
34
|
-
results = []
|
35
|
-
|
36
|
-
visitor = lambda do |parents|
|
37
|
-
each do |child|
|
38
|
-
result = parents + [child]
|
39
|
-
|
40
|
-
if result.length < sample_size
|
41
|
-
visitor.call result
|
42
|
-
else
|
43
|
-
yield result if block_given?
|
44
|
-
results << result
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
visitor.call []
|
50
|
-
results
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
unless method_defined? :enumerations
|
55
|
-
##
|
56
|
-
# Returns all possible enumerations of all possible lengths.
|
57
|
-
#
|
58
|
-
# @param [Proc] sampler
|
59
|
-
# If given, each enumeration is passed to this block.
|
60
|
-
#
|
61
|
-
def enumerations &sampler
|
62
|
-
all_lengths_impl :enumeration, &sampler
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
unless method_defined? :combination
|
67
|
-
##
|
68
|
-
# Returns all possible combinations made from
|
69
|
-
# sample_size number of items from this list.
|
70
|
-
#
|
71
|
-
# @param [Integer] sample_size
|
72
|
-
# The length of each combination.
|
73
|
-
#
|
74
|
-
# @param [Proc] sampler
|
75
|
-
# If given, each combination is passed to this block.
|
76
|
-
#
|
77
|
-
def combination(sample_size = self.length, &sampler)
|
78
|
-
pnk_cnk_impl(sample_size, true, &sampler)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
unless method_defined? :combinations
|
83
|
-
##
|
84
|
-
# Returns all possible combinations of all possible lengths.
|
85
|
-
#
|
86
|
-
# @param [Proc] sampler
|
87
|
-
# If given, each combination is passed to this block.
|
88
|
-
#
|
89
|
-
def combinations &sampler
|
90
|
-
all_lengths_impl :combination, &sampler
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
unless method_defined? :permutation
|
95
|
-
##
|
96
|
-
# Returns all possible permutations made from
|
97
|
-
# sample_size number of items from this list.
|
98
|
-
#
|
99
|
-
# @param [Integer] sample_size
|
100
|
-
# The length of each permutation.
|
101
|
-
#
|
102
|
-
# @param [Proc] sampler
|
103
|
-
# If given, each permutation is passed to this block.
|
104
|
-
#
|
105
|
-
def permutation(sample_size = self.length, &sampler)
|
106
|
-
pnk_cnk_impl(sample_size, false, &sampler)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
unless method_defined? :permutations
|
111
|
-
##
|
112
|
-
# Returns all possible permutations of all possible lengths.
|
113
|
-
#
|
114
|
-
# @param [Proc] sampler
|
115
|
-
# If given, each permutation is passed to this block.
|
116
|
-
#
|
117
|
-
def permutations &sampler
|
118
|
-
all_lengths_impl :permutation, &sampler
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
private
|
123
|
-
|
124
|
-
##
|
125
|
-
# Returns results of the given method name for all possible sample sizes.
|
126
|
-
#
|
127
|
-
def all_lengths_impl method_name, &sampler
|
128
|
-
results = []
|
129
|
-
|
130
|
-
0.upto(length) do |i|
|
131
|
-
results << __send__(method_name, i, &sampler)
|
132
|
-
end
|
133
|
-
|
134
|
-
results
|
135
|
-
end
|
136
|
-
|
137
|
-
##
|
138
|
-
# Common implementation for permutation and combination functions.
|
139
|
-
#
|
140
|
-
# @param [Integer] sample_size
|
141
|
-
# Maximum depth of traversal, at which point to stop
|
142
|
-
# further traversal and to start collecting results.
|
143
|
-
#
|
144
|
-
# @param [boolean] exclude_parents
|
145
|
-
# Prevent already visited vertices from being
|
146
|
-
# visited again in subsequent iterations?
|
147
|
-
#
|
148
|
-
def pnk_cnk_impl sample_size, exclude_parents
|
149
|
-
results = []
|
150
|
-
|
151
|
-
if sample_size >= 0 && sample_size < self.length
|
152
|
-
##
|
153
|
-
# @param [#each] parents
|
154
|
-
# list of visited vertices, including the current vertex
|
155
|
-
#
|
156
|
-
# @param [#each] children
|
157
|
-
# list of unvisited vertices adjacent to current vertex
|
158
|
-
#
|
159
|
-
# @param [Integer] depth
|
160
|
-
# current depth of the traversal tree
|
161
|
-
#
|
162
|
-
visitor = lambda do |parents, children, depth|
|
163
|
-
# traverse the graph until we reach the fringe
|
164
|
-
# vertices (leaf nodes of the traversal tree)
|
165
|
-
if depth < sample_size - 1
|
166
|
-
children.each do |c|
|
167
|
-
next_children = children - (exclude_parents ? parents : [c])
|
168
|
-
next_parents = parents + [c]
|
169
|
-
next_depth = depth + 1
|
170
|
-
|
171
|
-
visitor.call next_parents, next_children, next_depth
|
172
|
-
end
|
173
|
-
else
|
174
|
-
# now we have reached the fringe vertices
|
175
|
-
children.each do |c|
|
176
|
-
result = parents + [c]
|
177
|
-
yield result if block_given?
|
178
|
-
results << result
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
visitor.call [], self, 0
|
184
|
-
end
|
185
|
-
|
186
|
-
results
|
187
|
-
end
|
188
|
-
end
|
data/test/ember/template_test.rb
DELETED
@@ -1,137 +0,0 @@
|
|
1
|
-
require 'ember/template'
|
2
|
-
|
3
|
-
describe do
|
4
|
-
BLANK = [''] # the empty string
|
5
|
-
NEWLINES = ["\n", "\r\n"]
|
6
|
-
SPACES = [' ', "\t"]
|
7
|
-
WHITESPACE = SPACES + NEWLINES
|
8
|
-
OPERATIONS = [nil, '=', '#', *WHITESPACE]
|
9
|
-
|
10
|
-
##
|
11
|
-
# Invokes the given block, passing in the result
|
12
|
-
# of Array#join, for every possible combination.
|
13
|
-
#
|
14
|
-
def each_join array
|
15
|
-
raise ArgumentError unless block_given?
|
16
|
-
|
17
|
-
array.permutations do |combo|
|
18
|
-
yield combo.join
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "A template" do
|
23
|
-
it "renders single & multi-line comments as nothing" do
|
24
|
-
each_join(WHITESPACE) do |s|
|
25
|
-
render("<%##{s}an#{s}eRuby#{s}comment#{s}%>").must_equal("")
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
it "renders directives with whitespace-only bodies as nothing" do
|
30
|
-
each_join(WHITESPACE) do |s|
|
31
|
-
OPERATIONS.each do |o|
|
32
|
-
render("<%#{o}#{s}%>").must_equal("")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
it "renders escaped directives in unescaped form" do
|
38
|
-
render("<%%%>").must_equal("<%%>")
|
39
|
-
|
40
|
-
render("<%% %>").must_equal("<% %>")
|
41
|
-
|
42
|
-
E SyntaxError, "the trailing delimiter must not be unescaped" do
|
43
|
-
render("<% %%>")
|
44
|
-
end
|
45
|
-
|
46
|
-
render("<%%%%>").must_equal("<%%%>",
|
47
|
-
"the trailing delimiter must not be unescaped")
|
48
|
-
|
49
|
-
each_join(WHITESPACE) do |s|
|
50
|
-
body = "#{s}an#{s}eRuby#{s}directive#{s}"
|
51
|
-
|
52
|
-
OPERATIONS.each do |o|
|
53
|
-
render("<%%#{o}#{body}%>").must_equal("<%#{o}#{body}%>")
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
it "renders whitespace surrounding vocal directives correctly" do
|
59
|
-
o = rand.to_s
|
60
|
-
i = "<%= #{o} %>"
|
61
|
-
|
62
|
-
each_join(WHITESPACE) do |s|
|
63
|
-
(BLANK + NEWLINES).enumeration do |a, b|
|
64
|
-
render("a#{a}#{s}#{i}#{b}#{s}b").must_equal("a#{a}#{s}#{o}#{b}#{s}b")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
it "renders whitespace surrounding silent directives correctly" do
|
70
|
-
i = '<%%>'
|
71
|
-
o = ''
|
72
|
-
|
73
|
-
each_join(SPACES) do |s|
|
74
|
-
NEWLINES.each do |n|
|
75
|
-
# without preceding newline
|
76
|
-
render("a#{s}#{i}#{n}b").must_equal("a#{o}b")
|
77
|
-
|
78
|
-
# with preceding newline
|
79
|
-
render("a#{n}#{s}#{i}#{n}b").must_equal("a#{n}#{o}b")
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def render input, options = {}
|
85
|
-
Ember::Template.new(input, options).render
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe "A program compiled from a template" do
|
90
|
-
it "has the same number of lines as its input, regardless of template options" do
|
91
|
-
(BLANK + NEWLINES).each do |s|
|
92
|
-
test_num_lines s
|
93
|
-
test_num_lines "hello#{s}world"
|
94
|
-
|
95
|
-
OPERATIONS.each do |o|
|
96
|
-
test_num_lines "<%#{o}hello#{s}world%>"
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
OPTIONS = [:shorthand, :infer_end, :unindent]
|
102
|
-
|
103
|
-
##
|
104
|
-
# Checks that the given input template is compiled into the same
|
105
|
-
# number of lines of Ruby code for all possible template options.
|
106
|
-
#
|
107
|
-
def test_num_lines input
|
108
|
-
num_input_lines = count_lines(input)
|
109
|
-
|
110
|
-
each_option_combo(OPTIONS) do |options|
|
111
|
-
template = Ember::Template.new(input, options)
|
112
|
-
program = template.program
|
113
|
-
|
114
|
-
count_lines(program).must_equal num_input_lines, "template program compiled with #{options.inspect} has different number of lines for input #{input.inspect}"
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
##
|
119
|
-
# Counts the number of lines in the given string.
|
120
|
-
#
|
121
|
-
def count_lines string
|
122
|
-
string.to_s.scan(/$/).length
|
123
|
-
end
|
124
|
-
|
125
|
-
##
|
126
|
-
# Invokes the given block, passing in an options hash
|
127
|
-
# for Ember::Template, for every possible combination.
|
128
|
-
#
|
129
|
-
def each_option_combo options
|
130
|
-
raise ArgumentError unless block_given?
|
131
|
-
|
132
|
-
options.combinations do |flags|
|
133
|
-
yield Hash[ *flags.map {|f| [f, true] }.flatten ]
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
data/test/runner
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Adds the project library directory
|
4
|
-
# and this test directory to Ruby's
|
5
|
-
# load path and runs the given tests.
|
6
|
-
#
|
7
|
-
# Usage: ruby test/runner [TESTS_TO_RUN]
|
8
|
-
#
|
9
|
-
# Where: TESTS_TO_RUN is a list of files
|
10
|
-
# or file globbing patterns that
|
11
|
-
# describe a set of files to run.
|
12
|
-
#
|
13
|
-
# If this parameter is not given,
|
14
|
-
# all *_test.rb files within or
|
15
|
-
# beneath this directory are run.
|
16
|
-
|
17
|
-
lib_dir = File.expand_path('../../lib', __FILE__)
|
18
|
-
test_dir = File.expand_path('..', __FILE__)
|
19
|
-
$LOAD_PATH.unshift lib_dir, test_dir
|
20
|
-
|
21
|
-
require 'ember/inochi'
|
22
|
-
require 'test_helper'
|
23
|
-
|
24
|
-
ARGV << "#{test_dir}/**/*_test.rb" if ARGV.empty?
|
25
|
-
ARGV.each {|glob| Dir[glob].each {|test| load test } }
|