soroban 0.9.1 → 0.10.0

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.
@@ -44,7 +44,10 @@ module Soroban
44
44
  logical ( space? ',' space? logical )*
45
45
  end
46
46
  rule number
47
- ( float / integer / '-' float / '-' integer )
47
+ ( percentage / float / integer / '-' percentage / '-' float / '-' integer )
48
+ end
49
+ rule percentage
50
+ float space? '%' <PercentValue> / integer space? '%' <PercentValue>
48
51
  end
49
52
  rule float
50
53
  [0-9]* '.' [0-9]+ <FloatValue>
@@ -28,6 +28,12 @@ module Soroban
28
28
  end
29
29
  end
30
30
 
31
+ class PercentValue < Treetop::Runtime::SyntaxNode
32
+ def rewrite_ruby(value)
33
+ "#{value.to_f / 100.0}"
34
+ end
35
+ end
36
+
31
37
  class Function < Treetop::Runtime::SyntaxNode
32
38
  def rewrite_ruby(value)
33
39
  match = /^([^(]*)(.*)$/.match(value)
@@ -172,4 +172,12 @@ describe "Soroban" do
172
172
  sheet.A3.should eq(3)
173
173
  end
174
174
 
175
+ it "supports percentages" do
176
+ sheet.set(:A1 => "7")
177
+ sheet.set(:A2 => "=A1 + 30 %")
178
+ sheet.A2.should eq(7.3)
179
+ sheet.set(:A3 => "=-30.0% + A2")
180
+ sheet.A3.should eq(7)
181
+ end
182
+
175
183
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soroban
3
3
  version: !ruby/object:Gem::Version
4
- hash: 57
4
+ hash: 55
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 9
9
- - 1
10
- version: 0.9.1
8
+ - 10
9
+ - 0
10
+ version: 0.10.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason Hutchens
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2014-10-22 00:00:00 Z
18
+ date: 2014-10-24 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: treetop