lxl 0.2.3 → 0.2.4

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.
Files changed (6) hide show
  1. data/CHANGES +4 -0
  2. data/README +1 -1
  3. data/VERSION +1 -1
  4. data/lib/lxl.rb +21 -2
  5. data/test/lxl_test.rb +9 -0
  6. metadata +2 -2
data/CHANGES CHANGED
@@ -1,3 +1,7 @@
1
+ 0.2.4
2
+
3
+ - Added Deferred function calls via register_deferred
4
+
1
5
  0.2.3
2
6
 
3
7
  - tokenize now returns [TypesArray, TokensArray]
data/README CHANGED
@@ -41,7 +41,7 @@ Install
41
41
  License
42
42
  -------
43
43
 
44
- LXL uses John Carter's LittleLexer for parsing.
44
+ LXL incorporates John Carter's LittleLexer for parsing.
45
45
  Distributes under the same terms as LittleLexer.
46
46
  http://www.rubyforge.org/projects/littlelexer/
47
47
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
data/lib/lxl.rb CHANGED
@@ -150,12 +150,18 @@ class LXL::Parser
150
150
  @constants[name] = value
151
151
  end
152
152
 
153
- # Registers constant for each symbol, with the same name and value
153
+ # Register a constant for each symbol of the same name and value
154
154
  #
155
155
  def register_symbols(*symbols)
156
156
  symbols.each { |s| register_constant(s, s) }
157
157
  end
158
158
 
159
+ # Register each symbol as a Deferred function call
160
+ #
161
+ def register_deferred(*symbols)
162
+ symbols.each { |s| register_function(s) { |*args| LXL::Deferred.new(s, *args) } }
163
+ end
164
+
159
165
  protected
160
166
 
161
167
  # Translate to uppercase symbol
@@ -238,11 +244,24 @@ class LXL::Parser
238
244
 
239
245
  end
240
246
 
247
+ # Deferred function call (snapshots the symbol and arguments).
248
+ #
249
+ class LXL::Deferred
250
+
251
+ attr_accessor :symbol, :args
252
+
253
+ def initialize(symbol, *args)
254
+ @symbol = symbol
255
+ @args = args
256
+ end
257
+
258
+ end
259
+
241
260
  # John Carter's LittleLexer
242
261
  #
243
262
  # http://www.rubyforge.org/projects/littlelexer
244
263
  #
245
- # CHANGE: types are returned as [Symbol*] vs String
264
+ # CHANGE: types are returned as [*Symbol] vs String
246
265
  #
247
266
  class LXL::LittleLexer #:nodoc: all
248
267
 
@@ -31,5 +31,14 @@ class LXLTest < Test::Unit::TestCase
31
31
  results = lxl.eval(formulas)
32
32
  expected.each_index { |i| assert_equal(expected[i], results[i]) }
33
33
  end
34
+
35
+ def test_deferred
36
+ lxl = LXL::Parser.new
37
+ lxl.register_deferred(:TESTING)
38
+ res = lxl.eval('=TESTING(1,2,3)')
39
+ assert_equal(LXL::Deferred, res.class)
40
+ assert_equal(:TESTING, res.symbol)
41
+ assert_equal(3, res.args.last)
42
+ end
34
43
 
35
44
  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.2.3
7
- date: 2005-02-08
6
+ version: 0.2.4
7
+ date: 2005-02-09
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