agilibox 1.0.7 → 1.0.8
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/app/serializers/agilibox/serializers/base.rb +40 -0
- data/app/serializers/agilibox/serializers/xlsx.rb +1 -13
- data/lib/agilibox/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c492625f29e6a413965c9744b23a8de2cdc9a2b7
|
4
|
+
data.tar.gz: 2aa12b3967dfd2ac0c6c7ec4f2cb1057536b52ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8ebd6d3948bffa2af483a9e8ecff2db6dcfc7da7afcb6ecbefb40cf719e94f2ecf723a6e041383e3272dac291abc0af56ad3819ed96189227fa7bffc79fa65e
|
7
|
+
data.tar.gz: 03fd5d1a9fc8de1267bb830c11dcc08665335a48595797f8fd782ba93d77111a19c20880a46929a7b7994a790f678e10b9f6fa41c9c262172dedbd0002366ad0
|
data/CHANGELOG.md
CHANGED
@@ -14,4 +14,44 @@ class Agilibox::Serializers::Base
|
|
14
14
|
raise NotImplementedError
|
15
15
|
end
|
16
16
|
|
17
|
+
class << self
|
18
|
+
def decimals_precision
|
19
|
+
@decimals_precision ||= 2
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_writer :decimals_precision
|
23
|
+
|
24
|
+
def format_integer(value)
|
25
|
+
value
|
26
|
+
end
|
27
|
+
|
28
|
+
def format_decimal(value)
|
29
|
+
value.to_f.round(decimals_precision) # Fix BigDecimal and 0.1 + 0.2
|
30
|
+
end
|
31
|
+
|
32
|
+
def format_boolean(value)
|
33
|
+
I18n.t(value.to_s)
|
34
|
+
end
|
35
|
+
|
36
|
+
def format_datetime(value)
|
37
|
+
Agilibox::AllHelpers.date(value)
|
38
|
+
end
|
39
|
+
|
40
|
+
def format_default(value)
|
41
|
+
value.to_s
|
42
|
+
end
|
43
|
+
|
44
|
+
def formatter_for(value)
|
45
|
+
return :integer if value.is_a?(Integer)
|
46
|
+
return :decimal if value.is_a?(Numeric)
|
47
|
+
return :boolean if value.is_a?(TrueClass) || value.is_a?(FalseClass)
|
48
|
+
return :datetime if value.is_a?(Date) || value.is_a?(Time)
|
49
|
+
return :default
|
50
|
+
end
|
51
|
+
|
52
|
+
def format(value)
|
53
|
+
formatter = "format_" + formatter_for(value).to_s
|
54
|
+
public_send(formatter, value)
|
55
|
+
end
|
56
|
+
end # class << self
|
17
57
|
end
|
@@ -11,18 +11,7 @@ class Agilibox::Serializers::XLSX < Agilibox::Serializers::Base
|
|
11
11
|
@xlsx ||= Axlsx::Package.new do |p|
|
12
12
|
p.workbook.add_worksheet do |sheet|
|
13
13
|
data.each do |line|
|
14
|
-
values = line.map
|
15
|
-
if value.is_a?(Integer)
|
16
|
-
value
|
17
|
-
elsif value.is_a?(Numeric)
|
18
|
-
value.to_f # Fix BigDecimal
|
19
|
-
elsif value == true || value == false
|
20
|
-
I18n.t(value.to_s)
|
21
|
-
else
|
22
|
-
value.to_s
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
14
|
+
values = line.map { |value| self.class.format(value) }
|
26
15
|
sheet.add_row(values)
|
27
16
|
end
|
28
17
|
end
|
@@ -30,5 +19,4 @@ class Agilibox::Serializers::XLSX < Agilibox::Serializers::Base
|
|
30
19
|
p.use_shared_strings = true
|
31
20
|
end
|
32
21
|
end
|
33
|
-
|
34
22
|
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.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- agilidée
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails-i18n
|