excel_to_code 0.0.10 → 0.0.11
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.
- data/src/commands/excel_to_x.rb +4 -2
- data/src/extract.rb +1 -0
- data/src/extract/extract_shared_formulae_targets.rb +15 -0
- data/src/rewrite/rewrite_shared_formulae.rb +8 -6
- metadata +11 -11
- data/src/compile/c/a.out +0 -0
data/src/commands/excel_to_x.rb
CHANGED
@@ -232,6 +232,8 @@ class ExcelToX
|
|
232
232
|
extract ExtractSharedFormulae, xml_filename, [name, 'Formulae (shared)']
|
233
233
|
apply_rewrite RewriteFormulaeToAst, [name, 'Formulae (shared)']
|
234
234
|
|
235
|
+
extract ExtractSharedFormulaeTargets, xml_filename, [name, 'Formulae (shared targets)']
|
236
|
+
|
235
237
|
extract ExtractArrayFormulae, xml_filename, [name, 'Formulae (array)']
|
236
238
|
apply_rewrite RewriteFormulaeToAst, [name, 'Formulae (array)']
|
237
239
|
|
@@ -298,7 +300,7 @@ class ExcelToX
|
|
298
300
|
end
|
299
301
|
|
300
302
|
def rewrite_shared_formulae(name,xml_filename)
|
301
|
-
|
303
|
+
rewrite RewriteSharedFormulae, [name, 'Formulae (shared)'], [name, 'Formulae (shared targets)'], [name, 'Formulae (shared)']
|
302
304
|
end
|
303
305
|
|
304
306
|
def rewrite_array_formulae(name,xml_filename)
|
@@ -781,4 +783,4 @@ class ExcelToX
|
|
781
783
|
File.expand_path(File.join(args))
|
782
784
|
end
|
783
785
|
|
784
|
-
end
|
786
|
+
end
|
data/src/extract.rb
CHANGED
@@ -3,6 +3,7 @@ require_relative "extract/extract_array_formulae"
|
|
3
3
|
require_relative "extract/extract_formulae"
|
4
4
|
require_relative "extract/extract_relationships"
|
5
5
|
require_relative "extract/extract_shared_formulae"
|
6
|
+
require_relative "extract/extract_shared_formulae_targets"
|
6
7
|
require_relative "extract/extract_shared_strings"
|
7
8
|
require_relative "extract/extract_simple_formulae"
|
8
9
|
require_relative "extract/extract_values"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative 'extract_formulae'
|
2
|
+
|
3
|
+
class ExtractSharedFormulaeTargets < ExtractFormulae
|
4
|
+
|
5
|
+
def start_formula(type,attributes)
|
6
|
+
return unless type == 'shared'
|
7
|
+
@parsing = true
|
8
|
+
end
|
9
|
+
|
10
|
+
def write_formula
|
11
|
+
output.write @ref
|
12
|
+
output.write "\n"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -1,18 +1,19 @@
|
|
1
1
|
require_relative 'ast_copy_formula'
|
2
2
|
|
3
3
|
class RewriteSharedFormulae
|
4
|
-
def self.rewrite(input,output)
|
5
|
-
new.rewrite(input,output)
|
4
|
+
def self.rewrite(input, shared_targets, output)
|
5
|
+
new.rewrite(input, shared_targets, output)
|
6
6
|
end
|
7
7
|
|
8
|
-
def rewrite(input,output)
|
8
|
+
def rewrite(input, shared_targets, output)
|
9
|
+
shared_targets = shared_targets.lines.map(&:strip).to_a
|
9
10
|
input.lines do |line|
|
10
11
|
ref, copy_range, formula = line.split("\t")
|
11
|
-
share_formula(ref,formula,copy_range,output)
|
12
|
+
share_formula(ref, formula, copy_range, shared_targets, output)
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
15
|
-
def share_formula(ref,formula,copy_range,output)
|
16
|
+
def share_formula(ref, formula, copy_range, shared_targets, output)
|
16
17
|
shared_ast = eval(formula)
|
17
18
|
copier = AstCopyFormula.new
|
18
19
|
copy_range = Area.for(copy_range)
|
@@ -28,6 +29,7 @@ class RewriteSharedFormulae
|
|
28
29
|
|
29
30
|
copy_range.offsets.each do |row,column|
|
30
31
|
new_ref = start_reference.offset(row,column)
|
32
|
+
next unless shared_targets.include?(new_ref)
|
31
33
|
copier.rows_to_move = row + offset_from_formula_to_start_rows
|
32
34
|
copier.columns_to_move = column + offset_from_formula_to_start_columns
|
33
35
|
ast = copier.copy(shared_ast)
|
@@ -35,4 +37,4 @@ class RewriteSharedFormulae
|
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
|
-
end
|
40
|
+
end
|
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.11
|
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-07-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubypeg
|
16
|
-
requirement: &
|
16
|
+
requirement: &70307966168940 !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: *70307966168940
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: nokogiri
|
27
|
-
requirement: &
|
27
|
+
requirement: &70307966167440 !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: *70307966167440
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70307966165300 !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: *70307966165300
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: ffi
|
49
|
-
requirement: &
|
49
|
+
requirement: &70307966164020 !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: *70307966164020
|
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
|
@@ -84,7 +84,6 @@ files:
|
|
84
84
|
- src/commands/excel_to_ruby.rb
|
85
85
|
- src/commands/excel_to_x.rb
|
86
86
|
- src/commands.rb
|
87
|
-
- src/compile/c/a.out
|
88
87
|
- src/compile/c/compile_to_c.rb
|
89
88
|
- src/compile/c/compile_to_c_header.rb
|
90
89
|
- src/compile/c/compile_to_c_unit_test.rb
|
@@ -158,6 +157,7 @@ files:
|
|
158
157
|
- src/extract/extract_named_references.rb
|
159
158
|
- src/extract/extract_relationships.rb
|
160
159
|
- src/extract/extract_shared_formulae.rb
|
160
|
+
- src/extract/extract_shared_formulae_targets.rb
|
161
161
|
- src/extract/extract_shared_strings.rb
|
162
162
|
- src/extract/extract_simple_formulae.rb
|
163
163
|
- src/extract/extract_table.rb
|
data/src/compile/c/a.out
DELETED
Binary file
|