Class: Pod::Command::Repo::Sync

Inherits:
Pod::Command::Repo show all
Extended by:
Executable
Defined in:
lib/pod/command/sync-podspec.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Sync

Returns a new instance of Sync.



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/pod/command/sync-podspec.rb', line 35

def initialize(argv)
  @local_only = argv.flag?('local-only')
  @repo = argv.shift_argument
  @source = source_for_repo
  @source_urls = argv.option('sources', config.sources_manager.all.map(&:url).join(',')).split(',')
  @podspec = argv.shift_argument
  @private = argv.flag?('private', true)
  @message = argv.option('commit-message')
  @commit_message = argv.flag?('commit-message', false)
  @use_json = argv.flag?('use-json')
  @allow_overwrite = argv.flag?('overwrite', true)
  super
end

Class Method Details

.optionsObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/pod/command/sync-podspec.rb', line 23

def self.options
  [
    ["--sources=#{Pod::TrunkSource::TRUNK_REPO_URL}", 'The sources from which to pull dependent pods ' \
     '(defaults to all available repos). Multiple sources must be comma-delimited'],
    ['--local-only', 'Does not perform the step of pushing REPO to its remote'],
    ['--commit-message="Fix bug in pod"', 'Add custom commit message. Opens default editor if no commit ' \
      'message is specified'],
    ['--use-json', 'Convert the podspec to JSON before pushing it to the repo'],
    ['--no-overwrite', 'Disallow pushing that would overwrite an existing spec'],
  ].concat(super)
end

Instance Method Details

#runObject



59
60
61
62
63
64
65
66
# File 'lib/pod/command/sync-podspec.rb', line 59

def run
  open_editor if @commit_message && @message.nil?
  check_if_push_allowed
  check_repo_status
  update_repo
  add_specs_to_repo
  push_repo unless @local_only
end

#validate!Object



49
50
51
52
53
54
55
56
57
# File 'lib/pod/command/sync-podspec.rb', line 49

def validate!
  super
  help! 'A spec-repo name or url is required.' unless @repo
  unless @source && @source.repo.directory?
    raise Informative,
          "Unable to find the `#{@repo}` repo. " \
          'If it has not yet been cloned, add it via `pod repo add`.'
  end
end