excel_to_code 0.1.5 → 0.1.6
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.
- checksums.yaml +4 -4
- data/src/commands/excel_to_x.rb +41 -1
- 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: 5f0ca6f9f95aa9175bde4d6cdce638d4d11d09b3
|
4
|
+
data.tar.gz: f0ceec9fc7895942395cecb4b03428eb01bac979
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32560230728d0caaab4d270fd3e9faa6190160ad5fe4b198cacab2ca89d80cc4bdf9a039a5c9eabeacd3cb55bdc0bd6f225af6c432e256ba20f1787945d603c7
|
7
|
+
data.tar.gz: a2b72b13008837e562abbc86100925871ce33ba9f5fa47cf76d012aba306ac3f0756bdba35e77f552afa54f5e9a2d0bd26b8c3410446dbd0e884a44494b04511
|
data/src/commands/excel_to_x.rb
CHANGED
@@ -39,6 +39,8 @@ class ExcelToX
|
|
39
39
|
# To specify a named reference scoped to a worksheet, use ['worksheet', 'named reference'] instead
|
40
40
|
# of a string.
|
41
41
|
#
|
42
|
+
# Alternatively, can se to :where_possible to create setters for named references that point to setable cells
|
43
|
+
#
|
42
44
|
# Each named reference then has a function in the resulting C code of the form
|
43
45
|
# void set_named_reference_mangled_into_a_c_function(ExcelValue newValue)
|
44
46
|
#
|
@@ -59,11 +61,14 @@ class ExcelToX
|
|
59
61
|
attr_accessor :cells_to_keep
|
60
62
|
|
61
63
|
# Optional attribute. Specifies which named references should be included in the output
|
64
|
+
#
|
62
65
|
# Should be an array of strings. Each string is a named reference. Case sensitive.
|
63
66
|
#
|
64
67
|
# To specify a named reference scoped to a worksheet, use ['worksheet', 'named reference'] instead
|
65
68
|
# of a string.
|
66
69
|
#
|
70
|
+
# Alternatively, can specify :all to keep all named references
|
71
|
+
#
|
67
72
|
# Each named reference then has a function in the resulting C code of the form
|
68
73
|
# ExcelValue named_reference_mangled_into_a_c_function()
|
69
74
|
#
|
@@ -168,6 +173,10 @@ class ExcelToX
|
|
168
173
|
create_a_good_set_of_cells_that_should_be_settable_at_runtime
|
169
174
|
end
|
170
175
|
|
176
|
+
if named_references_that_can_be_set_at_runtime == :where_possible
|
177
|
+
work_out_which_named_references_can_be_set_at_runtime
|
178
|
+
end
|
179
|
+
|
171
180
|
filter_named_references
|
172
181
|
|
173
182
|
replace_formulae_with_their_results
|
@@ -396,7 +405,7 @@ class ExcelToX
|
|
396
405
|
# Returns a hash of named references, and the ast of their links
|
397
406
|
# where the named reference is global the key will be a string of
|
398
407
|
# its name and case sensitive.
|
399
|
-
# where the named reference is
|
408
|
+
# where the named reference is scoped to a worksheet, the key will be
|
400
409
|
# a two element array. The first element will be the sheet name. The
|
401
410
|
# second will be the name.
|
402
411
|
def named_references
|
@@ -416,6 +425,7 @@ class ExcelToX
|
|
416
425
|
def transfer_named_references_to_keep_into_cells_to_keep
|
417
426
|
log.debug "Started transfering named references to keep into cells to keep"
|
418
427
|
return unless @named_references_to_keep
|
428
|
+
@named_references_to_keep = named_references.keys if @named_references_to_keep == :all
|
419
429
|
@cells_to_keep ||= {}
|
420
430
|
all_named_references = named_references
|
421
431
|
@named_references_to_keep.each do |name|
|
@@ -431,6 +441,7 @@ class ExcelToX
|
|
431
441
|
def transfer_named_references_that_can_be_set_at_runtime_into_cells_that_can_be_set_at_runtime
|
432
442
|
log.debug "Started transfering named references that can be set at runtime into cells that can be set at runtime"
|
433
443
|
return unless @named_references_that_can_be_set_at_runtime
|
444
|
+
return if @named_references_that_can_be_set_at_runtime == :where_possible
|
434
445
|
@cells_that_can_be_set_at_runtime ||= {}
|
435
446
|
all_named_references = named_references
|
436
447
|
@named_references_that_can_be_set_at_runtime.each do |name|
|
@@ -463,6 +474,35 @@ class ExcelToX
|
|
463
474
|
end
|
464
475
|
end
|
465
476
|
|
477
|
+
def work_out_which_named_references_can_be_set_at_runtime
|
478
|
+
return unless @named_references_that_can_be_set_at_runtime
|
479
|
+
return unless @named_references_that_can_be_set_at_runtime == :where_possible
|
480
|
+
@named_references_that_can_be_set_at_runtime = []
|
481
|
+
all_named_references = named_references
|
482
|
+
@named_references_to_keep.each do |name|
|
483
|
+
ref = all_named_references[name]
|
484
|
+
if ref.first == :sheet_reference
|
485
|
+
sheet = ref[1]
|
486
|
+
cell = ref[2][1].gsub('$','')
|
487
|
+
s = @cells_that_can_be_set_at_runtime[sheet]
|
488
|
+
@named_references_that_can_be_set_at_runtime << name if s && s.include?(cell)
|
489
|
+
elsif ref.first.is_a?(Array)
|
490
|
+
ref = ref.first
|
491
|
+
p ref
|
492
|
+
settable = ref.all? do |row|
|
493
|
+
ref.all? do |column|
|
494
|
+
p column
|
495
|
+
sheet = column[1]
|
496
|
+
cell = column[2][1].gsub('$','')
|
497
|
+
s = @cells_that_can_be_set_at_runtime[sheet]
|
498
|
+
s && s.include?(cell)
|
499
|
+
end
|
500
|
+
end
|
501
|
+
@named_references_that_can_be_set_at_runtime << name if settable
|
502
|
+
end
|
503
|
+
end
|
504
|
+
end
|
505
|
+
|
466
506
|
# FIXME: Feels like a kludge
|
467
507
|
def filter_named_references
|
468
508
|
@named_references_to_keep ||= []
|
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.1.
|
4
|
+
version: 0.1.6
|
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: 2013-05-
|
11
|
+
date: 2013-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubypeg
|