excel_to_code 0.2.9 → 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/src/commands/excel_to_x.rb +21 -0
- data/src/rewrite/caching_formula_parser.rb +14 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d131943e44d296b38b2b2f52d4e710fb72b3290c
|
4
|
+
data.tar.gz: 1ced79386e0e176fb515794fb5026a4779d56c2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90c8c2c66e70b2beb0073a904d02c70444d3881bce4b570fe681a99098597319cee266611282f6789326efaf9a69198c85750633392c5aeae4fed329bfc7c521
|
7
|
+
data.tar.gz: 39325a065501520c32b29be75d0af212c498c8d8d2baf580e1a0e585b2841fa6610679a1298d2dbe86ab5bf6269821612b97ce969b1d178a514ea16ef4831e94
|
data/src/commands/excel_to_x.rb
CHANGED
@@ -130,6 +130,10 @@ class ExcelToX
|
|
130
130
|
# This gets all the formulae, values and tables out of the worksheets
|
131
131
|
extract_data_from_worksheets
|
132
132
|
|
133
|
+
# This is an early check that the functions in the extracted data have
|
134
|
+
# all got an implementation in, at least, the ruby code
|
135
|
+
check_all_functions_implemented
|
136
|
+
|
133
137
|
# This turns named references that are specified as getters and setters
|
134
138
|
# into a series of required cell references
|
135
139
|
transfer_named_references_to_keep_into_cells_to_keep
|
@@ -466,6 +470,23 @@ class ExcelToX
|
|
466
470
|
end
|
467
471
|
end
|
468
472
|
end
|
473
|
+
|
474
|
+
def check_all_functions_implemented
|
475
|
+
functions_that_are_removed_during_compilation = [:INDIRECT, :OFFSET, :ROW, :COLUMN, :TRANSPOSE]
|
476
|
+
functions_used = CachingFormulaParser.instance.functions_used.keys
|
477
|
+
functions_used.delete_if do |f|
|
478
|
+
MapFormulaeToRuby::FUNCTIONS[f]
|
479
|
+
end
|
480
|
+
functions_that_are_removed_during_compilation.each do |f|
|
481
|
+
functions_used.delete(f)
|
482
|
+
end
|
483
|
+
unless functions_used.empty?
|
484
|
+
puts
|
485
|
+
puts "The following functions have not been implemented in excel_to_code. Please see https://github.com/tamc/excel_to_code/blob/master/doc/How_to_add_a_missing_function.md"
|
486
|
+
puts functions_used
|
487
|
+
exit
|
488
|
+
end
|
489
|
+
end
|
469
490
|
|
470
491
|
# This makes sure that cells_to_keep includes named_references_to_keep
|
471
492
|
def transfer_named_references_to_keep_into_cells_to_keep
|
@@ -3,6 +3,8 @@ require 'singleton'
|
|
3
3
|
class CachingFormulaParser
|
4
4
|
include Singleton
|
5
5
|
|
6
|
+
attr_accessor :functions_used
|
7
|
+
|
6
8
|
def self.parse(*args)
|
7
9
|
instance.parse(*args)
|
8
10
|
end
|
@@ -19,6 +21,7 @@ class CachingFormulaParser
|
|
19
21
|
@operator_cache = {}
|
20
22
|
@comparator_cache = {}
|
21
23
|
@sheet_reference_cache = {}
|
24
|
+
@functions_used = {}
|
22
25
|
end
|
23
26
|
|
24
27
|
def parse(text)
|
@@ -30,15 +33,24 @@ class CachingFormulaParser
|
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
36
|
+
# FIXME: THe function bit in here isn't DRY or consistent
|
33
37
|
def map(ast)
|
34
38
|
return ast unless ast.is_a?(Array)
|
35
|
-
|
39
|
+
if ast[0] == :function
|
40
|
+
ast[1] = ast[1].to_sym
|
41
|
+
@functions_used[ast[1]] = true
|
42
|
+
end
|
36
43
|
if respond_to?(ast[0])
|
37
44
|
ast = send(ast[0], ast)
|
38
45
|
else
|
39
46
|
ast.each.with_index do |a,i|
|
40
47
|
next unless a.is_a?(Array)
|
41
|
-
|
48
|
+
|
49
|
+
if a[0] == :function
|
50
|
+
a[1] = a[1].to_sym
|
51
|
+
@functions_used[a[1]] = true
|
52
|
+
end
|
53
|
+
|
42
54
|
ast[i] = map(a)
|
43
55
|
end
|
44
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excel_to_code
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Counsell, Green on Black Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01
|
11
|
+
date: 2014-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubypeg
|