Sha256: a04cce0e733b77179fb72fb973e92eecbf6c0982e2ae185f9637e443fbcbbd9b

Contents?: true

Size: 1.35 KB

Versions: 8

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'

module Avm
  module EacRubyBase1
    module Sources
      class GemfileLocal
        class Sibling
          common_constructor :gemfile_local, :source
          delegate :relative_path, to: :source

          # @return [String]
          def gemspec_relative_path
            source.gemspec_path.relative_path_from(gemfile_local.source.path).to_path
          end

          # @return [String]
          def root_relative_path
            source.path.relative_path_from(gemfile_local.source.path).to_path
          end

          # @return [String]
          def target_content
            "gem '#{source.gem_name}', #{gem_options_content} if #{condition_content}\n"
          end

          protected

          # @return [String]
          def condition_content
            "::File.file?(::File.expand_path('#{gemspec_relative_path}', __dir__))"
          end

          # @return [String]
          def gem_option_path
            ["::File.expand_path('", root_relative_path, "', __dir__)"].join
          end

          # @return [String]
          def gem_option_require
            'false'
          end

          # @return [String]
          def gem_options_content
            %w[path require].map { |v| [v, send("gem_option_#{v}")].join(': ') }.join(', ')
          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/sources/gemfile_local/sibling.rb
eac_tools-0.96.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/gemfile_local/sibling.rb
avm-eac_ruby_base1-0.35.0 lib/avm/eac_ruby_base1/sources/gemfile_local/sibling.rb
eac_tools-0.95.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/gemfile_local/sibling.rb
avm-eac_ruby_base1-0.34.1 lib/avm/eac_ruby_base1/sources/gemfile_local/sibling.rb
eac_tools-0.91.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/gemfile_local/sibling.rb
avm-eac_ruby_base1-0.34.0 lib/avm/eac_ruby_base1/sources/gemfile_local/sibling.rb
eac_tools-0.91.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/gemfile_local/sibling.rb