Sha256: 0fef8bef706ed61a568752b22c493c718aec395932b2e0d3b8642c8de7cd09fc

Contents?: true

Size: 680 Bytes

Versions: 2

Compression:

Stored size: 680 Bytes

Contents

require 'anvil/task'
require 'anvil/task/repositories'
require 'anvil/config'
require 'git'

module Projects
  class AddTask < Anvil::Task
    include Anvil::Task::Repositories
    description 'Adds a new project for anvil.'
    parser { arguments %w(name repository) }

    attr_reader :name, :repo

    def initialize(name, repo, _options = {})
      @name = name
      @repo = repo
    end

    def task
      url_to_clone = resolve_url(repo)
      logger.info "Clonning #{repo} on anvil's projects folder."
      clone_repo(url_to_clone, name)
    end

    def clone_repo(url, name)
      Dir.chdir(Anvil::Config.base_projects_path) { Git.clone(url, name) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
anvil-core-0.6.0 lib/tasks/projects/add_task.rb
anvil-core-0.5.0 lib/tasks/projects/add_task.rb