rubyless 0.8.5 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,4 +1,9 @@
1
- == 0.8.5
1
+ == 0.8.6 2011-11-09
2
+
3
+ * Minor enhancements
4
+ * Added support for 'nil'.
5
+
6
+ == 0.8.5 2011-07-11
2
7
 
3
8
  * Minor enhancements
4
9
  * Added support for append_args and multiple prepend arguments.
@@ -145,4 +150,4 @@
145
150
  == 0.1.0 2009-06-02
146
151
 
147
152
  * 1 major enhancement:
148
- * Initial alpha release.
153
+ * Initial alpha release.
@@ -1,3 +1,3 @@
1
1
  module RubyLess
2
- VERSION = '0.8.5'
2
+ VERSION = '0.8.6'
3
3
  end
@@ -64,6 +64,10 @@ module RubyLess
64
64
  t 'false', {:class => Boolean, :literal => false}
65
65
  end
66
66
 
67
+ def process_nil(*args)
68
+ t 'nil', {:class => NilClass, :literal => nil, :nil => true}
69
+ end
70
+
67
71
  def process_and(exp)
68
72
  t "(#{process(exp.shift)} and #{process(exp.shift)})", Boolean
69
73
  end
@@ -86,8 +90,18 @@ module RubyLess
86
90
  true_res = process(exp.shift)
87
91
  false_res = process(exp.shift)
88
92
 
89
- if true_res && false_res && true_res.klass != false_res.klass
90
- raise RubyLess::SyntaxError.new("Error in conditional expression: '#{true_res}' and '#{false_res}' do not return results of same type (#{true_res.klass} != #{false_res.klass}).")
93
+ if true_res && false_res
94
+ if true_res.klass != false_res.klass
95
+ if true_res.klass == NilClass
96
+ # Change true_res to false_res class (could_be_nil? is true)
97
+ true_res.opts[:class] = false_res.klass
98
+ elsif false_res.klass == NilClass
99
+ # Change false_res to true_res class (could_be_nil? is true)
100
+ false_res.opts[:class] = true_res.klass
101
+ else
102
+ raise RubyLess::SyntaxError.new("Error in conditional expression: '#{true_res}' and '#{false_res}' do not return results of same type (#{true_res.klass} != #{false_res.klass}).")
103
+ end
104
+ end
91
105
  end
92
106
  raise RubyLess::SyntaxError.new("Error in conditional expression.") unless true_res || false_res
93
107
  opts = {}
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.5"
8
+ s.version = "0.8.6"
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-07-11}
12
+ s.date = %q{2011-11-09}
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 = [
@@ -54,20 +54,8 @@ Gem::Specification.new do |s|
54
54
  ]
55
55
  s.homepage = %q{http://zenadmin.org/546}
56
56
  s.require_paths = ["lib"]
57
- s.rubygems_version = %q{1.6.1}
57
+ s.rubygems_version = %q{1.6.2}
58
58
  s.summary = %q{RubyLess is an interpreter for "safe ruby"}
59
- s.test_files = [
60
- "test/RubyLess_test.rb",
61
- "test/mock/active_record_mock.rb",
62
- "test/mock/dummy_class.rb",
63
- "test/mock/dummy_module.rb",
64
- "test/mock/property_column.rb",
65
- "test/safe_class_test.rb",
66
- "test/signature_hash_test.rb",
67
- "test/test_helper.rb",
68
- "test/typed_method_test.rb",
69
- "test/typed_string_test.rb"
70
- ]
71
59
 
72
60
  if s.respond_to? :specification_version then
73
61
  s.specification_version = 3
@@ -253,4 +253,13 @@ string_array:
253
253
 
254
254
  array_bad_method:
255
255
  src: "%w{foo bar}.plop(',')"
256
- res: "unknown method 'plop(String)' for '[\"foo\",\"bar\"]' of type [String]."
256
+ res: "unknown method 'plop(String)' for '[\"foo\",\"bar\"]' of type [String]."
257
+
258
+ nil:
259
+ src: 'nil'
260
+ tem: 'nil'
261
+
262
+ nil_in_op:
263
+ src: '(dictionary[:foo] == "something" ? "foo" : nil)'
264
+ tem: '(get_dict[:foo]=="something") ? "foo" : nil'
265
+ res: ''
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: 53
4
+ hash: 51
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 5
10
- version: 0.8.5
9
+ - 6
10
+ version: 0.8.6
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-07-11 00:00:00 +02:00
18
+ date: 2011-11-09 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -154,18 +154,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  requirements: []
155
155
 
156
156
  rubyforge_project:
157
- rubygems_version: 1.6.1
157
+ rubygems_version: 1.6.2
158
158
  signing_key:
159
159
  specification_version: 3
160
160
  summary: RubyLess is an interpreter for "safe ruby"
161
- test_files:
162
- - test/RubyLess_test.rb
163
- - test/mock/active_record_mock.rb
164
- - test/mock/dummy_class.rb
165
- - test/mock/dummy_module.rb
166
- - test/mock/property_column.rb
167
- - test/safe_class_test.rb
168
- - test/signature_hash_test.rb
169
- - test/test_helper.rb
170
- - test/typed_method_test.rb
171
- - test/typed_string_test.rb
161
+ test_files: []
162
+