expressive 0.0.1 → 0.0.2

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- expressive (0.0.1)
4
+ expressive (0.0.2)
5
5
  awesome_print (~> 1.0.2)
6
6
  polyglot (~> 0.3.3)
7
7
  treetop (~> 1.4.10)
@@ -1,3 +1,3 @@
1
1
  module Expressive
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/scope.rb CHANGED
@@ -43,11 +43,11 @@ class TopLevel < Scope
43
43
  scope[cells.first.text_value] = cells[1].eval(scope)
44
44
  end
45
45
 
46
- define('+') {|a,b| a + b }
47
- define('-') {|a,b| a - b }
48
- define('*') {|a,b| a * b }
49
- define('/') {|a,b| a / b }
46
+ define('+') {|a,b| a.to_f + b.to_f }
47
+ define('-') {|a,b| a.to_f - b.to_f }
48
+ define('*') {|a,b| a.to_f * b.to_f }
49
+ define('/') {|a,b| a.to_f / b.to_f }
50
50
  define('=') {|a,b| a == b }
51
- define('sum') {|*args| args.flatten.reduce(:+) }
51
+ define('sum') {|*args| args.flatten.map(&:to_f).reduce(:+) }
52
52
  end
53
53
  end
@@ -21,11 +21,11 @@ describe "Expressive" do
21
21
  end
22
22
 
23
23
  describe "understands arithmetic" do
24
- it { Expressive.run("(+ 4 2)").should eql 6 }
25
- it { Expressive.run("(- 4 2)").should eql 2 }
26
- it { Expressive.run("(* 4 2)").should eql 8 }
27
- it { Expressive.run("(/ 4 2)").should eql 2 }
28
- it { Expressive.run("(sum 1 2 3)").should eql 6}
24
+ it { Expressive.run("(+ 4 2)").should eql 6.0 }
25
+ it { Expressive.run("(- 4 2)").should eql 2.0 }
26
+ it { Expressive.run("(* 4 2)").should eql 8.0 }
27
+ it { Expressive.run("(/ 4 2)").should eql 2.0 }
28
+ it { Expressive.run("(sum 1 2 3)").should eql 6.0}
29
29
  end
30
30
 
31
31
  describe "understands compound statements" do
@@ -45,11 +45,11 @@ describe "Expressive" do
45
45
  @scope["order_no"].should eql 1234
46
46
  end
47
47
  it "should reuse set properties" do
48
- Expressive.run("(set order_no 1234)(+ order_no 11)", @scope).should eql 1245
48
+ Expressive.run("(set order_no 1234)(+ order_no 11)", @scope).should eql 1245.0
49
49
  end
50
50
  it "should sum scoped arrays" do
51
51
  @scope["sub_totals"] = [100, 200, 300]
52
- Expressive.run("(sum sub_totals)", @scope).should eql 600
52
+ Expressive.run("(sum sub_totals)", @scope).should eql 600.0
53
53
  end
54
54
  end
55
55
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expressive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-03 00:00:00.000000000 Z
12
+ date: 2012-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby_gntp
@@ -193,7 +193,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
193
  version: '0'
194
194
  segments:
195
195
  - 0
196
- hash: -3389860880342306290
196
+ hash: -3233629507963509909
197
197
  required_rubygems_version: !ruby/object:Gem::Requirement
198
198
  none: false
199
199
  requirements:
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
202
  version: '0'
203
203
  segments:
204
204
  - 0
205
- hash: -3389860880342306290
205
+ hash: -3233629507963509909
206
206
  requirements: []
207
207
  rubyforge_project:
208
208
  rubygems_version: 1.8.23