rails-exporter 0.0.11 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +13 -8
- data/Rakefile +12 -11
- data/lib/rails_exporter/engine.rb +5 -0
- data/lib/rails_exporter/exporter.rb +3 -0
- data/lib/rails_exporter/version.rb +1 -1
- data/spec/rails_exporter/base_spec.rb +11 -0
- data/spec/rails_exporter/engine_spec.rb +5 -0
- data/spec/rails_exporter/exporter_spec.rb +9 -0
- data/spec/rails_exporter/helper_spec.rb +5 -0
- data/spec/rails_exporter_spec.rb +7 -0
- data/spec/rails_helper.rb +66 -0
- data/spec/spec_helper.rb +100 -0
- data/spec/test_app/Rakefile +6 -0
- data/spec/test_app/app/assets/config/manifest.js +4 -0
- data/spec/test_app/app/assets/javascripts/application.js +13 -0
- data/spec/test_app/app/assets/javascripts/cable.js +13 -0
- data/spec/test_app/app/assets/stylesheets/application.css +15 -0
- data/spec/test_app/app/channels/application_cable/channel.rb +4 -0
- data/spec/test_app/app/channels/application_cable/connection.rb +4 -0
- data/spec/test_app/app/controllers/application_controller.rb +3 -0
- data/spec/test_app/app/helpers/application_helper.rb +2 -0
- data/spec/test_app/app/jobs/application_job.rb +2 -0
- data/spec/test_app/app/mailers/application_mailer.rb +4 -0
- data/spec/test_app/app/models/application_record.rb +3 -0
- data/spec/test_app/app/views/layouts/application.html.erb +14 -0
- data/spec/test_app/app/views/layouts/mailer.html.erb +13 -0
- data/spec/test_app/app/views/layouts/mailer.text.erb +1 -0
- data/spec/test_app/bin/bundle +3 -0
- data/spec/test_app/bin/rails +4 -0
- data/spec/test_app/bin/rake +4 -0
- data/spec/test_app/bin/setup +38 -0
- data/spec/test_app/bin/update +29 -0
- data/spec/test_app/bin/yarn +11 -0
- data/spec/test_app/config.ru +5 -0
- data/spec/test_app/config/application.rb +26 -0
- data/spec/test_app/config/boot.rb +5 -0
- data/spec/test_app/config/cable.yml +10 -0
- data/spec/test_app/config/database.yml +25 -0
- data/spec/test_app/config/environment.rb +5 -0
- data/spec/test_app/config/environments/development.rb +54 -0
- data/spec/test_app/config/environments/production.rb +91 -0
- data/spec/test_app/config/environments/test.rb +42 -0
- data/spec/test_app/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/test_app/config/initializers/assets.rb +14 -0
- data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/test_app/config/initializers/cookies_serializer.rb +5 -0
- data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/test_app/config/initializers/inflections.rb +16 -0
- data/spec/test_app/config/initializers/mime_types.rb +4 -0
- data/spec/test_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/test_app/config/locales/en.yml +33 -0
- data/spec/test_app/config/puma.rb +56 -0
- data/spec/test_app/config/routes.rb +3 -0
- data/spec/test_app/config/secrets.yml +32 -0
- data/spec/test_app/config/spring.rb +6 -0
- data/spec/test_app/db/schema.rb +15 -0
- data/spec/test_app/package.json +5 -0
- data/spec/test_app/public/404.html +67 -0
- data/spec/test_app/public/422.html +67 -0
- data/spec/test_app/public/500.html +66 -0
- data/spec/test_app/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/test_app/public/apple-touch-icon.png +0 -0
- data/spec/test_app/public/favicon.ico +0 -0
- metadata +175 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dbf6c483c1bb4010ab215a8942027c2c114ce76f7b8fc541a4cf39871754308d
|
4
|
+
data.tar.gz: 0c40e99735364d5d5073b8f1a60f59d2465940efd303a9dd42e761367d875218
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c8bd85da0cc10ee446af85a1eac8d098246e20655f93c61eef85d0cd4c55dbbec92104920f5393f7ccccc8d9e467017ebaf1aca75641b2a67e7da2ff689c468
|
7
|
+
data.tar.gz: 912658d5a451fe9620ab569381d656e3f9f0f0ce6cec3563d9689586da81139a6cefabac6ae490b8f3efebefe233f9a3f83b81a5cd7a05295499831e36af8c21
|
data/README.md
CHANGED
@@ -4,13 +4,13 @@ Rails Exporter (CSV, XML, XLS, XSLX)
|
|
4
4
|
|
5
5
|
## How to install
|
6
6
|
|
7
|
-
Add it to your
|
7
|
+
Add it to your `Gemfile`:
|
8
8
|
```ruby
|
9
9
|
gem 'rails-exporter'
|
10
10
|
```
|
11
11
|
|
12
12
|
Run the following command to install it:
|
13
|
-
```
|
13
|
+
```shell
|
14
14
|
$ bundle install
|
15
15
|
$ rails generate rails_exporter:install
|
16
16
|
```
|
@@ -19,7 +19,7 @@ $ rails generate rails_exporter:install
|
|
19
19
|
|
20
20
|
You can generate exporters `app/exporters/example_exporter.rb`
|
21
21
|
|
22
|
-
```
|
22
|
+
```bash
|
23
23
|
$ rails generate rails_exporter:exporter example
|
24
24
|
```
|
25
25
|
|
@@ -53,12 +53,16 @@ end
|
|
53
53
|
### How to use
|
54
54
|
|
55
55
|
You can call `export_to` from **Array** or **ActiveRecord::Relation** objects:
|
56
|
-
```
|
56
|
+
```ruby
|
57
57
|
records = MyModel.all
|
58
|
-
records.export_to(:csv) # or MyModelExporter.export_to_csv(records)
|
58
|
+
records.export_to(:csv) # or MyModelExporter.export_to_csv(records)
|
59
59
|
|
60
60
|
records = [MyModel.first, MyModel.last]
|
61
61
|
records.export_to(:xml) # or MyModelExporter.export_to_xml(records)
|
62
|
+
|
63
|
+
## With context :simple
|
64
|
+
# records.export_to(:csv, :simple)
|
65
|
+
# or MyModelExporter.export_to_csv(records, :simple)
|
62
66
|
```
|
63
67
|
|
64
68
|
### Avaliable Types
|
@@ -66,7 +70,7 @@ You can call `export_to` from **Array** or **ActiveRecord::Relation** objects:
|
|
66
70
|
You can call `RailsExporter::Base.file_types` to list all supported file types:
|
67
71
|
```ruby
|
68
72
|
RailsExporter::Base.file_types.each do |type|
|
69
|
-
|
73
|
+
puts type
|
70
74
|
end
|
71
75
|
```
|
72
76
|
|
@@ -76,7 +80,7 @@ Modify you `config/locales/exporters.en.yml`
|
|
76
80
|
|
77
81
|
### Controller Example
|
78
82
|
|
79
|
-
```
|
83
|
+
```ruby
|
80
84
|
class UsersController < ApplicationController
|
81
85
|
def index
|
82
86
|
@users = User.all
|
@@ -90,10 +94,11 @@ class UsersController < ApplicationController
|
|
90
94
|
end
|
91
95
|
end
|
92
96
|
```
|
97
|
+
|
93
98
|
### MimeTypes
|
94
99
|
|
95
100
|
Declare XLS as a new mimetype in `config/initializers/mime_types`:
|
96
|
-
```
|
101
|
+
```ruby
|
97
102
|
Mime::Type.register "application/vnd.ms-excel", :xls
|
98
103
|
Mime::Type.register "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", :xlsx
|
99
104
|
```
|
data/Rakefile
CHANGED
@@ -4,20 +4,21 @@ rescue LoadError
|
|
4
4
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
5
|
end
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'RailsExporter'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
16
|
|
17
|
-
APP_RAKEFILE = File.expand_path("../
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/test_app/Rakefile", __FILE__)
|
18
18
|
load 'rails/tasks/engine.rake'
|
19
19
|
load 'rails/tasks/statistics.rake'
|
20
|
-
Bundler::GemHelper.install_tasks
|
20
|
+
# Bundler::GemHelper.install_tasks
|
21
|
+
require 'bundler/gem_tasks'
|
21
22
|
|
22
23
|
# require 'rake/testtask'
|
23
24
|
# Rake::TestTask.new(:test) do |t|
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
SimpleCov.start do
|
4
|
+
add_group 'Files', ['rails_exporter', 'lib/rails_exporter']
|
5
|
+
add_filter ['spec','rails-exporter']
|
6
|
+
end
|
7
|
+
|
8
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
9
|
+
require 'spec_helper'
|
10
|
+
ENV['RAILS_ENV'] ||= 'test'
|
11
|
+
require File.expand_path('../../spec/test_app/config/environment', __FILE__)
|
12
|
+
# Prevent database truncation if the environment is production
|
13
|
+
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
14
|
+
require 'rspec/rails'
|
15
|
+
# Add additional requires below this line. Rails is not loaded until this point!
|
16
|
+
|
17
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
18
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
19
|
+
# run as spec files by default. This means that files in spec/support that end
|
20
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
21
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
22
|
+
# end with _spec.rb. You can configure this pattern with the --pattern
|
23
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
24
|
+
#
|
25
|
+
# The following line is provided for convenience purposes. It has the downside
|
26
|
+
# of increasing the boot-up time by auto-requiring all files in the support
|
27
|
+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
28
|
+
# require only the support files necessary.
|
29
|
+
#
|
30
|
+
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
31
|
+
|
32
|
+
# Checks for pending migration and applies them before tests are run.
|
33
|
+
# If you are not using ActiveRecord, you can remove this line.
|
34
|
+
ActiveRecord::Migration.maintain_test_schema!
|
35
|
+
ActiveJob::Base.queue_adapter = :test
|
36
|
+
|
37
|
+
RSpec.configure do |config|
|
38
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
39
|
+
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
40
|
+
|
41
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
42
|
+
# examples within a transaction, remove the following line or assign false
|
43
|
+
# instead of true.
|
44
|
+
config.use_transactional_fixtures = true
|
45
|
+
|
46
|
+
# RSpec Rails can automatically mix in different behaviours to your tests
|
47
|
+
# based on their file location, for example enabling you to call `get` and
|
48
|
+
# `post` in specs under `spec/controllers`.
|
49
|
+
#
|
50
|
+
# You can disable this behaviour by removing the line below, and instead
|
51
|
+
# explicitly tag your specs with their type, e.g.:
|
52
|
+
#
|
53
|
+
# RSpec.describe UsersController, :type => :controller do
|
54
|
+
# # ...
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
# The different available types are documented in the features, such as in
|
58
|
+
# https://relishapp.com/rspec/rspec-rails/docs
|
59
|
+
config.infer_spec_type_from_file_location!
|
60
|
+
|
61
|
+
# Filter lines from Rails gems in backtraces.
|
62
|
+
config.filter_rails_from_backtrace!
|
63
|
+
# arbitrary gems may also be filtered via:
|
64
|
+
# config.filter_gems_from_backtrace("gem name")
|
65
|
+
|
66
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
16
|
+
RSpec.configure do |config|
|
17
|
+
# rspec-expectations config goes here. You can use an alternate
|
18
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
19
|
+
# assertions if you prefer.
|
20
|
+
config.expect_with :rspec do |expectations|
|
21
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
22
|
+
# and `failure_message` of custom matchers include text for helper methods
|
23
|
+
# defined using `chain`, e.g.:
|
24
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
25
|
+
# # => "be bigger than 2 and smaller than 4"
|
26
|
+
# ...rather than:
|
27
|
+
# # => "be bigger than 2"
|
28
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
29
|
+
end
|
30
|
+
|
31
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
32
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
33
|
+
config.mock_with :rspec do |mocks|
|
34
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
35
|
+
# a real object. This is generally recommended, and will default to
|
36
|
+
# `true` in RSpec 4.
|
37
|
+
mocks.verify_partial_doubles = true
|
38
|
+
end
|
39
|
+
|
40
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
41
|
+
# have no way to turn it off -- the option exists only for backwards
|
42
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
43
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
44
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
45
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
46
|
+
|
47
|
+
# The settings below are suggested to provide a good initial experience
|
48
|
+
# with RSpec, but feel free to customize to your heart's content.
|
49
|
+
=begin
|
50
|
+
# This allows you to limit a spec run to individual examples or groups
|
51
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
52
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
53
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
54
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
55
|
+
config.filter_run_when_matching :focus
|
56
|
+
|
57
|
+
# Allows RSpec to persist some state between runs in order to support
|
58
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
59
|
+
# you configure your source control system to ignore this file.
|
60
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
61
|
+
|
62
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
63
|
+
# recommended. For more details, see:
|
64
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
65
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
66
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
67
|
+
config.disable_monkey_patching!
|
68
|
+
|
69
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
70
|
+
# be too noisy due to issues in dependencies.
|
71
|
+
config.warnings = true
|
72
|
+
|
73
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
74
|
+
# file, and it's useful to allow more verbose output when running an
|
75
|
+
# individual spec file.
|
76
|
+
if config.files_to_run.one?
|
77
|
+
# Use the documentation formatter for detailed output,
|
78
|
+
# unless a formatter has already been configured
|
79
|
+
# (e.g. via a command-line flag).
|
80
|
+
config.default_formatter = "doc"
|
81
|
+
end
|
82
|
+
|
83
|
+
# Print the 10 slowest examples and example groups at the
|
84
|
+
# end of the spec run, to help surface which specs are running
|
85
|
+
# particularly slow.
|
86
|
+
config.profile_examples = 10
|
87
|
+
|
88
|
+
# Run specs in random order to surface order dependencies. If you find an
|
89
|
+
# order dependency and want to debug it, you can fix the order by providing
|
90
|
+
# the seed, which is printed after each run.
|
91
|
+
# --seed 1234
|
92
|
+
config.order = :random
|
93
|
+
|
94
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
95
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
96
|
+
# test failures related to randomization by passing the same `--seed` value
|
97
|
+
# as the one that triggered the failure.
|
98
|
+
Kernel.srand config.seed
|
99
|
+
=end
|
100
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
+
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
|
3
|
+
//
|
4
|
+
//= require action_cable
|
5
|
+
//= require_self
|
6
|
+
//= require_tree ./channels
|
7
|
+
|
8
|
+
(function() {
|
9
|
+
this.App || (this.App = {});
|
10
|
+
|
11
|
+
App.cable = ActionCable.createConsumer();
|
12
|
+
|
13
|
+
}).call(this);
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|