agilibox 1.9.20 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b79eff8bab58fe3ca456bb0f4ed5eb18de97fd7a82dc247751a094a4fb91a961
|
4
|
+
data.tar.gz: b13ee9bd49da7ceccee0f20737706ab1a9a3d4762688902bc773be94950af6cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 599316ad810f15843e060a9cc5034cc76b505cde1bda4066deccd8bad1470986ad5bf3fecaa1e4712ede494904a06851a5df1a8852beeb0a087e5677bf118bb8
|
7
|
+
data.tar.gz: 92a2e1834215bfd50c322163cb59dfa22ea025aa4e52ee345815b5cebadb4cc3f45f376d8205e934e8aba4c8cf7cfe71813e367d4dd06e53cbbe1cf6cf329c3f
|
data/CHANGELOG.md
CHANGED
@@ -39,8 +39,8 @@ class Agilibox::Serializers::Base
|
|
39
39
|
I18n.t(value.to_s)
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
43
|
-
|
42
|
+
def format_date_or_time(value)
|
43
|
+
value
|
44
44
|
end
|
45
45
|
|
46
46
|
def format_default(value)
|
@@ -48,10 +48,10 @@ class Agilibox::Serializers::Base
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def formatter_for(value)
|
51
|
-
return :integer
|
52
|
-
return :decimal
|
53
|
-
return :boolean
|
54
|
-
return :
|
51
|
+
return :integer if value.is_a?(Integer)
|
52
|
+
return :decimal if value.is_a?(Numeric)
|
53
|
+
return :boolean if value.is_a?(TrueClass) || value.is_a?(FalseClass)
|
54
|
+
return :date_or_time if value.is_a?(Date) || value.is_a?(Time)
|
55
55
|
return :default
|
56
56
|
end
|
57
57
|
|
@@ -1,7 +1,13 @@
|
|
1
1
|
class Agilibox::Serializers::XLSX < Agilibox::Serializers::Base
|
2
2
|
def render_inline
|
3
3
|
headers, *data = formatted_data
|
4
|
-
|
4
|
+
|
5
|
+
SpreadsheetArchitect.to_xlsx(
|
6
|
+
headers: headers,
|
7
|
+
data: data,
|
8
|
+
freeze_headers: true,
|
9
|
+
range_styles: range_styles(data[0]),
|
10
|
+
)
|
5
11
|
end
|
6
12
|
|
7
13
|
def render_file(file_path)
|
@@ -9,4 +15,24 @@ class Agilibox::Serializers::XLSX < Agilibox::Serializers::Base
|
|
9
15
|
f.write(render_inline)
|
10
16
|
end
|
11
17
|
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def range_styles(row)
|
22
|
+
return [] if row.nil?
|
23
|
+
|
24
|
+
date_range_styles(row) + time_range_styles(row)
|
25
|
+
end
|
26
|
+
|
27
|
+
def date_range_styles(row)
|
28
|
+
row.each_index.select { row[_1].is_a?(Date) }.map do
|
29
|
+
{range: {rows: :all, columns: _1}, styles: {format_code: "dd/mm/yyyy"}}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def time_range_styles(row)
|
34
|
+
row.each_index.select { row[_1].is_a?(Time) }.map do
|
35
|
+
{range: {rows: :all, columns: _1}, styles: {format_code: "dd/mm/yyyy hh:mm:ss"}}
|
36
|
+
end
|
37
|
+
end
|
12
38
|
end
|
data/lib/agilibox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agilibox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- agilidée
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails-i18n
|
@@ -163,7 +163,6 @@ files:
|
|
163
163
|
- app/models/concerns/agilibox/search.rb
|
164
164
|
- app/models/concerns/agilibox/timestamp_helpers.rb
|
165
165
|
- app/serializers/agilibox/serializers.rb
|
166
|
-
- app/serializers/agilibox/serializers/axlsx.rb
|
167
166
|
- app/serializers/agilibox/serializers/base.rb
|
168
167
|
- app/serializers/agilibox/serializers/xlsx.rb
|
169
168
|
- app/services/agilibox/service.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
class Agilibox::Serializers::AXLSX < Agilibox::Serializers::Base
|
2
|
-
def render_inline
|
3
|
-
xlsx.to_stream.read.force_encoding("BINARY")
|
4
|
-
end
|
5
|
-
|
6
|
-
def render_file(file_path)
|
7
|
-
xlsx.serialize(file_path)
|
8
|
-
end
|
9
|
-
|
10
|
-
def xlsx
|
11
|
-
@xlsx ||= Axlsx::Package.new do |p|
|
12
|
-
p.workbook.add_worksheet do |sheet|
|
13
|
-
formatted_data.each do |line|
|
14
|
-
sheet.add_row(line)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
p.use_shared_strings = true
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|