cocoapods-core 0.34.1 → 0.34.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e66913ba427c63f53357342686a63e63ba07c863
4
- data.tar.gz: f958368c60696a32d4960c0e2703c18a450887d6
3
+ metadata.gz: a94f1af3077b3e043f869fbdbb2e09c242aefeb5
4
+ data.tar.gz: a73fb826f1d22b75ead258ac0e148bd6cf82a510
5
5
  SHA512:
6
- metadata.gz: 7e274277975927d3a9fba81f4813df67d540dcf648e20f1edb0657c0b7b01896b74a7232402a591631b4c3ef059350bcb453d48418298b8883137ea00217e6e2
7
- data.tar.gz: 54418fabcd515910c7c04cf97bb5fb5204cfcf1b6c8e256e2bb61d4f36c7602a42f4047ece29aad42a8c2672b5dc984467b61dbe8930872728cbee3b201e906b
6
+ metadata.gz: bf461d926d3deddaf2aab6a6e6fcd68c9c3c85a4b1eb1730fcc1d9399f5b390d53f3a57f8544c54962a6ad31916f0858995adc9b0495958046b8ce180ae1c3b2
7
+ data.tar.gz: 5d409665efa687120435c9186ae0a58dbf14725ca5afca4a46b9169fe6b2e8c54e1e983037e6053634ab631c2460482585d0a3f2e62adb36a7c352b6ff13329d
@@ -1,5 +1,5 @@
1
1
  module Pod
2
2
  # The version of the cocoapods-core.
3
3
  #
4
- CORE_VERSION = '0.34.1' unless defined? Pod::CORE_VERSION
4
+ CORE_VERSION = '0.34.2' unless defined? Pod::CORE_VERSION
5
5
  end
@@ -145,6 +145,16 @@ module Pod
145
145
  # pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git'
146
146
  #
147
147
  #
148
+ # To use a different branch of the repo:
149
+ #
150
+ # pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :branch => 'dev'
151
+ #
152
+ #
153
+ # To use a tag of the repo:
154
+ #
155
+ # pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :tag => '0.7.0'
156
+ #
157
+ #
148
158
  # Or specify a commit:
149
159
  #
150
160
  # pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :commit => '082f8319af'
@@ -1,8 +1,6 @@
1
1
  require 'cocoapods-core/source/acceptor'
2
2
  require 'cocoapods-core/source/aggregate'
3
3
  require 'cocoapods-core/source/health_reporter'
4
- require 'cocoapods-core/source/abstract_data_provider'
5
- require 'cocoapods-core/source/file_system_data_provider'
6
4
 
7
5
  module Pod
8
6
  # The Source class is responsible to manage a collection of podspecs.
@@ -16,37 +14,40 @@ module Pod
16
14
  # "#{SPEC_NAME}/#{VERSION}/#{SPEC_NAME}.podspec"
17
15
  #
18
16
  class Source
19
- # @return [AbstractDataProvider] the data provider for this source.
17
+ # @return [Pathname] The path where the source is stored.
20
18
  #
21
- attr_accessor :data_provider
19
+ attr_reader :repo
22
20
 
23
21
  # @param [Pathname, String] repo @see #repo.
24
22
  #
25
- def initialize(repo = nil)
26
- # TODO: Temporary solution to aide the transition
27
- if repo.is_a?(String) || repo.is_a?(Pathname)
28
- @data_provider = FileSystemDataProvider.new(repo)
29
- else
30
- @data_provider = repo
31
- end
23
+ def initialize(repo)
24
+ @repo = Pathname.new(repo)
32
25
  end
33
26
 
34
27
  # @return [String] The name of the source.
35
28
  #
36
29
  def name
37
- data_provider.name
30
+ repo.basename.to_s
38
31
  end
39
32
 
40
33
  # @return [String] The URL of the source.
41
34
  #
42
35
  def url
43
- data_provider.url
36
+ Dir.chdir(repo) do
37
+ remote = `git ls-remote --get-url`.chomp
38
+
39
+ if $?.success?
40
+ remote
41
+ elsif (repo + '.git').exist?
42
+ "file://#{repo}/.git"
43
+ end
44
+ end
44
45
  end
45
46
 
46
47
  # @return [String] The type of the source.
47
48
  #
48
49
  def type
49
- data_provider.type
50
+ 'file system'
50
51
  end
51
52
 
52
53
  alias_method :to_s, :name
@@ -77,12 +78,14 @@ module Pod
77
78
  #
78
79
  #
79
80
  def pods
80
- pods = data_provider.pods
81
- unless pods
82
- raise Informative, "Unable to find the #{data_provider.type} source " \
83
- "named: `#{data_provider.name}`"
81
+ unless specs_dir
82
+ raise Informative, "Unable to find a source named: `#{name}`"
84
83
  end
85
- pods
84
+ specs_dir_as_string = specs_dir.to_s
85
+ Dir.entries(specs_dir).select do |entry|
86
+ valid_name = entry[0, 1] != '.'
87
+ valid_name && File.directory?(File.join(specs_dir_as_string, entry))
88
+ end.sort
86
89
  end
87
90
 
88
91
  # @return [Array<Version>] all the available versions for the Pod, sorted
@@ -92,8 +95,20 @@ module Pod
92
95
  # the name of the Pod.
93
96
  #
94
97
  def versions(name)
95
- versions = data_provider.versions(name)
96
- versions.map { |version| Version.new(version) } if versions
98
+ return nil unless specs_dir
99
+ raise ArgumentError, 'No name' unless name
100
+ pod_dir = specs_dir + name
101
+ return unless pod_dir.exist?
102
+ pod_dir.children.map do |v|
103
+ basename = v.basename.to_s
104
+ begin
105
+ Version.new(basename) if v.directory? && basename[0, 1] != '.'
106
+ rescue ArgumentError => e
107
+ raise Informative, 'An unexpected version directory ' \
108
+ "`#{basename}` was encountered for the " \
109
+ "`#{pod_dir}` Pod in the `#{name}` repository."
110
+ end
111
+ end.compact.sort.reverse
97
112
  end
98
113
 
99
114
  # @return [Specification] the specification for a given version of Pod.
@@ -115,6 +130,8 @@ module Pod
115
130
  # @return [Pathname] The path of the specification.
116
131
  #
117
132
  def specification_path(name, version)
133
+ raise ArgumentError, 'No name' unless name
134
+ raise ArgumentError, 'No version' unless version
118
135
  path = specs_dir + name + version.to_s
119
136
  specification_path = path + "#{name}.podspec.json"
120
137
  unless specification_path.exist?
@@ -124,7 +141,7 @@ module Pod
124
141
  raise StandardError, "Unable to find the specification #{name} " \
125
142
  "(#{version}) in the #{name} source."
126
143
  end
127
- spec
144
+ specification_path
128
145
  end
129
146
 
130
147
  # @return [Array<Specification>] all the specifications contained by the
@@ -159,22 +176,6 @@ module Pod
159
176
  pods.map { |pod_name| set(pod_name) }
160
177
  end
161
178
 
162
- # Returns the path of the specification with the given name and version.
163
- #
164
- # @param [String] name
165
- # the name of the Pod.
166
- #
167
- # @param [Version,String] version
168
- # the version for the specification.
169
- #
170
- # @return [Pathname] The path of the specification.
171
- #
172
- # @todo Remove.
173
- #
174
- def specification_path(name, version)
175
- data_provider.specification_path(name, version)
176
- end
177
-
178
179
  public
179
180
 
180
181
  # @!group Searching the source
@@ -183,16 +184,20 @@ module Pod
183
184
  # @return [Set] a set for a given dependency. The set is identified by the
184
185
  # name of the dependency and takes into account subspecs.
185
186
  #
187
+ # @note This method is optimized for fast lookups by name, i.e. it does
188
+ # *not* require iterating through {#pod_sets}
189
+ #
186
190
  # @todo Rename to #load_set
187
191
  #
188
192
  def search(query)
193
+ unless specs_dir
194
+ raise Informative, "Unable to find a source named: `#{name}`"
195
+ end
189
196
  if query.is_a?(Dependency)
190
- name = query.root_name
191
- else
192
- name = query
197
+ query = query.root_name
193
198
  end
194
- pod_sets.find do |set|
195
- set.name == name
199
+ if (specs_dir + query).directory?
200
+ set(query)
196
201
  end
197
202
  end
198
203
 
@@ -213,23 +218,19 @@ module Pod
213
218
  def search_by_name(query, full_text_search = false)
214
219
  regexp_query = /#{query}/i
215
220
  if full_text_search
216
- if data_provider.is_a?(FileSystemDataProvider)
217
- pod_sets.reject do |set|
218
- texts = []
219
- begin
220
- s = set.specification
221
- texts << s.name
222
- texts += s.authors.keys
223
- texts << s.summary
224
- texts << s.description
225
- rescue
226
- CoreUI.warn "Skipping `#{set.name}` because the podspec " \
227
- 'contains errors.'
228
- end
229
- texts.grep(regexp_query).empty?
221
+ pod_sets.reject do |set|
222
+ texts = []
223
+ begin
224
+ s = set.specification
225
+ texts << s.name
226
+ texts += s.authors.keys
227
+ texts << s.summary
228
+ texts << s.description
229
+ rescue
230
+ CoreUI.warn "Skipping `#{set.name}` because the podspec " \
231
+ 'contains errors.'
230
232
  end
231
- else
232
- []
233
+ texts.grep(regexp_query).empty?
233
234
  end
234
235
  else
235
236
  names = pods.grep(regexp_query)
@@ -302,6 +303,24 @@ module Pod
302
303
  nil
303
304
  end
304
305
 
306
+ # @return [Pathname] The directory where the specs are stored.
307
+ #
308
+ # @note In previous versions of CocoaPods they used to be stored in
309
+ # the root of the repo. This lead to issues, especially with
310
+ # the GitHub interface and now the are stored in a dedicated
311
+ # folder.
312
+ #
313
+ def specs_dir
314
+ @specs_dir ||= begin
315
+ specs_sub_dir = repo + 'Specs'
316
+ if specs_sub_dir.exist?
317
+ specs_sub_dir
318
+ elsif repo.exist?
319
+ repo
320
+ end
321
+ end
322
+ end
323
+
305
324
  #-------------------------------------------------------------------------#
306
325
  end
307
326
  end
@@ -37,7 +37,6 @@ module Pod
37
37
  sources.each do |source|
38
38
  pods_by_source[source] = source.pods
39
39
  end
40
- sources = pods_by_source.keys
41
40
  pods = pods_by_source.values.flatten.uniq
42
41
 
43
42
  pods.map do |pod|
@@ -110,8 +109,8 @@ module Pod
110
109
  root_spec_names = pods_by_source.values.flatten.uniq
111
110
  root_spec_names.each do |pod|
112
111
  sources = []
113
- pods_by_source.each do |source, pods|
114
- sources << source if pods.include?(pod)
112
+ @sources.each do |s|
113
+ sources << s if pods_by_source[s].include?(pod)
115
114
  end
116
115
  result << Specification::Set.new(pod, sources)
117
116
  end
@@ -122,7 +122,7 @@ module Pod
122
122
  # @return [void]
123
123
  #
124
124
  def check_stray_specs
125
- all_paths = Pathname.glob(source.data_provider.repo + '**/*.podspec{,.json}')
125
+ all_paths = Pathname.glob(source.repo + '**/*.podspec{,.json}')
126
126
  stray_specs = all_paths - report.analyzed_paths
127
127
  stray_specs.each do |path|
128
128
  report.add_message(:error, 'Stray spec', path)
@@ -120,7 +120,7 @@ module Pod
120
120
  # pod.
121
121
  #
122
122
  def self.name_and_version_from_string(string_representation)
123
- match_data = string_representation.match(/\A(\S*)(?: \((.+)\))?\Z/)
123
+ match_data = string_representation.match(/\A((?:\s?[^\s(])+)(?: \((.+)\))?\Z/)
124
124
  unless match_data
125
125
  raise Informative, 'Invalid string representation for a ' \
126
126
  "specification: `#{string_representation}`. " \
@@ -8,7 +8,7 @@ module Pod
8
8
  # a Pod. This class stores the information of the dependencies that required
9
9
  # a Pod in the resolution process.
10
10
  #
11
- # @note The alphabetical order of the sets is used to select a
11
+ # @note The order in which the sets are provided is used to select a
12
12
  # specification if multiple are available for a given version.
13
13
  #
14
14
  # @note The set class is not and should be not aware of the backing store
@@ -32,8 +32,7 @@ module Pod
32
32
  #
33
33
  def initialize(name, sources = [])
34
34
  @name = name
35
- sources = sources.is_a?(Array) ? sources : [sources]
36
- @sources = sources.sort_by(&:name)
35
+ @sources = Array(sources)
37
36
  @dependencies_by_requirer_name = {}
38
37
  @dependencies = []
39
38
  end
@@ -84,23 +83,20 @@ module Pod
84
83
  # {#required_version}.
85
84
  #
86
85
  # @note If multiple sources have a specification for the
87
- # {#required_version} The alphabetical order of their names is
88
- # used to disambiguate.
86
+ # {#required_version}, the order in which they are provided
87
+ # is used to disambiguate.
89
88
  #
90
89
  def specification
91
- path = specification_path_for_version(required_version)
90
+ path = specification_paths_for_version(required_version).first
92
91
  Specification.from_file(path)
93
92
  end
94
93
 
95
- # TODO
94
+ # @return [Array<String>] the paths to specifications for the given
95
+ # version
96
96
  #
97
- def specification_path_for_version(_version)
98
- sources = []
99
- versions_by_source.each do |source, source_versions|
100
- sources << source if source_versions.include?(required_version)
101
- end
102
- source = sources.sort_by(&:name).first
103
- source.specification_path(name, required_version)
97
+ def specification_paths_for_version(_version)
98
+ sources = @sources.select { |source| versions_by_source[source].include?(required_version) }
99
+ sources.map { |source| source.specification_path(name, required_version) }
104
100
  end
105
101
 
106
102
  # @return [Version] the highest version that satisfies the stored
@@ -139,8 +135,12 @@ module Pod
139
135
 
140
136
  # @return [Pathname] The path of the highest version.
141
137
  #
138
+ # @note If multiple sources have a specification for the
139
+ # {#required_version}, the order in which they are provided
140
+ # is used to disambiguate.
141
+ #
142
142
  def highest_version_spec_path
143
- specification_path_for_version(highest_version)
143
+ specification_paths_for_version(highest_version).first
144
144
  end
145
145
 
146
146
  # @return [Hash{Source => Version}] all the available versions for the
@@ -218,7 +218,7 @@ module Pod
218
218
  def compute_creation_date(set)
219
219
  date = get_value(set, :creation_date)
220
220
  unless date
221
- Dir.chdir(set.sources.first.data_provider.repo) do
221
+ Dir.chdir(set.sources.first.repo) do
222
222
  git_log = `git log --first-parent --format=%ct "#{set.name}"`
223
223
  creation_date = git_log.split("\n").last.to_i
224
224
  date = Time.at(creation_date)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.34.1
4
+ version: 0.34.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Duran
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-09-26 00:00:00.000000000 Z
12
+ date: 2014-10-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -103,10 +103,8 @@ files:
103
103
  - lib/cocoapods-core/podfile/target_definition.rb
104
104
  - lib/cocoapods-core/podfile.rb
105
105
  - lib/cocoapods-core/requirement.rb
106
- - lib/cocoapods-core/source/abstract_data_provider.rb
107
106
  - lib/cocoapods-core/source/acceptor.rb
108
107
  - lib/cocoapods-core/source/aggregate.rb
109
- - lib/cocoapods-core/source/file_system_data_provider.rb
110
108
  - lib/cocoapods-core/source/health_reporter.rb
111
109
  - lib/cocoapods-core/source.rb
112
110
  - lib/cocoapods-core/specification/consumer.rb
@@ -1,74 +0,0 @@
1
- module Pod
2
- class Source
3
- # Defines the required and the optional methods of a data provider.
4
- #
5
- class AbstractDataProvider
6
- public
7
-
8
- # @group Required methods
9
- #-----------------------------------------------------------------------#
10
-
11
- # @return [String] The name of the source.
12
- #
13
- def name
14
- raise StandardError, 'Abstract method.'
15
- end
16
-
17
- # @return [String] The URL of the source.
18
- #
19
- def url
20
- raise StandardError, 'Abstract method.'
21
- end
22
-
23
- # @return [String] The user friendly type of the source.
24
- #
25
- def type
26
- raise StandardError, 'Abstract method.'
27
- end
28
-
29
- # @return [Array<String>] The list of the name of all the Pods known to
30
- # the Source.
31
- #
32
- def pods
33
- raise StandardError, 'Abstract method.'
34
- end
35
-
36
- # @return [Array<String>] All the available versions of a given Pod,
37
- # sorted from highest to lowest.
38
- #
39
- # @param [String] name
40
- # The name of the Pod.
41
- #
42
- def versions(_name)
43
- raise StandardError, 'Abstract method.'
44
- end
45
-
46
- # @return [Specification] The specification for a given version of a Pod.
47
- #
48
- # @param [String] name
49
- # The name of the Pod.
50
- #
51
- # @param [String] version
52
- # The version of the Pod.
53
- #
54
- def specification(_name, _version)
55
- raise StandardError, 'Abstract method.'
56
- end
57
-
58
- # @return [Specification] The contents of the specification for a given
59
- # version of a Pod.
60
- #
61
- # @param [String] name
62
- # the name of the Pod.
63
- #
64
- # @param [String] version
65
- # the version of the Pod.
66
- #
67
- def specification_contents(_name, _version)
68
- raise StandardError, 'Abstract method.'
69
- end
70
-
71
- #-----------------------------------------------------------------------#
72
- end
73
- end
74
- end
@@ -1,162 +0,0 @@
1
- module Pod
2
- class Source
3
- # Data provider for a `Pod::Source` backed by a repository hosted in the
4
- # file system.
5
- #
6
- class FileSystemDataProvider < AbstractDataProvider
7
- # @return [Pathname] The path where the source is stored.
8
- #
9
- attr_reader :repo
10
-
11
- # @param [Pathname, String] repo @see #repo.
12
- #
13
- def initialize(repo)
14
- @repo = Pathname.new(repo)
15
- end
16
-
17
- public
18
-
19
- # @group Required methods
20
- #-----------------------------------------------------------------------#
21
-
22
- # @return [String] The name of the source.
23
- #
24
- def name
25
- repo.basename.to_s
26
- end
27
-
28
- # @return [String] The URL of the source.
29
- #
30
- def url
31
- Dir.chdir(repo) do
32
- remote = `git ls-remote --get-url`.chomp
33
- remote if $?.success?
34
- end
35
- end
36
-
37
- # @return [String] The user friendly type of the source.
38
- #
39
- def type
40
- 'file system'
41
- end
42
-
43
- # @return [Array<String>] The list of the name of all the Pods known to
44
- # the Source.
45
- #
46
- # @note Using Pathname#children is sensibly slower.
47
- #
48
- def pods
49
- return nil unless specs_dir
50
- specs_dir_as_string = specs_dir.to_s
51
- Dir.entries(specs_dir).select do |entry|
52
- valid_name = entry[0, 1] != '.'
53
- valid_name && File.directory?(File.join(specs_dir_as_string, entry))
54
- end.sort
55
- end
56
-
57
- # @return [Array<String>] All the available versions of a given Pod,
58
- # sorted from highest to lowest.
59
- #
60
- # @param [String] name
61
- # The name of the Pod.
62
- #
63
- def versions(name)
64
- return nil unless specs_dir
65
- raise ArgumentError, 'No name' unless name
66
- pod_dir = specs_dir + name
67
- return unless pod_dir.exist?
68
- pod_dir.children.map do |v|
69
- basename = v.basename.to_s
70
- begin
71
- Version.new(basename) if v.directory? && basename[0, 1] != '.'
72
- rescue ArgumentError => e
73
- raise Informative, 'An unexpected version directory ' \
74
- "`#{basename}` was encountered for the " \
75
- "`#{pod_dir}` Pod in the `#{name}` repository."
76
- end
77
- end.compact.sort.reverse.map(&:to_s)
78
- end
79
-
80
- # @return [Specification] The specification for a given version of a Pod.
81
- #
82
- # @param [String] name
83
- # The name of the Pod.
84
- #
85
- # @param [String] version
86
- # The version of the Pod.
87
- #
88
- def specification(name, version)
89
- path = specification_path(name, version)
90
- Pod::Specification.from_file(path) if path && path.exist?
91
- end
92
-
93
- # @return [Specification] The contents of the specification for a given
94
- # version of a Pod.
95
- #
96
- # @param [String] name
97
- # the name of the Pod.
98
- #
99
- # @param [String] version
100
- # the version of the Pod.
101
- #
102
- def specification_contents(name, version)
103
- path = specification_path(name, version)
104
- File.open(path, 'r:utf-8') { |f| f.read } if path && path.exist?
105
- end
106
-
107
- public
108
-
109
- # @group Other methods
110
- #-----------------------------------------------------------------------#
111
-
112
- # Returns the path of the specification with the given name and version.
113
- #
114
- # @param [String] name
115
- # the name of the Pod.
116
- #
117
- # @param [Version,String] version
118
- # the version for the specification.
119
- #
120
- # @return [Pathname] The path of the specification.
121
- #
122
- def specification_path(name, version)
123
- raise ArgumentError, 'No name' unless name
124
- raise ArgumentError, 'No version' unless version
125
- return nil unless specs_dir
126
- path = specs_dir + name + version.to_s
127
- specification_path = path + "#{name}.podspec.json"
128
- specification_path.exist?
129
- unless specification_path.exist?
130
- specification_path = path + "#{name}.podspec"
131
- end
132
- specification_path
133
- end
134
-
135
- private
136
-
137
- # @group Private Helpers
138
- #-----------------------------------------------------------------------#
139
-
140
- # @return [Pathname] The directory where the specs are stored.
141
- #
142
- # @note In previous versions of CocoaPods they used to be stored in
143
- # the root of the repo. This lead to issues, especially with
144
- # the GitHub interface and now the are stored in a dedicated
145
- # folder.
146
- #
147
- def specs_dir
148
- unless @specs_dir
149
- specs_sub_dir = repo + 'Specs'
150
- if specs_sub_dir.exist?
151
- @specs_dir = specs_sub_dir
152
- elsif repo.exist?
153
- @specs_dir = repo
154
- end
155
- end
156
- @specs_dir
157
- end
158
-
159
- #-----------------------------------------------------------------------#
160
- end
161
- end
162
- end