Skip to content

Commit

Permalink
Change capitalization of Etl and Html to make zeitwerk happy
Browse files Browse the repository at this point in the history
  • Loading branch information
moveson committed Dec 22, 2024
1 parent 4f7cfe4 commit 425e834
Show file tree
Hide file tree
Showing 79 changed files with 169 additions and 169 deletions.
4 changes: 2 additions & 2 deletions app/controllers/api/v1/event_groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ def import
authorize @resource

limited_response = params[:limited_response]&.to_boolean
importer = ::ETL::ImporterFromContext.build(@resource, params, current_user)
importer = ::Etl::ImporterFromContext.build(@resource, params, current_user)
importer.import
errors = importer.errors + importer.invalid_records.map { |record| jsonapi_error_object(record) }

if errors.present?
render json: { errors: errors }, status: :unprocessable_entity
else
::ETL::EventGroupImportProcess.perform!(@resource, importer)
::Etl::EventGroupImportProcess.perform!(@resource, importer)
if limited_response
render json: {}, status: :created
else
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/api/v1/events_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require "etl/etl"
require "etl"

module Api
module V1
Expand Down Expand Up @@ -53,14 +53,14 @@ def spread
end

def import
importer = ::ETL::ImporterFromContext.build(@event, params, current_user)
importer = ::Etl::ImporterFromContext.build(@event, params, current_user)
importer.import
errors = importer.errors + importer.invalid_records.map { |record| jsonapi_error_object(record) }

if errors.present?
render json: {errors: errors}, status: :unprocessable_entity
else
::ETL::EventImportProcess.perform!(@event, importer)
::Etl::EventImportProcess.perform!(@event, importer)
render json: {}, status: :created
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/import_jobs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require "etl/etl"
require "etl"

class ImportJobsController < ApplicationController
before_action :authenticate_user!
Expand Down Expand Up @@ -64,7 +64,7 @@ def csv_templates
format.csv do
parent = params[:parent_type].constantize.find(params[:parent_id])
import_job_format = params[:import_job_format].to_sym
csv_template_headers = ::ETL::CsvTemplates.headers(import_job_format, parent)
csv_template_headers = ::Etl::CsvTemplates.headers(import_job_format, parent)
csv_template = csv_template_headers.join(",") + "\n"
filename_components = [import_job_format, parent.class.name.underscore, parent.id, "template.csv"]
filename = filename_components.join("_")
Expand Down
4 changes: 2 additions & 2 deletions app/jobs/import_async_job.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

require "etl/etl"
require "etl"

class ImportAsyncJob < ApplicationJob
def perform(import_job_id)
import_job = ImportJob.find(import_job_id)
set_current_user(current_user: import_job.user)

::ETL::AsyncImporter.import!(import_job)
::Etl::AsyncImporter.import!(import_job)
end
end
4 changes: 2 additions & 2 deletions app/models/proto_record.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require "etl/etl"
require "etl"
require "ostruct"

class ProtoRecord
include ETL::Transformable
include Etl::Transformable

attr_accessor :record_type, :record_action
attr_reader :children, :attributes
Expand Down
2 changes: 2 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ class Application < Rails::Application
# in config/environments, which are processed later.
#
# config.eager_load_paths << Rails.root.join("extras")

Dir[Rails.root.join('lib/core_ext/**/*.rb')].each { |file| require file }
end
end
3 changes: 2 additions & 1 deletion lib/core_ext/action_view/helpers/url_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

module CoreExt
module UrlHelper
alias original_link_to link_to
# Monkey Patch link_to to translate the boolean attribute "disabled" into a class
# Using the signature (*args, &blocks) makes this patch resistant to API changes
# since all args are captured as is
Expand All @@ -23,6 +22,8 @@ module ActionView
module Helpers
module UrlHelper
include CoreExt::UrlHelper

alias original_link_to link_to
end
end
end
34 changes: 34 additions & 0 deletions lib/etl.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

module Etl
end

require_relative "etl/csv_templates"
require_relative "etl/errors"
require_relative "etl/extractor"
require_relative "etl/transformer"
require_relative "etl/loader"
require_relative "etl/transformable"

# Importers

require_relative "etl/event_group_import_process"
require_relative "etl/event_import_process"
require_relative "etl/importer"
require_relative "etl/importer_from_context"
require_relative "etl/async_importer"

# Extractors
Dir.glob("lib/etl/extractors/**/*.rb") { |file| require Rails.root.join(file) }

# Transformers
require_relative "etl/transformers/base_transformer"
Dir.glob("lib/etl/transformers/**/*.rb") { |file| require Rails.root.join(file) }

# Loaders

require_relative "etl/loaders/base_loader"
Dir.glob("lib/etl/loaders/**/*.rb") { |file| require Rails.root.join(file) }

# Helpers
Dir.glob("lib/etl/helpers/**/*.rb") { |file| require Rails.root.join(file) }
12 changes: 5 additions & 7 deletions lib/etl/async_importer.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# frozen_string_literal: true

require_relative "errors"

module ETL
module Etl
class AsyncImporter
include ETL::Errors
include Etl::Errors

def self.import!(import_job)
new(import_job).import!
Expand Down Expand Up @@ -81,7 +79,7 @@ def extract_data
import_job.extracting!
files.each do |file|
import_job.set_elapsed_time!
extractor = ::ETL::Extractor.new(file, extract_strategy)
extractor = ::Etl::Extractor.new(file, extract_strategy)
self.extracted_structs += extractor.extract
self.errors += extractor.errors
import_job.update(row_count: extracted_structs.size)
Expand All @@ -92,7 +90,7 @@ def transform_data
import_job.transforming!
import_job.set_elapsed_time!
options = { parent: parent, import_job: import_job }.merge(custom_options)
transformer = ::ETL::Transformer.new(extracted_structs, transform_strategy, options)
transformer = ::Etl::Transformer.new(extracted_structs, transform_strategy, options)
self.transformed_protos = transformer.transform
self.errors += transformer.errors
end
Expand All @@ -101,7 +99,7 @@ def load_records
import_job.loading!
import_job.set_elapsed_time!
options = { import_job: import_job }.merge(custom_options)
loader = ::ETL::Loader.new(transformed_protos, load_strategy, options)
loader = ::Etl::Loader.new(transformed_protos, load_strategy, options)
loader.load_records
self.errors += loader.errors
end
Expand Down
2 changes: 1 addition & 1 deletion lib/etl/csv_templates.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module ETL
module Etl
class CsvTemplates
PERSON_ATTRIBUTES = [
"First Name",
Expand Down
2 changes: 1 addition & 1 deletion lib/etl/errors.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module ETL
module Etl
module Errors
def bad_url_error(url, error)
{ title: "Bad URL", detail: { messages: ["#{url} reported an error: #{error}"] } }
Expand Down
34 changes: 0 additions & 34 deletions lib/etl/etl.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/etl/event_group_import_process.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module ETL
module Etl
class EventGroupImportProcess
def self.perform!(event_group, importer)
new(event_group, importer).perform!
Expand Down
2 changes: 1 addition & 1 deletion lib/etl/event_import_process.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module ETL
module Etl
class EventImportProcess
def self.perform!(event, importer)
new(event, importer).perform!
Expand Down
2 changes: 1 addition & 1 deletion lib/etl/extractor.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module ETL
module Etl
class Extractor
def initialize(source_data, extract_strategy_class, options = {})
@source_data = source_data
Expand Down
6 changes: 3 additions & 3 deletions lib/etl/extractors/adilas_bear_html_strategy.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

module ETL
module Etl
module Extractors
class AdilasBearHTMLStrategy
include ETL::Errors
class AdilasBearHtmlStrategy
include Etl::Errors
attr_reader :errors

def initialize(source_data, options)
Expand Down
4 changes: 2 additions & 2 deletions lib/etl/extractors/csv_file_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
require "csv"
require "ostruct"

module ETL
module Etl
module Extractors
class CsvFileStrategy
include ETL::Errors
include Etl::Errors

MAX_FILE_SIZE = 2.megabytes
BYTE_ORDER_MARK = String.new("\xEF\xBB\xBF").force_encoding("UTF-8").freeze
Expand Down
6 changes: 3 additions & 3 deletions lib/etl/extractors/its_your_race_html_strategy.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

module ETL
module Etl
module Extractors
class ItsYourRaceHTMLStrategy
include ETL::Errors
class ItsYourRaceHtmlStrategy
include Etl::Errors
attr_reader :errors

def initialize(source_data, options)
Expand Down
4 changes: 2 additions & 2 deletions lib/etl/extractors/pass_through_strategy.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

module ETL
module Etl
module Extractors
class PassThroughStrategy
include ETL::Errors
include Etl::Errors
attr_reader :errors

def initialize(raw_data, options)
Expand Down
4 changes: 2 additions & 2 deletions lib/etl/extractors/race_result_api_strategy.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# frozen_string_literal: true

module ETL
module Etl
module Extractors
class RaceResultApiStrategy
NAME_WITHOUT_BIB_REGEX = /[^ #0-9\.].*/

include ETL::Errors
include Etl::Errors
attr_reader :errors

def initialize(raw_data, options)
Expand Down
4 changes: 2 additions & 2 deletions lib/etl/extractors/race_result_strategy.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

module ETL
module Etl
module Extractors
class RaceResultStrategy
include ETL::Errors
include Etl::Errors
attr_reader :errors

def initialize(raw_data, options)
Expand Down
2 changes: 1 addition & 1 deletion lib/etl/helpers/race_result_api_uri_builder.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module ETL
module Etl
module Helpers
class RaceResultApiUriBuilder
def initialize(rr_event_id, rr_api_key)
Expand Down
2 changes: 1 addition & 1 deletion lib/etl/helpers/race_result_uri_builder.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module ETL
module Etl
module Helpers
class RaceResultUriBuilder
def initialize(rr_event_id, rr_contest_id, rr_format)
Expand Down
Loading

0 comments on commit 425e834

Please sign in to comment.