excel_to_code 0.2.20 → 0.2.21

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8683fda68a9053d3873f3ae6612dc61af4ad4393
4
- data.tar.gz: 5ce67a7a836a8931a2b41f7f790ca07b9c565960
3
+ metadata.gz: 7dfb614b4506cd5feb1fdf4ed13261b19e33af1c
4
+ data.tar.gz: 5e06790944edc88f7ccea7959e4a1a1a6119fffb
5
5
  SHA512:
6
- metadata.gz: abef9a443559d67c2dd453d6c386febc7516c2fa88b13c2a0a8e43e932809d90d51e400e637bf4845d85bd6296136805c42e762b1d7dc563192ba0b32841f93d
7
- data.tar.gz: 6d74e0cfe7dcdad64037700c137066f21afddc10f2acafb2df63c8348e26ea0618e1b321697af7b1024853949bbc71ef1bfd87edb0839e7c75e039ae5d7d36d3
6
+ metadata.gz: 3f5287bc61bfaa773332bfd7361eb062cf3f3246649ce677699374745fdb68cb707899457a003faabd04caa3285483a04a465e8a6864bdcad8a593faa417bf00
7
+ data.tar.gz: 1dbe79f4c2bf8dcb78db9f033f30ce1dfd0f5e44b3e8004a51b2f42f62507001ae3e3c17e25a19af075af0b67d25598cd214b7b0a39987f994ca7333e6300c2f
data/bin/excel_to_c CHANGED
@@ -4,7 +4,6 @@ require_relative '../src/excel_to_code'
4
4
 
5
5
  command = ExcelToC.new
6
6
 
7
- #FIXME: Add a version option
8
7
  opts = OptionParser.new do |opts|
9
8
  opts.banner = <<-END
10
9
 
@@ -20,18 +19,15 @@ END
20
19
  opts.separator ""
21
20
  opts.separator "Specific options:"
22
21
 
23
- opts.on('-s','--settable WORKSHEET','Make it possible to set the values of cells in this worksheet at runtime. By default no values are settable.') do |sheet|
24
- command.cells_that_can_be_set_at_runtime = { sheet => :all }
22
+ opts.on('-v','--version', 'Prints the version number of this code') do
23
+ puts ExcelToCode.version
24
+ exit
25
25
  end
26
26
 
27
27
  opts.on('-o','--output-name NAME','Filename to give to c version of code (and associated ruby interface). Defaults to a folder with the same name as the excel file.') do |name|
28
28
  command.output_name = name
29
29
  end
30
-
31
- opts.on('-p','--prune-except WORKSHEET',"Remove all cells except those on this worksheet, or that are required to calculate values on that worksheet. By default keeps all cells.") do |sheet|
32
- command.cells_to_keep = { sheet => :all }
33
- end
34
-
30
+
35
31
  opts.on('-c','--compile',"Compile the generated code (where relevant)") do
36
32
  command.actually_compile_code = true
37
33
  end
@@ -39,15 +35,20 @@ END
39
35
  opts.on('-r','--run-tests',"Compile the generated code and then run the tests") do
40
36
  command.actually_run_tests = true
41
37
  end
42
-
43
- opts.on('--sloppy-tests',"The generated tests treat blanks and zeros as equivalent and only require numbers to be approximately the same. This is the default.") do
44
- command.sloppy_tests = true
38
+
39
+ opts.on('-n','--named-references',"Transfer named references from spreadsheet to generated code") do
40
+ command.named_references_that_can_be_set_at_runtime = :where_possible
41
+ command.named_references_to_keep = :all
45
42
  end
46
43
 
47
- opts.on('--precise-tests',"The generated tests treat blanks and zeros as different and requires numbers to be exactly the same.") do
48
- command.sloppy_tests = false
44
+ opts.on('-s','--settable WORKSHEET','Make it possible to set the values of cells in this worksheet at runtime. By default no values are settable.') do |sheet|
45
+ command.cells_that_can_be_set_at_runtime = { sheet => :all }
49
46
  end
50
47
 
48
+ opts.on('-p','--prune-except WORKSHEET',"Remove all cells except those on this worksheet, or that are required to calculate values on that worksheet. By default keeps all cells.") do |sheet|
49
+ command.cells_to_keep = { sheet => :all }
50
+ end
51
+
51
52
  opts.on('--isolate WORKSHEET', "Only performs translation and optimiation of that one worksheet. Useful for debugging an incorrect translation of a large worksheet") do |sheet|
52
53
  command.isolate = sheet
53
54
  end
data/bin/excel_to_ruby CHANGED
@@ -19,28 +19,38 @@ END
19
19
  opts.separator ""
20
20
  opts.separator "Specific options:"
21
21
 
22
- opts.on('-s','--settable WORKSHEET','Make it possible to set the values of cells in this worksheet at runtime. By default no values are settable.') do |sheet|
23
- command.cells_that_can_be_set_at_runtime = { sheet => :all }
22
+ opts.on('-v','--version', 'Prints the version number of this code') do
23
+ puts ExcelToCode.version
24
+ exit
24
25
  end
25
26
 
26
- opts.on('-o','--output-name NAME','Filename to give to ruby version of code. Defaults to a folder with the same name as the excel file.') do |name|
27
+ opts.on('-o','--output-name NAME','Filename to give to c version of code (and associated ruby interface). Defaults to a folder with the same name as the excel file.') do |name|
27
28
  command.output_name = name
28
29
  end
29
-
30
- opts.on('-p','--prune-except WORKSHEET',"Remove all cells except those on this worksheet, or that are required to calculate values on that worksheet. By default keeps all cells.") do |sheet|
31
- command.cells_to_keep = { sheet => :all }
30
+
31
+ opts.on('-c','--compile',"Compile the generated code (where relevant)") do
32
+ command.actually_compile_code = true
32
33
  end
33
-
34
- opts.on('-r','--run-tests',"Run the generated tests") do
34
+
35
+ opts.on('-r','--run-tests',"Compile the generated code and then run the tests") do
35
36
  command.actually_run_tests = true
36
37
  end
37
-
38
- opts.on('--sloppy-tests',"The generated tests treat blanks and zeros as equivalent and only require numbers to be approximately the same. This is the default.") do
39
- command.sloppy_tests = true
38
+
39
+ opts.on('-n','--named-references',"Transfer named references from spreadsheet to generated code") do
40
+ command.named_references_that_can_be_set_at_runtime = :where_possible
41
+ command.named_references_to_keep = :all
42
+ end
43
+
44
+ opts.on('-s','--settable WORKSHEET','Make it possible to set the values of cells in this worksheet at runtime. By default no values are settable.') do |sheet|
45
+ command.cells_that_can_be_set_at_runtime = { sheet => :all }
40
46
  end
41
47
 
42
- opts.on('--precise-tests',"The generated tests treat blanks and zeros as different and requires numbers to be exactly the same.") do
43
- command.sloppy_tests = false
48
+ opts.on('-p','--prune-except WORKSHEET',"Remove all cells except those on this worksheet, or that are required to calculate values on that worksheet. By default keeps all cells.") do |sheet|
49
+ command.cells_to_keep = { sheet => :all }
50
+ end
51
+
52
+ opts.on('--isolate WORKSHEET', "Only performs translation and optimiation of that one worksheet. Useful for debugging an incorrect translation of a large worksheet") do |sheet|
53
+ command.isolate = sheet
44
54
  end
45
55
 
46
56
  opts.on("-h", "--help", "Show this message") do
@@ -540,7 +540,14 @@ class ExcelToX
540
540
  def transfer_named_references_to_keep_into_cells_to_keep
541
541
  log.info "Transfering named references to keep into cells to keep"
542
542
  return unless @named_references_to_keep
543
- @named_references_to_keep = @named_references.keys if @named_references_to_keep == :all
543
+ if @named_references_to_keep == :all
544
+ @named_references_to_keep = @named_references.keys
545
+ # If the user has specified named_references_to_keep == :all, but there are none, fall back
546
+ if @named_references_to_keep.empty?
547
+ log.warn "named_references_to_keep == :all, but no named references found"
548
+ return
549
+ end
550
+ end
544
551
  @cells_to_keep ||= {}
545
552
  @named_references_to_keep.each do |name|
546
553
  ref = @named_references[name]
data/src/compile/c/a.out CHANGED
Binary file
@@ -482,6 +482,9 @@ int test_functions() {
482
482
  ExcelValue sumifs_array_9[] = { new_excel_number(10), new_excel_string("10.0")};
483
483
  assert(sumifs(new_excel_number(100),2,sumifs_array_9).number == 100);
484
484
 
485
+ ExcelValue sumifs_array_9b[] = { new_excel_string("10"), new_excel_number(10.0)};
486
+ assert(sumifs(new_excel_number(100),2,sumifs_array_9b).number == 100);
487
+
485
488
  ExcelValue sumifs_array_10[] = { sumifs_array_4_v, new_excel_string("CO2"), sumifs_array_5_v, new_excel_number(2)};
486
489
  assert(sumifs(sumifs_array_3_v,4, sumifs_array_10).number == 0);
487
490
 
@@ -37,7 +37,14 @@ module ExcelFunctions
37
37
 
38
38
  pass = case check_value
39
39
  when String
40
- check_value.downcase == required_value.to_s.downcase
40
+ case required_value
41
+ when String
42
+ check_value.downcase == required_value.downcase
43
+ when Numeric
44
+ check_value.to_f == required_value.to_f
45
+ else
46
+ check_value.downcase == required_value.to_s.downcase
47
+ end
41
48
  when true, false
42
49
  check_value == required_value
43
50
  when nil
data/src/excel_to_code.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class ExcelToCode
2
- def self.version() "0.2.20" end
2
+ def self.version() "0.2.21" end
3
3
  end
4
4
 
5
5
  require_relative 'commands'
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.20
4
+ version: 0.2.21
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-03-31 00:00:00.000000000 Z
11
+ date: 2014-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubypeg