rubyless 0.8.6 → 0.8.7

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/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.8.7 2012-09-24
2
+
3
+ * Minor enhancements
4
+ * Added support for Range.
5
+
1
6
  == 0.8.6 2011-11-09
2
7
 
3
8
  * Minor enhancements
@@ -13,7 +13,7 @@ class StringDictionary
13
13
  safe_method ['[]', Symbol] => {:class => String, :nil => true}
14
14
  end
15
15
 
16
- RubyLess::SafeClass.safe_literal_class Fixnum => Number, Float => Number, Symbol => Symbol, Regexp => Regexp
16
+ RubyLess::SafeClass.safe_literal_class Fixnum => Number, Float => Number, Symbol => Symbol, Regexp => Regexp, Range => Range
17
17
  RubyLess::SafeClass.safe_method_for( Number,
18
18
  [:==, Number] => Boolean, [:< , Number] => Boolean, [:> , Number] => Boolean,
19
19
  [:<=, Number] => Boolean, [:>=, Number] => Boolean, [:- , Number] => Number,
@@ -1,3 +1,3 @@
1
1
  module RubyLess
2
- VERSION = '0.8.6'
2
+ VERSION = '0.8.7'
3
3
  end
@@ -175,6 +175,12 @@ module RubyLess
175
175
  def process_dstr(exp)
176
176
  t "\"#{parse_dstr(exp)}\"", String
177
177
  end
178
+
179
+ def process_dot2(exp)
180
+ a = process(exp.shift)
181
+ b = process(exp.shift)
182
+ t "(#{a}..#{b})", Range
183
+ end
178
184
 
179
185
  def process_evstr(exp)
180
186
  exp.empty? ? t('', String) : process(exp.shift)
@@ -2,7 +2,8 @@
2
2
  module RubyLess
3
3
  class SignatureHash < Hash
4
4
  alias get []
5
-
5
+
6
+ # This method is used *A LOT*, make sure it stays as fast as possible.
6
7
  def [](signature)
7
8
  if type = get(signature)
8
9
  # fastest: all keys are equal
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.6"
8
+ s.version = "0.8.7"
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{2011-11-09}
12
+ s.date = %q{2012-09-24}
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 = [
@@ -22,6 +22,18 @@ symbol:
22
22
  src: ":foobar"
23
23
  sxp: 's(:lit, :foobar)'
24
24
 
25
+ range_lit:
26
+ src: '(0..4).to_a'
27
+ sxp: 's(:call, s(:lit, 0..4), :to_a, s(:arglist))'
28
+ tem: '[0, 1, 2, 3, 4]'
29
+
30
+ range_to_a:
31
+ context:
32
+ x: 4
33
+ src: '(0..id).to_a'
34
+ sxp: "s(:call, s(:dot2, s(:lit, 0), s(:call, nil, :id, s(:arglist))), :to_a, s(:arglist))"
35
+ tem: '(0..node.zip).to_a'
36
+
25
37
  rewrite_variables:
26
38
  src: "!prev.ancestor?(main) && !node.ancestor?(main)"
27
39
  tem: "(not previous.ancestor?(@node) and not node.ancestor?(@node))"
@@ -56,6 +56,8 @@ class RubyLessTest < Test::Unit::TestCase
56
56
  safe_method_for Array, [:map, Symbol] => {:method => 'nil', :class => nil, :pre_processor => self.map_proc}
57
57
 
58
58
  safe_method_for Array, [:join, String] => {:method => 'join', :class => String, :pre_processor => true}
59
+
60
+ safe_method_for Range, :to_a => {:class => [Number], :pre_processor => true}
59
61
 
60
62
  safe_method_for Hash, :to_param => String
61
63
 
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: 51
4
+ hash: 49
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 6
10
- version: 0.8.6
9
+ - 7
10
+ version: 0.8.7
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: 2011-11-09 00:00:00 +01:00
18
+ date: 2012-09-24 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency