cocoapods-x 0.0.1
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/LICENSE +22 -0
- data/README.md +36 -0
- data/lib/cocoapods-x.rb +1 -0
- data/lib/cocoapods-x/command.rb +16 -0
- data/lib/cocoapods-x/command/edit.rb +70 -0
- data/lib/cocoapods-x/command/environment.rb +17 -0
- data/lib/cocoapods-x/command/environment/init.rb +30 -0
- data/lib/cocoapods-x/command/environment/install.rb +29 -0
- data/lib/cocoapods-x/command/environment/update.rb +30 -0
- data/lib/cocoapods-x/command/libary.rb +16 -0
- data/lib/cocoapods-x/command/libary/build.rb +14 -0
- data/lib/cocoapods-x/command/libary/create.rb +49 -0
- data/lib/cocoapods-x/command/repos.rb +74 -0
- data/lib/cocoapods-x/command/xcode.rb +15 -0
- data/lib/cocoapods-x/command/xcode/clean.rb +75 -0
- data/lib/cocoapods-x/command/xcode/open.rb +51 -0
- data/lib/cocoapods-x/extension.rb +3 -0
- data/lib/cocoapods-x/extension/configure.rb +79 -0
- data/lib/cocoapods-x/extension/environment.rb +112 -0
- data/lib/cocoapods-x/extension/environment/definition.rb +90 -0
- data/lib/cocoapods-x/extension/environment/dsl.rb +76 -0
- data/lib/cocoapods-x/extension/environment/pod.rb +23 -0
- data/lib/cocoapods-x/extension/environment/podfile.rb +40 -0
- data/lib/cocoapods-x/extension/environment/source.rb +24 -0
- data/lib/cocoapods-x/extension/sandbox.rb +64 -0
- data/lib/cocoapods-x/extension/sandbox/project.rb +51 -0
- data/lib/cocoapods-x/extension/sandbox/projects.rb +25 -0
- data/lib/cocoapods-x/extension/sandbox/protocol.rb +24 -0
- data/lib/cocoapods-x/extension/sandbox/repos.rb +57 -0
- data/lib/cocoapods-x/extension/sandbox/template.rb +77 -0
- data/lib/cocoapods-x/extension/sandbox/workspace.rb +45 -0
- data/lib/cocoapods-x/gem_version.rb +3 -0
- data/lib/cocoapods_plugin.rb +2 -0
- metadata +106 -0
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'cocoapods-x/extension/sandbox'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class X < Command
|
6
|
+
class XC < X
|
7
|
+
class Clean < XC
|
8
|
+
|
9
|
+
self.summary = 'Remove the cache for xcode.'
|
10
|
+
|
11
|
+
self.description = <<-DESC
|
12
|
+
Remove 'Pods' 'Podfile.lock' 'DerivedData'.
|
13
|
+
|
14
|
+
If there is multiple cache for various versions of the requested item,
|
15
|
+
you will be asked which one to clean. Use `--all` to clean them all.
|
16
|
+
DESC
|
17
|
+
|
18
|
+
def self.options
|
19
|
+
[
|
20
|
+
['--all', 'Remove all the cached without asking']
|
21
|
+
].concat(super)
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(argv)
|
25
|
+
@cache_files = Pod::X::Sandbox::xcode_cachefiles
|
26
|
+
@wipe_all = argv.flag?('all')
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
def run
|
31
|
+
if @wipe_all
|
32
|
+
remove_files ['Pods', 'Podfile.lock', 'DerivedData']
|
33
|
+
else
|
34
|
+
begin
|
35
|
+
choices = ['Pods', 'Podfile.lock', 'Pods and Podfile.lock', 'DerivedData', 'All']
|
36
|
+
index = UI.choose_from_array(choices, 'Which item do you want to remove?')
|
37
|
+
case index
|
38
|
+
when 0
|
39
|
+
remove_files ['Pods']
|
40
|
+
when 1
|
41
|
+
remove_files ['Podfile.lock']
|
42
|
+
when 2
|
43
|
+
remove_files ['Pods', 'Podfile.lock']
|
44
|
+
when 3
|
45
|
+
remove_files ['DerivedData']
|
46
|
+
when 4
|
47
|
+
remove_files ['Pods', 'Podfile.lock', 'DerivedData']
|
48
|
+
end
|
49
|
+
rescue => exception
|
50
|
+
UI.puts "[!] #{exception}".red
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
extend Executable
|
58
|
+
executable :rm
|
59
|
+
|
60
|
+
def remove_files files
|
61
|
+
files.each do |file|
|
62
|
+
url = @cache_files[file]
|
63
|
+
unless url.nil?
|
64
|
+
UI.section("Removing #{file} => #{url}.") do
|
65
|
+
rm! ['-rf', url]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
class X < Command
|
4
|
+
class XC < X
|
5
|
+
class Open < XC
|
6
|
+
|
7
|
+
self.summary = 'Open current dir xcodeproj or xcworkspace.'
|
8
|
+
|
9
|
+
self.description = 'Open current dir xcodeproj or xcworkspace.'
|
10
|
+
|
11
|
+
def initialize(argv)
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
urls_w = Dir[File.join(Dir.pwd, "*.xcworkspace")]
|
17
|
+
urls_p = Dir[File.join(Dir.pwd, "*.xcodeproj")]
|
18
|
+
urls = urls_w + urls_p
|
19
|
+
if urls_w.size == 1
|
20
|
+
openxc(urls_w[0])
|
21
|
+
elsif urls_p.size == 1
|
22
|
+
openxc(urls_p[0])
|
23
|
+
elsif urls.size > 0
|
24
|
+
choices = urls.map { |l| File.basename(l) }
|
25
|
+
begin
|
26
|
+
index = UI.choose_from_array(choices, 'Which file do you want to open?')
|
27
|
+
openxc(urls[index])
|
28
|
+
rescue => exception
|
29
|
+
UI.puts "[!] #{exception}".red
|
30
|
+
end
|
31
|
+
else
|
32
|
+
openxc('/Applications/Xcode.app')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
extend Executable
|
39
|
+
executable :open
|
40
|
+
|
41
|
+
def openxc url
|
42
|
+
UI.section("Opening #{File.basename(url)}.") do
|
43
|
+
open! [url]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'cocoapods-x/extension/sandbox'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
module X
|
5
|
+
class Configurator
|
6
|
+
|
7
|
+
def self.find_conf? project_url
|
8
|
+
projects = Pod::X::Sandbox::workspace::projects
|
9
|
+
for project_debug_url in Dir.glob(projects::root + '*') do
|
10
|
+
conf = Pod::X::Configurator::new project_url, project_debug_url
|
11
|
+
if conf.verify?
|
12
|
+
break
|
13
|
+
end
|
14
|
+
end
|
15
|
+
if conf.nil? || !conf.verify?
|
16
|
+
conf = nil
|
17
|
+
end
|
18
|
+
conf
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.create_conf! project_url
|
22
|
+
index = 0
|
23
|
+
name = File.basename(project_url)
|
24
|
+
projects = Pod::X::Sandbox::workspace::projects
|
25
|
+
begin
|
26
|
+
project_debug_url = projects::root + "#{name}@#{index}"
|
27
|
+
index += 1
|
28
|
+
end while project_debug_url.exist?
|
29
|
+
Pod::X::Configurator::new project_url, project_debug_url
|
30
|
+
end
|
31
|
+
|
32
|
+
attr_reader :conf
|
33
|
+
|
34
|
+
def initialize project_url, project_debug_url
|
35
|
+
@conf = { 'project_url' => project_url.to_s, 'project_debug_url' => project_debug_url.to_s }
|
36
|
+
end
|
37
|
+
|
38
|
+
def url
|
39
|
+
File.join(project_debug_url, '.conf')
|
40
|
+
end
|
41
|
+
|
42
|
+
def project_url
|
43
|
+
@conf['project_url']
|
44
|
+
end
|
45
|
+
|
46
|
+
def project_debug_url
|
47
|
+
@conf['project_debug_url']
|
48
|
+
end
|
49
|
+
|
50
|
+
def verify?
|
51
|
+
valid = false
|
52
|
+
unless url.nil? || project_url.nil? || project_debug_url.nil?
|
53
|
+
if File.exist?(url) && File.exist?(project_url) && File.exist?(project_debug_url)
|
54
|
+
begin json = JSON.parse(File.read(url))
|
55
|
+
rescue => exception
|
56
|
+
end
|
57
|
+
valid = @conf == json
|
58
|
+
end
|
59
|
+
end
|
60
|
+
valid
|
61
|
+
end
|
62
|
+
|
63
|
+
def sync
|
64
|
+
begin json = JSON.parse(File.read(url))
|
65
|
+
rescue => exception
|
66
|
+
end
|
67
|
+
unless json.nil?
|
68
|
+
@conf = json.merge(@conf)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def save!
|
73
|
+
return nil if verify?
|
74
|
+
File.write(url, @conf.to_json)
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'cocoapods-x/extension/sandbox'
|
2
|
+
require 'cocoapods-x/extension/configure'
|
3
|
+
require 'cocoapods-x/extension/environment/dsl'
|
4
|
+
require 'cocoapods-x/extension/environment/pod'
|
5
|
+
require 'cocoapods-x/extension/environment/source'
|
6
|
+
require 'cocoapods-x/extension/environment/podfile'
|
7
|
+
require 'cocoapods-x/extension/environment/definition'
|
8
|
+
|
9
|
+
module Pod
|
10
|
+
module X
|
11
|
+
class Environment
|
12
|
+
|
13
|
+
Podinfo = Struct::new(:name, :version, :share, :repo_url)
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@pods = Pod::X::Pods::new
|
17
|
+
@source = Pod::X::Source::new
|
18
|
+
|
19
|
+
@runing = false
|
20
|
+
@project = nil
|
21
|
+
@workspace = nil
|
22
|
+
@pods_list = nil
|
23
|
+
@source_list = nil
|
24
|
+
run
|
25
|
+
end
|
26
|
+
|
27
|
+
def runing?
|
28
|
+
@runing
|
29
|
+
end
|
30
|
+
|
31
|
+
def podinfo? name, version
|
32
|
+
return nil if name.nil?
|
33
|
+
share = @pods_list[name]
|
34
|
+
return nil if share.nil?
|
35
|
+
repo_url = @source_list[name]
|
36
|
+
Podinfo::new(name, version, share, repo_url)
|
37
|
+
end
|
38
|
+
|
39
|
+
def pod_path? info
|
40
|
+
unless info.share
|
41
|
+
repos = @project::repos
|
42
|
+
else
|
43
|
+
repos = @workspace::repos
|
44
|
+
end
|
45
|
+
path = repos.pod_path!(info.name, info.version, info.share, info.repo_url)
|
46
|
+
if !path.exist? || path.empty?
|
47
|
+
path = repos.pod_path_clone!(info.name, info.version, info.share, info.repo_url)
|
48
|
+
end
|
49
|
+
path
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.environment
|
53
|
+
@@shared ||= Pod::X::Environment::new
|
54
|
+
@@shared
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.install!
|
58
|
+
Pod::X::Sandbox::install!
|
59
|
+
Pod::X::Sandbox::workspace
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.update!
|
63
|
+
Pod::X::Sandbox::update!
|
64
|
+
Pod::X::Sandbox::workspace
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.init!
|
68
|
+
project_url = Pathname(Dir.pwd)
|
69
|
+
Pod::X::Sandbox::install!
|
70
|
+
Pod::X::Sandbox::podfile_exists! project_url
|
71
|
+
conf = Pod::X::Configurator::find_conf? project_url
|
72
|
+
conf ||= Pod::X::Configurator::create_conf! project_url
|
73
|
+
project = Pod::X::Sandbox::Project::new conf
|
74
|
+
project.install!
|
75
|
+
project
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def run
|
81
|
+
project_url = Dir.pwd
|
82
|
+
conf = Pod::X::Configurator::find_conf? project_url
|
83
|
+
return nil if conf.nil?
|
84
|
+
|
85
|
+
@project = Pod::X::Sandbox::Project::new conf
|
86
|
+
@project.install!
|
87
|
+
pods_file = @project.pods_file
|
88
|
+
return nil unless pods_file.exist?
|
89
|
+
|
90
|
+
@workspace = Pod::X::Sandbox::workspace
|
91
|
+
source_file = @workspace.source_file
|
92
|
+
return nil unless source_file.exist?
|
93
|
+
|
94
|
+
@pods::build pods_file
|
95
|
+
@pods_list = @pods.list
|
96
|
+
@pods_list ||= Hash::new
|
97
|
+
@pods_list = @pods_list.is_a?(Hash) ? @pods_list : Hash.new;
|
98
|
+
|
99
|
+
@source::build source_file
|
100
|
+
@source_list = @source.list
|
101
|
+
@source_list ||= Hash::new
|
102
|
+
@source_list = @source_list.is_a?(Hash) ? @source_list : Hash.new;
|
103
|
+
|
104
|
+
if @pods_list.size > 0 && @source_list.size > 0
|
105
|
+
@runing = true
|
106
|
+
UI.puts 'Pod::X Working...'.green
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Pod
|
2
|
+
module X
|
3
|
+
class Source
|
4
|
+
class Definition
|
5
|
+
|
6
|
+
attr_reader :domain
|
7
|
+
attr_reader :parent
|
8
|
+
attr_reader :children
|
9
|
+
attr_reader :map
|
10
|
+
|
11
|
+
def initialize(domain, parent)
|
12
|
+
@domain = domain
|
13
|
+
@parent = parent
|
14
|
+
@children = []
|
15
|
+
@map = Hash::new(nil)
|
16
|
+
if parent.is_a?(Pod::X::Source::Definition)
|
17
|
+
parent.children << self
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def list
|
22
|
+
hash = Hash::new(nil)
|
23
|
+
hash = hash.merge(@map)
|
24
|
+
for source in children do
|
25
|
+
hash = hash.merge(source.map)
|
26
|
+
end
|
27
|
+
hash
|
28
|
+
end
|
29
|
+
|
30
|
+
def store_pod(name = nil, *requirements)
|
31
|
+
options = requirements.last
|
32
|
+
options ||= Hash::new(nil)
|
33
|
+
options = options.is_a?(Hash) ? options : Hash::new(nil)
|
34
|
+
|
35
|
+
group = options[:group] || name
|
36
|
+
git = options[:git] || "#{name}.git"
|
37
|
+
|
38
|
+
if domain.start_with? "git@"
|
39
|
+
store_pod_git(name, group, git)
|
40
|
+
elsif domain.size > 0
|
41
|
+
store_pod_http(name, group, git)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def store_pod_git(name, group, git)
|
46
|
+
source = "#{domain}:#{group}/#{git}"
|
47
|
+
map[name] = source
|
48
|
+
end
|
49
|
+
|
50
|
+
def store_pod_http(name, group, git)
|
51
|
+
source = Pathname(domain)
|
52
|
+
source += group
|
53
|
+
source += git
|
54
|
+
map[name] = source.to_s
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
module Pod
|
63
|
+
module X
|
64
|
+
class Pods
|
65
|
+
class Definition
|
66
|
+
|
67
|
+
attr_reader :map
|
68
|
+
|
69
|
+
def initialize
|
70
|
+
@map = Hash::new(nil)
|
71
|
+
end
|
72
|
+
|
73
|
+
def list
|
74
|
+
@map
|
75
|
+
end
|
76
|
+
|
77
|
+
def store_pod(name = nil, *requirements)
|
78
|
+
options = requirements.last
|
79
|
+
options ||= Hash::new(nil)
|
80
|
+
options = options.is_a?(Hash) ? options : Hash::new(nil)
|
81
|
+
value = options[:share]
|
82
|
+
value = value.nil? ? true : value
|
83
|
+
value = (value.is_a?(TrueClass) || value.is_a?(FalseClass)) ? value : true
|
84
|
+
@map[name] = value
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
|
2
|
+
module Pod
|
3
|
+
module X
|
4
|
+
module DSLBuilder
|
5
|
+
|
6
|
+
def build url
|
7
|
+
contents = File.exist?(url) ? File.open(url, 'r:utf-8', &:read) : nil
|
8
|
+
# Work around for Rubinius incomplete encoding in 1.9 mode
|
9
|
+
if !contents.nil? && contents.respond_to?(:encoding) && contents.encoding.name != 'UTF-8'
|
10
|
+
contents.encode!('UTF-8')
|
11
|
+
end
|
12
|
+
if !contents.nil? && contents.tr!('“”‘’‛', %(""'''))
|
13
|
+
# Changes have been made
|
14
|
+
CoreUI.warn "Smart quotes were detected and ignored in your #{File.basename(url)}. " \
|
15
|
+
'To avoid issues in the future, you should not use ' \
|
16
|
+
'TextEdit for editing it. If you are not using TextEdit, ' \
|
17
|
+
'you should turn off smart quotes in your editor of choice.'
|
18
|
+
end
|
19
|
+
unless contents.nil?
|
20
|
+
begin
|
21
|
+
eval(contents, nil, url.to_s)
|
22
|
+
rescue Exception => e
|
23
|
+
message = "Invalid `#{File.basename(url)}` file: #{e.message}"
|
24
|
+
raise DSLError.new(message, url, e, contents)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
module Pod
|
34
|
+
module X
|
35
|
+
class Pods
|
36
|
+
module DSL
|
37
|
+
|
38
|
+
def pod(name = nil, *requirements)
|
39
|
+
unless name
|
40
|
+
raise StandardError, 'A development requires a name.'
|
41
|
+
end
|
42
|
+
@current_pods_definition.store_pod(name, *requirements)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
module Pod
|
51
|
+
module X
|
52
|
+
class Source
|
53
|
+
module DSL
|
54
|
+
|
55
|
+
def source(domain, options = nil)
|
56
|
+
if options
|
57
|
+
raise Informative, "Unsupported options `#{options}` for domain `#{domain}`."
|
58
|
+
end
|
59
|
+
|
60
|
+
@current_domain_definition = Pod::X::Source::Definition::new(domain, @parent)
|
61
|
+
yield if block_given?
|
62
|
+
ensure
|
63
|
+
@current_domain_definition = nil
|
64
|
+
end
|
65
|
+
|
66
|
+
def pod(name = nil, *requirements)
|
67
|
+
unless name
|
68
|
+
raise StandardError, 'A development requires a name.'
|
69
|
+
end
|
70
|
+
@current_domain_definition.store_pod(name, *requirements)
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|