class Pod::Command::RepoSvn::Push

Public Class Methods

new(argv) click to toggle source
Calls superclass method
# 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
options() click to toggle source
Calls superclass method
# 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

Public Instance Methods

add_specs_to_repo() click to toggle source
# 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
run() click to toggle source
# File lib/pod/command/repo_svn/push.rb, line 35
def run
  update_repo
  add_specs_to_repo
end
update_repo() click to toggle source

Updates the git repo against the remote.

@return [void]

# 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!() click to toggle source
Calls superclass method
# File lib/pod/command/repo_svn/push.rb, line 30
def validate!
  super
  help! 'A spec-repo name is required.' unless @repo
end

Private Instance Methods

podspec_files() click to toggle source

@return [Array<Pathname>] The path of the specifications to push.

# File lib/pod/command/repo_svn/push.rb, line 79
def podspec_files
  if @podspec
    path = Pathname(@podspec)
    raise Informative, "Couldn't find #{@podspec}" unless path.exist?
    [path]
  else
    files = Pathname.glob('*.podspec{,.json}')
    raise Informative, "Couldn't find any podspec files in current directory" if files.empty?
    files
  end
end
repo_dir() click to toggle source

@return [Pathname] The directory of the repository.

# File lib/pod/command/repo_svn/push.rb, line 93
def repo_dir
  specs_dir = Pathname.new(File.join(config.repos_dir, @repo, 'Specs'))
  dir = config.repos_dir + @repo
  if specs_dir.exist?
    dir = specs_dir
  elsif dir.exist?
    dir
  else
    raise Informative, "`#{@repo}` repo not found either in #{specs_dir} or #{dir}"
  end
  dir
end