wlang 2.0.1 → 2.1.0

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.
Files changed (46) hide show
  1. data/CHANGELOG.md +27 -0
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +16 -0
  4. data/README.md +32 -55
  5. data/lib/wlang.rb +8 -0
  6. data/lib/wlang/compiler/grammar.citrus +19 -16
  7. data/lib/wlang/dialect.rb +18 -14
  8. data/lib/wlang/html.rb +7 -11
  9. data/lib/wlang/scope.rb +68 -28
  10. data/lib/wlang/scope/binding_scope.rb +3 -3
  11. data/lib/wlang/scope/null_scope.rb +34 -0
  12. data/lib/wlang/scope/object_scope.rb +18 -7
  13. data/lib/wlang/scope/proc_scope.rb +4 -4
  14. data/lib/wlang/scope/sinatra_scope.rb +44 -0
  15. data/lib/wlang/template.rb +10 -2
  16. data/lib/wlang/tilt/wlang_template.rb +1 -1
  17. data/lib/wlang/version.rb +2 -2
  18. data/spec/assumptions/test_core.rb +8 -0
  19. data/spec/fixtures/templates/hello_from_sinatra.wlang +1 -0
  20. data/spec/integration/html/test_greater.rb +12 -2
  21. data/spec/integration/sinatra/test_partials.rb +35 -0
  22. data/spec/integration/test_examples.rb +2 -2
  23. data/spec/spec_helper.rb +7 -0
  24. data/spec/unit/compiler/test_grammar.rb +1 -1
  25. data/spec/unit/compiler/test_parser.rb +17 -0
  26. data/spec/unit/dialect/test_context.rb +28 -0
  27. data/spec/unit/dialect/test_evaluate.rb +10 -0
  28. data/spec/unit/dialect/test_render.rb +4 -0
  29. data/spec/unit/scope/sinatra_scope/test_fetch.rb +28 -0
  30. data/spec/unit/scope/test_binding_scope.rb +1 -1
  31. data/spec/unit/scope/test_chain.rb +5 -5
  32. data/spec/unit/scope/test_coerce.rb +7 -3
  33. data/spec/unit/scope/test_null_scope.rb +35 -0
  34. data/spec/unit/scope/test_object_scope.rb +1 -1
  35. data/spec/unit/scope/test_proc_scope.rb +1 -1
  36. data/spec/unit/scope/test_push.rb +70 -0
  37. data/spec/unit/template/test_call_args_conventions.rb +101 -0
  38. data/spec/unit/test_assumptions.rb +12 -0
  39. data/spec/unit/test_scope.rb +26 -16
  40. data/wlang.gemspec +2 -0
  41. data/wlang.noespec +3 -1
  42. metadata +143 -33
  43. data/lib/wlang/scope/proxy_scope.rb +0 -18
  44. data/lib/wlang/scope/root_scope.rb +0 -24
  45. data/spec/unit/scope/test_proxy_scope.rb +0 -22
  46. 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