Sha256: 759529c08d3285c7ea221ac755eefe6649452d35345d744ff315afc0301424a7

Contents?: true

Size: 1.07 KB

Versions: 10

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'avm/eac_ruby_base1/sources/base'
require 'eac_ruby_utils/core_ext'
require 'eac_templates/core_ext'
require 'fileutils'

module EacRailsGemSupport
  module Rspec
    class AppendableRailsApp
      enable_simple_cache
      common_constructor :gem_dir, :append_dir, :target_dir, default: [nil] do
        self.target_dir = ::EacRubyUtils::Fs::ClearableDirectory.new(
          (target_dir || ::Dir.mktmpdir).to_pathname
        )
        build
      end

      protected

      def build
        clear_target
        copy_app_base
        copy_append_directory
        database_migrate
      end

      def database_migrate
        the_gem.bundle('exec', 'rake', 'db:migrate').chdir_root.execute!
      end

      def clear_target
        target_dir.clear
      end

      def copy_app_base
        template.apply(self, target_dir)
      end

      def copy_append_directory
        ::FileUtils.cp_r("#{append_dir}/.", target_dir)
      end

      def the_gem_uncached
        ::Avm::EacRubyBase1::Sources::Base.new(target_dir)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
eac_rails_gem_support-0.10.1 lib/eac_rails_gem_support/rspec/appendable_rails_app.rb
eac_rails_gem_support-0.10.0 lib/eac_rails_gem_support/rspec/appendable_rails_app.rb
eac_rails_gem_support-0.9.2 lib/eac_rails_gem_support/rspec/appendable_rails_app.rb
eac_rails_gem_support-0.9.1 lib/eac_rails_gem_support/rspec/appendable_rails_app.rb
eac_rails_gem_support-0.9.0 lib/eac_rails_gem_support/rspec/appendable_rails_app.rb
eac_rails_gem_support-0.8.0 lib/eac_rails_gem_support/rspec/appendable_rails_app.rb
eac_rails_gem_support-0.7.2 lib/eac_rails_gem_support/rspec/appendable_rails_app.rb
eac_rails_gem_support-0.7.1 lib/eac_rails_gem_support/rspec/appendable_rails_app.rb
eac_rails_gem_support-0.7.0 lib/eac_rails_gem_support/rspec/appendable_rails_app.rb
eac_rails_gem_support-0.6.0 lib/eac_rails_gem_support/rspec/appendable_rails_app.rb