Sha256: ac73c50b3adb0ef3957e372268c7b440c3ffe53155313f9664f8efa0b7ed600c

Contents?: true

Size: 944 Bytes

Versions: 3

Compression:

Stored size: 944 Bytes

Contents

module GitCompound
  module Command
    module Procedure
      module Element
        # Manifest mixin
        #
        module Manifest
          def initialize(opts)
            super
            @manifest = manifest_load(opts[:manifest])
          end

          def self.included(parent_class)
            parent_class.class_eval do
              include Element::Option
              add_argument :manifest, type: :string, scope: :global
            end
          end

          private

          def manifest_load(filename)
            files = filename ? [filename] : GitCompound::Manifest::FILENAMES
            found = files.select { |file| File.exist?(file) }

            raise GitCompoundError,
                  "Manifest `#{filename || files.inspect}` not found !" if found.empty?

            contents = File.read(found.first)
            GitCompound::Manifest.new(contents)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
git_compound-0.2.2 lib/git_compound/command/procedure/element/manifest.rb
git_compound-0.2.1 lib/git_compound/command/procedure/element/manifest.rb
git_compound-0.2.0 lib/git_compound/command/procedure/element/manifest.rb