Sha256: 70a17819dc7220e3399a0529fc08bceade6710b8250c29c8d1f6ffc83abad5f5

Contents?: true

Size: 1.82 KB

Versions: 8

Compression:

Stored size: 1.82 KB

Contents

# frozen_string_literal: true

require 'avm/eac_ruby_base1/source_generators/base/version_builder'
require 'avm/source_generators/base'
require 'eac_ruby_utils/core_ext'

module Avm
  module EacRubyBase1
    module SourceGenerators
      class Base < ::Avm::SourceGenerators::Base
        module Dependencies
          common_concern

          COMMON_DEPENDENCY_GEMS = %w[eac_ruby_utils].freeze
          DEVELOPMENT_DEPENDENCY_GEMS = %w[eac_ruby_gem_support].freeze

          module ClassMethods
            # @return [Array<String>]
            def common_dependency_gems
              COMMON_DEPENDENCY_GEMS
            end

            # @return [Array<String>]
            def development_dependency_gems
              DEVELOPMENT_DEPENDENCY_GEMS
            end
          end

          # @return [String]
          def common_dependencies
            dependencies_section(:common_dependency_gems, '')
          end

          def dependency_version(gem_name)
            ::Avm::EacRubyBase1::SourceGenerators::Base::VersionBuilder.new(gem_name, options).to_s
          end

          # @return [String]
          def development_dependencies
            dependencies_section(:development_dependency_gems, 'development_')
          end

          protected

          # @param gem_name [String]
          # @param prefix [String]
          # @return [String]
          def dependency_line(gem_name, prefix)
            "#{IDENT}s.add_#{prefix}dependency '#{gem_name}', #{dependency_version(gem_name)}\n"
          end

          # @param setting_key [Symbol]
          # @param prefix [String]
          # @return [String]
          def dependencies_section(gems_method, prefix)
            self.class.send(gems_method).sort.map { |gem_name| dependency_line(gem_name, prefix) }
              .join.rstrip
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
avm-eac_ruby_base1-0.35.1 lib/avm/eac_ruby_base1/source_generators/base/dependencies.rb
eac_tools-0.96.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/dependencies.rb
avm-eac_ruby_base1-0.35.0 lib/avm/eac_ruby_base1/source_generators/base/dependencies.rb
eac_tools-0.95.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/dependencies.rb
avm-eac_ruby_base1-0.34.1 lib/avm/eac_ruby_base1/source_generators/base/dependencies.rb
eac_tools-0.91.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/dependencies.rb
avm-eac_ruby_base1-0.34.0 lib/avm/eac_ruby_base1/source_generators/base/dependencies.rb
eac_tools-0.91.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/dependencies.rb