Sha256: 431989f3fff17e6b96bbd969b64d8a142eb8dbc26f2f463002fb3d71dde936b3

Contents?: true

Size: 1.66 KB

Versions: 63

Compression:

Stored size: 1.66 KB

Contents

# frozen_string_literal: true

require 'avm/registry'
require 'avm/sources/configuration'
require 'avm/launcher/paths/real'
require 'avm/projects/stereotype/job_comparator'
require 'eac_ruby_utils/core_ext'
require 'avm/projects/stereotypes'
require 'i18n'

module Avm
  module Tools
    class AppSrc
      enable_simple_cache
      common_constructor :path do
        self.path = path.to_pathname
        source_stereotypes_mixins
      end

      delegate :configuration, to: :avm_instance
      delegate :to_s, to: :path

      def locale
        configuration.if_present(&:locale) || ::I18n.default_locale
      end

      # Backward compatibility with [Avm::Launcher::Paths::Logical].
      # @return [Avm::Launcher::Paths::Real].
      def real
        ::Avm::Launcher::Paths::Real.new(path.to_path)
      end

      def run_job(job, job_args = [])
        stereotypes_jobs(job, job_args).each(&:run)
      end

      private

      def avm_instance_uncached
        ::Avm::Registry.sources.detect(path)
      end

      def stereotypes_jobs(job, job_args)
        job_class_method = "#{job}_class"
        r = []
        stereotypes.each do |stereotype|
          r << stereotype.send(job_class_method).new(self, *job_args) if
          stereotype.send(job_class_method).present?
        end
        r.sort { |a, b| ::Avm::Projects::Stereotype::JobComparator.new(a, b).result }
      end

      def stereotypes_uncached
        ::Avm::Projects::Stereotypes.list.select { |s| s.match?(self) }
      end

      def source_stereotypes_mixins
        stereotypes.each do |s|
          s.local_project_mixin_module.if_present { |v| singleton_class.include(v) }
        end
      end
    end
  end
end

Version data entries

63 entries across 63 versions & 2 rubygems

Version Path
eac_tools-0.32.0 sub/avm-tools/lib/avm/tools/app_src.rb
avm-tools-0.136.2 lib/avm/tools/app_src.rb
eac_tools-0.31.1 sub/avm-tools/lib/avm/tools/app_src.rb
eac_tools-0.31.0 sub/avm-tools/lib/avm/tools/app_src.rb
avm-tools-0.136.1 lib/avm/tools/app_src.rb
eac_tools-0.30.0 sub/avm-tools/lib/avm/tools/app_src.rb
eac_tools-0.29.0 sub/avm-tools/lib/avm/tools/app_src.rb
avm-tools-0.136.0 lib/avm/tools/app_src.rb
eac_tools-0.28.0 sub/avm-tools/lib/avm/tools/app_src.rb
eac_tools-0.27.2 sub/avm-tools/lib/avm/tools/app_src.rb
eac_tools-0.27.1 sub/avm-tools/lib/avm/tools/app_src.rb
avm-tools-0.135.0 lib/avm/tools/app_src.rb
eac_tools-0.27.0 sub/avm-tools/lib/avm/tools/app_src.rb
avm-tools-0.134.0 lib/avm/tools/app_src.rb
eac_tools-0.26.0 sub/avm-tools/lib/avm/tools/app_src.rb
eac_tools-0.25.1 sub/avm-tools/lib/avm/tools/app_src.rb
eac_tools-0.25.0 sub/avm-tools/lib/avm/tools/app_src.rb
eac_tools-0.24.1 sub/avm-tools/lib/avm/tools/app_src.rb
avm-tools-0.133.0 lib/avm/tools/app_src.rb
eac_tools-0.24.0 sub/avm-tools/lib/avm/tools/app_src.rb