Class: Pod::Source::GitHubDataProvider
- Inherits:
-
AbstractDataProvider
- Object
- AbstractDataProvider
- Pod::Source::GitHubDataProvider
- Defined in:
- lib/cocoapods-core/source/github_data_provider.rb
Overview
Data provider for a ‘Pod::Source` backed by a repository hosted on GitHub and accessed via the HTTP API. Only pure JSON repos using the `Specs` subdir to store the specifications are supported.
Instance Attribute Summary collapse
-
#branch ⇒ String
readonly
The branch of the repo if the default one shouldn’t be used.
-
#repo_id ⇒ String
readonly
The identifier of the repository (user name and repo name) or the full URL of the repo.
Data Source collapse
-
#name ⇒ String
The name of the Source.
-
#pods ⇒ Array<String>
The list of the name of all the Pods known to the Source.
-
#specification(name, version) ⇒ Specification
The specification for a given version of a Pod.
-
#specification_contents(name, version) ⇒ Specification
The contents of the specification for a given version of a Pod.
-
#type ⇒ String
The user friendly type of the source.
-
#versions(name) ⇒ Array<String>
All the available versions of a given Pod, sorted from highest to lowest.
Instance Method Summary collapse
-
#initialize(repo_id, branch = nil) ⇒ GitHubDataProvider
constructor
A new instance of GitHubDataProvider.
Constructor Details
#initialize(repo_id, branch = nil) ⇒ GitHubDataProvider
Returns a new instance of GitHubDataProvider.
21 22 23 24 |
# File 'lib/cocoapods-core/source/github_data_provider.rb', line 21 def initialize(repo_id, branch = nil) @repo_id = repo_id @branch = branch end |
Instance Attribute Details
#branch ⇒ String (readonly)
Returns The branch of the repo if the default one shouldn’t be used.
16 17 18 |
# File 'lib/cocoapods-core/source/github_data_provider.rb', line 16 def branch @branch end |
#repo_id ⇒ String (readonly)
Returns The identifier of the repository (user name and repo name) or the full URL of the repo.
11 12 13 |
# File 'lib/cocoapods-core/source/github_data_provider.rb', line 11 def repo_id @repo_id end |
Instance Method Details
#name ⇒ String
Returns The name of the Source. User name and repo.
33 34 35 |
# File 'lib/cocoapods-core/source/github_data_provider.rb', line 33 def name GitHub.normalized_repo_id(repo_id) end |
#pods ⇒ Array<String>
Returns The list of the name of all the Pods known to the Source.
46 47 48 49 50 |
# File 'lib/cocoapods-core/source/github_data_provider.rb', line 46 def pods root_contents = get_github_contents('Specs') pods = dir_names(root_contents) pods.sort if pods end |
#specification(name, version) ⇒ Specification
Returns The specification for a given version of a Pod.
76 77 78 79 80 81 82 83 |
# File 'lib/cocoapods-core/source/github_data_provider.rb', line 76 def specification(name, version) raise ArgumentError, 'No name' unless name raise ArgumentError, 'No version' unless version spec_content = specification_contents(name, version) if spec_content Pod::Specification.from_json(spec_content) end end |
#specification_contents(name, version) ⇒ Specification
Returns The contents of the specification for a given version of a Pod.
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/cocoapods-core/source/github_data_provider.rb', line 94 def specification_contents(name, version) raise ArgumentError, 'No name' unless name raise ArgumentError, 'No version' unless version path = "Specs/#{name}/#{version}/#{name}.podspec.json" file_contents = get_github_contents(path) if file_contents if file_contents['encoding'] == 'base64' require 'base64' Base64.decode64(file_contents['content']) end end end |
#type ⇒ String
Returns The user friendly type of the source.
39 40 41 |
# File 'lib/cocoapods-core/source/github_data_provider.rb', line 39 def type 'GitHub API' end |
#versions(name) ⇒ Array<String>
Returns All the available versions of a given Pod, sorted from highest to lowest.
58 59 60 61 62 63 64 65 66 |
# File 'lib/cocoapods-core/source/github_data_provider.rb', line 58 def versions(name) raise ArgumentError, 'No name' unless name contents = get_github_contents("Specs/#{name}") pre_vers = dir_names(contents) return nil if pre_vers.nil? pre_vers.each do |v| Version.new(v) end.sort.reverse.map(&:to_s) end |