Class: Pod::Command::Setup
- Inherits:
-
Pod::Command
- Object
- CLAide::Command
- Pod::Command
- Pod::Command::Setup
- Extended by:
- Executable
- Defined in:
- lib/cocoapods/command/setup.rb
Setup steps collapse
-
#add_master_repo ⇒ void
Adds the master repo from the remote.
-
#set_master_repo_branch ⇒ void
Sets the repo to the master branch.
-
#set_master_repo_url ⇒ void
Sets the url of the master repo according to whether it is push.
-
#update_master_repo ⇒ void
Updates the master repo against the remote.
Private helpers collapse
-
#master_repo_dir ⇒ Pathname
The directory of the master repo.
-
#master_repo_is_push? ⇒ Bool
If the master repo is already configured in push mode.
-
#push? ⇒ String
Checks if the user asked to setup the master repo in push mode or if the repo was already in push mode.
-
#read_only_url ⇒ String
The read only url of the master repo.
-
#read_write_url ⇒ String
The read-write url of the master repo.
-
#url ⇒ String
The url to use according to whether push mode should be enabled.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Setup
constructor
A new instance of Setup.
- #run ⇒ Object
Methods included from Executable
Methods inherited from Pod::Command
Methods included from Pod::Config::Mixin
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
.options ⇒ Object
15 16 17 |
# File 'lib/cocoapods/command/setup.rb', line 15 def self. [["--push", "Use this option to enable push access once granted"]].concat(super) end |
Instance Method Details
#add_master_repo ⇒ void
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_dir ⇒ Pathname
Returns 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.
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.
113 114 115 |
# File 'lib/cocoapods/command/setup.rb', line 113 def push? @push ||= (@push_option || master_repo_is_push?) end |
#read_only_url ⇒ String
Returns 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_url ⇒ String
Returns 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 |
#run ⇒ Object
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_branch ⇒ void
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_url ⇒ void
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_repo ⇒ void
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 |
#url ⇒ String
Returns 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 |