Sha256: c642e800722d2f0cc55fb0b22f02b3327bc08c349598f42f2a02189e1af4e145

Contents?: true

Size: 693 Bytes

Versions: 6

Compression:

Stored size: 693 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 do
      arguments %w[name repository]
    end

    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

6 entries across 6 versions & 1 rubygems

Version Path
anvil-core-0.4.2 lib/tasks/projects/add_task.rb
anvil-core-0.4.1 lib/tasks/projects/add_task.rb
anvil-core-0.4.0 lib/tasks/projects/add_task.rb
anvil-core-0.3.2 lib/tasks/projects/add_task.rb
anvil-core-0.3.1 lib/tasks/projects/add_task.rb
anvil-core-0.3.0 lib/tasks/projects/add_task.rb