cocoapods-links 0.1.0 → 0.2.0

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: 8f6dfa8e827e6e802fd332318988367826582abc
4
- data.tar.gz: 41177f411fcf5d1e58fbded0a49d036beb7720d1
3
+ metadata.gz: 0defda2414869d041a19060d7b9c9193f1849003
4
+ data.tar.gz: 1f415a1613a482f2133e1ef24ac186c02f9a280a
5
5
  SHA512:
6
- metadata.gz: e0176b4d5c15d542e87cb81886865c59798a00ac0b013a2834558f573d31e1f0e423d905f4715929ddeb6dc027ff2d37f8953939ebfc2720d7d8a8b4a434ad9d
7
- data.tar.gz: b45cc452c2d3047c3d41e7543cba9ae4da3ae824e336fdfcf477a0afa0fdb3d9e8406471b2f4d01b3d0e6c49fdf3122d8d16bbb2df3339a2a39359d4c96f1024
6
+ metadata.gz: 62a21ae117b79564ceaabfdb6118eef8b46837541fa0103752ed32bd4fc6c1ffe99bd349965f66a5d87fcdd7536b3ac75167f1bba4d67aa5bb236b5685e9f607
7
+ data.tar.gz: 9c01e974e73845a2bace2d40825fc5a7021121c3d64530e50a31f497620b030b1e71615c1665f646234f9992f198d523c92a82def2d4a0d6c764e293ca7ba7f2
data/Gemfile.lock CHANGED
@@ -1,67 +1,70 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocoapods-links (0.1.0)
4
+ cocoapods-links (0.2.0)
5
5
  cocoapods (~> 0.35)
6
6
  json (~> 1.8)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (4.2.0)
11
+ activesupport (4.2.5)
12
12
  i18n (~> 0.7)
13
13
  json (~> 1.7, >= 1.7.7)
14
14
  minitest (~> 5.1)
15
15
  thread_safe (~> 0.3, >= 0.3.4)
16
16
  tzinfo (~> 1.1)
17
17
  bacon (1.2.0)
18
- claide (0.7.0)
19
- cocoapods (0.35.0)
20
- activesupport (>= 3.2.15)
21
- claide (~> 0.7.0)
22
- cocoapods-core (= 0.35.0)
23
- cocoapods-downloader (~> 0.8.0)
24
- cocoapods-plugins (~> 0.3.1)
25
- cocoapods-trunk (~> 0.4.1)
26
- cocoapods-try (~> 0.4.2)
18
+ claide (0.9.1)
19
+ cocoapods (0.39.0)
20
+ activesupport (>= 4.0.2)
21
+ claide (~> 0.9.1)
22
+ cocoapods-core (= 0.39.0)
23
+ cocoapods-downloader (~> 0.9.3)
24
+ cocoapods-plugins (~> 0.4.2)
25
+ cocoapods-search (~> 0.1.0)
26
+ cocoapods-stats (~> 0.6.2)
27
+ cocoapods-trunk (~> 0.6.4)
28
+ cocoapods-try (~> 0.5.1)
27
29
  colored (~> 1.2)
28
30
  escape (~> 0.0.4)
29
- molinillo (~> 0.1.2)
30
- nap (~> 0.8)
31
- open4 (~> 1.3)
32
- xcodeproj (~> 0.20.2)
33
- cocoapods-core (0.35.0)
34
- activesupport (>= 3.2.15)
31
+ molinillo (~> 0.4.0)
32
+ nap (~> 1.0)
33
+ xcodeproj (~> 0.28.2)
34
+ cocoapods-core (0.39.0)
35
+ activesupport (>= 4.0.2)
35
36
  fuzzy_match (~> 2.0.4)
36
- nap (~> 0.8.0)
37
- cocoapods-downloader (0.8.1)
38
- cocoapods-plugins (0.3.2)
37
+ nap (~> 1.0)
38
+ cocoapods-downloader (0.9.3)
39
+ cocoapods-plugins (0.4.2)
39
40
  nap
40
- cocoapods-trunk (0.4.1)
41
- nap (>= 0.8)
41
+ cocoapods-search (0.1.0)
42
+ cocoapods-stats (0.6.2)
43
+ cocoapods-trunk (0.6.4)
44
+ nap (>= 0.8, < 2.0)
42
45
  netrc (= 0.7.8)
43
- cocoapods-try (0.4.3)
46
+ cocoapods-try (0.5.1)
44
47
  colored (1.2)
45
48
  escape (0.0.4)
46
49
  fuzzy_match (2.0.4)
47
50
  i18n (0.7.0)
48
- json (1.8.2)
51
+ json (1.8.3)
49
52
  metaclass (0.0.4)
50
- minitest (5.5.1)
53
+ minitest (5.8.3)
51
54
  mocha (1.1.0)
52
55
  metaclass (~> 0.0.1)
53
56
  mocha-on-bacon (0.2.2)
54
57
  mocha (>= 0.13.0)
55
- molinillo (0.1.2)
56
- nap (0.8.0)
58
+ molinillo (0.4.1)
59
+ nap (1.0.0)
57
60
  netrc (0.7.8)
58
- open4 (1.3.4)
59
61
  rake (10.4.2)
60
- thread_safe (0.3.4)
62
+ thread_safe (0.3.5)
61
63
  tzinfo (1.2.2)
62
64
  thread_safe (~> 0.1)
63
- xcodeproj (0.20.2)
65
+ xcodeproj (0.28.2)
64
66
  activesupport (>= 3)
67
+ claide (~> 0.9.1)
65
68
  colored (~> 1.2)
66
69
 
67
70
  PLATFORMS
@@ -74,3 +77,6 @@ DEPENDENCIES
74
77
  mocha
75
78
  mocha-on-bacon
76
79
  rake
80
+
81
+ BUNDLED WITH
82
+ 1.11.2
data/README.md CHANGED
@@ -23,21 +23,24 @@ you modify your `Podfile`:
23
23
  ```ruby
24
24
  pod 'Bar', :path => "/path/to/bar/checkout"
25
25
  ```
26
- The problem with this you have to make a temporary change to your `Podfile`
26
+ This development flow requires you to make a temporary change to your `Podfile`
27
27
  that is managed by source control. Wouldn't it be great if CocoaPods offered a means to manage
28
28
  development pods without having to alter files under source control?
29
29
 
30
30
  Enter cocoapods-links.
31
31
 
32
- Wtth cocoapods-links link functionality allows developers to easily test their pods.
32
+ With cocoapods-links, developers can easily test their pods using the provided link functionality.
33
33
  Linking is a two-step process:
34
34
 
35
- Using `pod link` in a project folder will register a global link. Then, in some other pod,
36
- `pod link <name>` will create a link to the registered pod as a Development pod.
35
+ Using `pod link` in a project folder will register a global link. Then, in another pod,
36
+ `pod link <name>` will create a link to the registered pod as a development pod.
37
37
 
38
- This allows to easily test a pod because changes will be reflected immediately.
38
+ This allows developers to easily test a pod because changes will be reflected immediately.
39
39
  When the link is no longer necessary, simply remove it with `pod unlink <name>`.
40
40
 
41
+ **NOTE:** Although the `Podfile` and `Podfile.lock` will not be updated using links, the Pods xcodeproj will be updated. If you check in the contents of your Pods directory then you must make sure
42
+ to unlink your development pods prior to committing any changes.
43
+
41
44
  ## Usage
42
45
 
43
46
  #### Register
@@ -1,3 +1,3 @@
1
1
  module CocoapodsLinks
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require 'pod/pod'
2
+ require 'pod/lockfile'
2
3
  require 'pod/command/link'
3
4
  require 'pod/command/unlink'
4
5
  require 'pod/command/list'
data/lib/pod/links.rb CHANGED
@@ -146,6 +146,21 @@ module Pod
146
146
  end
147
147
  end
148
148
 
149
+ #
150
+ # Get list of pods that are linked for the current pod project
151
+ #
152
+ # @return an array of installed links
153
+ #
154
+ def self.installed_links
155
+ installed = []
156
+ self.linked_pods.each do |pod|
157
+ unless self.get_registered_link(pod).nil?
158
+ installed.append(pod)
159
+ end
160
+ end
161
+ return installed
162
+ end
163
+
149
164
  #
150
165
  # Prints a formatted message with the Pod Links prefix
151
166
  #
@@ -0,0 +1,244 @@
1
+ require 'pod/links'
2
+
3
+ #
4
+ # Logic:
5
+ # Override of the Lockfile generation to filter out linked pods in favor of their previously
6
+ # installed state (e.g. the state reflected from the Podfile). This is somewhat brittle as it
7
+ # depends on the format of the Lockfile hash contents. If the format changes, then this will also
8
+ # need to be changed. It would be far better to integrate the link filtering elsewhere but this
9
+ # works "for now"
10
+ #
11
+
12
+ module Pod
13
+ class Lockfile
14
+
15
+ PODFILE_LOCK = "Podfile.lock"
16
+
17
+ alias_method :real_write_to_disk, :write_to_disk
18
+
19
+ #
20
+ # Hook the Podfile.lock file generation to allow us to filter out the links added to the
21
+ # Podfile.lock. The logic here is to replace the new Podfile.lock link content with what existed
22
+ # before the link was added. Currently, this is called for both Podfile.lock and Manifest.lock
23
+ # file so we only want to alter the Podfile.lock
24
+ #
25
+ # @param path path to write the .lock file to
26
+ #
27
+ def write_to_disk(path)
28
+
29
+ # code here mimics the original method but with link filtering
30
+ filename = File.basename(path)
31
+ path.dirname.mkpath unless path.dirname.exist?
32
+ yaml = to_link_yaml
33
+ File.open(path, 'w') { |f| f.write(yaml) }
34
+ self.defined_in_file = path
35
+ end
36
+
37
+ #
38
+ # Will create pretty print YAML stringfrom the links hash that is to be dumped to a Podfile.lock
39
+ #
40
+ # This code is identical to `to_yaml` except we pass the `to_link_hash` instead of the `to_hash`
41
+ #
42
+ # @returns the YAML string content to dump to a Podfile.lock without link content
43
+ #
44
+ def to_link_yaml
45
+ keys_hint = [
46
+ 'PODS',
47
+ 'DEPENDENCIES',
48
+ 'EXTERNAL SOURCES',
49
+ 'CHECKOUT OPTIONS',
50
+ 'SPEC CHECKSUMS',
51
+ 'COCOAPODS',
52
+ ]
53
+ YAMLHelper.convert_hash(to_link_hash, keys_hint, "\n\n")
54
+ end
55
+
56
+ #
57
+ # Will get the Podfile.lock contents hash after replacing the linked content with its previous
58
+ # Podfile.lock information keeping the Podfile and Podfile.lock in sync and clear of any link
59
+ # data
60
+ #
61
+ # @returns hash that is to be dumped to the Podfile.lock file without link content
62
+ #
63
+ def to_link_hash
64
+
65
+ # retrieve the lock contents with links
66
+ after_hash = to_hash
67
+
68
+ unless File.exists?(PODFILE_LOCK)
69
+ return after_hash
70
+ end
71
+
72
+ # retrieve the lock content before the links
73
+ before_hash = YAML.load(File.read(PODFILE_LOCK))
74
+
75
+ # retrieve installed links
76
+ links = Pod::Command::Links.installed_links
77
+
78
+ #
79
+ # Logic:
80
+ # Here we will replace anything that changed in the contents that will be dumped in the
81
+ # Podfile.lock due to links with the data that previously exists in the Podfile.lock. This
82
+ # allows the Podfile.lock with the dependency trees to remain unchanged when linking
83
+ # developement pods. The Podfile.lock contains several keys, but we only need to alter the
84
+ # following:
85
+ #
86
+ # - PODS
87
+ # - DEPENDENCIES
88
+ # - EXTERNAL SOURCES
89
+ # - CHECKOUT OPTIONS
90
+ # - SPEC CHECKSUMS
91
+ #
92
+ after_hash['PODS'] =
93
+ merge_pods links, before_hash['PODS'], after_hash['PODS']
94
+
95
+ after_hash['DEPENDENCIES'] =
96
+ merge_dependencies links, before_hash['DEPENDENCIES'], after_hash['DEPENDENCIES']
97
+
98
+ after_hash['EXTERNAL SOURCES'] =
99
+ merge_hashes links, before_hash['EXTERNAL SOURCES'], after_hash['EXTERNAL SOURCES']
100
+
101
+ after_hash['CHECKOUT OPTIONS'] =
102
+ merge_hashes links, before_hash['CHECKOUT OPTIONS'], after_hash['CHECKOUT OPTIONS']
103
+
104
+ after_hash['SPEC CHECKSUMS'] =
105
+ merge_hashes links, before_hash['SPEC CHECKSUMS'], after_hash['SPEC CHECKSUMS']
106
+
107
+ return after_hash
108
+ end
109
+
110
+ def merge_pods(links, before, after)
111
+ links.each do |link|
112
+ before_index = find_pod_index before, link
113
+ after_index = find_pod_index after, link
114
+ unless before_index.nil? || after_index.nil?
115
+
116
+ # get previous value
117
+ after_value = after[after_index]
118
+
119
+ # update new value
120
+ after[after_index] = before[before_index]
121
+
122
+ # iterate and update all dependencies of previous value
123
+ if after_value.is_a?(Hash)
124
+
125
+ # clean all deps that may have been added as new deps
126
+ after_value[after_value.keys[0]].each do |key|
127
+ # key: CocoaLumberjack/Core or CocoaLumberjack/Extensions (= 1.9.2)
128
+ key_desc = key.split(" (", 2)[0]
129
+
130
+ inner_after_index = find_pod_index after, key_desc
131
+ inner_before_index = find_pod_index before, key_desc
132
+
133
+ unless inner_before_index.nil? && inner_after_index.nil?
134
+ after[inner_after_index] = before[inner_before_index]
135
+ else
136
+ # if it was removed in the new deps
137
+ unless before_index.nil?
138
+ after.insert(before_index, before[before_index])
139
+ end
140
+ end
141
+ end
142
+ end
143
+ end
144
+ end
145
+ return after
146
+ end
147
+
148
+ #
149
+ # Will merge the DEPENDENCIES of the Podfile.lock before a link and after a link
150
+ #
151
+ # @param links the installed links
152
+ # @param before the DEPENDENCIES in the Podfile.lock before the link occurs
153
+ # @param after the DEPENDENCIES after the link (includes new link that we want to filter out)
154
+ #
155
+ # @returns the merged DEPENDENCIES replacing any links that were added with their previous value
156
+ #
157
+ def merge_dependencies(links, before, after)
158
+ links.each do |link|
159
+ before_index = find_dependency_index before, link
160
+ after_index = find_dependency_index after, link
161
+ unless before_index.nil? || after_index.nil?
162
+ after[after_index] = before[before_index]
163
+ end
164
+ end
165
+ return after
166
+ end
167
+
168
+ #
169
+ # Will merge the hashes of the Podfile.lock before a link and after a link
170
+ #
171
+ # @param links the installed links
172
+ # @param before the hash in the Podfile.lock before the link occurs
173
+ # @param after the hash after the link (includes new link that we want to filter out)
174
+ #
175
+ # @returns the merged hash replacing any links that were added with their previous value
176
+ #
177
+ def merge_hashes(links, before, after)
178
+ if before.nil?
179
+ return after
180
+ end
181
+ links.each do |link|
182
+ if before.has_key?(link)
183
+ after[link] = before[link]
184
+ else
185
+ if after.has_key?(link)
186
+ after.delete(link)
187
+ end
188
+ end
189
+ end
190
+ return after
191
+ end
192
+
193
+ private
194
+
195
+ #
196
+ # Find the index in the pod array based on the link name. The pod array
197
+ # also contains version/path information so we need to massage the pod value
198
+ # for comparison. Pods are in the following format:
199
+ #
200
+ # Name (requirements)
201
+ #
202
+ # Example:
203
+ # Alamofire (= 1.1.3)
204
+ #
205
+ # @param pods the array to search
206
+ # @param name the name of the pod to find
207
+ #
208
+ # NOTE: the pods in the array can be strings or hashes, so we will check for both
209
+ #
210
+ # @return the index of nil
211
+ #
212
+ def find_pod_index(pods, name)
213
+ pods.index { |pod|
214
+ desc = pod
215
+ if pod.is_a?(Hash)
216
+ desc = pod.keys[0]
217
+ end
218
+ desc.split(" (", 2)[0] == name
219
+ }
220
+ end
221
+
222
+ #
223
+ # Find the index in the dependency array based on the link name. The dependency array
224
+ # also contains version/path information so we need to massage the dependency value
225
+ # for comparison. Dependencies are in the following format:
226
+ #
227
+ # Name (requirements)
228
+ #
229
+ # Example:
230
+ # Alamofire (= 1.1.3)
231
+ # Quick (from `https://github.com/Quick/Quick`, tag `v0.2.2`)
232
+ #
233
+ # @param dependencies the array to search
234
+ # @param name the name of the dependency to find
235
+ #
236
+ # @returns the index of nil
237
+ #
238
+ def find_dependency_index(dependencies, name)
239
+ dependencies.index { |dependency|
240
+ dependency.split(" (", 2)[0] == name
241
+ }
242
+ end
243
+ end
244
+ end
data/lib/pod/pod.rb CHANGED
@@ -15,7 +15,13 @@ module Pod
15
15
  # via the link instead of the provided requirements (e.g. it will setup local pod development
16
16
  # for the link). If the link does not exist, then the pod will be installed normally
17
17
  #
18
- link = Pod::Command::Links.get_link(name)
18
+
19
+ # handle subspec link
20
+ linked_name = name
21
+ if name.include? "/"
22
+ linked_name = name.split("/")[0]
23
+ end
24
+ link = Pod::Command::Links.get_link(linked_name)
19
25
  unless link.nil?
20
26
  Pod::Command::Links.print "Using link '#{name}' > #{link['path']}"
21
27
  real_pod(name, :path => link['path'], &block)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-links
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Owens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-11 00:00:00.000000000 Z
11
+ date: 2016-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods
@@ -90,6 +90,7 @@ files:
90
90
  - lib/pod/command/list.rb
91
91
  - lib/pod/command/unlink.rb
92
92
  - lib/pod/links.rb
93
+ - lib/pod/lockfile.rb
93
94
  - lib/pod/pod.rb
94
95
  - spec/command/link_spec.rb
95
96
  - spec/command/list_spec.rb