cadenza 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/cadenza +10 -0
- data/lib/cadenza.rb +1 -0
- data/lib/cadenza/cli.rb +39 -0
- data/lib/cadenza/context.rb +16 -0
- data/lib/cadenza/context_object.rb +10 -0
- data/lib/cadenza/text_renderer.rb +1 -1
- data/lib/cadenza/version.rb +1 -1
- metadata +89 -34
data/bin/cadenza
ADDED
data/lib/cadenza.rb
CHANGED
data/lib/cadenza/cli.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module Cadenza
|
5
|
+
class Cli
|
6
|
+
class Options < OptionParser
|
7
|
+
attr_reader :options
|
8
|
+
|
9
|
+
def self.parse!
|
10
|
+
parser = new("Cadenza")
|
11
|
+
parser.set_opts.parse!
|
12
|
+
parser.options
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(*args)
|
16
|
+
@options = {}
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def context_option(context)
|
21
|
+
@options[:context] = MultiJson.load(context)
|
22
|
+
end
|
23
|
+
|
24
|
+
def set_opts
|
25
|
+
on("--context json") do |value|
|
26
|
+
context_option value
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.run!(path, context)
|
32
|
+
Cadenza::BaseContext.add_loader Cadenza::FilesystemLoader.new(File.expand_path('.'))
|
33
|
+
Cadenza::BaseContext.whiny_template_loading = true
|
34
|
+
|
35
|
+
Cadenza.render_template path, context
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
data/lib/cadenza/context.rb
CHANGED
@@ -301,6 +301,7 @@ module Cadenza
|
|
301
301
|
sym_identifier = identifier.to_sym
|
302
302
|
|
303
303
|
# allow looking up array indexes with dot notation, example: alphabet.0 => "a"
|
304
|
+
#TODO: the /\d+/ regex doesn't have the \A\z terminators, could that allow expected calling? example: alpabet.a0
|
304
305
|
if scope.respond_to?(:[]) and scope.is_a?(Array) and identifier =~ /\d+/
|
305
306
|
return scope[identifier.to_i]
|
306
307
|
end
|
@@ -310,6 +311,21 @@ module Cadenza
|
|
310
311
|
return scope[identifier] || scope[sym_identifier]
|
311
312
|
end
|
312
313
|
|
314
|
+
#TODO: security vulnerability below, we use #send on an object which can
|
315
|
+
# allow us to call private or protected methods on an object.
|
316
|
+
#
|
317
|
+
# We could use #public_send but it is only available in Ruby 1.9.x so
|
318
|
+
# we would have to drop 1.8.7 support.
|
319
|
+
#
|
320
|
+
# Alternatively we could forbid binding regular objects to contexts
|
321
|
+
# entirely and require that any bound object is a subclass of Cadenza::Drop
|
322
|
+
# Knowing this we could take public methods defined on the object
|
323
|
+
# and subtract public methods defined on the drop to get a list of
|
324
|
+
# safely callable methods. And it will work in 1.8.7
|
325
|
+
#
|
326
|
+
# This won't happen until Cadenza 0.8.0 however as it will possibly break
|
327
|
+
# backwards compatibility.
|
328
|
+
|
313
329
|
# if the identifier is a callable method then call that
|
314
330
|
return scope.send(sym_identifier) if scope.respond_to?(sym_identifier)
|
315
331
|
|
data/lib/cadenza/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cadenza
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,27 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: multi_json
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.3.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.3.0
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: rake
|
16
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
17
33
|
none: false
|
18
34
|
requirements:
|
19
35
|
- - ~>
|
@@ -21,10 +37,15 @@ dependencies:
|
|
21
37
|
version: 0.9.2
|
22
38
|
type: :development
|
23
39
|
prerelease: false
|
24
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.9.2
|
25
46
|
- !ruby/object:Gem::Dependency
|
26
47
|
name: rspec
|
27
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
28
49
|
none: false
|
29
50
|
requirements:
|
30
51
|
- - ~>
|
@@ -32,10 +53,15 @@ dependencies:
|
|
32
53
|
version: 2.6.0
|
33
54
|
type: :development
|
34
55
|
prerelease: false
|
35
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.6.0
|
36
62
|
- !ruby/object:Gem::Dependency
|
37
63
|
name: racc
|
38
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
39
65
|
none: false
|
40
66
|
requirements:
|
41
67
|
- - ~>
|
@@ -43,10 +69,15 @@ dependencies:
|
|
43
69
|
version: 1.4.6
|
44
70
|
type: :development
|
45
71
|
prerelease: false
|
46
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.4.6
|
47
78
|
- !ruby/object:Gem::Dependency
|
48
79
|
name: nokogiri-diff
|
49
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
50
81
|
none: false
|
51
82
|
requirements:
|
52
83
|
- - ~>
|
@@ -54,10 +85,15 @@ dependencies:
|
|
54
85
|
version: 0.1.0
|
55
86
|
type: :development
|
56
87
|
prerelease: false
|
57
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.1.0
|
58
94
|
- !ruby/object:Gem::Dependency
|
59
95
|
name: yard
|
60
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
61
97
|
none: false
|
62
98
|
requirements:
|
63
99
|
- - ! '>='
|
@@ -65,10 +101,15 @@ dependencies:
|
|
65
101
|
version: '0'
|
66
102
|
type: :development
|
67
103
|
prerelease: false
|
68
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
69
110
|
- !ruby/object:Gem::Dependency
|
70
111
|
name: guard-rspec
|
71
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
72
113
|
none: false
|
73
114
|
requirements:
|
74
115
|
- - ! '>='
|
@@ -76,10 +117,15 @@ dependencies:
|
|
76
117
|
version: '0'
|
77
118
|
type: :development
|
78
119
|
prerelease: false
|
79
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
80
126
|
- !ruby/object:Gem::Dependency
|
81
127
|
name: guard-shell
|
82
|
-
requirement:
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
83
129
|
none: false
|
84
130
|
requirements:
|
85
131
|
- - ! '>='
|
@@ -87,40 +133,49 @@ dependencies:
|
|
87
133
|
version: '0'
|
88
134
|
type: :development
|
89
135
|
prerelease: false
|
90
|
-
version_requirements:
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
91
142
|
description:
|
92
143
|
email:
|
93
144
|
- whoward.tke@gmail.com
|
94
|
-
executables:
|
145
|
+
executables:
|
146
|
+
- cadenza
|
95
147
|
extensions: []
|
96
148
|
extra_rdoc_files: []
|
97
149
|
files:
|
98
|
-
- lib/cadenza/
|
150
|
+
- lib/cadenza/lexer.rb
|
151
|
+
- lib/cadenza/context.rb
|
152
|
+
- lib/cadenza/filesystem_loader.rb
|
153
|
+
- lib/cadenza/cli.rb
|
154
|
+
- lib/cadenza/blocks/standard_blocks.rb
|
155
|
+
- lib/cadenza/context_object.rb
|
156
|
+
- lib/cadenza/filters/standard_filters.rb
|
157
|
+
- lib/cadenza/error.rb
|
158
|
+
- lib/cadenza/nodes/document_node.rb
|
99
159
|
- lib/cadenza/nodes/operation_node.rb
|
100
|
-
- lib/cadenza/nodes/filter_node.rb
|
101
|
-
- lib/cadenza/nodes/if_node.rb
|
102
160
|
- lib/cadenza/nodes/text_node.rb
|
103
|
-
- lib/cadenza/nodes/variable_node.rb
|
104
|
-
- lib/cadenza/nodes/document_node.rb
|
105
161
|
- lib/cadenza/nodes/for_node.rb
|
106
|
-
- lib/cadenza/nodes/
|
162
|
+
- lib/cadenza/nodes/if_node.rb
|
163
|
+
- lib/cadenza/nodes/generic_block_node.rb
|
107
164
|
- lib/cadenza/nodes/inject_node.rb
|
165
|
+
- lib/cadenza/nodes/variable_node.rb
|
108
166
|
- lib/cadenza/nodes/constant_node.rb
|
109
167
|
- lib/cadenza/nodes/block_node.rb
|
110
|
-
- lib/cadenza/
|
168
|
+
- lib/cadenza/nodes/boolean_inverse_node.rb
|
169
|
+
- lib/cadenza/nodes/filter_node.rb
|
111
170
|
- lib/cadenza/functional_variables/standard_functional_variables.rb
|
112
|
-
- lib/cadenza/
|
113
|
-
- lib/cadenza/filters/standard_filters.rb
|
171
|
+
- lib/cadenza/version.rb
|
114
172
|
- lib/cadenza/text_renderer.rb
|
115
|
-
- lib/cadenza/
|
116
|
-
- lib/cadenza/racc_parser.rb
|
117
|
-
- lib/cadenza/blocks/standard_blocks.rb
|
173
|
+
- lib/cadenza/parser.rb
|
118
174
|
- lib/cadenza/base_renderer.rb
|
119
|
-
- lib/cadenza/
|
120
|
-
- lib/cadenza/
|
121
|
-
- lib/cadenza/context.rb
|
122
|
-
- lib/cadenza/error.rb
|
175
|
+
- lib/cadenza/token.rb
|
176
|
+
- lib/cadenza/racc_parser.rb
|
123
177
|
- lib/cadenza.rb
|
178
|
+
- bin/cadenza
|
124
179
|
homepage: http://github.com/whoward/Cadenza
|
125
180
|
licenses: []
|
126
181
|
post_install_message:
|
@@ -141,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
196
|
version: '0'
|
142
197
|
requirements: []
|
143
198
|
rubyforge_project:
|
144
|
-
rubygems_version: 1.8.
|
199
|
+
rubygems_version: 1.8.24
|
145
200
|
signing_key:
|
146
201
|
specification_version: 3
|
147
202
|
summary: Powerful text templating language similar to Smarty/Liquid/Django
|