Class: Pod::Command::RepoRsync::Add

Inherits:
Pod::Command::RepoRsync show all
Defined in:
lib/pod/command/repo_rsync/add.rb

Instance Method Summary collapse

Methods inherited from Pod::Command::RepoRsync

#dir

Constructor Details

#initialize(argv) ⇒ Add

Returns a new instance of Add.



18
19
20
21
22
23
24
# File 'lib/pod/command/repo_rsync/add.rb', line 18

def initialize(argv)
  @name, @url, @ssh_argv = argv.shift_argument, argv.shift_argument, argv.shift_argument
  if @url && !@url.end_with?("/")
    @url = @url+"/"
  end
  super
end

Instance Method Details

#runObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/pod/command/repo_rsync/add.rb', line 33

def run
  UI.section("Checking out spec-repo `#{@name}` from `#{@url}` using rsync") do
    config.repos_dir.mkpath
    dir=config.repos_dir+@name
    Dir.chdir(config.repos_dir) do
      cmd = "rsync #{@ssh_argv || ""} -rtlz#{config.verbose? ? "v" : ""} --exclude=.rsync_config --delete \"#{@url}\" \"#{dir}\""
      UI.puts cmd if config.verbose?
      system(cmd)
      if $?.success?
        source = RsyncSource.new(dir)
        source.url = @url
        source.argv = @ssh_argv
        source.save_config
      end
    end
  end
end

#validate!Object



26
27
28
29
30
31
# File 'lib/pod/command/repo_rsync/add.rb', line 26

def validate!
  super
  unless @name && @url
    help! "Adding a spec-repo needs a `NAME` and a `URL`."
  end
end