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

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

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.



23
24
25
26
27
28
# File 'lib/pod/command/repo_svn/push.rb', line 23

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

Class Method Details

.optionsObject



19
20
21
# File 'lib/pod/command/repo_svn/push.rb', line 19

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



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/pod/command/repo_svn/push.rb', line 49

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} --force 2> /dev/null`
        UI.puts `svn commit -m "#{message}"`
      end
    end
  end
end

#runObject



35
36
37
38
# File 'lib/pod/command/repo_svn/push.rb', line 35

def run
  update_repo
  add_specs_to_repo
end

#update_repovoid

This method returns an undefined value.

Updates the git repo against the remote.



44
45
46
47
# File 'lib/pod/command/repo_svn/push.rb', line 44

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

#validate!Object



30
31
32
33
# File 'lib/pod/command/repo_svn/push.rb', line 30

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