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.



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

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

Instance Method Details

#runObject



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

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 -rtlz#{config.verbose? ? "v" : ""} \"#{@url}\" \"#{dir}\""
      UI.puts cmd if config.verbose?
      system(cmd)
      if $?.success?
        File.open(dir+".rsync_config", "w:UTF-8") do |f|
          f.write @url
        end
      end
    end
  end
end

#validate!Object



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

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