rails-exporter 0.0.3 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails_exporter/base.rb +2 -4
- data/lib/rails_exporter/exporter.rb +4 -7
- data/lib/rails_exporter/version.rb +2 -2
- 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: 41c61f002ac8a7a320d997dbd776883f559fb663
|
4
|
+
data.tar.gz: 4d218e2bcb266c62e6d5bb65c0da8fa19c475eb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2633fe4f71f8080bead1dbdd3aecf34657202d47fa1e44d8e844d45fd75ba85da5b6272e7d6e9fe78bbfefaea7980ea22be92eca014133974b2c34b42eb0da4c
|
7
|
+
data.tar.gz: db69716d162786d25c50da66714e4b701ed315a5129f80192cf686a0904e7883e2fcd2f97cf2fc30d4fd5b9cac6022c8c321f7bac9405ece8747be70c4a800a1
|
data/lib/rails_exporter/base.rb
CHANGED
@@ -34,13 +34,11 @@ module RailsExporter
|
|
34
34
|
end
|
35
35
|
|
36
36
|
label = I18n.t(attribute, default: [attribute.to_s.humanize], scope: [:exporters, @exporter_name])
|
37
|
-
self.exporters[@exporter_name] << {column: attribute, label: label, type: normalize_type(type), block: block}
|
37
|
+
self.exporters[@exporter_name] << {column: attribute, label: label, type: normalize_type(type), block: (block_given? ? block : nil)}
|
38
38
|
end
|
39
39
|
|
40
40
|
def columns(exporter_name=:default)
|
41
|
-
self.exporters[exporter_name]
|
42
|
-
attribute.slice(:column, :label, :type)
|
43
|
-
end
|
41
|
+
self.exporters[exporter_name]
|
44
42
|
end
|
45
43
|
|
46
44
|
private
|
@@ -34,8 +34,7 @@ module RailsExporter
|
|
34
34
|
xml.record do |r|
|
35
35
|
i = 0
|
36
36
|
get_columns(context).map do |attr|
|
37
|
-
attr
|
38
|
-
xml.tag!(attr, get_values[i], {title: attr_name(attr)})
|
37
|
+
xml.tag!(attr[:column], get_values[i], {title: attr_name(attr)})
|
39
38
|
i+=1
|
40
39
|
end
|
41
40
|
end
|
@@ -56,8 +55,7 @@ module RailsExporter
|
|
56
55
|
spreadsheet.row(0).default_format = Spreadsheet::Format.new :weight => :bold
|
57
56
|
#HEADER
|
58
57
|
get_columns(context).each_with_index do |attr, i|
|
59
|
-
|
60
|
-
spreadsheet.row(0).insert i, (self.human_attribute_name(attr) || attr)
|
58
|
+
spreadsheet.row(0).insert i, attr_name(attr)
|
61
59
|
end
|
62
60
|
#ROWS
|
63
61
|
records.each_with_index do |record, i|
|
@@ -81,13 +79,12 @@ module RailsExporter
|
|
81
79
|
|
82
80
|
def get_values(record, context)
|
83
81
|
get_columns(context).map do |attribute|
|
84
|
-
|
82
|
+
unless attribute[:block].nil?
|
85
83
|
value = attribute[:block].call(record)
|
86
|
-
value.to_s
|
87
84
|
else
|
88
85
|
value = (record.send(attribute[:column]) rescue '')
|
89
|
-
normalize_value(value, attribute[:type])
|
90
86
|
end
|
87
|
+
normalize_value(value, attribute[:type])
|
91
88
|
end
|
92
89
|
end
|
93
90
|
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module RailsExporter
|
2
|
-
VERSION = "0.0.
|
3
|
-
end
|
2
|
+
VERSION = "0.0.6"
|
3
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-exporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno Porto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spreadsheet
|