rubyless 0.8.10 → 0.8.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,12 @@
1
+ == 0.8.11 2013-10-30
2
+
3
+ * Minor enhancement
4
+ * Fixed pre_processor when result is not a String.
5
+
1
6
  == 0.8.10 2013-06-13
2
7
 
3
8
  * Minor enhancement
4
- * Fixed Range handling
9
+ * Fixed Range handling.
5
10
 
6
11
  == 0.8.9 2013-04-16
7
12
 
@@ -1,3 +1,3 @@
1
1
  module RubyLess
2
- VERSION = '0.8.10'
2
+ VERSION = '0.8.11'
3
3
  end
@@ -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 => String, :literal => res)
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 => String, :literal => res)
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 => String, :literal => res)
357
+ return t(res.inspect, :class => opts[:class], :literal => res)
358
358
  end
359
359
  end
360
360
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rubyless}
8
- s.version = "0.8.10"
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-06-13}
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 = [
@@ -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]."
@@ -26,3 +26,7 @@ equal:
26
26
  src: "str == 'str'"
27
27
  tem: '(str=="str")'
28
28
  res: 'true'
29
+
30
+ split:
31
+ src: "'one.two'.split('.').join('/')"
32
+ tem: '"one/two"'
@@ -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: 43
4
+ hash: 41
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 10
10
- version: 0.8.10
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-06-13 00:00:00 +02:00
18
+ date: 2013-10-30 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency