wlang 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +27 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +16 -0
- data/README.md +32 -55
- data/lib/wlang.rb +8 -0
- data/lib/wlang/compiler/grammar.citrus +19 -16
- data/lib/wlang/dialect.rb +18 -14
- data/lib/wlang/html.rb +7 -11
- data/lib/wlang/scope.rb +68 -28
- data/lib/wlang/scope/binding_scope.rb +3 -3
- data/lib/wlang/scope/null_scope.rb +34 -0
- data/lib/wlang/scope/object_scope.rb +18 -7
- data/lib/wlang/scope/proc_scope.rb +4 -4
- data/lib/wlang/scope/sinatra_scope.rb +44 -0
- data/lib/wlang/template.rb +10 -2
- data/lib/wlang/tilt/wlang_template.rb +1 -1
- data/lib/wlang/version.rb +2 -2
- data/spec/assumptions/test_core.rb +8 -0
- data/spec/fixtures/templates/hello_from_sinatra.wlang +1 -0
- data/spec/integration/html/test_greater.rb +12 -2
- data/spec/integration/sinatra/test_partials.rb +35 -0
- data/spec/integration/test_examples.rb +2 -2
- data/spec/spec_helper.rb +7 -0
- data/spec/unit/compiler/test_grammar.rb +1 -1
- data/spec/unit/compiler/test_parser.rb +17 -0
- data/spec/unit/dialect/test_context.rb +28 -0
- data/spec/unit/dialect/test_evaluate.rb +10 -0
- data/spec/unit/dialect/test_render.rb +4 -0
- data/spec/unit/scope/sinatra_scope/test_fetch.rb +28 -0
- data/spec/unit/scope/test_binding_scope.rb +1 -1
- data/spec/unit/scope/test_chain.rb +5 -5
- data/spec/unit/scope/test_coerce.rb +7 -3
- data/spec/unit/scope/test_null_scope.rb +35 -0
- data/spec/unit/scope/test_object_scope.rb +1 -1
- data/spec/unit/scope/test_proc_scope.rb +1 -1
- data/spec/unit/scope/test_push.rb +70 -0
- data/spec/unit/template/test_call_args_conventions.rb +101 -0
- data/spec/unit/test_assumptions.rb +12 -0
- data/spec/unit/test_scope.rb +26 -16
- data/wlang.gemspec +2 -0
- data/wlang.noespec +3 -1
- metadata +143 -33
- data/lib/wlang/scope/proxy_scope.rb +0 -18
- data/lib/wlang/scope/root_scope.rb +0 -24
- data/spec/unit/scope/test_proxy_scope.rb +0 -22
- data/spec/unit/scope/test_root_scope.rb +0 -22
@@ -1,18 +0,0 @@
|
|
1
|
-
module WLang
|
2
|
-
class Scope
|
3
|
-
class ProxyScope < Scope
|
4
|
-
|
5
|
-
def fetch(key, &blk)
|
6
|
-
subject.fetch(key) do
|
7
|
-
parent.fetch(key, &blk)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def inspect
|
12
|
-
subject.inspect
|
13
|
-
end
|
14
|
-
alias :to_s :inspect
|
15
|
-
|
16
|
-
end # class ProxyScope
|
17
|
-
end # class Scope
|
18
|
-
end # module WLang
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module WLang
|
2
|
-
class Scope
|
3
|
-
class RootScope < Scope
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
super(nil,nil)
|
7
|
-
end
|
8
|
-
|
9
|
-
def pop
|
10
|
-
raise "Unable to pop from root scope"
|
11
|
-
end
|
12
|
-
|
13
|
-
def fetch(key)
|
14
|
-
block_given? ? yield : throw(:fail)
|
15
|
-
end
|
16
|
-
|
17
|
-
def inspect
|
18
|
-
"RootScope"
|
19
|
-
end
|
20
|
-
alias :to_s :inspect
|
21
|
-
|
22
|
-
end # class RootScope
|
23
|
-
end # class Scope
|
24
|
-
end # module WLang
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
module WLang
|
3
|
-
class Scope
|
4
|
-
describe ProxyScope do
|
5
|
-
|
6
|
-
it 'delegates fetch to its subject' do
|
7
|
-
proxy = Scope.coerce(Scope.coerce(:who => "World"))
|
8
|
-
proxy.fetch(:who).should eq("World")
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'delegates fetch to its parent when not found' do
|
12
|
-
proxy = Scope.coerce(Scope.root, Scope.coerce(:who => "World"))
|
13
|
-
proxy.fetch(:who).should eq("World")
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'fetches `self` correctly' do
|
17
|
-
Scope.coerce(Scope.coerce(12)).fetch(:self).should eq(12)
|
18
|
-
end
|
19
|
-
|
20
|
-
end # describe ProxyScope
|
21
|
-
end # class Scope
|
22
|
-
end # module WLang
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
module WLang
|
3
|
-
class Scope
|
4
|
-
describe RootScope do
|
5
|
-
|
6
|
-
let(:scope){ RootScope.new }
|
7
|
-
|
8
|
-
it 'throws on fetch' do
|
9
|
-
lambda{ scope.fetch(:who) }.should throw_symbol(:fail)
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'throws on fetch even on `self`' do
|
13
|
-
lambda{ scope.fetch(:self) }.should throw_symbol(:fail)
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'raises on pop' do
|
17
|
-
lambda{ scope.pop }.should raise_error
|
18
|
-
end
|
19
|
-
|
20
|
-
end # describe ProxyScope
|
21
|
-
end # class Scope
|
22
|
-
end # module WLang
|