Class: CocoapodsRepoSq::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods_repo_sq/repository.rb

Overview

Class that represents the credentials needed to access a Square SDK repository of podspecs for a given Square Application. Responsible for downloading a copy of the repository from Square servers and cache it on the local filesystem.

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, username, password, url, path) ⇒ Repository

Returns a new instance of Repository

Parameters:

  • name (String)

    nickname under which a Square SDK repository was registered on the CocoapodsRepoSq::RepositoryStore.

  • username (String)

    server user name used to access a specific Square SDK repository.

  • password (String)

    server password used to access a specific Square SDK repository.

  • url (String)

    Square SDK repositories server url.

  • path (String)

    local filesystem path where this repository cache of podspecs is stored.



79
80
81
82
83
84
85
# File 'lib/cocoapods_repo_sq/repository.rb', line 79

def initialize(name, username, password, url, path)
  @name = name
  @username = username
  @url = url
  @password = password
  @path = path
end

Class Attribute Details

.currentCocoapodsRepoSq::Repository

Square SDK repository set by the plugin initialization on the Podfile. This setting is used by the Downloader class to know which repository to download files from in the context of a pod install or pod update command call. When a podspec indicates a Square source it does not have a Square SDK repository reference to provide to the Downloader class so this global setting is used instead.

Returns:



40
41
42
# File 'lib/cocoapods_repo_sq/repository.rb', line 40

def current
  @current
end

Instance Attribute Details

#nameString (readonly)

Returns nickname under which a Square SDK repository was registered on the CocoapodsRepoSq::RepositoryStore.

Returns:



46
47
48
# File 'lib/cocoapods_repo_sq/repository.rb', line 46

def name
  @name
end

#passwordString (readonly)

Returns server password used to access a specific Square SDK repository.

Returns:

  • (String)

    server password used to access a specific Square SDK repository.



54
55
56
# File 'lib/cocoapods_repo_sq/repository.rb', line 54

def password
  @password
end

#pathString (readonly)

Returns local filesystem path where this repository cache of podspecs is stored.

Returns:

  • (String)

    local filesystem path where this repository cache of podspecs is stored.



62
63
64
# File 'lib/cocoapods_repo_sq/repository.rb', line 62

def path
  @path
end

#urlString (readonly)

Returns Square SDK repositories server url.

Returns:

  • (String)

    Square SDK repositories server url.



58
59
60
# File 'lib/cocoapods_repo_sq/repository.rb', line 58

def url
  @url
end

#usernameString (readonly)

Returns server user name used to access a specific Square SDK repository.

Returns:

  • (String)

    server user name used to access a specific Square SDK repository.



50
51
52
# File 'lib/cocoapods_repo_sq/repository.rb', line 50

def username
  @username
end

Instance Method Details

#update_specsObject

Updates the local copy of the podspecs from the Square SDK repository



88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/cocoapods_repo_sq/repository.rb', line 88

def update_specs
  # download new specs to a temp directory
  new_specs_path = get_temporary_path
  downloader = Downloader.new(new_specs_path, "specs.zip", :repository => self)
  downloader.download

  # perform cleanup
  specs_path = File.join(@path, 'Specs')
  FileUtils.rm(File.join(new_specs_path, "file.zip"))
  FileUtils.rm_rf(specs_path)
  FileUtils.mv(new_specs_path, specs_path)
  nil
end