cocoapods-links 0.1.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 +7 -0
- data/.gitignore +1 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +76 -0
- data/LICENSE +22 -0
- data/README.md +86 -0
- data/Rakefile +18 -0
- data/cocoapods_links.gemspec +34 -0
- data/lib/cocoapods_links.rb +3 -0
- data/lib/cocoapods_plugin.rb +4 -0
- data/lib/pod/command/link.rb +44 -0
- data/lib/pod/command/list.rb +30 -0
- data/lib/pod/command/unlink.rb +44 -0
- data/lib/pod/links.rb +239 -0
- data/lib/pod/pod.rb +28 -0
- data/spec/command/link_spec.rb +15 -0
- data/spec/command/list_spec.rb +15 -0
- data/spec/command/unlink_spec.rb +15 -0
- data/spec/spec_helper.rb +8 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8f6dfa8e827e6e802fd332318988367826582abc
|
4
|
+
data.tar.gz: 41177f411fcf5d1e58fbded0a49d036beb7720d1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e0176b4d5c15d542e87cb81886865c59798a00ac0b013a2834558f573d31e1f0e423d905f4715929ddeb6dc027ff2d37f8953939ebfc2720d7d8a8b4a434ad9d
|
7
|
+
data.tar.gz: b45cc452c2d3047c3d41e7543cba9ae4da3ae824e336fdfcf477a0afa0fdb3d9e8406471b2f4d01b3d0e6c49fdf3122d8d16bbb2df3339a2a39359d4c96f1024
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cocoapods-links (0.1.0)
|
5
|
+
cocoapods (~> 0.35)
|
6
|
+
json (~> 1.8)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (4.2.0)
|
12
|
+
i18n (~> 0.7)
|
13
|
+
json (~> 1.7, >= 1.7.7)
|
14
|
+
minitest (~> 5.1)
|
15
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
16
|
+
tzinfo (~> 1.1)
|
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)
|
27
|
+
colored (~> 1.2)
|
28
|
+
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)
|
35
|
+
fuzzy_match (~> 2.0.4)
|
36
|
+
nap (~> 0.8.0)
|
37
|
+
cocoapods-downloader (0.8.1)
|
38
|
+
cocoapods-plugins (0.3.2)
|
39
|
+
nap
|
40
|
+
cocoapods-trunk (0.4.1)
|
41
|
+
nap (>= 0.8)
|
42
|
+
netrc (= 0.7.8)
|
43
|
+
cocoapods-try (0.4.3)
|
44
|
+
colored (1.2)
|
45
|
+
escape (0.0.4)
|
46
|
+
fuzzy_match (2.0.4)
|
47
|
+
i18n (0.7.0)
|
48
|
+
json (1.8.2)
|
49
|
+
metaclass (0.0.4)
|
50
|
+
minitest (5.5.1)
|
51
|
+
mocha (1.1.0)
|
52
|
+
metaclass (~> 0.0.1)
|
53
|
+
mocha-on-bacon (0.2.2)
|
54
|
+
mocha (>= 0.13.0)
|
55
|
+
molinillo (0.1.2)
|
56
|
+
nap (0.8.0)
|
57
|
+
netrc (0.7.8)
|
58
|
+
open4 (1.3.4)
|
59
|
+
rake (10.4.2)
|
60
|
+
thread_safe (0.3.4)
|
61
|
+
tzinfo (1.2.2)
|
62
|
+
thread_safe (~> 0.1)
|
63
|
+
xcodeproj (0.20.2)
|
64
|
+
activesupport (>= 3)
|
65
|
+
colored (~> 1.2)
|
66
|
+
|
67
|
+
PLATFORMS
|
68
|
+
ruby
|
69
|
+
|
70
|
+
DEPENDENCIES
|
71
|
+
bacon
|
72
|
+
bundler (~> 1.6)
|
73
|
+
cocoapods-links!
|
74
|
+
mocha
|
75
|
+
mocha-on-bacon
|
76
|
+
rake
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Mike Owens <mike.owens11@gmail.com>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# cocoapods-links
|
2
|
+
|
3
|
+
A CocoaPods plugin to manage local development pods
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```bash
|
8
|
+
gem install cocoapods-links
|
9
|
+
```
|
10
|
+
|
11
|
+
## Purpose
|
12
|
+
Let's face it, pod development with local dependencies can be a pain. Let's say you have a project
|
13
|
+
`MyApp` a few pods declared in your `Podfile`:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
pod 'Foo', '~> 1.0.0'
|
17
|
+
pod 'Bar', :git => 'https://github.com/MyCompany/Bar.git', :tag => "1.0.1"
|
18
|
+
```
|
19
|
+
|
20
|
+
Perhaps you need to make some modifications to `Bar` to implement a new feature in `MyApp`. So
|
21
|
+
you modify your `Podfile`:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
pod 'Bar', :path => "/path/to/bar/checkout"
|
25
|
+
```
|
26
|
+
The problem with this you have to make a temporary change to your `Podfile`
|
27
|
+
that is managed by source control. Wouldn't it be great if CocoaPods offered a means to manage
|
28
|
+
development pods without having to alter files under source control?
|
29
|
+
|
30
|
+
Enter cocoapods-links.
|
31
|
+
|
32
|
+
Wtth cocoapods-links link functionality allows developers to easily test their pods.
|
33
|
+
Linking is a two-step process:
|
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.
|
37
|
+
|
38
|
+
This allows to easily test a pod because changes will be reflected immediately.
|
39
|
+
When the link is no longer necessary, simply remove it with `pod unlink <name>`.
|
40
|
+
|
41
|
+
## Usage
|
42
|
+
|
43
|
+
#### Register
|
44
|
+
To register a pod for local development linking:
|
45
|
+
|
46
|
+
```bash
|
47
|
+
pod link
|
48
|
+
```
|
49
|
+
|
50
|
+
#### Unregister
|
51
|
+
To unregister a pod:
|
52
|
+
|
53
|
+
```bash
|
54
|
+
pod unlink
|
55
|
+
```
|
56
|
+
|
57
|
+
#### Link
|
58
|
+
To link a pod for use in another pod project:
|
59
|
+
|
60
|
+
```bash
|
61
|
+
pod link <name>
|
62
|
+
```
|
63
|
+
|
64
|
+
#### Unlink
|
65
|
+
To unlink a pod from a pod project:
|
66
|
+
|
67
|
+
```bash
|
68
|
+
pod unlink <name>
|
69
|
+
```
|
70
|
+
|
71
|
+
#### List
|
72
|
+
To list all registered pods
|
73
|
+
|
74
|
+
```bash
|
75
|
+
pod list links
|
76
|
+
```
|
77
|
+
|
78
|
+
To list all linked pods in a pod project:
|
79
|
+
|
80
|
+
```bash
|
81
|
+
pod list links --linked
|
82
|
+
```
|
83
|
+
|
84
|
+
### License
|
85
|
+
|
86
|
+
cocoapods-links is released under the MIT license. See [LICENSE](LICENSE).
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
|
3
|
+
task :default => :spec
|
4
|
+
|
5
|
+
task :spec do
|
6
|
+
title 'Running Specs'
|
7
|
+
files = FileList['spec/**/*_spec.rb'].shuffle.join(' ')
|
8
|
+
sh "bundle exec bacon #{files}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def title(title)
|
12
|
+
cyan_title = "\033[0;36m#{title}\033[0m"
|
13
|
+
puts
|
14
|
+
puts '-' * 80
|
15
|
+
puts cyan_title
|
16
|
+
puts '-' * 80
|
17
|
+
puts
|
18
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cocoapods_links.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'cocoapods-links'
|
8
|
+
spec.version = CocoapodsLinks::VERSION
|
9
|
+
spec.authors = ['Mike Owens']
|
10
|
+
spec.email = ['mike.owens11@gmail.com']
|
11
|
+
spec.summary = 'A CocoaPods plugin for linking and unlinking local pods for local development'
|
12
|
+
spec.description = <<-DESC
|
13
|
+
This CocoaPods plugin linking functionality allows to easily test their pods.
|
14
|
+
|
15
|
+
This plugin adds the following commands to the CococPods command line:
|
16
|
+
|
17
|
+
* pod link <name>
|
18
|
+
* pod unlink <name>
|
19
|
+
* pod list links
|
20
|
+
|
21
|
+
DESC
|
22
|
+
spec.homepage = 'https://github.com/mowens/cocoapods-links'
|
23
|
+
spec.license = 'MIT'
|
24
|
+
|
25
|
+
spec.files = `git ls-files`.split($/)
|
26
|
+
spec.test_files = spec.files.grep(%r{^spec/})
|
27
|
+
spec.require_paths = ['lib']
|
28
|
+
|
29
|
+
spec.add_dependency 'cocoapods', '~> 0.35'
|
30
|
+
spec.add_dependency 'json', '~> 1.8'
|
31
|
+
|
32
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
33
|
+
spec.add_development_dependency 'rake', '~> 10.4'
|
34
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'pod/links'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Link < Command
|
6
|
+
self.summary = 'Create pod links for local pod development'
|
7
|
+
self.description = <<-DESC
|
8
|
+
The link functionality allows developers to easily test their pods.
|
9
|
+
Linking is a two-step process:
|
10
|
+
|
11
|
+
Using 'pod link' in a project folder will create a global link.
|
12
|
+
Then, in some other pod, 'pod link <name>' will create a link to
|
13
|
+
the local pod as a Development pod.
|
14
|
+
|
15
|
+
This allows to easily test a pod because changes will be reflected immediately.
|
16
|
+
When the link is no longer necessary, simply remove it with 'pod unlink <name>'.
|
17
|
+
DESC
|
18
|
+
|
19
|
+
self.arguments = [
|
20
|
+
CLAide::Argument.new('POD_NAME', false)
|
21
|
+
]
|
22
|
+
|
23
|
+
def initialize(argv)
|
24
|
+
@pod = argv.shift_argument()
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# if no pod is given from the command line then we will create a link for the current pod
|
30
|
+
# so other pods can link it as a development dependency
|
31
|
+
#
|
32
|
+
# if a pod name is given from the command line then we will link that pod into the current
|
33
|
+
# pod as a development dependency
|
34
|
+
#
|
35
|
+
def run
|
36
|
+
unless @pod.nil?
|
37
|
+
Pod::Command::Links.link @pod
|
38
|
+
else
|
39
|
+
Pod::Command::Links.register
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'pod/links'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class List
|
6
|
+
class Links < List
|
7
|
+
|
8
|
+
self.summary = 'List links'
|
9
|
+
self.description = <<-DESC
|
10
|
+
List the registered links
|
11
|
+
DESC
|
12
|
+
|
13
|
+
def self.options
|
14
|
+
[[
|
15
|
+
'--linked', 'List pods linked in the current project'
|
16
|
+
]].concat(super)
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(argv)
|
20
|
+
@linked = argv.flag?('linked')
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def run
|
25
|
+
Pod::Command::Links.list @linked
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'pod/links'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Unlink < Command
|
6
|
+
self.summary = 'Remove pod links'
|
7
|
+
self.description = <<-DESC
|
8
|
+
The unlink functionality allows developers to remove reference to their local pods
|
9
|
+
when they are finished testing
|
10
|
+
|
11
|
+
Using 'pod unlink' in a project folder will remove the global link.
|
12
|
+
|
13
|
+
Using 'pod unlink <name>' will remove the link to the <name> developement pod
|
14
|
+
and install the <name> pod configured in the Podfile
|
15
|
+
|
16
|
+
This allows to easily remove developement pod references
|
17
|
+
DESC
|
18
|
+
|
19
|
+
self.arguments = [
|
20
|
+
CLAide::Argument.new('POD_NAME', false)
|
21
|
+
]
|
22
|
+
|
23
|
+
def initialize(argv)
|
24
|
+
@pod = argv.shift_argument()
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# if no pod is given from the command line then we will unregister the pod from the
|
30
|
+
# registered links
|
31
|
+
#
|
32
|
+
# if a pod name is given from the command line then we will unlink the given pod from
|
33
|
+
# the project
|
34
|
+
#
|
35
|
+
def run
|
36
|
+
unless @pod.nil?
|
37
|
+
Pod::Command::Links.unlink @pod
|
38
|
+
else
|
39
|
+
Pod::Command::Links.unregister
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/pod/links.rb
ADDED
@@ -0,0 +1,239 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Command
|
6
|
+
|
7
|
+
#
|
8
|
+
# Links utility that provides functionality around managing CocoaPod links
|
9
|
+
#
|
10
|
+
module Links
|
11
|
+
|
12
|
+
#
|
13
|
+
# Defines the path where the links database is stored (e.g. from pod link)
|
14
|
+
#
|
15
|
+
REGISTERED_DB = File.expand_path('~/.cocoapods/plugins/link/registered.json')
|
16
|
+
|
17
|
+
#
|
18
|
+
# Defines the path where per pod links are stored (e.g. from pod link <foo> command)
|
19
|
+
#
|
20
|
+
LINKED_DB = File.expand_path('~/.cocoapods/plugins/link/linked.json')
|
21
|
+
|
22
|
+
#
|
23
|
+
# Register a pod for local development in the current working directory. This working
|
24
|
+
# directory must have a .podspec defining the pod
|
25
|
+
#
|
26
|
+
def self.register
|
27
|
+
self.print "Registering '#{self.podspec.name}' > #{Dir.pwd}"
|
28
|
+
self.write_db(REGISTERED_DB, self.registerd_db, {
|
29
|
+
self.podspec.name => {
|
30
|
+
"path" => Dir.pwd
|
31
|
+
}
|
32
|
+
})
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# Unregister a pod
|
37
|
+
#
|
38
|
+
def self.unregister
|
39
|
+
self.print "Unregistering '#{self.podspec.name}' > #{Dir.pwd}"
|
40
|
+
db = self.registerd_db
|
41
|
+
db.delete(self.podspec.name)
|
42
|
+
self.write_db(REGISTERED_DB, db)
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# Creates a link for the given pod into the current project. The pod must be registered
|
47
|
+
# using `pod link`
|
48
|
+
#
|
49
|
+
# @param pod the name of the pod to link into the current project
|
50
|
+
#
|
51
|
+
def self.link(pod)
|
52
|
+
# only allow registered links to be used
|
53
|
+
registered_link = self.get_registered_link pod
|
54
|
+
if registered_link.nil?
|
55
|
+
Command::help! "Pod '#{pod}'' is not registered. Did you run `pod link` from the #{pod} directory?"
|
56
|
+
end
|
57
|
+
|
58
|
+
# add the linked pod
|
59
|
+
linked_pods = [pod]
|
60
|
+
if self.linked_db.has_key?(Dir.pwd)
|
61
|
+
linked_pods = linked_pods.concat self.linked_db[Dir.pwd]['pods']
|
62
|
+
end
|
63
|
+
|
64
|
+
self.print "Adding link to '#{pod}' > #{registered_link['path']}"
|
65
|
+
self.write_db(LINKED_DB, self.linked_db, {
|
66
|
+
Dir.pwd => {
|
67
|
+
'pods' => linked_pods.uniq
|
68
|
+
}
|
69
|
+
})
|
70
|
+
|
71
|
+
# install pod from link
|
72
|
+
Pod::Command::Install.run(CLAide::ARGV.new ["--no-repo-update"])
|
73
|
+
end
|
74
|
+
|
75
|
+
#
|
76
|
+
# Will unlink the give pod from the current pod project
|
77
|
+
#
|
78
|
+
# @param pod the name of the pod to unlink
|
79
|
+
#
|
80
|
+
def self.unlink(pod)
|
81
|
+
if self.linked_db.has_key?(Dir.pwd)
|
82
|
+
linked_pods = self.linked_db[Dir.pwd]['pods']
|
83
|
+
linked_pods.delete(pod)
|
84
|
+
|
85
|
+
#
|
86
|
+
# Update databased based on link state
|
87
|
+
# if links exist, update list of links
|
88
|
+
# if links do not exist, remove entry
|
89
|
+
#
|
90
|
+
self.print "Removing link to '#{pod}'"
|
91
|
+
if linked_pods.empty?
|
92
|
+
db = self.linked_db
|
93
|
+
db.delete(Dir.pwd)
|
94
|
+
self.write_db(LINKED_DB, db)
|
95
|
+
else
|
96
|
+
self.write_db(LINKED_DB, self.linked_db, {
|
97
|
+
Dir.pwd => {
|
98
|
+
'pods' => linked_pods
|
99
|
+
}
|
100
|
+
})
|
101
|
+
end
|
102
|
+
|
103
|
+
# install pod from repo
|
104
|
+
Pod::Command::Install.run(CLAide::ARGV.new [])
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
#
|
109
|
+
# Entry point for the `pod` hook to check if the current pod project should use a linked pod
|
110
|
+
# of installed from the pod requirements. In order for a link to be returned the following
|
111
|
+
# must hold true:
|
112
|
+
#
|
113
|
+
# 1. The pod must be registered (e.g. pod link)
|
114
|
+
# 2. The current pod project must have linked the registered link (e.g. pod link <name>)
|
115
|
+
#
|
116
|
+
# @param name the name of the pod to find a link for
|
117
|
+
#
|
118
|
+
# @returns the registered link for the given name or nil
|
119
|
+
#
|
120
|
+
def self.get_link(name)
|
121
|
+
if self.linked_pods.include?(name)
|
122
|
+
return self.get_registered_link name
|
123
|
+
end
|
124
|
+
return nil
|
125
|
+
end
|
126
|
+
|
127
|
+
#
|
128
|
+
# List the links.
|
129
|
+
#
|
130
|
+
# - If linked is true then list the linked pods in the current project
|
131
|
+
# - Id linked is false then list the registered links
|
132
|
+
#
|
133
|
+
# @param linked flag to determine which links to list
|
134
|
+
#
|
135
|
+
def self.list(linked = false)
|
136
|
+
if linked
|
137
|
+
self.print "Linked pods:"
|
138
|
+
self.linked_pods.each do |pod|
|
139
|
+
self.print "* #{pod}"
|
140
|
+
end
|
141
|
+
else
|
142
|
+
self.print "Registered pods:"
|
143
|
+
self.registerd_db.each do |pod, link|
|
144
|
+
self.print "* #{pod} > #{link['path']}"
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
#
|
150
|
+
# Prints a formatted message with the Pod Links prefix
|
151
|
+
#
|
152
|
+
def self.print(message)
|
153
|
+
UI.puts("Pod #{'Links'.cyan} #{message}")
|
154
|
+
end
|
155
|
+
|
156
|
+
private
|
157
|
+
|
158
|
+
#
|
159
|
+
# Retrieve the registered links database from disk
|
160
|
+
#
|
161
|
+
# @returns the registered links database
|
162
|
+
#
|
163
|
+
def self.registerd_db
|
164
|
+
if File.exists?(REGISTERED_DB)
|
165
|
+
return JSON.parse(File.read(REGISTERED_DB))
|
166
|
+
end
|
167
|
+
return {}
|
168
|
+
end
|
169
|
+
|
170
|
+
#
|
171
|
+
# Retrieve the linked database from disk
|
172
|
+
#
|
173
|
+
# @returns the linked database
|
174
|
+
#
|
175
|
+
def self.linked_db
|
176
|
+
if File.exists?(LINKED_DB)
|
177
|
+
return JSON.parse(File.read(LINKED_DB))
|
178
|
+
end
|
179
|
+
return {}
|
180
|
+
end
|
181
|
+
|
182
|
+
#
|
183
|
+
# Retrieve a link for the given name from the database. If the link does not exist in the
|
184
|
+
# for the given name then this will return nil
|
185
|
+
#
|
186
|
+
# @param name the name of the link to retrieve from the database
|
187
|
+
#
|
188
|
+
# @return the link for the given name or nil
|
189
|
+
#
|
190
|
+
def self.get_registered_link(name)
|
191
|
+
if self.registerd_db.has_key?(name)
|
192
|
+
return self.registerd_db[name]
|
193
|
+
end
|
194
|
+
return nil
|
195
|
+
end
|
196
|
+
|
197
|
+
#
|
198
|
+
# Retrieve the names of the linked pods for the current project (e.g. the current directory)
|
199
|
+
#
|
200
|
+
# @returns a list of pods that are linked for the current project
|
201
|
+
#
|
202
|
+
def self.linked_pods
|
203
|
+
if self.linked_db.has_key?(Dir.pwd)
|
204
|
+
return self.linked_db[Dir.pwd]['pods']
|
205
|
+
end
|
206
|
+
return []
|
207
|
+
end
|
208
|
+
|
209
|
+
#
|
210
|
+
# Read the podspec in the current working directory
|
211
|
+
#
|
212
|
+
# @returns the podspec
|
213
|
+
#
|
214
|
+
def self.podspec
|
215
|
+
spec = Dir["#{Dir.pwd}/*.podspec"]
|
216
|
+
if spec.empty?
|
217
|
+
help! 'A .podspec must exist in the directory `pod link` is ran'
|
218
|
+
end
|
219
|
+
return Specification.from_file(spec.fetch(0))
|
220
|
+
end
|
221
|
+
|
222
|
+
#
|
223
|
+
# Will write the provided database to disk with the newly provided link content
|
224
|
+
#
|
225
|
+
# @param filename the name of the file to write the links to
|
226
|
+
# @param links the content to write to disk
|
227
|
+
#
|
228
|
+
def self.write_db(db_path, db, entry = {})
|
229
|
+
dirname = File.dirname(db_path)
|
230
|
+
unless File.directory?(dirname)
|
231
|
+
FileUtils.mkdir_p(dirname)
|
232
|
+
end
|
233
|
+
File.open(db_path,'w') do |f|
|
234
|
+
f.write(JSON.pretty_generate(db.merge(entry)))
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
data/lib/pod/pod.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'pod/links'
|
2
|
+
|
3
|
+
#
|
4
|
+
# In order to support installing pods from links we want to override the pod entry point
|
5
|
+
# in the pod spec so we can lookup a link prior to installing the pod
|
6
|
+
#
|
7
|
+
module Pod
|
8
|
+
class Podfile
|
9
|
+
module DSL
|
10
|
+
alias_method :real_pod, :pod
|
11
|
+
def pod(name = nil, *requirements, &block)
|
12
|
+
#
|
13
|
+
# Logic:
|
14
|
+
# Lookup a link for the given pod name. If a link exists then the pod will be installed
|
15
|
+
# via the link instead of the provided requirements (e.g. it will setup local pod development
|
16
|
+
# for the link). If the link does not exist, then the pod will be installed normally
|
17
|
+
#
|
18
|
+
link = Pod::Command::Links.get_link(name)
|
19
|
+
unless link.nil?
|
20
|
+
Pod::Command::Links.print "Using link '#{name}' > #{link['path']}"
|
21
|
+
real_pod(name, :path => link['path'], &block)
|
22
|
+
else
|
23
|
+
real_pod(name, *requirements, &block)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
describe Command::Link do
|
5
|
+
describe 'CLAide' do
|
6
|
+
it 'registers itself' do
|
7
|
+
Command.parse(['link']).should.be.instance_of Command::Link
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
before do
|
12
|
+
@command = Pod::Command::Link.new CLAide::ARGV.new []
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
describe Command::List::Links do
|
5
|
+
describe 'CLAide' do
|
6
|
+
it 'registers itself' do
|
7
|
+
Command.parse(%w(list links)).should.be.instance_of Command::List::Links
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
before do
|
12
|
+
@command = Pod::Command::List::Links.new CLAide::ARGV.new []
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
describe Command::Unlink do
|
5
|
+
describe 'CLAide' do
|
6
|
+
it 'registers itself' do
|
7
|
+
Command.parse(['unlink']).should.be.instance_of Command::Unlink
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
before do
|
12
|
+
@command = Pod::Command::Unlink.new CLAide::ARGV.new []
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoapods-links
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Owens
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cocoapods
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.35'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.35'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.4'
|
69
|
+
description: " This CocoaPods plugin linking functionality
|
70
|
+
allows to easily test their pods.\n\n This plugin adds the
|
71
|
+
following commands to the CococPods command line:\n \n
|
72
|
+
\ * pod link <name>\n * pod unlink
|
73
|
+
<name>\n * pod list links\n \n"
|
74
|
+
email:
|
75
|
+
- mike.owens11@gmail.com
|
76
|
+
executables: []
|
77
|
+
extensions: []
|
78
|
+
extra_rdoc_files: []
|
79
|
+
files:
|
80
|
+
- .gitignore
|
81
|
+
- Gemfile
|
82
|
+
- Gemfile.lock
|
83
|
+
- LICENSE
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- cocoapods_links.gemspec
|
87
|
+
- lib/cocoapods_links.rb
|
88
|
+
- lib/cocoapods_plugin.rb
|
89
|
+
- lib/pod/command/link.rb
|
90
|
+
- lib/pod/command/list.rb
|
91
|
+
- lib/pod/command/unlink.rb
|
92
|
+
- lib/pod/links.rb
|
93
|
+
- lib/pod/pod.rb
|
94
|
+
- spec/command/link_spec.rb
|
95
|
+
- spec/command/list_spec.rb
|
96
|
+
- spec/command/unlink_spec.rb
|
97
|
+
- spec/spec_helper.rb
|
98
|
+
homepage: https://github.com/mowens/cocoapods-links
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
metadata: {}
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options: []
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements: []
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 2.2.2
|
119
|
+
signing_key:
|
120
|
+
specification_version: 4
|
121
|
+
summary: A CocoaPods plugin for linking and unlinking local pods for local development
|
122
|
+
test_files:
|
123
|
+
- spec/command/link_spec.rb
|
124
|
+
- spec/command/list_spec.rb
|
125
|
+
- spec/command/unlink_spec.rb
|
126
|
+
- spec/spec_helper.rb
|