Class: Pod::Command::Setup

Inherits:
Pod::Command show all
Extended by:
Executable
Defined in:
lib/cocoapods/command/setup.rb

Setup steps collapse

Private helpers collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Executable

executable, execute_command

Methods inherited from Pod::Command

parse, report_error, run

Methods included from Pod::Config::Mixin

#config

Constructor Details

#initialize(argv) ⇒ Setup

Returns a new instance of Setup.



22
23
24
25
# File 'lib/cocoapods/command/setup.rb', line 22

def initialize(argv)
  @push_option  = argv.flag?('push')
  super
end

Class Method Details

.optionsObject



15
16
17
# File 'lib/cocoapods/command/setup.rb', line 15

def self.options
  [["--push", "Use this option to enable push access once granted"]].concat(super)
end

Instance Method Details

#add_master_repovoid

This method returns an undefined value.

Adds the master repo from the remote.



60
61
62
# File 'lib/cocoapods/command/setup.rb', line 60

def add_master_repo
  @command ||= Repo::Add.parse(['master', url, 'master']).run
end

#master_repo_dirPathname

Returns the directory of the master repo.

Returns:

  • (Pathname)

    the directory of the master repo.



129
130
131
# File 'lib/cocoapods/command/setup.rb', line 129

def master_repo_dir
  SourcesManager.master_repo_dir
end

#master_repo_is_push?Bool

Returns if the master repo is already configured in push mode.

Returns:

  • (Bool)

    if the master repo is already configured in push mode.



119
120
121
122
123
124
125
# File 'lib/cocoapods/command/setup.rb', line 119

def master_repo_is_push?
  return false unless master_repo_dir.exist?
  Dir.chdir(master_repo_dir) do
    url = git('config --get remote.origin.url')
    url.chomp == read_write_url
  end
end

#push?String

Checks if the user asked to setup the master repo in push mode or if the repo was already in push mode.

Returns:

  • (String)

    whether the master repo should be set up in push mode.



113
114
115
# File 'lib/cocoapods/command/setup.rb', line 113

def push?
  @push ||= (@push_option || master_repo_is_push?)
end

#read_only_urlString

Returns the read only url of the master repo.

Returns:

  • (String)

    the read only url of the master repo.



98
99
100
# File 'lib/cocoapods/command/setup.rb', line 98

def read_only_url
  'https://github.com/CocoaPods/Specs.git'
end

#read_write_urlString

Returns the read-write url of the master repo.

Returns:

  • (String)

    the read-write url of the master repo.



104
105
106
# File 'lib/cocoapods/command/setup.rb', line 104

def read_write_url
  '[email protected]:CocoaPods/Specs.git'
end

#runObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cocoapods/command/setup.rb', line 27

def run
  UI.section "Setting up CocoaPods master repo" do
    if master_repo_dir.exist?
      set_master_repo_url
      set_master_repo_branch
      update_master_repo
    else
      add_master_repo
    end
  end

  access_type = push? ? "push" : "read-only"
  UI.puts "Setup completed (#{access_type} access)".green
end

#set_master_repo_branchvoid

Note:

This is not needed anymore as it was used for CocoaPods 0.6 release candidates.

This method returns an undefined value.

Sets the repo to the master branch.



79
80
81
82
83
# File 'lib/cocoapods/command/setup.rb', line 79

def set_master_repo_branch
  Dir.chdir(master_repo_dir) do
    git("checkout master")
  end
end

#set_master_repo_urlvoid

This method returns an undefined value.

Sets the url of the master repo according to whether it is push.



50
51
52
53
54
# File 'lib/cocoapods/command/setup.rb', line 50

def set_master_repo_url
  Dir.chdir(master_repo_dir) do
    git("remote set-url origin '#{url}'")
  end
end

#update_master_repovoid

This method returns an undefined value.

Updates the master repo against the remote.



68
69
70
# File 'lib/cocoapods/command/setup.rb', line 68

def update_master_repo
  SourcesManager.update('master', true)
end

#urlString

Returns the url to use according to whether push mode should be enabled.

Returns:

  • (String)

    the url to use according to whether push mode should be enabled.



92
93
94
# File 'lib/cocoapods/command/setup.rb', line 92

def url
  (push?) ? read_write_url : read_only_url
end