rubyless 0.8.10 → 0.8.11
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -1
- data/lib/ruby_less/info.rb +1 -1
- data/lib/ruby_less/processor.rb +3 -3
- data/rubyless.gemspec +2 -2
- data/test/RubyLess/errors.yml +5 -1
- data/test/RubyLess/string.yml +4 -0
- data/test/RubyLess_test.rb +8 -0
- metadata +4 -4
data/History.txt
CHANGED
data/lib/ruby_less/info.rb
CHANGED
data/lib/ruby_less/processor.rb
CHANGED
@@ -296,7 +296,7 @@ module RubyLess
|
|
296
296
|
res = @helper.send(proc, *args.list.map(&:literal))
|
297
297
|
end
|
298
298
|
|
299
|
-
return res.kind_of?(TypedString) ? res : t(res.inspect, :class =>
|
299
|
+
return res.kind_of?(TypedString) ? res : t(res.inspect, :class => opts[:class], :literal => res)
|
300
300
|
end
|
301
301
|
|
302
302
|
if opts[:accept_nil]
|
@@ -350,11 +350,11 @@ module RubyLess
|
|
350
350
|
# This can happen if we use native methods on TypedString (like gsub) that return a new
|
351
351
|
# typedstring without calling initialize....
|
352
352
|
if res.opts.nil?
|
353
|
-
res.instance_variable_set(:@opts, :class =>
|
353
|
+
res.instance_variable_set(:@opts, :class => opts[:class], :literal => res)
|
354
354
|
end
|
355
355
|
return res
|
356
356
|
else
|
357
|
-
return t(res.inspect, :class =>
|
357
|
+
return t(res.inspect, :class => opts[:class], :literal => res)
|
358
358
|
end
|
359
359
|
end
|
360
360
|
end
|
data/rubyless.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rubyless}
|
8
|
-
s.version = "0.8.
|
8
|
+
s.version = "0.8.11"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Gaspard Bucher"]
|
12
|
-
s.date = %q{2013-
|
12
|
+
s.date = %q{2013-10-30}
|
13
13
|
s.description = %q{RubyLess is an interpreter for "safe ruby". The idea is to transform some "unsafe" ruby code into safe, type checked ruby, eventually rewriting some variables or methods.}
|
14
14
|
s.email = %q{gaspard@teti.ch}
|
15
15
|
s.extra_rdoc_files = [
|
data/test/RubyLess/errors.yml
CHANGED
@@ -78,4 +78,8 @@ unknown_constant:
|
|
78
78
|
|
79
79
|
ternary_operator:
|
80
80
|
src: "@foo ? 'xx' : 15"
|
81
|
-
tem: "/Error in conditional expression.*String != Number/"
|
81
|
+
tem: "/Error in conditional expression.*String != Number/"
|
82
|
+
|
83
|
+
unknown_method_in_list_ctx:
|
84
|
+
src: "list.upcase"
|
85
|
+
tem: "unknown method 'upcase()' for 'list' of type [String]."
|
data/test/RubyLess/string.yml
CHANGED
data/test/RubyLess_test.rb
CHANGED
@@ -44,6 +44,7 @@ class RubyLessTest < Test::Unit::TestCase
|
|
44
44
|
safe_method_for String, [:==, String] => Boolean
|
45
45
|
safe_method_for String, [:to_s] => String
|
46
46
|
safe_method_for String, [:to_i] => {:class => Number, :pre_processor => true}
|
47
|
+
safe_method_for String, [:split, String] => {:class => [String], :pre_processor => true}
|
47
48
|
safe_method_for String, [:gsub, Regexp, String] => {:class => String, :pre_processor => Proc.new {|this, reg, str|
|
48
49
|
# We have to test if 'this' is a literal
|
49
50
|
if literal = this.literal
|
@@ -86,6 +87,9 @@ class RubyLessTest < Test::Unit::TestCase
|
|
86
87
|
|
87
88
|
# methods on nil
|
88
89
|
safe_method_for Object, :blank? => Boolean
|
90
|
+
|
91
|
+
# array context
|
92
|
+
safe_method :list => [String]
|
89
93
|
|
90
94
|
def safe_const_type(constant)
|
91
95
|
if constant == 'Page'
|
@@ -148,6 +152,10 @@ class RubyLessTest < Test::Unit::TestCase
|
|
148
152
|
def sub
|
149
153
|
SubDummy.new
|
150
154
|
end
|
155
|
+
|
156
|
+
def list
|
157
|
+
%w{a b c}
|
158
|
+
end
|
151
159
|
|
152
160
|
def str
|
153
161
|
"str"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 41
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 11
|
10
|
+
version: 0.8.11
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Gaspard Bucher
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-
|
18
|
+
date: 2013-10-30 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|