Class: Pod::Command::Repo::AddCodingAr

Inherits:
Pod::Command::Repo show all
Defined in:
lib/coding_ar_command.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ AddCodingAr

Returns a new instance of AddCodingAr.



10
11
12
13
# File 'lib/coding_ar_command.rb', line 10

def initialize(argv)
  @name, @url = argv.shift_argument, argv.shift_argument
  super
end

Instance Method Details

#create_coding_ar_url_file(repo_dir) ⇒ Object



42
43
44
45
46
47
48
# 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

#runObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 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.exist?(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!Object



15
16
17
18
19
20
# 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