Class: Pod::Command::Repo::Add
- Inherits:
-
Pod::Command::Repo
- Object
- CLAide::Command
- Pod::Command
- Pod::Command::Repo
- Pod::Command::Repo::Add
- Defined in:
- lib/cocoapods/command/repo/add.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#checkout_branch ⇒ void
private
Checks out the branch of the git spec-repo if provided.
-
#clone_repo ⇒ void
private
Clones the git spec-repo according to parameters passed to the command.
-
#create_repos_dir ⇒ void
private
Creates the repos directory specified in the configuration by
config.repos_dir
. -
#initialize(argv) ⇒ Add
constructor
A new instance of Add.
- #run ⇒ Object
- #validate! ⇒ Object
Methods inherited from Pod::Command::Repo
Methods included from Executable
capture_command, capture_command!, #executable, execute_command, popen3, reader, which, which!
Methods inherited from Pod::Command
#ensure_master_spec_repo_exists!, ensure_not_root_or_allowed!, git_version, #installer_for_config, report_error, run, #verify_lockfile_exists!, verify_minimum_git_version!, #verify_podfile_exists!, verify_xcode_license_approved!
Methods included from Pod::Config::Mixin
Constructor Details
#initialize(argv) ⇒ Add
Returns a new instance of Add.
24 25 26 27 28 29 30 |
# File 'lib/cocoapods/command/repo/add.rb', line 24 def initialize(argv) @name = argv.shift_argument @url = argv.shift_argument @branch = argv.shift_argument @progress = argv.flag?('progress') super end |
Class Method Details
.options ⇒ Object
18 19 20 21 22 |
# File 'lib/cocoapods/command/repo/add.rb', line 18 def self. [ ['--progress', 'Show the progress of cloning the spec repository'], ].concat(super) end |
Instance Method Details
#checkout_branch ⇒ void (private)
This method returns an undefined value.
Checks out the branch of the git spec-repo if provided.
96 97 98 |
# File 'lib/cocoapods/command/repo/add.rb', line 96 def checkout_branch Dir.chdir(dir) { git!('checkout', @branch) } if @branch end |
#clone_repo ⇒ void (private)
This method returns an undefined value.
Clones the git spec-repo according to parameters passed to the command.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/cocoapods/command/repo/add.rb', line 75 def clone_repo changes = if @progress { :verbose => true } else {} end config.with_changes(changes) do Dir.chdir(config.repos_dir) do command = ['clone', @url] command << '--progress' if @progress command << '--' << @name git!(command) end end end |
#create_repos_dir ⇒ void (private)
This method returns an undefined value.
Creates the repos directory specified in the configuration by
config.repos_dir
.
63 64 65 66 67 68 |
# File 'lib/cocoapods/command/repo/add.rb', line 63 def create_repos_dir config.repos_dir.mkpath rescue => e raise Informative, "Could not create '#{config.repos_dir}', the CocoaPods repo cache directory.\n" \ "#{e.class.name}: #{e.}" end |
#run ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/cocoapods/command/repo/add.rb', line 43 def run section = "Cloning spec repo `#{@name}` from `#{@url}`" section << " (branch `#{@branch}`)" if @branch UI.section(section) do create_repos_dir clone_repo checkout_branch config.sources_manager.sources([dir.basename.to_s]).each(&:verify_compatibility!) end end |
#validate! ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cocoapods/command/repo/add.rb', line 32 def validate! super unless @name && @url help! 'Adding a repo needs a `NAME` and a `URL`.' end if @name == 'trunk' raise Informative, "Repo name `trunk` is reserved for CocoaPods' main spec repo accessed via CDN." end end |