ntq_excelsior_engine 0.1.0

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.
Files changed (36) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +31 -0
  4. data/Rakefile +8 -0
  5. data/app/assets/config/ntq_excelsior_engine_manifest.js +1 -0
  6. data/app/assets/stylesheets/ntq_excelsior_engine/application.css +15 -0
  7. data/app/controllers/ntq_excelsior_engine/application_controller.rb +4 -0
  8. data/app/controllers/ntq_excelsior_engine/importers_controller.rb +41 -0
  9. data/app/controllers/ntq_excelsior_engine/imports_controller.rb +73 -0
  10. data/app/helpers/ntq_excelsior_engine/application_helper.rb +4 -0
  11. data/app/helpers/ntq_excelsior_engine/importers_helper.rb +4 -0
  12. data/app/interactors/ntq_excelsior_engine/exporters/export_import_errors.rb +26 -0
  13. data/app/interactors/ntq_excelsior_engine/imports/check_lines.rb +29 -0
  14. data/app/interactors/ntq_excelsior_engine/imports/import_lines.rb +29 -0
  15. data/app/interactors/ntq_excelsior_engine/imports/load_lines.rb +34 -0
  16. data/app/interactors/ntq_excelsior_engine/imports/prepare_pipeline.rb +10 -0
  17. data/app/interactors/ntq_excelsior_engine/imports/process_import.rb +7 -0
  18. data/app/jobs/ntq_excelsior_engine/application_job.rb +4 -0
  19. data/app/jobs/ntq_excelsior_engine/process_import_job.rb +14 -0
  20. data/app/mailers/ntq_excelsior_engine/application_mailer.rb +6 -0
  21. data/app/models/ntq_excelsior_engine/application_record.rb +5 -0
  22. data/app/models/ntq_excelsior_engine/import.rb +49 -0
  23. data/app/models/ntq_excelsior_engine/import_line.rb +17 -0
  24. data/app/views/layouts/ntq_excelsior_engine/application.html.erb +15 -0
  25. data/app/views/ntq_excelsior_engine/importers/show.json.jbuilder +6 -0
  26. data/app/views/ntq_excelsior_engine/imports/status.json.jbuilder +13 -0
  27. data/config/routes.rb +12 -0
  28. data/db/migrate/20230224161258_create_ntq_excelsior_engine_imports.rb +18 -0
  29. data/db/migrate/20230224162132_create_ntq_excelsior_engine_import_lines.rb +14 -0
  30. data/lib/generators/ntq_excelsior_engine/install_generator.rb +11 -0
  31. data/lib/generators/templates/ntq_excelsior_engine.rb +16 -0
  32. data/lib/ntq_excelsior_engine/engine.rb +5 -0
  33. data/lib/ntq_excelsior_engine/version.rb +3 -0
  34. data/lib/ntq_excelsior_engine.rb +26 -0
  35. data/lib/tasks/ntq_excelsior_engine_tasks.rake +4 -0
  36. metadata +198 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bf2cdefe015d0e80fc5f1da71883944024e63fb58322843f9cdc2d41d1d30e23
4
+ data.tar.gz: 455b68875ada31f10127d455302f8de2b2d471f1223929a86208e8f19e14a629
5
+ SHA512:
6
+ metadata.gz: e5f73015433c7466285d76e03bc58d47244787df787ad770d5af581fe393bad57f5711bd89242bb05d0399e7302f7b7edb29499c3d64298e14f202e69824c70c
7
+ data.tar.gz: d6be0c59205fb54dff3a66931fd58e505e9082d808a81a433cd9ee027ce9f12760d32f265552c0807fc8b0433ddf3791e83b95e097df6c42bca2b4f3a95758fb
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2023 Kevin
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # NtqExcelsiorEngine
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem "ntq_excelsior_engine"
12
+
13
+ bundle exec rails generate ntq_excelsior_engine:install
14
+ bundle exec rails ntq_excelsior_engine:install:migrations
15
+ ```
16
+
17
+ And then execute:
18
+ ```bash
19
+ $ bundle
20
+ ```
21
+
22
+ Or install it yourself as:
23
+ ```bash
24
+ $ gem install ntq_excelsior_engine
25
+ ```
26
+
27
+ ## Contributing
28
+ Contribution directions go here.
29
+
30
+ ## License
31
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/ntq_excelsior_engine .css
@@ -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
+ */
@@ -0,0 +1,4 @@
1
+ module NtqExcelsiorEngine
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,41 @@
1
+ module NtqExcelsiorEngine
2
+ class ImportersController < ApplicationController
3
+ before_action :ensure_valid_importer_type!, except: [:status]
4
+
5
+ def show
6
+ @importer = @importer.to_s.constantize
7
+ render layout: false
8
+ end
9
+
10
+ def sample_file
11
+ return render nothing: true, status: 404 unless @importer.to_s.constantize.sample_file.present?
12
+
13
+ send_file "#{Rails.root}/#{@importer.to_s.constantize.sample_file}", disposition: 'attachment'
14
+ end
15
+
16
+ def status
17
+ valid_types = NtqExcelsiorEngine.importers.keys.map(&:to_s)
18
+
19
+ importing_files = NtqExcelsiorEngine::Import.importing
20
+ importing_files = importing_files.where(import_type: params[:type]) if params[:type].present? && valid_types.include?(params[:type])
21
+
22
+ job_status_json = {}
23
+ job_status_json[:refetch] = false
24
+ importing_files.each do |importing_file|
25
+ job_status_json[importing_file.import_type] = Sidekiq::Status.get_all(importing_file.job_id)
26
+ job_status_json[:refetch] = true
27
+ end
28
+
29
+ render json: { status: job_status_json }
30
+ end
31
+
32
+ private
33
+
34
+ def ensure_valid_importer_type!
35
+ valid_types = NtqExcelsiorEngine.importers.keys.map(&:to_s)
36
+ return render json: {}, status: 422 unless valid_types.include?(params[:type]) || params[:type].blank?
37
+
38
+ @importer = NtqExcelsiorEngine.importers[params[:type].to_sym]
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,73 @@
1
+ require 'csv'
2
+
3
+ module NtqExcelsiorEngine
4
+ class ImportsController < ::ApplicationController
5
+ skip_before_action :verify_authenticity_token
6
+ before_action :ensure_valid_importer_type!, only: [:create]
7
+
8
+ ALLOWED_IMPORT_ACTIONS = %w(import)
9
+
10
+ def index
11
+ import_files = NtqExcelsiorEngine::Import.all
12
+ import_files = import_files.where(import_type: params[:import_type]) if params[:import_type]
13
+ import_files = import_files.order(created_at: :desc)
14
+
15
+ render json: { import_files: import_files.map { |import_file| import_file.to_builder.attributes! } }
16
+ end
17
+
18
+ def export_errors
19
+ @import_file = NtqExcelsiorEngine::Import.find(params[:id])
20
+ render nothing: true, status: 404 unless @import_file.error?
21
+ ctx = NtqExcelsiorEngine::Exporters::ExportImportErrors.call(import: @import_file)
22
+ blob = @import_file.file.blob
23
+ filename = blob.filename
24
+ send_data ctx.stream, type: blob.content_type, filename: "#{filename.base}_errors#{filename.extension_with_delimiter}"
25
+ end
26
+
27
+ def show
28
+ @import_file = ::NtqExcelsiorEngine::Import.find params[:id]
29
+ render :status, layout: false
30
+ end
31
+
32
+
33
+ def create
34
+ @import_file = ::NtqExcelsiorEngine::Import.new import_type: params[:type]
35
+ @import_file.file = file_params
36
+ yield(import_file) if block_given?
37
+ @import_file.inspect
38
+ if @import_file.save
39
+ unless NtqExcelsiorEngine.async
40
+ NtqExcelsiorEngine::Imports::ProcessImport.call(id: @import_file.id, actions: NtqExcelsiorEngine.actions_on_create.map(&:to_s))
41
+ end
42
+ end
43
+ render :status, layout: false
44
+ end
45
+
46
+ def update
47
+ @import_file = ::NtqExcelsiorEngine::Import.find params[:id]
48
+ if params[:action].present? && ALLOWED_IMPORT_ACTIONS.include?(params[:to_state])
49
+ if NtqExcelsiorEngine.async
50
+ @import_file.process_import!(actions: [params[:to_state]])
51
+ else
52
+ NtqExcelsiorEngine::Imports::ProcessImport.call(id: @import_file.id, actions: [params[:to_state]])
53
+ end
54
+ @import_file.update(state: 'importing') if params[:to_state] == "import"
55
+ end
56
+ render :status, layout: false
57
+ end
58
+
59
+ private
60
+
61
+ def ensure_valid_importer_type!
62
+ valid_types = NtqExcelsiorEngine.importers.keys.map(&:to_s)
63
+ return render json: {}, status: 422 unless valid_types.include?(params[:type]) || params[:type].blank?
64
+
65
+ @importer = NtqExcelsiorEngine.importers[params[:type].to_sym]
66
+ end
67
+
68
+ def file_params
69
+ params.require(:file)
70
+ end
71
+
72
+ end
73
+ end
@@ -0,0 +1,4 @@
1
+ module NtqExcelsiorEngine
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module NtqExcelsiorEngine
2
+ module ImportersHelper
3
+ end
4
+ end
@@ -0,0 +1,26 @@
1
+ module NtqExcelsiorEngine
2
+ class Exporters::ExportImportErrors
3
+ include Interactor
4
+
5
+ def call
6
+ import = context.import
7
+
8
+ package = Axlsx::Package.new
9
+ wb = package.workbook
10
+ wb_styles = wb.styles
11
+ wb.add_worksheet(name: import.import_type) do |sheet|
12
+ sheet.add_row import.headers.keys.concat(['error'])
13
+ import.import_lines.each do |import_line|
14
+ data = []
15
+ import.headers.each do |_h, accessor|
16
+ data << import_line.line[accessor] || ''
17
+ end
18
+ data << import_line.line_errors if import_line.line_errors.present?
19
+ sheet.add_row data
20
+ end
21
+ end
22
+
23
+ context.stream = package.to_stream.read
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,29 @@
1
+ module NtqExcelsiorEngine
2
+ class Imports::CheckLines
3
+ include Interactor
4
+
5
+ around do |interactor|
6
+ if context.actions && context.actions.include?("check") && context.import && context.importer
7
+ interactor.call
8
+ end
9
+ end
10
+
11
+ def call
12
+ import = context.import
13
+ importer = context.importer.new
14
+ begin
15
+ import.update(state: 'checking')
16
+ import.import_lines.each do |line|
17
+ result = importer.import_line(line.line, save: false)
18
+ line.update(status: result[:status], line_errors: result[:errors], action: result[:action])
19
+ end
20
+ sleep 2 if NtqExcelsiorEngine.debug
21
+ import.update(state: import.import_lines.in_error.any? ? 'error' : 'checked')
22
+ rescue => e
23
+ p e.inspect
24
+ Appsignal.send_error(e)
25
+ import.update(state: 'error', backtrace: e.backtrace.join('\n'))
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ module NtqExcelsiorEngine
2
+ class Imports::ImportLines
3
+ include Interactor
4
+
5
+ around do |interactor|
6
+ if context.actions && context.actions.include?("import") && context.import && !context.import.error? && context.importer
7
+ interactor.call
8
+ end
9
+ end
10
+
11
+ def call
12
+ import = context.import
13
+ importer = context.importer.new
14
+ begin
15
+ import.update(state: 'importing')
16
+ import.import_lines.each do |line|
17
+ result = importer.import_line(line.line, save: true)
18
+ line.update(status: result[:status], line_errors: result[:errors], action: result[:action])
19
+ end
20
+ sleep 2 if NtqExcelsiorEngine.debug
21
+ import.update(state: import.import_lines.in_error.any? ? 'error' : 'imported')
22
+ rescue => e
23
+ p e.inspect
24
+ Appsignal.send_error(e)
25
+ import.update(state: 'error', backtrace: e.backtrace.join('\n'))
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,34 @@
1
+ module NtqExcelsiorEngine
2
+ class Imports::LoadLines
3
+ include Interactor
4
+
5
+ around do |interactor|
6
+ if context.actions && context.actions.include?("load") && context.import && context.importer
7
+ interactor.call
8
+ end
9
+ end
10
+
11
+ def call
12
+ import = context.import
13
+ importer = context.importer.new
14
+ begin
15
+ import.update(state: 'buffering')
16
+
17
+ importer.file = import.temp_file
18
+ lines = importer.lines
19
+
20
+ import_lines = []
21
+ lines.each do |line|
22
+ import_lines << NtqExcelsiorEngine::ImportLine.new(line: line, import: import)
23
+ end
24
+ NtqExcelsiorEngine::ImportLine.import(import_lines)
25
+ sleep 2 if NtqExcelsiorEngine.debug
26
+ import.update(headers: importer.detect_header_scheme, state: 'buffered')
27
+ import.temp_file.unlink
28
+ rescue => e
29
+ Appsignal.send_error(e)
30
+ import.update(state: 'error', backtrace: e.backtrace.join('\n'))
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,10 @@
1
+ module NtqExcelsiorEngine
2
+ class Imports::PreparePipeline
3
+ include Interactor
4
+
5
+ def call
6
+ context.import = NtqExcelsiorEngine::Import.find(context.id)
7
+ context.importer = context.import.importer_klass
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ module NtqExcelsiorEngine
2
+ class Imports::ProcessImport
3
+ include Interactor::Organizer
4
+
5
+ organize Imports::PreparePipeline, Imports::LoadLines, Imports::CheckLines, Imports::ImportLines
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ module NtqExcelsiorEngine
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,14 @@
1
+ module NtqExcelsiorEngine
2
+ class ProcessImportJob
3
+ include Sidekiq::Worker
4
+ include Sidekiq::Status::Worker
5
+
6
+ sidekiq_options queue: 'default', retry: 0
7
+
8
+ def perform(id, actions = NtqExcelsiorEngine.actions_on_create.map(&:to_s).join(','))
9
+ import = NtqExcelsiorEngine::Import.find(id)
10
+ import.update(job_id: jid)
11
+ Imports::ProcessImport.call(id: id, actions: actions.split(','))
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,6 @@
1
+ module NtqExcelsiorEngine
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: "from@example.com"
4
+ layout "mailer"
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module NtqExcelsiorEngine
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,49 @@
1
+ module NtqExcelsiorEngine
2
+ class Import < ::ApplicationRecord
3
+ VALID_CONTENT_TYPES = %w[
4
+ application/vnd.ms-excel
5
+ application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
6
+ application/vnd.ms-excel.sheet.macroenabled.12
7
+ application/vnd.ms-excel.sheet.macroEnabled.12
8
+ ].freeze
9
+
10
+ self.table_name = "excelsior_imports"
11
+
12
+ enum state: { pending: 'pending', buffering: 'buffering', buffered: 'buffered', imported: 'imported', error: 'error', importing: 'importing', checking: 'checking', checked: 'checked' }
13
+
14
+ serialize :options, Hash
15
+ serialize :headers, Hash
16
+ serialize :stats, Hash
17
+
18
+ has_one_attached :file
19
+ has_many :import_lines, foreign_key: :excelsior_import_id
20
+
21
+ validates :file, presence: true
22
+ validates :state, presence: true
23
+ validates :import_type, presence: true
24
+ validates :import_type, inclusion: { in: NtqExcelsiorEngine.importers.keys.map(&:to_s) }, on: :create
25
+
26
+ after_create_commit :process_import!
27
+
28
+ def temp_file
29
+ return @tmp if @tmp
30
+
31
+ filename = file.blob.filename
32
+ @tmp = Tempfile.new([filename.base, filename.extension_with_delimiter], binmode: true)
33
+ @tmp.write(file.download)
34
+ @tmp.rewind
35
+ @tmp
36
+ end
37
+
38
+ def importer_klass
39
+ NtqExcelsiorEngine.importers[import_type.to_sym]
40
+ end
41
+
42
+ def process_import!(actions: NtqExcelsiorEngine.actions_on_create.map(&:to_s))
43
+ if NtqExcelsiorEngine.async
44
+ job_id = NtqExcelsiorEngine::ProcessImportJob.perform_async(id, actions.join(','))
45
+ p "ASYNC #{job_id}"
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,17 @@
1
+ module NtqExcelsiorEngine
2
+ class ImportLine < ApplicationRecord
3
+ self.table_name = "excelsior_import_lines"
4
+
5
+ serialize :line, Hash
6
+
7
+ validates :status, inclusion: { in: %w[error success] }, allow_blank: true
8
+ validates :action, inclusion: { in: %w[create update] }, allow_blank: true
9
+
10
+ belongs_to :import, foreign_key: :excelsior_import_id
11
+
12
+ scope :in_error, -> { where(status: 'error') }
13
+ scope :successes, -> { where(status: 'success') }
14
+ scope :is_create, -> { where(action: 'create') }
15
+ scope :is_update, -> { where(action: 'update') }
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Ntq excelsior engine</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag "ntq_excelsior_engine/application", media: "all" %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
@@ -0,0 +1,6 @@
1
+ json.set! :data do
2
+ json.notice @importer.structure
3
+ json.max_error_count @importer.max_error_count
4
+ # json.async @importer.async
5
+ json.sample_file @importer.sample_file ? download_sample_file_url(type: params[:type]) : nil
6
+ end
@@ -0,0 +1,13 @@
1
+ json.set! :data do
2
+ json.id @import_file.id
3
+ json.state @import_file.state
4
+ if @import_file.error?
5
+ json.error_file download_errors_file_url(@import_file.id)
6
+ end
7
+ if %[checked imported importing].include? @import_file.state
8
+ json.errors_count @import_file.import_lines.in_error.count
9
+ json.success_count @import_file.import_lines.successes.count
10
+ json.create_count @import_file.import_lines.successes.is_create.count
11
+ json.update_count @import_file.import_lines.successes.is_update.count
12
+ end
13
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,12 @@
1
+ NtqExcelsiorEngine::Engine.routes.draw do
2
+ if NtqExcelsiorEngine.import_active
3
+ get 'importers/show'
4
+ get '/importers/:type' => "importers#show"
5
+ get '/importers/:type/sample_file' => "importers#sample_file", as: :download_sample_file
6
+ get '/importers/status' => "importers#status"
7
+
8
+ post '/imports/:type' => "imports#create"
9
+ get '/imports/:id/export_errors' => "imports#export_errors", as: :download_errors_file
10
+ resources :imports, only: [:show, :update]
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ class CreateNtqExcelsiorEngineImports < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :excelsior_imports do |t|
4
+ t.string :state, limit: 32, null: false, default: "pending"
5
+ t.string :import_type, limit: 191, null: false
6
+ t.string :job_id, limit: 191
7
+ t.text :options
8
+ t.text :headers
9
+ t.text :error_message
10
+ t.text :stats
11
+ t.text :backtrace
12
+ t.string :created_by, limit: 64
13
+
14
+ t.index :import_type
15
+ t.timestamps
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ class CreateNtqExcelsiorEngineImportLines < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :excelsior_import_lines do |t|
4
+ t.belongs_to :excelsior_import, foreign_key: true
5
+ t.string :status, limit: 32
6
+ t.string :action, limit: 32
7
+ t.text :line
8
+ t.text :line_errors
9
+ t.timestamps
10
+
11
+ t.index :status
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ module NtqExcelsiorEngine
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../templates", __FILE__)
5
+
6
+ def copy_initializer_file
7
+ template "ntq_excelsior_engine.rb", "config/initializers/ntq_excelsior_engine.rb"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ # require 'user_importer'
2
+
3
+ NtqExcelsiorEngine.setup do |config|
4
+
5
+ # config.import_active = true
6
+
7
+ # config.importers = {
8
+ # user: UserImporter
9
+ # }
10
+
11
+ # config.debug = false
12
+ # config.async = false
13
+ # config.actions_on_create = [:load, :check, :import]
14
+ # config.action_cable = false
15
+
16
+ end
@@ -0,0 +1,5 @@
1
+ module NtqExcelsiorEngine
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace NtqExcelsiorEngine
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module NtqExcelsiorEngine
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,26 @@
1
+ require "ntq_excelsior_engine/version"
2
+ require "ntq_excelsior_engine/engine"
3
+
4
+ module NtqExcelsiorEngine
5
+ mattr_accessor :import_active
6
+ @@import_active = true
7
+
8
+ mattr_accessor :importers
9
+ @@importers = {}
10
+
11
+ mattr_accessor :async
12
+ @@async = false
13
+
14
+ mattr_accessor :actions_on_create
15
+ @@actions_on_create = [:load, :check, :import]
16
+
17
+ mattr_accessor :action_cable
18
+ @@action_cable = false
19
+
20
+ mattr_accessor :debug
21
+ @@debug = false
22
+
23
+ def self.setup
24
+ yield self
25
+ end
26
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :ntq_excelsior_engine do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,198 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ntq_excelsior_engine
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kevin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-02-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "<"
18
+ - !ruby/object:Gem::Version
19
+ version: '8'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: '6'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "<"
28
+ - !ruby/object:Gem::Version
29
+ version: '8'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '6'
33
+ - !ruby/object:Gem::Dependency
34
+ name: jbuilder
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "<"
38
+ - !ruby/object:Gem::Version
39
+ version: '3'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '3'
47
+ - !ruby/object:Gem::Dependency
48
+ name: ntq_excelsior
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "<"
52
+ - !ruby/object:Gem::Version
53
+ version: '2'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '2'
61
+ - !ruby/object:Gem::Dependency
62
+ name: caxlsx
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "<"
66
+ - !ruby/object:Gem::Version
67
+ version: '4'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: '4'
75
+ - !ruby/object:Gem::Dependency
76
+ name: sidekiq
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "<"
80
+ - !ruby/object:Gem::Version
81
+ version: '8'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "<"
87
+ - !ruby/object:Gem::Version
88
+ version: '8'
89
+ - !ruby/object:Gem::Dependency
90
+ name: sidekiq-status
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: interactor-rails
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ - !ruby/object:Gem::Dependency
118
+ name: activerecord-import
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :runtime
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ description: Excelsior engine
132
+ email:
133
+ - kevin@9troisquarts.com
134
+ executables: []
135
+ extensions: []
136
+ extra_rdoc_files: []
137
+ files:
138
+ - MIT-LICENSE
139
+ - README.md
140
+ - Rakefile
141
+ - app/assets/config/ntq_excelsior_engine_manifest.js
142
+ - app/assets/stylesheets/ntq_excelsior_engine/application.css
143
+ - app/controllers/ntq_excelsior_engine/application_controller.rb
144
+ - app/controllers/ntq_excelsior_engine/importers_controller.rb
145
+ - app/controllers/ntq_excelsior_engine/imports_controller.rb
146
+ - app/helpers/ntq_excelsior_engine/application_helper.rb
147
+ - app/helpers/ntq_excelsior_engine/importers_helper.rb
148
+ - app/interactors/ntq_excelsior_engine/exporters/export_import_errors.rb
149
+ - app/interactors/ntq_excelsior_engine/imports/check_lines.rb
150
+ - app/interactors/ntq_excelsior_engine/imports/import_lines.rb
151
+ - app/interactors/ntq_excelsior_engine/imports/load_lines.rb
152
+ - app/interactors/ntq_excelsior_engine/imports/prepare_pipeline.rb
153
+ - app/interactors/ntq_excelsior_engine/imports/process_import.rb
154
+ - app/jobs/ntq_excelsior_engine/application_job.rb
155
+ - app/jobs/ntq_excelsior_engine/process_import_job.rb
156
+ - app/mailers/ntq_excelsior_engine/application_mailer.rb
157
+ - app/models/ntq_excelsior_engine/application_record.rb
158
+ - app/models/ntq_excelsior_engine/import.rb
159
+ - app/models/ntq_excelsior_engine/import_line.rb
160
+ - app/views/layouts/ntq_excelsior_engine/application.html.erb
161
+ - app/views/ntq_excelsior_engine/importers/show.json.jbuilder
162
+ - app/views/ntq_excelsior_engine/imports/status.json.jbuilder
163
+ - config/routes.rb
164
+ - db/migrate/20230224161258_create_ntq_excelsior_engine_imports.rb
165
+ - db/migrate/20230224162132_create_ntq_excelsior_engine_import_lines.rb
166
+ - lib/generators/ntq_excelsior_engine/install_generator.rb
167
+ - lib/generators/templates/ntq_excelsior_engine.rb
168
+ - lib/ntq_excelsior_engine.rb
169
+ - lib/ntq_excelsior_engine/engine.rb
170
+ - lib/ntq_excelsior_engine/version.rb
171
+ - lib/tasks/ntq_excelsior_engine_tasks.rake
172
+ homepage: https://github.com/9troisquarts/ntq-excelsior-engine
173
+ licenses:
174
+ - MIT
175
+ metadata:
176
+ homepage_uri: https://github.com/9troisquarts/ntq-excelsior-engine
177
+ source_code_uri: https://github.com/9troisquarts/ntq-excelsior-engine
178
+ changelog_uri: https://github.com/9troisquarts/ntq-excelsior-engine/CHANGELOG.md
179
+ post_install_message:
180
+ rdoc_options: []
181
+ require_paths:
182
+ - lib
183
+ required_ruby_version: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ required_rubygems_version: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ requirements: []
194
+ rubygems_version: 3.3.7
195
+ signing_key:
196
+ specification_version: 4
197
+ summary: NtqExcelsiorEngine.
198
+ test_files: []