export_manager 0.1.0 → 0.1.1
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/README.md +10 -0
- data/app/controllers/export_manager/export_manager_controller.rb +0 -3
- data/lib/export_manager/version.rb +1 -1
- data/lib/export_manager.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58ce4d82284296f0a5eb94bcfe2292be7fc954e23ecce55198692fd353f95bc0
|
4
|
+
data.tar.gz: 1994b72616f21d174a801f88d3ea3c8d9e0f3ce6fa1b4028a5c342f1761017fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 412b576a42d26daf338ee8a82bccb42188f958be822fd34e1cf4262b8e1733ae4eaa173813b837d2fee67a8888b3d29f96b6057e8fabd15ccb2954cfca1d9190
|
7
|
+
data.tar.gz: 2c50436235c21854f58ee5dc324d28f0a0f189d96cdc3dd2875d7176cb261d249c6dd69397cd4147fe2919843ad2ced2e1aa49c6551234e51820d92b8f135b3f
|
data/README.md
CHANGED
@@ -7,6 +7,8 @@ The ExportManager allows users to export data from dynamic tables with dynamic c
|
|
7
7
|
## Quick Start
|
8
8
|
```ruby
|
9
9
|
1) gem "export_manager"
|
10
|
+
gem "caxlsx"
|
11
|
+
gem "caxlsx_rails"
|
10
12
|
2) Add on config/routes.rb -> mount ExportManager::Engine, at: '/'
|
11
13
|
3) Add manifest.js
|
12
14
|
//= link export_manager/application.css
|
@@ -26,6 +28,8 @@ Add this line to your application's Gemfile:
|
|
26
28
|
|
27
29
|
```ruby
|
28
30
|
gem "export_manager"
|
31
|
+
gem "caxlsx"
|
32
|
+
gem "caxlsx_rails"
|
29
33
|
```
|
30
34
|
|
31
35
|
And then execute:
|
@@ -56,5 +60,11 @@ JSON_FILE_NAME = "JSON_EXPORT_#{Date.today}.json"
|
|
56
60
|
XML_FILE_NAME = "XML_EXPORT_#{Date.today}.xml"
|
57
61
|
```
|
58
62
|
|
63
|
+
If an authenticated user has the admin? method returning true, they can access the ExportManager engine at /.
|
64
|
+
```ruby
|
65
|
+
authenticated :user, ->(user) { user.admin? } do
|
66
|
+
mount ExportManager::Engine, at: '/'
|
67
|
+
end
|
68
|
+
```
|
59
69
|
## License
|
60
70
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -66,9 +66,6 @@ module ExportManager
|
|
66
66
|
excel_data = ExportManager.generate_json(records, columns)
|
67
67
|
send_json(excel_data, file_name)
|
68
68
|
when "xml"
|
69
|
-
puts "records======#{records.first}"
|
70
|
-
puts "columns======#{columns}"
|
71
|
-
|
72
69
|
xml_data = ExportManager.generate_xml(records, columns)
|
73
70
|
send_xml(xml_data, file_name)
|
74
71
|
end
|
data/lib/export_manager.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "export_manager/version"
|
2
2
|
require "export_manager/engine"
|
3
|
+
require "csv"
|
3
4
|
|
4
5
|
module ExportManager
|
5
6
|
def self.generate_csv(records, columns)
|
@@ -13,7 +14,7 @@ module ExportManager
|
|
13
14
|
|
14
15
|
def self.generate_excel(records, columns)
|
15
16
|
wb = Axlsx::Package.new
|
16
|
-
wb.workbook.add_worksheet(name: "
|
17
|
+
wb.workbook.add_worksheet(name: "Report") do |sheet|
|
17
18
|
sheet.add_row columns
|
18
19
|
|
19
20
|
records.each do |record|
|