plasma 0.1.1 → 0.1.3
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.
- data/Rakefile +1 -1
- data/bin/plasma +0 -0
- data/lib/extras/plasma_engine.rb +24 -0
- data/lib/extras/plasma_view.rb +3 -1
- data/lib/plasma.rb +14 -0
- data/lib/plasma/interpreter/plasma_grammarnode.rb +9 -9
- metadata +5 -3
data/Rakefile
CHANGED
data/bin/plasma
CHANGED
File without changes
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Plasma
|
2
|
+
class PlasmaEngine
|
3
|
+
def self.compile_template(io, name, mod)
|
4
|
+
path = File.expand_path(io.path)
|
5
|
+
code = io.read.gsub(/"/, '\"')
|
6
|
+
plasma = <<-interpret
|
7
|
+
def #{name}
|
8
|
+
Plasma::Interpreter.interpret("#{code}")
|
9
|
+
end
|
10
|
+
interpret
|
11
|
+
|
12
|
+
m = mod.is_a?(Module) ? :module_eval : :instance_eval
|
13
|
+
mod.__send__(m, plasma, path || '(plasma)')
|
14
|
+
name
|
15
|
+
end
|
16
|
+
|
17
|
+
module Mixin
|
18
|
+
def concat_plasma(string, binding)
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
data/lib/extras/plasma_view.rb
CHANGED
data/lib/plasma.rb
CHANGED
@@ -9,5 +9,19 @@ PLASMA_TEST = File.join(PLASMA_PACKAGE_ROOT, 'test')
|
|
9
9
|
|
10
10
|
require File.join(PLASMA_ROOT, 'interpreter')
|
11
11
|
require File.join(PLASMA_LIB, 'extras/plasma_view')
|
12
|
+
require File.join(PLASMA_LIB, 'extras/plasma_engine')
|
12
13
|
|
13
14
|
$LOAD_PATH.unshift(dir)
|
15
|
+
|
16
|
+
module Plasma
|
17
|
+
module Interpreter
|
18
|
+
PLASMA = PlasmaInterpreter.new
|
19
|
+
|
20
|
+
def self.interpret(code, env=nil)
|
21
|
+
PLASMA.interpret(code, env)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
|
@@ -160,6 +160,12 @@ module Plasma
|
|
160
160
|
class FailedToParseException < Exception
|
161
161
|
end
|
162
162
|
|
163
|
+
class Treetop::Runtime::SyntaxNode
|
164
|
+
def to_s
|
165
|
+
text_value
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
163
169
|
class PlasmaNode < Treetop::Runtime::SyntaxNode
|
164
170
|
def evaluate(env)
|
165
171
|
orb.evaluate(env)
|
@@ -186,12 +192,6 @@ module Plasma
|
|
186
192
|
end
|
187
193
|
end
|
188
194
|
|
189
|
-
class Treetop::Runtime::SyntaxNode
|
190
|
-
def to_s
|
191
|
-
text_value
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
195
|
class TemplateNode < PlasmaNode
|
196
196
|
def evaluate(env)
|
197
197
|
value = body.empty? ? '' : body.elements.inject('') do |so_far, el|
|
@@ -368,10 +368,10 @@ module Plasma
|
|
368
368
|
|
369
369
|
class NumNode < PlasmaNode
|
370
370
|
def evaluate(env)
|
371
|
-
if self.
|
372
|
-
text_value.to_f
|
373
|
-
else
|
371
|
+
if self.decimal.empty?
|
374
372
|
text_value.to_i
|
373
|
+
else
|
374
|
+
text_value.to_f
|
375
375
|
end
|
376
376
|
end
|
377
377
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plasma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Spangler
|
@@ -9,11 +9,12 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-09-24 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: treetop
|
17
|
+
type: :runtime
|
17
18
|
version_requirement:
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|
@@ -41,6 +42,7 @@ files:
|
|
41
42
|
- test/template_test.plasma
|
42
43
|
- test/template_test.rb
|
43
44
|
- lib/extras
|
45
|
+
- lib/extras/plasma_engine.rb
|
44
46
|
- lib/extras/plasma_view.rb
|
45
47
|
- lib/plasma
|
46
48
|
- lib/plasma/include
|
@@ -81,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
83
|
requirements: []
|
82
84
|
|
83
85
|
rubyforge_project: plasma
|
84
|
-
rubygems_version: 1.0
|
86
|
+
rubygems_version: 1.2.0
|
85
87
|
signing_key:
|
86
88
|
specification_version: 2
|
87
89
|
summary: plasma --- a lightweight interpreted templating language in treetop and ruby
|