class Pod::Command::Repo::AddCodingAr

Public Class Methods

new(argv) click to toggle source
Calls superclass method
# File lib/coding_ar_command.rb, line 10
def initialize(argv)
  @name, @url = argv.shift_argument, argv.shift_argument
  super
end

Public Instance Methods

create_coding_ar_url_file(repo_dir) click to toggle source
# File lib/coding_ar_command.rb, line 42
def create_coding_ar_url_file(repo_dir)
  url_path = File.join(repo_dir, ".coding_ar_url")
  url_file = File.new(url_path, "wb")
  url_file << @url
  url_file.close
  url_path
end
run() click to toggle source
# File lib/coding_ar_command.rb, line 22
def run
  require 'coding_ar_util'

  UI.section("Adding CODING-AR-backed repository `#@url` into local spec repo `#@name`") do
    if !CodingArUtil.coding_ar_service?(@url)
      raise Informative, "`#@url` seems not to be a CODING-AR-backed repository."
    end

    raise Informative, "Local spec repo #@name (in #{dir}) already exists." if File.exists?(dir)

    FileUtils.mkdir_p dir

    begin
      url_path = create_coding_ar_url_file dir
    rescue => e
      raise Informative, "Cannot create file '#{url_path}' because : #{e.message}."
    end
  end
end
validate!() click to toggle source
Calls superclass method
# File lib/coding_ar_command.rb, line 15
def validate!
  super
  unless @name && @url
    help! 'This command requires both a repo name and a url.'
  end
end