let Zeitwerk autoload the `lib/` directory
this also allows the UseCase classes to be hot reloaded in dev 🎉
- remove use_case requires (except for the exporter as Zeitwerk
doesn't know about the subclasses)
- move version.rb to lib/retrospring so that Zeitwerk knows where
to find Retrospring::Version
This commit is contained in:
parent
447d1f7e6d
commit
9413d23a02
|
@ -1,5 +1,5 @@
|
||||||
require 'use_case/user/ban'
|
# frozen_string_literal: true
|
||||||
require 'use_case/user/unban'
|
|
||||||
require 'errors'
|
require 'errors'
|
||||||
|
|
||||||
class Ajax::ModerationController < AjaxController
|
class Ajax::ModerationController < AjaxController
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "errors"
|
require "errors"
|
||||||
require "use_case/question/create"
|
|
||||||
require "use_case/question/create_followers"
|
|
||||||
require "use_case/question/destroy"
|
|
||||||
|
|
||||||
class Ajax::QuestionController < AjaxController
|
class Ajax::QuestionController < AjaxController
|
||||||
def destroy
|
def destroy
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "use_case/relationship/create"
|
|
||||||
require "use_case/relationship/destroy"
|
|
||||||
require "errors"
|
require "errors"
|
||||||
|
|
||||||
class Ajax::RelationshipController < AjaxController
|
class Ajax::RelationshipController < AjaxController
|
||||||
|
|
|
@ -8,8 +8,6 @@ start = Time.now
|
||||||
Bundler.require(*Rails.groups)
|
Bundler.require(*Rails.groups)
|
||||||
puts 'processing time of bundler require: ' + "#{(Time.now - start).round(3).to_s.ljust(5, '0')}s".light_green
|
puts 'processing time of bundler require: ' + "#{(Time.now - start).round(3).to_s.ljust(5, '0')}s".light_green
|
||||||
|
|
||||||
require_relative "../lib/version"
|
|
||||||
|
|
||||||
module Justask
|
module Justask
|
||||||
class Application < Rails::Application
|
class Application < Rails::Application
|
||||||
# Settings in config/environments/* take precedence over those specified here.
|
# Settings in config/environments/* take precedence over those specified here.
|
||||||
|
@ -17,7 +15,11 @@ module Justask
|
||||||
# -- all .rb files in that directory are automatically loaded.
|
# -- all .rb files in that directory are automatically loaded.
|
||||||
|
|
||||||
config.load_defaults 6.0
|
config.load_defaults 6.0
|
||||||
config.autoload_paths += %W["#{config.root}/app/validators"]
|
# add `lib/` to the autoload paths so zeitwerk can find e.g. our `UseCase`s
|
||||||
|
# without an explicit `require`, and also take care of hot reloading the code
|
||||||
|
# (really useful in development!)
|
||||||
|
config.autoload_paths << config.root.join("lib")
|
||||||
|
config.eager_load_paths << config.root.join("lib")
|
||||||
|
|
||||||
# Use Sidekiq for background jobs
|
# Use Sidekiq for background jobs
|
||||||
config.active_job.queue_adapter = :sidekiq
|
config.active_job.queue_adapter = :sidekiq
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace :version do
|
||||||
now = Time.now.utc
|
now = Time.now.utc
|
||||||
today_ymd = %i[year month day].map { now.public_send(_1) }
|
today_ymd = %i[year month day].map { now.public_send(_1) }
|
||||||
|
|
||||||
version_path = Rails.root.join("lib/version.rb")
|
version_path = Rails.root.join("lib/retrospring/version.rb")
|
||||||
version_contents = File.read(version_path)
|
version_contents = File.read(version_path)
|
||||||
|
|
||||||
patch_contents = lambda do |key, val|
|
patch_contents = lambda do |key, val|
|
||||||
|
@ -35,7 +35,7 @@ namespace :version do
|
||||||
|
|
||||||
desc "Commit and tag a new release"
|
desc "Commit and tag a new release"
|
||||||
task commit: :environment do
|
task commit: :environment do
|
||||||
version_path = Rails.root.join("lib/version.rb")
|
version_path = Rails.root.join("lib/retrospring/version.rb")
|
||||||
|
|
||||||
puts "Committing version"
|
puts "Committing version"
|
||||||
sh %(git commit -m 'Bump version to #{Retrospring::Version}' -- #{version_path.to_s.inspect})
|
sh %(git commit -m 'Bump version to #{Retrospring::Version}' -- #{version_path.to_s.inspect})
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "use_case/data_export/base"
|
|
||||||
|
|
||||||
module UseCase
|
module UseCase
|
||||||
module DataExport
|
module DataExport
|
||||||
class Answers < UseCase::DataExport::Base
|
class Answers < UseCase::DataExport::Base
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "use_case/data_export/base"
|
|
||||||
|
|
||||||
module UseCase
|
module UseCase
|
||||||
module DataExport
|
module DataExport
|
||||||
class Appendables < UseCase::DataExport::Base
|
class Appendables < UseCase::DataExport::Base
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
require "json"
|
require "json"
|
||||||
|
|
||||||
require "use_case/base"
|
|
||||||
|
|
||||||
module UseCase
|
module UseCase
|
||||||
module DataExport
|
module DataExport
|
||||||
class Base < UseCase::Base
|
class Base < UseCase::Base
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "use_case/data_export/base"
|
|
||||||
|
|
||||||
module UseCase
|
module UseCase
|
||||||
module DataExport
|
module DataExport
|
||||||
class Comments < UseCase::DataExport::Base
|
class Comments < UseCase::DataExport::Base
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "use_case/data_export/base"
|
|
||||||
|
|
||||||
module UseCase
|
module UseCase
|
||||||
module DataExport
|
module DataExport
|
||||||
class MuteRules < UseCase::DataExport::Base
|
class MuteRules < UseCase::DataExport::Base
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "use_case/data_export/base"
|
|
||||||
|
|
||||||
module UseCase
|
module UseCase
|
||||||
module DataExport
|
module DataExport
|
||||||
class Questions < UseCase::DataExport::Base
|
class Questions < UseCase::DataExport::Base
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "use_case/data_export/base"
|
|
||||||
|
|
||||||
module UseCase
|
module UseCase
|
||||||
module DataExport
|
module DataExport
|
||||||
class Relationships < UseCase::DataExport::Base
|
class Relationships < UseCase::DataExport::Base
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "use_case/data_export/base"
|
|
||||||
|
|
||||||
module UseCase
|
module UseCase
|
||||||
module DataExport
|
module DataExport
|
||||||
class Theme < UseCase::DataExport::Base
|
class Theme < UseCase::DataExport::Base
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
require "httparty"
|
require "httparty"
|
||||||
|
|
||||||
require "use_case/data_export/base"
|
|
||||||
|
|
||||||
module UseCase
|
module UseCase
|
||||||
module DataExport
|
module DataExport
|
||||||
class User < UseCase::DataExport::Base
|
class User < UseCase::DataExport::Base
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "use_case/base"
|
|
||||||
require "errors"
|
require "errors"
|
||||||
|
|
||||||
module UseCase
|
module UseCase
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "use_case/base"
|
|
||||||
|
|
||||||
module UseCase
|
module UseCase
|
||||||
module Question
|
module Question
|
||||||
class CreateFollowers < UseCase::Base
|
class CreateFollowers < UseCase::Base
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "use_case/base"
|
|
||||||
require "errors"
|
require "errors"
|
||||||
|
|
||||||
module UseCase
|
module UseCase
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "use_case/base"
|
|
||||||
require "errors"
|
require "errors"
|
||||||
|
|
||||||
module UseCase
|
module UseCase
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "use_case/base"
|
|
||||||
require "errors"
|
require "errors"
|
||||||
|
|
||||||
module UseCase
|
module UseCase
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "use_case/base"
|
|
||||||
|
|
||||||
module UseCase
|
module UseCase
|
||||||
module User
|
module User
|
||||||
class Ban < UseCase::Base
|
class Ban < UseCase::Base
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'use_case/base'
|
|
||||||
|
|
||||||
module UseCase
|
module UseCase
|
||||||
module User
|
module User
|
||||||
class Unban < UseCase::Base
|
class Unban < UseCase::Base
|
||||||
|
@ -24,4 +22,4 @@ module UseCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "version"
|
|
||||||
|
|
||||||
RSpec.describe Retrospring::Version do
|
RSpec.describe Retrospring::Version do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
allow(Retrospring::Version).to receive(:year) { 1984 }
|
allow(Retrospring::Version).to receive(:year) { 1984 }
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
require "use_case/data_export/answers"
|
|
||||||
|
|
||||||
describe UseCase::DataExport::Answers, :data_export do
|
describe UseCase::DataExport::Answers, :data_export do
|
||||||
include ActiveSupport::Testing::TimeHelpers
|
include ActiveSupport::Testing::TimeHelpers
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
require "use_case/data_export/appendables"
|
|
||||||
|
|
||||||
describe UseCase::DataExport::Appendables, :data_export do
|
describe UseCase::DataExport::Appendables, :data_export do
|
||||||
include ActiveSupport::Testing::TimeHelpers
|
include ActiveSupport::Testing::TimeHelpers
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
require "use_case/data_export/comments"
|
|
||||||
|
|
||||||
describe UseCase::DataExport::Comments, :data_export do
|
describe UseCase::DataExport::Comments, :data_export do
|
||||||
include ActiveSupport::Testing::TimeHelpers
|
include ActiveSupport::Testing::TimeHelpers
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
require "use_case/data_export/mute_rules"
|
|
||||||
|
|
||||||
describe UseCase::DataExport::MuteRules, :data_export do
|
describe UseCase::DataExport::MuteRules, :data_export do
|
||||||
include ActiveSupport::Testing::TimeHelpers
|
include ActiveSupport::Testing::TimeHelpers
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
require "use_case/data_export/questions"
|
|
||||||
|
|
||||||
describe UseCase::DataExport::Questions, :data_export do
|
describe UseCase::DataExport::Questions, :data_export do
|
||||||
include ActiveSupport::Testing::TimeHelpers
|
include ActiveSupport::Testing::TimeHelpers
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
require "use_case/data_export/relationships"
|
|
||||||
|
|
||||||
describe UseCase::DataExport::Relationships, :data_export do
|
describe UseCase::DataExport::Relationships, :data_export do
|
||||||
include ActiveSupport::Testing::TimeHelpers
|
include ActiveSupport::Testing::TimeHelpers
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
require "use_case/data_export/theme"
|
|
||||||
|
|
||||||
describe UseCase::DataExport::Theme, :data_export do
|
describe UseCase::DataExport::Theme, :data_export do
|
||||||
include ActiveSupport::Testing::TimeHelpers
|
include ActiveSupport::Testing::TimeHelpers
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
require "use_case/data_export/user"
|
|
||||||
|
|
||||||
describe UseCase::DataExport::User, :data_export do
|
describe UseCase::DataExport::User, :data_export do
|
||||||
let(:user_params) do
|
let(:user_params) do
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
require "errors"
|
require "errors"
|
||||||
require "use_case/question/create_followers"
|
|
||||||
|
|
||||||
describe UseCase::Question::CreateFollowers do
|
describe UseCase::Question::CreateFollowers do
|
||||||
subject do
|
subject do
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
require "errors"
|
require "errors"
|
||||||
require "use_case/question/create"
|
|
||||||
|
|
||||||
describe UseCase::Question::Create do
|
describe UseCase::Question::Create do
|
||||||
subject do
|
subject do
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
require "errors"
|
require "errors"
|
||||||
require "use_case/question/destroy"
|
|
||||||
|
|
||||||
describe UseCase::Question::Destroy do
|
describe UseCase::Question::Destroy do
|
||||||
subject do
|
subject do
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
require "use_case/relationship/create"
|
|
||||||
require "errors"
|
require "errors"
|
||||||
|
|
||||||
describe UseCase::Relationship::Create do
|
describe UseCase::Relationship::Create do
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
require "use_case/relationship/destroy"
|
|
||||||
require "errors"
|
require "errors"
|
||||||
|
|
||||||
describe UseCase::Relationship::Destroy do
|
describe UseCase::Relationship::Destroy do
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
raise ArgumentError.new("This file should only be required in the 'test' environment! Current environment: #{Rails.env}") unless Rails.env.test?
|
raise ArgumentError.new("This file should only be required in the 'test' environment! Current environment: #{Rails.env}") unless Rails.env.test?
|
||||||
|
|
||||||
require "use_case/data_export/base"
|
|
||||||
|
|
||||||
# an example exporter to be used for the tests of `Exporter`
|
# an example exporter to be used for the tests of `Exporter`
|
||||||
#
|
#
|
||||||
# this only returning basic files, nothing user-specific. each exporter should be tested individually.
|
# this only returning basic files, nothing user-specific. each exporter should be tested individually.
|
||||||
|
|
Loading…
Reference in New Issue