Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer require_relative over path injection #307

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .rubocop_todo.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@
#
# Rackup config for the Colore app
#
require 'pathname'
require "sinatra"

BASE = Pathname.new(__FILE__).realpath.parent
$: << BASE
$: << BASE + 'lib'
require 'config/initializers/sidekiq'

require 'app'
require_relative 'config/initializers/sidekiq'
require_relative 'lib/app'

require 'sidekiq/web'
require 'sidekiq/cron/web'
Expand Down
4 changes: 2 additions & 2 deletions config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

require 'pathname'
require 'sidekiq'
require 'config'

require_relative '../../lib/config'

Sidekiq.configure_server do |config|
config.redis = Colore::C_.redis
Expand Down
5 changes: 3 additions & 2 deletions lib/app.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# frozen_string_literal: true

require 'pathname'
require 'haml'
require 'net/http'
require 'sinatra/base'
require 'pathname'
require 'pp'
require 'sinatra/base'

require_relative 'colore'

module Colore
Expand Down
3 changes: 2 additions & 1 deletion lib/autoheathen.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require 'heathen'
require_relative 'heathen'

require_relative 'autoheathen/config'
require_relative 'autoheathen/email_processor'
9 changes: 4 additions & 5 deletions lib/autoheathen/email_processor.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# frozen_string_literal: true

require 'filemagic/ext'
require 'haml'
require 'logger'
require 'mail'
require 'pathname'
require 'yaml'
require 'logger'
require 'haml'
require 'filemagic/ext'
require_relative 'config'
require 'heathen'

module AutoHeathen
class EmailProcessor
Expand Down
1 change: 1 addition & 0 deletions lib/config.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'erb'
require 'pathname'
require 'yaml'

Encoding.default_internal = 'UTF-8'
Expand Down
3 changes: 2 additions & 1 deletion lib/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

require 'filemagic/ext'
require 'mime/types'
require 'heathen'

require_relative 'heathen'

module Colore
# The Colore Converter is a glue class to allow Colore to access the Heathen conversion
Expand Down
1 change: 1 addition & 0 deletions lib/doc_key.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'digest/md5'
require 'pathname'

module Colore
# This is the unique identifier for a document, a composite of
Expand Down
6 changes: 4 additions & 2 deletions lib/document.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# frozen_string_literal: true

require 'filemagic/ext'
require 'fileutils'
require 'json'
require 'pathname'
require 'stringio'
require 'json'
require 'filemagic/ext'

require_relative 'doc_key'

module Colore
Expand Down
11 changes: 7 additions & 4 deletions lib/heathen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

require 'filemagic/ext'
require 'pathname'
HEATHEN_BASE = Pathname.new(__FILE__).realpath.parent + 'heathen'

require_relative 'heathen/errors'
require_relative 'heathen/filename'
Expand All @@ -11,6 +10,10 @@
require_relative 'heathen/converter'
require_relative 'heathen/executioner'
require_relative 'heathen/processor'
Dir.glob((HEATHEN_BASE + 'processor_methods' + '*.rb').to_s).each do |method|
require_relative method
end

require_relative 'heathen/processor_methods/convert_image'
require_relative 'heathen/processor_methods/htmltotext'
require_relative 'heathen/processor_methods/libreoffice'
require_relative 'heathen/processor_methods/pdftotext'
require_relative 'heathen/processor_methods/tesseract'
require_relative 'heathen/processor_methods/wkhtmltopdf'
2 changes: 2 additions & 0 deletions lib/heathen/processor.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

require 'fileutils'
require 'logger'
require 'pathname'

module Heathen
# The Processor is the heart of the Heathen conversion process. Mixed in to it are all
Expand Down
2 changes: 2 additions & 0 deletions lib/heathen/processor_methods/libreoffice.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'fileutils'

module Heathen
class Processor
DEV_SHM_PATH = '/dev/shm'
Expand Down
7 changes: 4 additions & 3 deletions lib/legacy_converter.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# frozen_string_literal: true

require 'pathname'
require 'digest/sha2'
require 'filemagic/ext'
require 'mime/types'
require 'heathen'
require 'digest/sha2'
require 'pathname'

require_relative 'heathen'

module Colore
# The Colore Legacy Converter provides the conversion functionality from
Expand Down
13 changes: 1 addition & 12 deletions lib/sidekiq_app.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
# frozen_string_literal: true

#
# Application initializer for the Colore Sidekiq process. See (BASE/run_sidekiq) for usage.
#
#
require 'pathname'
require 'sidekiq'

BASE = Pathname.new(__FILE__).realpath.parent.parent
$: << BASE # for config initializers
$: << BASE + 'lib'

require 'config/initializers/sidekiq'

require_relative '../config/initializers/sidekiq'
require_relative 'colore'
1 change: 1 addition & 0 deletions spec/helpers/storage.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'fileutils'
require 'pathname'

def tmp_storage_dir
Pathname.new('/tmp') + "colore_test.#{Process.pid}"
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

require 'byebug'
require 'logger'
require 'pathname'
require 'rack/test'
require 'sidekiq/testing'
require 'simplecov'
Expand Down