Class: Pod::Command::Repo

Inherits:
Pod::Command show all
Extended by:
Executable
Defined in:
lib/cocoapods/command/repo.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Executable

executable

Methods inherited from Pod::Command

options, parse, run

Methods included from Pod::Config::Mixin

#config

Constructor Details

#initialize(argv) ⇒ Repo

Returns a new instance of Repo.



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/cocoapods/command/repo.rb', line 27

def initialize(argv)
  case @action = argv.arguments[0]
  when 'add', 'set-url'
    unless (@name = argv.arguments[1]) && (@url = argv.arguments[2])
      raise Informative, "#{@action == 'add' ? 'Adding' : 'Updating the remote of'} a repo needs a `name' and a `url'."
    end
  when 'update'
    @name = argv.arguments[1]
  else
    super
  end
end

Class Method Details



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cocoapods/command/repo.rb', line 6

def self.banner
%{Managing spec-repos:

    $ pod repo add NAME URL

Clones `URL' in the local spec-repos directory at `~/.cocoapods'. The
remote can later be referred to by `NAME'.

    $ pod repo update NAME

Updates the local clone of the spec-repo `NAME'. If `NAME' is omitted
this will update all spec-repos in `~/.cocoapods'.

    $ pod repo set-url NAME URL

Updates the remote `URL' of the spec-repo `NAME'.}
end

Instance Method Details

#addObject



48
49
50
51
52
# File 'lib/cocoapods/command/repo.rb', line 48

def add
  puts "==> Cloning spec repo `#{@name}' from `#{@url}'" unless config.silent?
  config.repos_dir.mkpath
  Dir.chdir(config.repos_dir) { git("clone '#{@url}' #{@name}") }
end

#dirObject



40
41
42
# File 'lib/cocoapods/command/repo.rb', line 40

def dir
  config.repos_dir + @name
end

#runObject



44
45
46
# File 'lib/cocoapods/command/repo.rb', line 44

def run
  send @action.gsub('-', '_')
end

#set_urlObject



62
63
64
65
66
# File 'lib/cocoapods/command/repo.rb', line 62

def set_url
  Dir.chdir(dir) do
    git("remote set-url origin '#{@url}'")
  end
end

#updateObject



54
55
56
57
58
59
60
# File 'lib/cocoapods/command/repo.rb', line 54

def update
  dirs = @name ? [dir] : config.repos_dir.children
  dirs.each do |dir|
    puts "==> Updating spec repo `#{dir.basename}'" unless config.silent?
    Dir.chdir(dir) { git("pull") }
  end
end