lxl 0.4.1 → 0.4.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/CHANGES +5 -1
- data/VERSION +1 -1
- data/test/lxl_spreadsheet_test.rb +37 -15
- metadata +2 -2
data/CHANGES
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
0.4.2
|
2
|
+
|
3
|
+
- SpreadSheet example now works directly with ranges.
|
4
|
+
|
1
5
|
0.4.1
|
2
6
|
|
3
7
|
- LXL::Token, LXL::Parser#token_class, #store, #tokenize updated.
|
@@ -8,7 +12,7 @@
|
|
8
12
|
- All tokenizing code moved into tokenize (out of eval)
|
9
13
|
- Token class added
|
10
14
|
- Fixes bug with text (non-formula) strings and constant parsing
|
11
|
-
- Removed unnessecary Lexer code
|
15
|
+
- Removed unnessecary Lexer code.
|
12
16
|
|
13
17
|
0.3.8
|
14
18
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.2
|
@@ -1,9 +1,21 @@
|
|
1
1
|
#--
|
2
|
-
# LXL
|
3
|
-
# http://onestepback.org/index.cgi/Tech/Ruby/SlowingDownCalculations.rdoc
|
4
|
-
# http://onestepback.org/cgi-bin/osbwiki.pl?SpreadSheetCode
|
2
|
+
# =LXL SpreadSheet Interface
|
5
3
|
#
|
6
|
-
#
|
4
|
+
# An LXL interface to Jim Weirich�s SpreadSheet object.
|
5
|
+
#
|
6
|
+
# http://onestepback.org/index.cgi/Tech/Ruby/SlowingDownCalculations.rdoc
|
7
|
+
# http://onestepback.org/cgi-bin/osbwiki.pl?SpreadSheetCode
|
8
|
+
#
|
9
|
+
# =Usage
|
10
|
+
#
|
11
|
+
# MyLXL.eval('=A2') # => <SpreadSheet:1>[1,2]
|
12
|
+
# MyLXL.eval('=Sheet2!C4') # => <SpreadSheet:2>[3,4]
|
13
|
+
#
|
14
|
+
# =Notes
|
15
|
+
#
|
16
|
+
# * Spreadsheet#[a,b] does single lookups only.
|
17
|
+
# * Uses Range#sheet to specify the SpreadSheet object.
|
18
|
+
# * Uses a custom range class to perform lookups on the SpreadSheet object.
|
7
19
|
#++
|
8
20
|
|
9
21
|
$LOAD_PATH.unshift('../lib')
|
@@ -15,23 +27,30 @@ require 'lxl'
|
|
15
27
|
# Spreadsheet
|
16
28
|
#++
|
17
29
|
|
18
|
-
$
|
19
|
-
$
|
20
|
-
|
21
|
-
$
|
30
|
+
$sheet1 = SpreadSheet.new
|
31
|
+
$sheet1[1,2].value = 5 # Sheet1!A2
|
32
|
+
|
33
|
+
$sheet2 = SpreadSheet.new
|
34
|
+
$sheet2[3,4].value = 8 # Sheet2!C4
|
35
|
+
|
36
|
+
$book = {'Sheet1'=>$sheet1, 'Sheet2'=>$sheet2}
|
22
37
|
|
23
38
|
#--
|
24
39
|
# LXL Interface
|
25
40
|
#++
|
26
41
|
|
27
|
-
class
|
28
|
-
|
29
|
-
|
42
|
+
class SSRange < LXL::Range
|
43
|
+
|
44
|
+
def self.new(first, last)
|
45
|
+
range = super
|
46
|
+
sheet = $book[range.sheet || 'Sheet1']
|
47
|
+
sheet ? sheet[range.first_colnum, range.first_cell].value : 0
|
30
48
|
end
|
31
|
-
end
|
32
49
|
|
50
|
+
end
|
51
|
+
|
33
52
|
class MyLXL < LXL::Parser
|
34
|
-
def self.
|
53
|
+
def self.range_class() SSRange end
|
35
54
|
end
|
36
55
|
|
37
56
|
#--
|
@@ -39,7 +58,10 @@ end
|
|
39
58
|
#++
|
40
59
|
|
41
60
|
class SpreadsheetTest < Test::Unit::TestCase
|
42
|
-
def
|
43
|
-
assert_equal(
|
61
|
+
def test_range
|
62
|
+
assert_equal(5, MyLXL.eval('=A2'))
|
63
|
+
assert_equal($sheet1[1,2].value, MyLXL.eval('=Sheet1!A2'))
|
64
|
+
assert_equal(8, MyLXL.eval('=Sheet2!C4'))
|
65
|
+
assert_equal($sheet2[3,4].value, MyLXL.eval('=Sheet2!C4'))
|
44
66
|
end
|
45
67
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.3
|
|
3
3
|
specification_version: 1
|
4
4
|
name: lxl
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.4.
|
7
|
-
date: 2005-02-
|
6
|
+
version: 0.4.2
|
7
|
+
date: 2005-02-18
|
8
8
|
summary: LXL (Like Excel) is a mini-language that mimics Microsoft Excel formulas. Easily extended with new constants and functions.
|
9
9
|
require_paths:
|
10
10
|
- lib
|