Class: Dydra::Command::Create

Inherits:
Dydra::Command show all
Defined in:
lib/dydra/command/create.rb

Overview

Creates a new repository.

Instance Method Summary (collapse)

Methods inherited from Dydra::Command

#abort, #basename, #catch_errors, #debug?, #initialize, #parse_repository_specs, #parse_resource_specs, #require_gem!, #stderr, #stdout, #validate_repository_specs, #validate_resource_specs, #verbose?, #wrap_errors

Methods included from Dydra::Client

authenticate!, credentials_file, delete, get, get_json, post, reset!, resource, rpc, setup?

Constructor Details

This class inherits a constructor from Dydra::Command

Instance Method Details

- execute(*repositories)

This method returns an undefined value.

Parameters:

  • repository_specs (Array<String>)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dydra/command/create.rb', line 9

def execute(*repositories)
  puts "No repository specified" if repositories.empty?
  repositories.each do |repository|
    begin
      Repository.create!(repository)
      puts "#{repository} created."
    rescue RestClient::Forbidden
      puts "Insufficient permissions to create #{repository}."
    rescue RestClient::UnprocessableEntity
      puts "#{repository} already exists."
    rescue AuthenticationError => e
      puts e
    rescue RepositoryMisspecified => e
      puts e
    end
  end
end