cocoapods-core 0.28.0 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59ebc8caae99ff0b103a68db5da56f145260a701
4
- data.tar.gz: eb4956ae204fe1e15a008927bc56ab09c5c0ca57
3
+ metadata.gz: da81ad7e5574affa671f8df2cb9392a2adc60caf
4
+ data.tar.gz: 58d6aa2090f7c57af994b2125f97c105c72f8797
5
5
  SHA512:
6
- metadata.gz: 59cdc3c942852b9143f88b3218c378071e4266a6f197cfa86ad7ca84bef718cd26fe4418792b0e65a4951481e06304d2054a3d541cf9ca6847f238ec0d6ce829
7
- data.tar.gz: 3a090a0ab43fc39016d6a079571b66834b8ca04dd3a4cff462aa31883afee60cba36dc3e79af1b1bd4087bc9ddf651b094fee85e531f0f7d2565f8a04d06f166
6
+ metadata.gz: 190da0981dae81cc2053ce8b270981fda47b0577d75756a73266fe8128c8a9039a53442a59492320744e7becc1e5b0c7acf4a9dae5c23aef74a248817c76da0a
7
+ data.tar.gz: cd169506f6ef8cfd5c8b3a4918ff123553a063fdbeeed1deeb54a493ad26969ab2c7bbed32cee2dd4f70018854011dffcac9d6397a00c98aa0707a889018367c
@@ -2,5 +2,5 @@ module Pod
2
2
 
3
3
  # The version of the cocoapods-core.
4
4
  #
5
- CORE_VERSION = '0.28.0' unless defined? Pod::CORE_VERSION
5
+ CORE_VERSION = '0.29.0' unless defined? Pod::CORE_VERSION
6
6
  end
@@ -54,11 +54,34 @@ module Pod
54
54
  end
55
55
  end
56
56
 
57
- private
57
+ # Returns the contents of a file or directory in a repository.
58
+ #
59
+ # @param [String] url @see #repo
60
+ #
61
+ # @param [#to_s] path
62
+ # The path for which the contents are needed.
63
+ #
64
+ # @param [String] branch
65
+ # The branch for which to fetch the contents of the path.
66
+ #
67
+ # @return [Array] The list of the files and of the directories if the given
68
+ # path is a directory.
69
+ #
70
+ # @return [Hash] The contents of the file (usually base64 encoded).
71
+ #
72
+ def self.contents(url, path = nil, branch = nil)
73
+ if repo_id = normalized_repo_id(url)
74
+ request_url = "https://api.github.com/repos/#{repo_id}/contents"
75
+ request_url << "/#{path}" if path
76
+ request_url << "?ref=#{branch}" if branch
77
+ peform_request(request_url)
78
+ end
79
+ end
58
80
 
59
- #-------------------------------------------------------------------------#
81
+ private
60
82
 
61
83
  # @!group Private helpers
84
+ #-------------------------------------------------------------------------#
62
85
 
63
86
  # Returns the repo ID as it is or converting a GitHub URL.
64
87
  #
@@ -93,8 +116,16 @@ module Pod
93
116
  def self.peform_request(url)
94
117
  require 'rest'
95
118
  require 'json'
96
- response = REST.get(url)
97
- JSON.parse(response.body)
119
+ headers = { "User-Agent" => "CocoaPods" }
120
+ response = REST.get(url, headers)
121
+ body = JSON.parse(response.body)
122
+ if response.ok?
123
+ body
124
+ else
125
+ CoreUI.warn "Request to #{url} failed - #{response.status_code}"
126
+ CoreUI.warn body['message']
127
+ nil
128
+ end
98
129
  end
99
130
 
100
131
  #-------------------------------------------------------------------------#
@@ -1,6 +1,9 @@
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
+ require 'cocoapods-core/source/github_data_provider'
4
7
 
5
8
  module Pod
6
9
 
@@ -16,20 +19,31 @@ module Pod
16
19
  #
17
20
  class Source
18
21
 
19
- # @return [Pathname] the location of the repo of the source.
22
+ # @return [AbstractDataProvider] the data provider for this source.
20
23
  #
21
- attr_reader :repo
24
+ attr_accessor :data_provider
22
25
 
23
26
  # @param [Pathname, String] repo @see #repo.
24
27
  #
25
- def initialize(repo)
26
- @repo = Pathname.new(repo)
28
+ def initialize(repo = nil)
29
+ # TODO: Temporary solution to aide the transition
30
+ if repo.is_a?(String) || repo.is_a?(Pathname)
31
+ @data_provider = FileSystemDataProvider.new(repo)
32
+ else
33
+ @data_provider = repo
34
+ end
27
35
  end
28
36
 
29
- # @return [String] the name of the source.
37
+ # @return [String] The name of the source.
30
38
  #
31
39
  def name
32
- repo.basename.to_s
40
+ data_provider.name
41
+ end
42
+
43
+ # @return [String] The type of the source.
44
+ #
45
+ def type
46
+ data_provider.type
33
47
  end
34
48
 
35
49
  alias_method :to_s, :name
@@ -45,37 +59,27 @@ module Pod
45
59
  name <=> other.name
46
60
  end
47
61
 
48
- #-------------------------------------------------------------------------#
62
+ # @return [String] A description suitable for debugging.
63
+ #
64
+ def inspect
65
+ "#<#{self.class} name:#{name} type:#{type}>"
66
+ end
67
+
68
+ public
49
69
 
50
70
  # @!group Queering the source
71
+ #-------------------------------------------------------------------------#
51
72
 
52
73
  # @return [Array<String>] the list of the name of all the Pods.
53
74
  #
54
- # @note Using Pathname#children is sensibly slower.
55
75
  #
56
76
  def pods
57
- specs_dir_as_string = specs_dir.to_s
58
- Dir.entries(specs_dir).select do |entry|
59
- valid_name = !(entry == '.' || entry == '..' || entry == '.git')
60
- valid_name && File.directory?(File.join(specs_dir_as_string, entry))
77
+ pods = data_provider.pods
78
+ unless pods
79
+ raise Informative, "Unable to find the #{data_provider.type} source " \
80
+ "named: `#{data_provider.name}`"
61
81
  end
62
- end
63
-
64
- # Returns the set for the Pod with the given name.
65
- #
66
- # @param [String] pod_name
67
- # The name of the Pod.
68
- #
69
- # @return [Sets] the set.
70
- #
71
- def set(pod_name)
72
- Specification::Set.new(pod_name, self)
73
- end
74
-
75
- # @return [Array<Sets>] the sets of all the Pods.
76
- #
77
- def pod_sets
78
- pods.map { |pod_name| set(pod_name) }
82
+ pods
79
83
  end
80
84
 
81
85
  # @return [Array<Version>] all the available versions for the Pod, sorted
@@ -85,12 +89,8 @@ module Pod
85
89
  # the name of the Pod.
86
90
  #
87
91
  def versions(name)
88
- pod_dir = specs_dir + name
89
- return unless pod_dir.exist?
90
- pod_dir.children.map do |v|
91
- basename = v.basename.to_s
92
- Version.new(basename) if v.directory? && basename[0, 1] != '.'
93
- end.compact.sort.reverse
92
+ versions = data_provider.versions(name)
93
+ versions.map { |version| Version.new(version) } if versions
94
94
  end
95
95
 
96
96
  # @return [Specification] the specification for a given version of Pod.
@@ -113,7 +113,7 @@ module Pod
113
113
  #
114
114
  def specification_path(name, version)
115
115
  path = specs_dir + name + version.to_s
116
- specification_path = path + "#{name}.podspec.yaml"
116
+ specification_path = path + "#{name}.podspec.json"
117
117
  unless specification_path.exist?
118
118
  specification_path = path + "#{name}.podspec"
119
119
  end
@@ -121,7 +121,7 @@ module Pod
121
121
  raise StandardError, "Unable to find the specification #{name} " \
122
122
  "(#{version}) in the #{name} source."
123
123
  end
124
- specification_path
124
+ spec
125
125
  end
126
126
 
127
127
  # @return [Array<Specification>] all the specifications contained by the
@@ -139,9 +139,43 @@ module Pod
139
139
  specs.flatten.compact
140
140
  end
141
141
 
142
- #-------------------------------------------------------------------------#
142
+ # Returns the set for the Pod with the given name.
143
+ #
144
+ # @param [String] pod_name
145
+ # The name of the Pod.
146
+ #
147
+ # @return [Sets] the set.
148
+ #
149
+ def set(pod_name)
150
+ Specification::Set.new(pod_name, self)
151
+ end
152
+
153
+ # @return [Array<Sets>] the sets of all the Pods.
154
+ #
155
+ def pod_sets
156
+ pods.map { |pod_name| set(pod_name) }
157
+ end
158
+
159
+ # Returns the path of the specification with the given name and version.
160
+ #
161
+ # @param [String] name
162
+ # the name of the Pod.
163
+ #
164
+ # @param [Version,String] version
165
+ # the version for the specification.
166
+ #
167
+ # @return [Pathname] The path of the specification.
168
+ #
169
+ # @todo Remove.
170
+ #
171
+ def specification_path(name, version)
172
+ data_provider.specification_path(name, version)
173
+ end
174
+
175
+ public
143
176
 
144
177
  # @!group Searching the source
178
+ #-------------------------------------------------------------------------#
145
179
 
146
180
  # @return [Set] a set for a given dependency. The set is identified by the
147
181
  # name of the dependency and takes into account subspecs.
@@ -162,7 +196,7 @@ module Pod
162
196
  # @return [Array<Set>] The list of the sets that contain the search term.
163
197
  #
164
198
  # @param [String] query
165
- # the search term.
199
+ # the search term. Can be a regular expression.
166
200
  #
167
201
  # @param [Bool] full_text_search
168
202
  # whether the search should be limited to the name of the Pod or
@@ -171,20 +205,31 @@ module Pod
171
205
  # @note full text search requires to load the specification for each pod,
172
206
  # hence is considerably slower.
173
207
  #
208
+ # @todo Rename to #search
209
+ #
174
210
  def search_by_name(query, full_text_search = false)
211
+ regexp_query = /#{query}/i
175
212
  if full_text_search
176
- pod_sets.map do |set|
177
- begin
178
- s = set.specification
179
- text = "#{s.name} #{s.authors} #{s.summary} #{s.description}"
180
- rescue
181
- CoreUI.warn "Skipping `#{set.name}` because the podspec " \
182
- "contains errors."
213
+ if data_provider.is_a?(FileSystemDataProvider)
214
+ pod_sets.reject do |set|
215
+ texts = []
216
+ begin
217
+ s = set.specification
218
+ texts << s.name
219
+ texts += s.authors.keys
220
+ texts << s.summary
221
+ texts << s.description
222
+ rescue
223
+ CoreUI.warn "Skipping `#{set.name}` because the podspec " \
224
+ "contains errors."
225
+ end
226
+ texts.grep(regexp_query).empty?
183
227
  end
184
- set if text && text.downcase.include?(query.downcase)
185
- end.compact
228
+ else
229
+ []
230
+ end
186
231
  else
187
- names = pods.select { |name| name.downcase.include?(query.downcase) }
232
+ names = pods.grep(regexp_query)
188
233
  names.map { |pod_name| set(pod_name) }
189
234
  end
190
235
  end
@@ -205,9 +250,10 @@ module Pod
205
250
  end
206
251
  end
207
252
 
208
- #-------------------------------------------------------------------------#
253
+ public
209
254
 
210
255
  # @!group Representations
256
+ #-------------------------------------------------------------------------#
211
257
 
212
258
  # @return [Hash{String=>{String=>Specification}}] the static representation
213
259
  # of all the specifications grouped first by name and then by
@@ -231,29 +277,26 @@ module Pod
231
277
 
232
278
  private
233
279
 
234
- #-------------------------------------------------------------------------#
235
-
236
280
  # @group Private Helpers
281
+ #-------------------------------------------------------------------------#
237
282
 
238
- # @return [Pathname] The directory where the specs are stored.
283
+ # Loads the specification for the given Pod gracefully.
239
284
  #
240
- # @note In previous versions of CocoaPods they used to be stored in
241
- # the root of the repo. This lead to issues, especially with
242
- # the GitHub interface and now the are stored in a dedicated
243
- # folder.
285
+ # @param [String] name
286
+ # the name of the Pod.
244
287
  #
245
- def specs_dir
246
- unless @specs_dir
247
- specs_sub_dir = repo + 'Specs'
248
- if specs_sub_dir.exist?
249
- @specs_dir = specs_sub_dir
250
- elsif repo.exist?
251
- @specs_dir = repo
252
- else
253
- raise Informative, "Unable to find a source named: `#{name}`"
254
- end
255
- end
256
- @specs_dir
288
+ # @return [Specification] The specification for the last version of the
289
+ # Pod.
290
+ # @return [Nil] If the spec could not be loaded.
291
+ #
292
+ def load_spec_gracefully(name)
293
+ versions = versions(name)
294
+ version = versions.sort.last if versions
295
+ specification(name, version) if version
296
+ rescue Informative
297
+ Pod::CoreUI.warn "Skipping `#{name}` because the podspec " \
298
+ "contains errors."
299
+ nil
257
300
  end
258
301
 
259
302
  #-------------------------------------------------------------------------#
@@ -0,0 +1,71 @@
1
+ module Pod
2
+ class Source
3
+
4
+ # Defines the required and the optional methods of a data provider.
5
+ #
6
+ class AbstractDataProvider
7
+
8
+ public
9
+
10
+ # @group Required methods
11
+ #-----------------------------------------------------------------------#
12
+
13
+ # @return [String] The name of the source.
14
+ #
15
+ def name
16
+ raise StandardError, "Abstract method."
17
+ end
18
+
19
+ # @return [String] The user friendly type of the source.
20
+ #
21
+ def type
22
+ raise StandardError, "Abstract method."
23
+ end
24
+
25
+ # @return [Array<String>] The list of the name of all the Pods known to
26
+ # the Source.
27
+ #
28
+ def pods
29
+ raise StandardError, "Abstract method."
30
+ end
31
+
32
+ # @return [Array<String>] All the available versions of a given Pod,
33
+ # sorted from highest to lowest.
34
+ #
35
+ # @param [String] name
36
+ # The name of the Pod.
37
+ #
38
+ def versions(name)
39
+ raise StandardError, "Abstract method."
40
+ end
41
+
42
+ # @return [Specification] The specification for a given version of a Pod.
43
+ #
44
+ # @param [String] name
45
+ # The name of the Pod.
46
+ #
47
+ # @param [String] version
48
+ # The version of the Pod.
49
+ #
50
+ def specification(name, version)
51
+ raise StandardError, "Abstract method."
52
+ end
53
+
54
+ # @return [Specification] The contents of the specification for a given
55
+ # version of a Pod.
56
+ #
57
+ # @param [String] name
58
+ # the name of the Pod.
59
+ #
60
+ # @param [String] version
61
+ # the version of the Pod.
62
+ #
63
+ def specification_contents(name, version)
64
+ raise StandardError, "Abstract method."
65
+ end
66
+
67
+ #-----------------------------------------------------------------------#
68
+
69
+ end
70
+ end
71
+ end
@@ -72,7 +72,7 @@ module Pod
72
72
  # @return [Set] The most representative set for the Pod with the given
73
73
  # name.
74
74
  #
75
- def represenative_set(name)
75
+ def representative_set(name)
76
76
  representative_source = nil
77
77
  highest_version = nil
78
78
  all.each do |source|
@@ -0,0 +1,150 @@
1
+ module Pod
2
+ class Source
3
+
4
+ # Data provider for a `Pod::Source` backed by a repository hosted in the
5
+ # file system.
6
+ #
7
+ class FileSystemDataProvider < AbstractDataProvider
8
+
9
+ # @return [Pathname] The path where the source is stored.
10
+ #
11
+ attr_reader :repo
12
+
13
+ # @param [Pathname, String] repo @see #repo.
14
+ #
15
+ def initialize(repo)
16
+ @repo = Pathname.new(repo)
17
+ end
18
+
19
+ public
20
+
21
+ # @group Required methods
22
+ #-----------------------------------------------------------------------#
23
+
24
+ # @return [String] The name of the source.
25
+ #
26
+ def name
27
+ repo.basename.to_s
28
+ end
29
+
30
+ # @return [String] The user friendly type of the source.
31
+ #
32
+ def type
33
+ "file system"
34
+ end
35
+
36
+ # @return [Array<String>] The list of the name of all the Pods known to
37
+ # the Source.
38
+ #
39
+ # @note Using Pathname#children is sensibly slower.
40
+ #
41
+ def pods
42
+ return nil unless specs_dir
43
+ specs_dir_as_string = specs_dir.to_s
44
+ Dir.entries(specs_dir).select do |entry|
45
+ valid_name = !(entry == '.' || entry == '..' || entry == '.git')
46
+ valid_name && File.directory?(File.join(specs_dir_as_string, entry))
47
+ end.sort
48
+ end
49
+
50
+ # @return [Array<String>] All the available versions of a given Pod,
51
+ # sorted from highest to lowest.
52
+ #
53
+ # @param [String] name
54
+ # The name of the Pod.
55
+ #
56
+ def versions(name)
57
+ return nil unless specs_dir
58
+ raise ArgumentError, "No name" unless name
59
+ pod_dir = specs_dir + name
60
+ return unless pod_dir.exist?
61
+ pod_dir.children.map do |v|
62
+ basename = v.basename.to_s
63
+ basename if v.directory? && basename[0, 1] != '.'
64
+ end.compact.sort.reverse
65
+ end
66
+
67
+ # @return [Specification] The specification for a given version of a Pod.
68
+ #
69
+ # @param [String] name
70
+ # The name of the Pod.
71
+ #
72
+ # @param [String] version
73
+ # The version of the Pod.
74
+ #
75
+ def specification(name, version)
76
+ path = specification_path(name, version)
77
+ Pod::Specification.from_file(path) if path && path.exist?
78
+ end
79
+
80
+ # @return [Specification] The contents of the specification for a given
81
+ # version of a Pod.
82
+ #
83
+ # @param [String] name
84
+ # the name of the Pod.
85
+ #
86
+ # @param [String] version
87
+ # the version of the Pod.
88
+ #
89
+ def specification_contents(name, version)
90
+ path = specification_path(name, version)
91
+ File.open(path, 'r:utf-8') { |f| f.read } if path && path.exist?
92
+ end
93
+
94
+ public
95
+
96
+ # @group Other methods
97
+ #-----------------------------------------------------------------------#
98
+
99
+ # Returns the path of the specification with the given name and version.
100
+ #
101
+ # @param [String] name
102
+ # the name of the Pod.
103
+ #
104
+ # @param [Version,String] version
105
+ # the version for the specification.
106
+ #
107
+ # @return [Pathname] The path of the specification.
108
+ #
109
+ def specification_path(name, version)
110
+ raise ArgumentError, "No name" unless name
111
+ raise ArgumentError, "No version" unless version
112
+ return nil unless specs_dir
113
+ path = specs_dir + name + version.to_s
114
+ specification_path = path + "#{name}.podspec.json"
115
+ specification_path.exist?
116
+ unless specification_path.exist?
117
+ specification_path = path + "#{name}.podspec"
118
+ end
119
+ specification_path
120
+ end
121
+
122
+ private
123
+
124
+ # @group Private Helpers
125
+ #-----------------------------------------------------------------------#
126
+
127
+ # @return [Pathname] The directory where the specs are stored.
128
+ #
129
+ # @note In previous versions of CocoaPods they used to be stored in
130
+ # the root of the repo. This lead to issues, especially with
131
+ # the GitHub interface and now the are stored in a dedicated
132
+ # folder.
133
+ #
134
+ def specs_dir
135
+ unless @specs_dir
136
+ specs_sub_dir = repo + 'Specs'
137
+ if specs_sub_dir.exist?
138
+ @specs_dir = specs_sub_dir
139
+ elsif repo.exist?
140
+ @specs_dir = repo
141
+ end
142
+ end
143
+ @specs_dir
144
+ end
145
+
146
+ #-----------------------------------------------------------------------#
147
+
148
+ end
149
+ end
150
+ end
@@ -0,0 +1,143 @@
1
+ module Pod
2
+ class Source
3
+
4
+ # Data provider for a `Pod::Source` backed by a repository hosted on GitHub
5
+ # and accessed via the HTTP API. Only pure JSON repos using the `Specs`
6
+ # subdir to store the specifications are supported.
7
+ #
8
+ class GitHubDataProvider < AbstractDataProvider
9
+
10
+ # @return [String] The identifier of the repository (user name and repo
11
+ # name) or the full URL of the repo.
12
+ #
13
+ attr_reader :repo_id
14
+
15
+ # @return [String] The branch of the repo if the default one shouldn't be
16
+ # used.
17
+ #
18
+ attr_reader :branch
19
+
20
+ # @param [String] repo_id @see repo_id
21
+ # @param [String] branch @see branch
22
+ #
23
+ def initialize(repo_id, branch = nil)
24
+ @repo_id = repo_id
25
+ @branch = branch
26
+ end
27
+
28
+ public
29
+
30
+ # @group Data Source
31
+ #-----------------------------------------------------------------------#
32
+
33
+ # @return [String] The name of the Source. User name and repo.
34
+ #
35
+ def name
36
+ GitHub.normalized_repo_id(repo_id)
37
+ end
38
+
39
+ # @return [String] The user friendly type of the source.
40
+ #
41
+ def type
42
+ "GitHub API"
43
+ end
44
+
45
+ # @return [Array<String>] The list of the name of all the Pods known to
46
+ # the Source.
47
+ #
48
+ def pods
49
+ root_contents = get_github_contents("Specs")
50
+ pods = dir_names(root_contents)
51
+ pods.sort if pods
52
+ end
53
+
54
+ # @return [Array<String>] All the available versions of a given Pod,
55
+ # sorted from highest to lowest.
56
+ #
57
+ # @param [String] name
58
+ # The name of the Pod.
59
+ #
60
+ def versions(name)
61
+ raise ArgumentError, "No name" unless name
62
+ contents = get_github_contents("Specs/#{name}")
63
+ dir_names(contents)
64
+ end
65
+
66
+ # @return [Specification] The specification for a given version of a Pod.
67
+ #
68
+ # @param [String] name
69
+ # The name of the Pod.
70
+ #
71
+ # @param [String] version
72
+ # The version of the Pod.
73
+ #
74
+ def specification(name, version)
75
+ raise ArgumentError, "No name" unless name
76
+ raise ArgumentError, "No version" unless version
77
+ spec_content = specification_contents(name, version)
78
+ if spec_content
79
+ Pod::Specification.from_json(spec_content)
80
+ end
81
+ end
82
+
83
+ # @return [Specification] The contents of the specification for a given
84
+ # version of a Pod.
85
+ #
86
+ # @param [String] name
87
+ # the name of the Pod.
88
+ #
89
+ # @param [String] version
90
+ # the version of the Pod.
91
+ #
92
+ def specification_contents(name, version)
93
+ raise ArgumentError, "No name" unless name
94
+ raise ArgumentError, "No version" unless version
95
+ path = "Specs/#{name}/#{version}/#{name}.podspec.json"
96
+ file_contents = get_github_contents(path)
97
+ if file_contents
98
+ if file_contents['encoding'] == 'base64'
99
+ require "base64"
100
+ Base64.decode64(file_contents['content'])
101
+ end
102
+ end
103
+ end
104
+
105
+ private
106
+
107
+ # @group Private Helpers
108
+ #-----------------------------------------------------------------------#
109
+
110
+ # Performs a get request with the given URL.
111
+ #
112
+ # @param [String] url
113
+ # The URL of the resource.
114
+ #
115
+ # @return [Array, Hash] The information of the resource as Ruby objects.
116
+ #
117
+ def get_github_contents(path = nil)
118
+ Pod::GitHub.contents(repo_id, path, branch)
119
+ end
120
+
121
+ # @param [Array] [Array<Hash>] The contents of a directory.
122
+ #
123
+ # @return [Array<String>] Returns the list of the directories given the
124
+ # contents returned for the API of a directory.
125
+ #
126
+ # @return [Nil] If the directory was not found or the contents is not an
127
+ # array.
128
+ #
129
+ def dir_names(contents)
130
+ if contents.is_a?(Array)
131
+ contents.map do |entry|
132
+ if entry['type'] == 'dir'
133
+ entry['name']
134
+ end
135
+ end.compact
136
+ end
137
+ end
138
+
139
+ #-----------------------------------------------------------------------#
140
+
141
+ end
142
+ end
143
+ end
@@ -124,7 +124,7 @@ module Pod
124
124
  # @return [void]
125
125
  #
126
126
  def check_stray_specs
127
- all_paths = Pathname.glob(source.repo + '**/*.podspec{,.yaml}')
127
+ all_paths = Pathname.glob(source.data_provider.repo + '**/*.podspec{,.json}')
128
128
  stray_specs = all_paths - report.analyzed_paths
129
129
  stray_specs.each do |path|
130
130
  report.add_message(:error, "Stray spec", path)
@@ -3,7 +3,7 @@ require 'cocoapods-core/specification/dsl'
3
3
  require 'cocoapods-core/specification/linter'
4
4
  require 'cocoapods-core/specification/root_attribute_accessors'
5
5
  require 'cocoapods-core/specification/set'
6
- require 'cocoapods-core/specification/yaml'
6
+ require 'cocoapods-core/specification/json'
7
7
 
8
8
  module Pod
9
9
 
@@ -18,7 +18,7 @@ module Pod
18
18
  include Pod::Specification::DSL
19
19
  include Pod::Specification::DSL::Deprecations
20
20
  include Pod::Specification::RootAttributesAccessors
21
- include Pod::Specification::YAMLSupport
21
+ include Pod::Specification::JSONSupport
22
22
 
23
23
  # @return [Specification] the parent of the specification unless the
24
24
  # specification is a root.
@@ -127,7 +127,9 @@ module Pod
127
127
  match_data = string_representation.match(/(\S*) \((.*)\)/)
128
128
  unless match_data
129
129
  raise Informative, "Invalid string representation for a " \
130
- "Specification: `#{string_representation}`."
130
+ "Specification: `#{string_representation}`." \
131
+ "String representation should include the name and " \
132
+ "the version of a pod."
131
133
  end
132
134
  name = match_data[1]
133
135
  vers = Version.new(match_data[2])
@@ -559,8 +561,8 @@ module Pod
559
561
  unless spec.is_a?(Specification)
560
562
  raise Informative, "Invalid podspec file at path `#{path}`."
561
563
  end
562
- when '.yaml'
563
- spec = Specification.from_yaml(spec_contents)
564
+ when '.json'
565
+ spec = Specification.from_json(spec_contents)
564
566
  else
565
567
  raise Informative, "Unsupported specification format `#{path.extname}`."
566
568
  end
@@ -29,17 +29,17 @@ module Pod
29
29
  # [convention over configuration](http://en.wikipedia.org/wiki/Convention_over_configuration)
30
30
  # and thus it can be very simple:
31
31
  #
32
- # Pod::Spec.new do |s|
33
- # s.name = 'Reachability'
34
- # s.version = '3.1.0'
35
- # s.license = { :type => 'BSD' }
36
- # s.homepage = 'https://github.com/tonymillion/Reachability'
37
- # s.authors = { 'Tony Million' => 'tonymillion@gmail.com' }
38
- # s.summary = 'ARC and GCD Compatible Reachability Class for iOS and OS X. Drop in replacement for Apple Reachability.'
39
- # s.source = { :git => 'https://github.com/tonymillion/Reachability.git', :tag => 'v3.1.0' }
40
- # s.source_files = 'Reachability.{h,m}'
41
- # s.framework = 'SystemConfiguration'
42
- # s.requires_arc = true
32
+ # Pod::Spec.new do |spec|
33
+ # spec.name = 'Reachability'
34
+ # spec.version = '3.1.0'
35
+ # spec.license = { :type => 'BSD' }
36
+ # spec.homepage = 'https://github.com/tonymillion/Reachability'
37
+ # spec.authors = { 'Tony Million' => 'tonymillion@gmail.com' }
38
+ # spec.summary = 'ARC and GCD Compatible Reachability Class for iOS and OS X. Drop in replacement for Apple Reachability.'
39
+ # spec.source = { :git => 'https://github.com/tonymillion/Reachability.git', :tag => 'v3.1.0' }
40
+ # spec.source_files = 'Reachability.{h,m}'
41
+ # spec.framework = 'SystemConfiguration'
42
+ # spec.requires_arc = true
43
43
  # end
44
44
  #
45
45
  module DSL
@@ -259,7 +259,7 @@ module Pod
259
259
  #
260
260
  # spec.source = { :hg => "https://bitbucket.org/dcutting/hyperbek", :revision => "#{s.version}" }
261
261
  #
262
- # @example Using HTTP to download a compressed file of the code. It supports zip, tgz, bz2 and tar.
262
+ # @example Using HTTP to download a compressed file of the code. It supports zip, tgz, bz2, txz and tar.
263
263
  #
264
264
  # spec.source = { :http => "http://dev.wechatapp.com/download/sdk/WeChat_SDK_iOS_en.zip" }
265
265
  #
@@ -988,7 +988,7 @@ module Pod
988
988
  # attribute.
989
989
  #
990
990
  # The names of the bundles should at least include the name of the Pod
991
- # to minimize the change of name collisions.
991
+ # to minimize the chance of name collisions.
992
992
  #
993
993
  # To provide different resources per platform namespaced bundles *must*
994
994
  # be used.
@@ -96,7 +96,7 @@ module Pod
96
96
  CoreUI.warn "[#{to_s}] The pre install hook of the specification " \
97
97
  "DSL has been deprecated, use the `resource_bundles` or the " \
98
98
  "`prepare_command` attributes."
99
- @pre_install_callback = block
99
+ @pre_install_callback = block
100
100
  end
101
101
 
102
102
  # This is a convenience method which gets called after all pods have been
@@ -126,7 +126,7 @@ module Pod
126
126
  CoreUI.warn "[#{to_s}] The post install hook of the specification " \
127
127
  "DSL has been deprecated, use the `resource_bundles` or the " \
128
128
  "`prepare_command` attributes."
129
- @post_install_callback = block
129
+ @post_install_callback = block
130
130
  end
131
131
 
132
132
  #-----------------------------------------------------------------------#
@@ -1,13 +1,16 @@
1
1
  module Pod
2
2
  class Specification
3
- module YAMLSupport
3
+ module JSONSupport
4
4
 
5
- # @return [String] the yaml representation of the specification.
5
+ # @return [String] the json representation of the specification.
6
6
  #
7
- def to_yaml
8
- to_hash.to_yaml
7
+ def to_json(*a)
8
+ require 'json'
9
+ to_hash.to_json(*a)
9
10
  end
10
11
 
12
+ #-----------------------------------------------------------------------#
13
+
11
14
  # @return [Hash] the hash representation of the specification including
12
15
  # subspecs.
13
16
  #
@@ -25,7 +28,20 @@ module Pod
25
28
  def safe_to_hash?
26
29
  pre_install_callback.nil? && post_install_callback.nil?
27
30
  end
31
+ end
28
32
 
33
+ # Configures a new specification from the given JSON representation.
34
+ #
35
+ # @param [String] the JSON encoded hash which contains the information of
36
+ # the specification.
37
+ #
38
+ #
39
+ # @return [Specification] the specification
40
+ #
41
+ def self.from_json(json)
42
+ require 'json'
43
+ hash = JSON.parse(json)
44
+ from_hash(hash)
29
45
  end
30
46
 
31
47
  # Configures a new specification from the given hash.
@@ -48,17 +64,7 @@ module Pod
48
64
  spec
49
65
  end
50
66
 
51
- # Configures a new specification from the given YAML representation.
52
- #
53
- # @param [String] the YAML encoded hash which contains the information of
54
- # the specification.
55
- #
56
- #
57
- # @return [Specification] the specification
58
- #
59
- def self.from_yaml(yaml)
60
- hash = YAML.load(yaml)
61
- from_hash(hash)
62
- end
67
+ #-----------------------------------------------------------------------#
68
+
63
69
  end
64
70
  end
@@ -189,9 +189,9 @@ module Pod
189
189
  #
190
190
  # @return [void]
191
191
  #
192
- def run_validation_hooks(attributes)
193
-
194
- end
192
+ # def run_validation_hooks(attributes)
193
+ #
194
+ # end
195
195
 
196
196
  #-----------------------------------------------------------------------#
197
197
 
@@ -205,12 +205,16 @@ module Pod
205
205
  if spec.name && file
206
206
  acceptable_names = [
207
207
  spec.root.name + '.podspec',
208
- spec.root.name + '.podspec.yaml'
208
+ spec.root.name + '.podspec.json'
209
209
  ]
210
210
  names_match = acceptable_names.include?(file.basename.to_s)
211
211
  unless names_match
212
212
  error "The name of the spec should match the name of the file."
213
213
  end
214
+
215
+ if spec.root.name =~ /\s/
216
+ error "The name of a spec should not contain whitespace."
217
+ end
214
218
  end
215
219
  end
216
220
 
@@ -248,12 +252,38 @@ module Pod
248
252
  end
249
253
  end
250
254
 
255
+ # Performs validations related to the `homepage` attribute.
256
+ #
251
257
  def _validate_homepage(h)
252
258
  if h =~ %r[http://EXAMPLE]
253
259
  warning "The homepage has not been updated from default"
254
260
  end
255
261
  end
256
262
 
263
+ # Performs validations related to the `frameworks` attribute.
264
+ #
265
+ def _validate_frameworks(frameworks)
266
+ if frameworks_invalid?(frameworks)
267
+ error "A framework should only be specified by its name"
268
+ end
269
+ end
270
+
271
+ # Performs validations related to the `weak frameworks` attribute.
272
+ #
273
+ def _validate_weak_frameworks(frameworks)
274
+ if frameworks_invalid?(frameworks)
275
+ error "A weak framework should only be specified by its name"
276
+ end
277
+ end
278
+
279
+ # Performs validations related to the `libraries` attribute.
280
+ #
281
+ def _validate_libraries(libs)
282
+ if libraries_invalid?(libs)
283
+ error "A library should only be specified by its name"
284
+ end
285
+ end
286
+
257
287
  # Performs validations related to the `license` attribute.
258
288
  #
259
289
  def _validate_license(l)
@@ -391,6 +421,28 @@ module Pod
391
421
  end
392
422
  end
393
423
 
424
+ # Returns whether the frameworks are valid
425
+ #
426
+ # @params frameworks [Array<String>]
427
+ # The frameworks to be validated
428
+ #
429
+ # @return [Boolean] true if a framework ends in `.framework`
430
+ #
431
+ def frameworks_invalid?(frameworks)
432
+ frameworks.any? { |framework| framework.end_with?('.framework') }
433
+ end
434
+
435
+ # Returns whether the libraries are valid
436
+ #
437
+ # @params libs [Array<String>]
438
+ # The libraries to be validated
439
+ #
440
+ # @return [Boolean] true if a library ends with `.a`, `.dylib`, or
441
+ # starts with `lib`.
442
+ def libraries_invalid?(libs)
443
+ libs.any? { |lib| lib.end_with?('.a', '.dylib') || lib.start_with?('lib') }
444
+ end
445
+
394
446
  #-----------------------------------------------------------------------#
395
447
 
396
448
  # !@group Result Helpers
@@ -220,8 +220,8 @@ module Pod
220
220
  def compute_creation_date(set)
221
221
  date = get_value(set, :creation_date)
222
222
  unless date
223
- Dir.chdir(set.sources.first.repo) do
224
- git_log = `git log --first-parent --format=%ct #{set.name}`
223
+ Dir.chdir(set.sources.first.data_provider.repo) do
224
+ git_log = `git log --first-parent --format=%ct "#{set.name}"`
225
225
  creation_date = git_log.split("\n").last.to_i
226
226
  date = Time.at(creation_date)
227
227
  end
@@ -246,8 +246,8 @@ module Pod
246
246
  return if update_date && update_date > (Time.now - cache_expiration)
247
247
 
248
248
  spec = set.specification
249
- url = spec.source[:git] || ''
250
- repo = GitHub.repo(url)
249
+ url = spec.source[:git]
250
+ repo = GitHub.repo(url) if url
251
251
 
252
252
  if repo
253
253
  set_value(set, :gh_watchers, repo['watchers'])
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.28.0
4
+ version: 0.29.0
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: 2013-11-14 00:00:00.000000000 Z
12
+ date: 2013-12-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -46,7 +46,7 @@ dependencies:
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.5'
48
48
  - !ruby/object:Gem::Dependency
49
- name: json
49
+ name: json_pure
50
50
  requirement: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ~>
@@ -108,8 +108,11 @@ files:
108
108
  - lib/cocoapods-core/podfile/target_definition.rb
109
109
  - lib/cocoapods-core/podfile.rb
110
110
  - lib/cocoapods-core/requirement.rb
111
+ - lib/cocoapods-core/source/abstract_data_provider.rb
111
112
  - lib/cocoapods-core/source/acceptor.rb
112
113
  - lib/cocoapods-core/source/aggregate.rb
114
+ - lib/cocoapods-core/source/file_system_data_provider.rb
115
+ - lib/cocoapods-core/source/github_data_provider.rb
113
116
  - lib/cocoapods-core/source/health_reporter.rb
114
117
  - lib/cocoapods-core/source.rb
115
118
  - lib/cocoapods-core/specification/consumer.rb
@@ -118,12 +121,12 @@ files:
118
121
  - lib/cocoapods-core/specification/dsl/deprecations.rb
119
122
  - lib/cocoapods-core/specification/dsl/platform_proxy.rb
120
123
  - lib/cocoapods-core/specification/dsl.rb
124
+ - lib/cocoapods-core/specification/json.rb
121
125
  - lib/cocoapods-core/specification/linter.rb
122
126
  - lib/cocoapods-core/specification/root_attribute_accessors.rb
123
127
  - lib/cocoapods-core/specification/set/presenter.rb
124
128
  - lib/cocoapods-core/specification/set/statistics.rb
125
129
  - lib/cocoapods-core/specification/set.rb
126
- - lib/cocoapods-core/specification/yaml.rb
127
130
  - lib/cocoapods-core/specification.rb
128
131
  - lib/cocoapods-core/standard_error.rb
129
132
  - lib/cocoapods-core/vendor/requirement.rb