Class: Pod::Command::RepoSvn::Push

Inherits:
Pod::Command::RepoSvn show all
Defined in:
lib/pod/command/repo_svn.rb

Overview

———————————————————————–#

Pushes a podspec to the specified repo

Most of this was taken directly from the CocoaPods ‘push` command

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pod::Command::RepoSvn

#dir

Constructor Details

#initialize(argv) ⇒ Push

Returns a new instance of Push.



308
309
310
311
312
313
# File 'lib/pod/command/repo_svn.rb', line 308

def initialize(argv)
  @local_only = argv.flag?('local-only')
  @repo = argv.shift_argument
  @podspec = argv.shift_argument
  super
end

Class Method Details

.optionsObject



304
305
306
# File 'lib/pod/command/repo_svn.rb', line 304

def self.options
  [['--local-only', 'Does not perform the step of committing changes to REPO']].concat(super)
end

Instance Method Details

#add_specs_to_repoObject



334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/pod/command/repo_svn.rb', line 334

def add_specs_to_repo
  UI.puts "\nAdding the #{'spec'.pluralize(podspec_files.count)} to the `#{@repo}' repo\n".yellow
  podspec_files.each do |spec_file|
    spec = Pod::Specification.from_file(spec_file)
    output_path = File.join(repo_dir, spec.name, spec.version.to_s)
    if Pathname.new(output_path).exist?
      message = "[Fix] #{spec}"
    elsif Pathname.new(File.join(repo_dir, spec.name)).exist?
      message = "[Update] #{spec}"
    else
      message = "[Add] #{spec}"
    end

    FileUtils.mkdir_p(output_path)
    FileUtils.cp(spec_file, output_path)
    if !@local_only
      Dir.chdir(repo_dir) do
        # only commit if modified
        UI.puts "Committing changes"
        UI.puts `svn add #{spec.name} 2> /dev/null`
        UI.puts `svn commit -m "#{message}"`
      end
    end
  end
end

#runObject



320
321
322
323
# File 'lib/pod/command/repo_svn.rb', line 320

def run
  update_repo
  add_specs_to_repo
end

#update_repovoid

This method returns an undefined value.

Updates the git repo against the remote.



329
330
331
332
# File 'lib/pod/command/repo_svn.rb', line 329

def update_repo
  UI.puts "Updating the `#{@repo}' repo\n".yellow
  Dir.chdir(repo_dir) { UI.puts `svn update .` }
end

#validate!Object



315
316
317
318
# File 'lib/pod/command/repo_svn.rb', line 315

def validate!
  super
  help! 'A spec-repo name is required.' unless @repo
end