tofulcrum 0.0.11 → 0.0.12
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 +8 -8
- data/lib/tofulcrum/fulcrum-xls-form/xls_reader.rb +42 -3
- data/lib/tofulcrum/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzBhNzI3YWYyZTkxOTNmMjk5NmM4Yzg3ODBmODg5Y2E0NTJjNzA4MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Nzg5OTk3ZTAwMGI4NmRhNTliMTZmMzU5NDQ3OWRjZmZhYTRmMjI0MA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTJmNGQ3YmUzYTQxN2Q1MDQyNDQ2ZjE3MGU3MGEwMWRjMDdiZGIzZjFjY2I1
|
10
|
+
ZGUzODZkN2E1OWU3YzhmNWI3ZGZmOGVkMGEwYjk0ZTY2Zjg3ZDhjYTk2MWRj
|
11
|
+
NDA1ODhmMjAwOGQ4Yjk2MGM1ZDU2M2MzMWZmNWRmMDhmNGExMGI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTRhYjU1YzBmYjgwZmIzNmQ0MDRlZDNiYjQ5OGZmYjI3ZmZmNDc4NzM0Yjc4
|
14
|
+
MjBiNjJhYzljZmFmMmQ2YjdiODU3M2YyYjVlNDA2M2FlOTZhNTVhNzE4NDZk
|
15
|
+
NDg1YjBiMGQ1NjExMjk5YTMzYjg5MTJlNjE5MDEzNGQ3ZWE0OGQ=
|
@@ -27,12 +27,21 @@ module Fulcrum
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.parse_schema(spreadsheet)
|
30
|
+
elements = make_elements(make_hash(spreadsheet.sheet('form')))
|
31
|
+
|
32
|
+
record_title_key = nil
|
33
|
+
|
34
|
+
if record_title_field = @metadata['record_title_field']
|
35
|
+
record_title_key = find_element(elements, record_title_field)[:key]
|
36
|
+
end
|
37
|
+
|
30
38
|
form = { form: { name: @metadata['name'],
|
31
39
|
description: @metadata['description'],
|
32
40
|
status_field: @status_field,
|
33
|
-
|
41
|
+
record_title_key: record_title_key,
|
42
|
+
elements: elements } }
|
34
43
|
|
35
|
-
puts form
|
44
|
+
puts JSON.pretty_generate(form)
|
36
45
|
end
|
37
46
|
|
38
47
|
def self.make_elements(rows)
|
@@ -72,9 +81,16 @@ module Fulcrum
|
|
72
81
|
when 'repeatable end'
|
73
82
|
raise "repeatable end found without matching begin" if containers.count == 1
|
74
83
|
|
84
|
+
repeatable_title_field_key = nil
|
85
|
+
|
86
|
+
if (title_field = current_container[:title_field_key]) && title_field.present?
|
87
|
+
repeatable_title_field_key = find_element(current_container[:elements], title_field, include_repeatables: false)[:key]
|
88
|
+
end
|
89
|
+
|
90
|
+
current_container[:title_field_key] = repeatable_title_field_key
|
91
|
+
|
75
92
|
containers = containers[0..-2]
|
76
93
|
current_container = containers.last
|
77
|
-
|
78
94
|
end
|
79
95
|
end
|
80
96
|
|
@@ -97,6 +113,10 @@ module Fulcrum
|
|
97
113
|
hash[:key] = SecureRandom.hex(2)
|
98
114
|
|
99
115
|
case hash[:type]
|
116
|
+
when 'Section'
|
117
|
+
hash[:display] = row['display'] == 'drilldown' ? 'drilldown' : 'inline'
|
118
|
+
when 'Repeatable'
|
119
|
+
hash[:title_field_key] = row['title_field']
|
100
120
|
when 'ChoiceField'
|
101
121
|
hash[:choices] = @choices[row['choices']] if hash[:type] == 'ChoiceField'
|
102
122
|
hash[:allow_other] = boolean_value(row[:allow_other])
|
@@ -246,5 +266,24 @@ module Fulcrum
|
|
246
266
|
|
247
267
|
rows
|
248
268
|
end
|
269
|
+
|
270
|
+
def self.find_element(elements, data_name, opts={})
|
271
|
+
all_elements(elements, opts).find do |e|
|
272
|
+
e[:data_name] == data_name
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
def self.all_elements(elements, opts={})
|
277
|
+
elements.inject([]) do |array, el|
|
278
|
+
array << el
|
279
|
+
exclude_repeatables = !!opts[:exclude_repeatables]
|
280
|
+
if exclude_repeatables
|
281
|
+
array += all_elements(el[:elements], opts) if el[:elements] && el[:type] != 'Repeatable'
|
282
|
+
else
|
283
|
+
array += all_elements(el[:elements], opts) if el[:elements]
|
284
|
+
end
|
285
|
+
array
|
286
|
+
end
|
287
|
+
end
|
249
288
|
end
|
250
289
|
end
|
data/lib/tofulcrum/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tofulcrum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zac McCormick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|