inversion 1.3.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/Examples.md +134 -0
- data/GettingStarted.md +50 -0
- data/Guide.md +14 -0
- data/{History.rdoc → History.md} +59 -43
- data/{README.rdoc → README.md} +43 -34
- data/Tags.md +555 -0
- data/bin/inversion +4 -8
- data/lib/inversion/cli/api.rb +75 -0
- data/lib/inversion/cli/tagtokens.rb +34 -0
- data/lib/inversion/cli/tree.rb +70 -0
- data/lib/inversion/cli.rb +406 -0
- data/lib/inversion/exceptions.rb +0 -1
- data/lib/inversion/mixins.rb +10 -11
- data/lib/inversion/parser.rb +5 -6
- data/lib/inversion/refinements.rb +18 -0
- data/lib/inversion/renderstate.rb +24 -25
- data/lib/inversion/sinatra.rb +0 -1
- data/lib/inversion/template/attrtag.rb +7 -5
- data/lib/inversion/template/begintag.rb +0 -1
- data/lib/inversion/template/calltag.rb +0 -1
- data/lib/inversion/template/codetag.rb +37 -28
- data/lib/inversion/template/commenttag.rb +0 -1
- data/lib/inversion/template/configtag.rb +3 -4
- data/lib/inversion/template/containertag.rb +1 -2
- data/lib/inversion/template/defaulttag.rb +1 -2
- data/lib/inversion/template/elsetag.rb +0 -1
- data/lib/inversion/template/elsiftag.rb +0 -1
- data/lib/inversion/template/endtag.rb +2 -3
- data/lib/inversion/template/escapetag.rb +1 -2
- data/lib/inversion/template/fortag.rb +2 -3
- data/lib/inversion/template/fragmenttag.rb +1 -2
- data/lib/inversion/template/iftag.rb +3 -1
- data/lib/inversion/template/importtag.rb +2 -3
- data/lib/inversion/template/includetag.rb +1 -2
- data/lib/inversion/template/node.rb +4 -5
- data/lib/inversion/template/pptag.rb +1 -2
- data/lib/inversion/template/publishtag.rb +2 -3
- data/lib/inversion/template/rescuetag.rb +1 -2
- data/lib/inversion/template/subscribetag.rb +3 -4
- data/lib/inversion/template/tag.rb +3 -4
- data/lib/inversion/template/textnode.rb +1 -2
- data/lib/inversion/template/timedeltatag.rb +1 -2
- data/lib/inversion/template/unlesstag.rb +0 -1
- data/lib/inversion/template/uriencodetag.rb +1 -2
- data/lib/inversion/template/yieldtag.rb +0 -1
- data/lib/inversion/template.rb +18 -22
- data/lib/inversion/tilt.rb +1 -2
- data/lib/inversion.rb +2 -3
- data/lib/roda/plugins/inversion.rb +225 -0
- data/spec/helpers.rb +19 -13
- data/spec/inversion/mixins_spec.rb +1 -1
- data/spec/inversion/parser_spec.rb +1 -1
- data/spec/inversion/refinements_spec.rb +22 -0
- data/spec/inversion/renderstate_spec.rb +1 -1
- data/spec/inversion/sinatra_spec.rb +1 -1
- data/spec/inversion/template/attrtag_spec.rb +1 -1
- data/spec/inversion/template/begintag_spec.rb +1 -1
- data/spec/inversion/template/calltag_spec.rb +1 -1
- data/spec/inversion/template/codetag_spec.rb +24 -1
- data/spec/inversion/template/commenttag_spec.rb +1 -1
- data/spec/inversion/template/configtag_spec.rb +1 -1
- data/spec/inversion/template/containertag_spec.rb +1 -1
- data/spec/inversion/template/defaulttag_spec.rb +1 -1
- data/spec/inversion/template/elsetag_spec.rb +1 -1
- data/spec/inversion/template/elsiftag_spec.rb +1 -1
- data/spec/inversion/template/endtag_spec.rb +1 -1
- data/spec/inversion/template/escapetag_spec.rb +1 -1
- data/spec/inversion/template/fortag_spec.rb +1 -1
- data/spec/inversion/template/fragmenttag_spec.rb +1 -1
- data/spec/inversion/template/iftag_spec.rb +1 -1
- data/spec/inversion/template/importtag_spec.rb +1 -1
- data/spec/inversion/template/includetag_spec.rb +1 -1
- data/spec/inversion/template/node_spec.rb +1 -1
- data/spec/inversion/template/pptag_spec.rb +1 -1
- data/spec/inversion/template/publishtag_spec.rb +1 -1
- data/spec/inversion/template/rescuetag_spec.rb +1 -1
- data/spec/inversion/template/subscribetag_spec.rb +1 -1
- data/spec/inversion/template/tag_spec.rb +1 -1
- data/spec/inversion/template/textnode_spec.rb +1 -1
- data/spec/inversion/template/timedeltatag_spec.rb +1 -1
- data/spec/inversion/template/unlesstag_spec.rb +1 -1
- data/spec/inversion/template/uriencodetag_spec.rb +1 -1
- data/spec/inversion/template/yieldtag_spec.rb +1 -1
- data/spec/inversion/template_spec.rb +1 -1
- data/spec/inversion/tilt_spec.rb +1 -1
- data/spec/inversion_spec.rb +1 -1
- data/spec/roda/plugins/inversion_spec.rb +91 -0
- data.tar.gz.sig +0 -0
- metadata +90 -58
- metadata.gz.sig +0 -0
- data/Examples.rdoc +0 -134
- data/GettingStarted.rdoc +0 -44
- data/Guide.rdoc +0 -47
- data/Manifest.txt +0 -86
- data/Rakefile +0 -7
- data/Tags.rdoc +0 -560
- data/lib/inversion/command.rb +0 -278
- data/lib/inversion/monkeypatches.rb +0 -21
- data/spec/inversion/monkeypatches_spec.rb +0 -25
@@ -13,7 +13,7 @@ rescue LoadError => err
|
|
13
13
|
$sinatra_support = false
|
14
14
|
end
|
15
15
|
|
16
|
-
describe "Sinatra support", :if => $sinatra_support do
|
16
|
+
RSpec.describe "Sinatra support", :if => $sinatra_support do
|
17
17
|
include Rack::Test::Methods if defined?( ::Rack )
|
18
18
|
|
19
19
|
before( :each ) do
|
@@ -11,7 +11,7 @@ require 'inversion/template/rescuetag'
|
|
11
11
|
require 'inversion/template/endtag'
|
12
12
|
require 'inversion/renderstate'
|
13
13
|
|
14
|
-
describe Inversion::Template::BeginTag do
|
14
|
+
RSpec.describe Inversion::Template::BeginTag do
|
15
15
|
|
16
16
|
|
17
17
|
context "without any rescue clauses" do
|
@@ -5,7 +5,7 @@ require_relative '../../helpers'
|
|
5
5
|
|
6
6
|
require 'inversion/template/codetag'
|
7
7
|
|
8
|
-
describe Inversion::Template::CodeTag do
|
8
|
+
RSpec.describe Inversion::Template::CodeTag do
|
9
9
|
|
10
10
|
|
11
11
|
it "is an abstract class" do
|
@@ -70,4 +70,27 @@ describe Inversion::Template::CodeTag do
|
|
70
70
|
}.to raise_exception( ScriptError, /patterns already exist/i )
|
71
71
|
end
|
72
72
|
end
|
73
|
+
|
74
|
+
|
75
|
+
it "throws an error if trying to declare a tag pattern with an invalid character" do
|
76
|
+
expect {
|
77
|
+
Class.new( described_class ) do
|
78
|
+
tag_pattern "°°°" do |tag, match|
|
79
|
+
:foo
|
80
|
+
end
|
81
|
+
end
|
82
|
+
}.to raise_error( Ripper::TokenPattern::CompileError, /invalid char/i )
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
it "throws an error if given an invalid tag pattern" do
|
87
|
+
expect {
|
88
|
+
Class.new( described_class ) do
|
89
|
+
tag_pattern "$(ident)$(" do |tag, match|
|
90
|
+
:foo
|
91
|
+
end
|
92
|
+
end
|
93
|
+
}.to raise_error( Ripper::TokenPattern::CompileError, /unmatched paren/i )
|
94
|
+
end
|
95
|
+
|
73
96
|
end
|
@@ -8,7 +8,7 @@ require 'inversion/template/attrtag'
|
|
8
8
|
require 'inversion/template/textnode'
|
9
9
|
require 'inversion/renderstate'
|
10
10
|
|
11
|
-
describe Inversion::Template::CommentTag do
|
11
|
+
RSpec.describe Inversion::Template::CommentTag do
|
12
12
|
|
13
13
|
it "allows any free-form text in its body" do
|
14
14
|
# <?comment Disabled for now ?>...<?end?>
|
@@ -10,7 +10,7 @@ require 'inversion/template/commenttag'
|
|
10
10
|
require 'inversion/template/fortag'
|
11
11
|
require 'inversion/renderstate'
|
12
12
|
|
13
|
-
describe Inversion::Template::ElseTag do
|
13
|
+
RSpec.describe Inversion::Template::ElseTag do
|
14
14
|
|
15
15
|
it "handles a non-existant body" do
|
16
16
|
Inversion::Template::ElseTag.new( nil )
|
@@ -8,7 +8,7 @@ require 'inversion/template/textnode'
|
|
8
8
|
require 'inversion/template/endtag'
|
9
9
|
require 'inversion/renderstate'
|
10
10
|
|
11
|
-
describe Inversion::Template::EndTag do
|
11
|
+
RSpec.describe Inversion::Template::EndTag do
|
12
12
|
|
13
13
|
before( :each ) do
|
14
14
|
@tag = Inversion::Template::EndTag.new
|
@@ -9,7 +9,7 @@ require 'inversion/template/attrtag'
|
|
9
9
|
require 'inversion/template/textnode'
|
10
10
|
require 'inversion/renderstate'
|
11
11
|
|
12
|
-
describe Inversion::Template::ForTag do
|
12
|
+
RSpec.describe Inversion::Template::ForTag do
|
13
13
|
|
14
14
|
it "knows which identifiers should be added to the template" do
|
15
15
|
tag = Inversion::Template::ForTag.new( 'foo in bar' )
|
@@ -8,7 +8,7 @@ require 'inversion/template/attrtag'
|
|
8
8
|
require 'inversion/template/textnode'
|
9
9
|
require 'inversion/renderstate'
|
10
10
|
|
11
|
-
describe Inversion::Template::FragmentTag do
|
11
|
+
RSpec.describe Inversion::Template::FragmentTag do
|
12
12
|
|
13
13
|
it "raises a parse error if the body isn't a simple attribute" do
|
14
14
|
expect {
|
@@ -5,7 +5,7 @@ require_relative '../../helpers'
|
|
5
5
|
|
6
6
|
require 'inversion/template/importtag'
|
7
7
|
|
8
|
-
describe Inversion::Template::ImportTag do
|
8
|
+
RSpec.describe Inversion::Template::ImportTag do
|
9
9
|
|
10
10
|
it "can import a single attribute" do
|
11
11
|
tag = Inversion::Template::ImportTag.new( 'txn ' )
|
@@ -7,7 +7,7 @@ require 'timeout'
|
|
7
7
|
require 'inversion/template'
|
8
8
|
require 'inversion/template/includetag'
|
9
9
|
|
10
|
-
describe Inversion::Template::IncludeTag do
|
10
|
+
RSpec.describe Inversion::Template::IncludeTag do
|
11
11
|
|
12
12
|
it "renders the IncludeTag as an empty string" do
|
13
13
|
included_path = Pathname.pwd + 'included.tmpl'
|
@@ -9,7 +9,7 @@ require 'inversion/template/commenttag'
|
|
9
9
|
require 'inversion/template/fortag'
|
10
10
|
require 'inversion/renderstate'
|
11
11
|
|
12
|
-
describe Inversion::Template::RescueTag do
|
12
|
+
RSpec.describe Inversion::Template::RescueTag do
|
13
13
|
|
14
14
|
it "handles a non-existant body" do
|
15
15
|
tag = Inversion::Template::RescueTag.new( nil )
|
@@ -7,7 +7,7 @@ require 'inversion/template'
|
|
7
7
|
require 'inversion/template/textnode'
|
8
8
|
require 'inversion/template/subscribetag'
|
9
9
|
|
10
|
-
describe Inversion::Template::SubscribeTag do
|
10
|
+
RSpec.describe Inversion::Template::SubscribeTag do
|
11
11
|
|
12
12
|
|
13
13
|
it "raises a parse error if the key isn't a simple attribute" do
|
@@ -7,7 +7,7 @@ require 'inversion/template/unlesstag'
|
|
7
7
|
require 'inversion/template/textnode'
|
8
8
|
require 'inversion/renderstate'
|
9
9
|
|
10
|
-
describe Inversion::Template::UnlessTag do
|
10
|
+
RSpec.describe Inversion::Template::UnlessTag do
|
11
11
|
|
12
12
|
|
13
13
|
it "renders its contents if its attribute is false" do
|
@@ -5,7 +5,7 @@ require_relative '../../helpers'
|
|
5
5
|
|
6
6
|
require 'inversion/template/yieldtag'
|
7
7
|
|
8
|
-
describe Inversion::Template::YieldTag do
|
8
|
+
RSpec.describe Inversion::Template::YieldTag do
|
9
9
|
|
10
10
|
|
11
11
|
it "calls the renderstate's block before rendering, and renders as its return value" do
|
data/spec/inversion/tilt_spec.rb
CHANGED
data/spec/inversion_spec.rb
CHANGED
@@ -0,0 +1,91 @@
|
|
1
|
+
#!/usr/bin/env rspec -cfd -b
|
2
|
+
# vim: set noet nosta sw=4 ts=4 :
|
3
|
+
|
4
|
+
require_relative '../../helpers'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'roda'
|
8
|
+
$roda_support = true
|
9
|
+
rescue LoadError => err
|
10
|
+
warn "Roda support testing disabled: %p: %s" % [ err.class, err.message ]
|
11
|
+
$roda_support = false
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
RSpec.describe "Roda support", :if => $roda_support do
|
16
|
+
include Rack::Test::Methods if defined?( ::Rack )
|
17
|
+
|
18
|
+
before( :all ) do
|
19
|
+
setup_logging( :fatal )
|
20
|
+
end
|
21
|
+
|
22
|
+
before( :each ) do
|
23
|
+
allow( Inversion::Template ).to receive( :load ).and_return( tmpl )
|
24
|
+
app.app # looks weird, but creates an instance for Rack::Test.
|
25
|
+
end
|
26
|
+
|
27
|
+
let( :tmpl ) { Inversion::Template.new("Hi <?attr name ?>!") }
|
28
|
+
|
29
|
+
let( :app ) do
|
30
|
+
Class.new( Roda ) do
|
31
|
+
plugin :inversion
|
32
|
+
templates \
|
33
|
+
tmpl: 'template.tmpl'
|
34
|
+
|
35
|
+
route do |r|
|
36
|
+
r.get "symbol" do
|
37
|
+
:tmpl
|
38
|
+
end
|
39
|
+
|
40
|
+
r.get "unknown" do
|
41
|
+
template( :nope )
|
42
|
+
end
|
43
|
+
|
44
|
+
r.get "template" do
|
45
|
+
tmpl = template( :tmpl )
|
46
|
+
tmpl.name = "handsome"
|
47
|
+
return tmpl
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
it "registers itself with Roda on demand" do
|
55
|
+
plugs = Roda::RodaPlugins.instance_variable_get( :@plugins )
|
56
|
+
expect( plugs[:inversion] ).to be( Roda::RodaPlugins::Inversion )
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
it "extends the Roda DSL with a #template helper method" do
|
61
|
+
expect( app.instance_methods ).to include( :template )
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
it "falls through to Roda default behavior on unmapped symbols" do
|
66
|
+
get '/nonexistent'
|
67
|
+
expect( last_response ).to_not be_ok
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
it "can reference a known template via symbol" do
|
72
|
+
get '/symbol'
|
73
|
+
expect( last_response ).to be_ok
|
74
|
+
expect( last_response.body ).to eq( 'Hi !' )
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
it "can render a returned template via template()" do
|
79
|
+
get '/template'
|
80
|
+
expect( last_response ).to be_ok
|
81
|
+
expect( last_response.body ).to eq( 'Hi handsome!' )
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
it "fails fast if referencing an unknown template at runtime" do
|
86
|
+
expect {
|
87
|
+
get '/unknown'
|
88
|
+
}.to raise_error( ArgumentError, /no :nope template registered/ )
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
data.tar.gz.sig
CHANGED
Binary file
|