Sha256: 5838bf2ec99b67b7faea4c692575060ba58ace29a5c8417d34477a91472507a8

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'
require 'parseconfig'

module EacGit
  class Local
    class Subrepo
      class Config
        MAPPING = {
          command_version: :cmdver, commit_id: :commit, join_method: :method,
          parent_commit_id: :parent, remote_branch: :branch, remote_uri: :remote
        }.freeze

        class << self
          def from_file(file_path)
            new(
              ::ParseConfig.new(file_path.to_pathname)['subrepo']
            )
          end
        end

        common_constructor :values do
          self.values = values.with_indifferent_access
        end

        MAPPING.each_key do |method_name|
          define_method(method_name) do
            values[MAPPING.fetch(method_name)]
          end

          define_method("#{method_name}=") do |value|
            values[MAPPING.fetch(method_name)] = value
          end
        end

        def to_content
          "[subrepo]\n" + MAPPING.map { |k, v| "  #{v} = #{send(k)}\n" }.join # rubocop:disable Style/StringConcatenation
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
eac_tools-0.86.5 sub/eac_git/lib/eac_git/local/subrepo/config.rb
eac_tools-0.86.4 sub/eac_git/lib/eac_git/local/subrepo/config.rb
eac_tools-0.86.3 sub/eac_git/lib/eac_git/local/subrepo/config.rb
eac_git-0.16.0 lib/eac_git/local/subrepo/config.rb
eac_tools-0.86.2 sub/eac_git/lib/eac_git/local/subrepo/config.rb
eac_git-0.15.0 lib/eac_git/local/subrepo/config.rb
eac_tools-0.84.2 sub/eac_git/lib/eac_git/local/subrepo/config.rb