excel_to_code 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/src/commands/excel_to_c.rb +5 -3
- data/src/commands/excel_to_x.rb +25 -0
- metadata +10 -10
data/src/commands/excel_to_c.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
require_relative 'excel_to_x'
|
3
|
+
require 'ffi'
|
3
4
|
|
4
5
|
class ExcelToC < ExcelToX
|
5
6
|
|
@@ -129,8 +130,9 @@ class ExcelToC < ExcelToX
|
|
129
130
|
name = output_name.downcase
|
130
131
|
|
131
132
|
# Target for shared library
|
132
|
-
|
133
|
-
o.puts "
|
133
|
+
shared_library_name = FFI.map_library_name(name)
|
134
|
+
o.puts "#{shared_library_name}: #{name}.o"
|
135
|
+
o.puts "\tgcc -shared -o #{shared_library_name} #{name}.o"
|
134
136
|
o.puts
|
135
137
|
|
136
138
|
# Target for compiled version
|
@@ -141,7 +143,7 @@ class ExcelToC < ExcelToX
|
|
141
143
|
# Target for cleaning
|
142
144
|
o.puts "clean:"
|
143
145
|
o.puts "\trm #{name}.o"
|
144
|
-
o.puts "\trm
|
146
|
+
o.puts "\trm #{shared_library_name}"
|
145
147
|
|
146
148
|
close(o)
|
147
149
|
end
|
data/src/commands/excel_to_x.rb
CHANGED
@@ -114,6 +114,11 @@ class ExcelToX
|
|
114
114
|
separate_formulae_elements
|
115
115
|
replace_values_with_constants
|
116
116
|
|
117
|
+
# In case this hasn't been set by the user
|
118
|
+
if cells_that_can_be_set_at_runtime.empty?
|
119
|
+
create_a_good_set_of_cells_that_should_be_settable_at_runtime
|
120
|
+
end
|
121
|
+
|
117
122
|
# This actually creates the code (implemented in subclasses)
|
118
123
|
write_code
|
119
124
|
|
@@ -553,6 +558,26 @@ class ExcelToX
|
|
553
558
|
close(co)
|
554
559
|
end
|
555
560
|
|
561
|
+
def create_a_good_set_of_cells_that_should_be_settable_at_runtime
|
562
|
+
references = all_formulae("formulae_inlined_pruned_with_sheets.ast")
|
563
|
+
counter = CountFormulaReferences.new
|
564
|
+
count = counter.count(references)
|
565
|
+
|
566
|
+
count.each do |sheet,keys|
|
567
|
+
keys.each do |ref,count|
|
568
|
+
ast = references[sheet][ref]
|
569
|
+
next unless ast
|
570
|
+
p ast.first
|
571
|
+
if [:blank,:number,:null,:string,:constant,:percentage,:error,:boolean_true,:boolean_false].include?(ast.first)
|
572
|
+
@cells_that_can_be_set_at_runtime[sheet] ||= []
|
573
|
+
@cells_that_can_be_set_at_runtime[sheet] << ref.upcase
|
574
|
+
end
|
575
|
+
end
|
576
|
+
end
|
577
|
+
p @cells_that_can_be_set_at_runtime
|
578
|
+
|
579
|
+
end
|
580
|
+
|
556
581
|
# UTILITY FUNCTIONS
|
557
582
|
|
558
583
|
def settable(name)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excel_to_code
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubypeg
|
16
|
-
requirement: &
|
16
|
+
requirement: &70200308259560 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70200308259560
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: nokogiri
|
27
|
-
requirement: &
|
27
|
+
requirement: &70200305826260 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.5.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70200305826260
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70200305824320 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.7.0
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70200305824320
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: ffi
|
49
|
-
requirement: &
|
49
|
+
requirement: &70200305818740 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: 1.0.11
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70200305818740
|
58
58
|
description: ! "# excel_to_code\n\nConverts some excel spreadsheets (.xlsx, not .xls)
|
59
59
|
into some other programming languages (currently ruby or c).\nThis allows the excel
|
60
60
|
spreadsheets to be run programatically, without excel.\n\nIts cannonical source
|