Class: CocoapodsRepoSq::RepositoryStore
- Inherits:
-
Object
- Object
- CocoapodsRepoSq::RepositoryStore
- Defined in:
- lib/cocoapods_repo_sq/repository_store.rb
Overview
Class responsible for managing user configured Square SDK repositories. Repository settings and a local copy of the podspecs are stored on the filesystem inside Cocoapods’ home directory.
Class Method Summary collapse
-
.default ⇒ RepositoryStore
Default store located in Cocoapods’s home directory.
Instance Method Summary collapse
-
#exists?(name) ⇒ Boolean
Indicates if a Square SDK repository has been added to the store.
-
#get(name) ⇒ Repository
Returns a Repository instance if a Square SDK repository exists in the store with the given name.
-
#initialize(path = nil) ⇒ RepositoryStore
constructor
A new instance of RepositoryStore.
-
#list ⇒ Array<Repository>
Returns all repositories currently configured in the store as a list of Repository objects.
-
#register(name, username, password, url) ⇒ Repository
Registers a Square SDK repository on the local store.
-
#remove(name) ⇒ Boolean
Removes a Square SDK repository from the local store.
Constructor Details
#initialize(path = nil) ⇒ RepositoryStore
Returns a new instance of RepositoryStore
42 43 44 45 |
# File 'lib/cocoapods_repo_sq/repository_store.rb', line 42 def initialize(path = nil) path ||= File.join(Pod::Config.instance.home_dir, 'repo-sq') @path = ensure_path(path) end |
Class Method Details
.default ⇒ RepositoryStore
Default store located in Cocoapods’s home directory.
Used by the plugin to look for registered repositories or by the repo-sq
commands to manage registered repositories.
35 36 37 |
# File 'lib/cocoapods_repo_sq/repository_store.rb', line 35 def self.default @default ||= new end |
Instance Method Details
#exists?(name) ⇒ Boolean
Indicates if a Square SDK repository has been added to the store
55 56 57 |
# File 'lib/cocoapods_repo_sq/repository_store.rb', line 55 def exists?(name) File.exists?(settings_path(name)) end |
#get(name) ⇒ Repository
Returns a CocoapodsRepoSq::Repository instance if a Square SDK repository exists in the store with the given name
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/cocoapods_repo_sq/repository_store.rb', line 79 def get(name) return unless exists?(name) settings = load_settings!(name) Repository.new( settings[:name], settings[:username], settings[:password], settings[:url], repository_path(name) ) end |
#list ⇒ Array<Repository>
Returns all repositories currently configured in the store as a list of CocoapodsRepoSq::Repository objects
64 65 66 67 68 69 |
# File 'lib/cocoapods_repo_sq/repository_store.rb', line 64 def list Dir[File.join(@path, '*')].map do |dir| name = File.basename(dir) get(name) end.compact end |
#register(name, username, password, url) ⇒ Repository
Registers a Square SDK repository on the local store
111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/cocoapods_repo_sq/repository_store.rb', line 111 def register(name, username, password, url) if exists?(name) = "Square SDK repository `#{name}` is already configured" raise Pod::Informative, end begin store_settings!(name, username, password, url) Repository.new(name, username, password, url, repository_path(name)) rescue => error remove(name) raise error end end |
#remove(name) ⇒ Boolean
Removes a Square SDK repository from the local store
134 135 136 137 |
# File 'lib/cocoapods_repo_sq/repository_store.rb', line 134 def remove(name) path = repository_path(name) File.exists?(path) && FileUtils.rm_rf(path) && true end |