cocoapods-extension 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 96153a7c4d413e3e31e58037e800d01a6f80aec3df924ccdf13196acb6869a0f
4
+ data.tar.gz: d59efb16a44222b48965f75d96763bdd0e88bf6aea817ad4525a875118a853b3
5
+ SHA512:
6
+ metadata.gz: 1d63270625ec89861b113c6fea3be2b44033559b10e782a03917233016b745de14d4ef5dae7f5f8681e3068081ee9c0d3c7f6680b48f54762290d37e691f6976
7
+ data.tar.gz: 617ea8743d17764f2bc96d998ae808e0fc0b25e013959db64e49bfe9e60ab7eab3511990af693583f98f319b9bbbd661f4dc6cc9f49c82002bc8dbfbeb18bc6e
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2020 panghu <panghu.lee@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,49 @@
1
+ # cocoapods-extension
2
+
3
+ A description of cocoapods-extension.
4
+
5
+ ## Installation
6
+
7
+ $ gem install cocoapods-extension
8
+
9
+ ## Usage
10
+
11
+ development
12
+
13
+ $ pod dev update # update development env and template.
14
+ $ pod dev init # init project development env.
15
+ $ pod dev open --proj # open development project.
16
+ $ pod dev open --wks # open development workspace.
17
+
18
+ xcode
19
+
20
+ $ pod xc open # open xcodeproj xcworkspace or Xcode.app.
21
+ $ pod xc clean # Remove the cache files[Pods, Podfile.lock, DerivedData].
22
+
23
+
24
+ ```
25
+ │── .template
26
+ ├── projects
27
+ │ ├── Example@0
28
+ │ │ ├── .conf
29
+ │ │ ├── pod.rb
30
+ │ │ └── repos
31
+ │ │ ├── Foundation
32
+ │ │ │ └── Foundation.h
33
+ │ │ └── UIKit
34
+ │ │ └── UIKit.h
35
+ │ └── Example@1
36
+ │ ├── .conf
37
+ │ ├── pod.rb
38
+ │ └── repos
39
+ │ ├── Foundation
40
+ │ │ └── Foundation.h
41
+ │ └── UIKit
42
+ │ └── UIKit.h
43
+ ├── repos
44
+ │ ├── Foundation
45
+ │ │ └── Foundation.h
46
+ │ └── UIKit
47
+ │ └── UIKit.h
48
+ └── source.rb
49
+ ```
@@ -0,0 +1,47 @@
1
+ require 'cocoapods-extension/sandbox'
2
+
3
+ module Pod
4
+ class Command
5
+ class Dev < Command
6
+ class Create < Dev
7
+
8
+ extend Executable
9
+ executable :rm
10
+
11
+ self.summary = 'Creates a new project'
12
+ self.description = <<-DESC
13
+ Creates a scaffold for the development of a new project named `NAME`.
14
+ DESC
15
+
16
+ self.arguments = [
17
+ CLAide::Argument.new('NAME', true),
18
+ ]
19
+
20
+ def initialize(argv)
21
+ @name = argv.shift_argument
22
+ super
23
+ end
24
+
25
+ def run
26
+ project_name = @name
27
+ target_url = File.join(Dir::pwd, project_name)
28
+ configure_url = Pod::Extension::Sandbox::workspace::template::configure
29
+ template_url = Pod::Extension::Sandbox::workspace::template::ios_template
30
+ if Dir::exist?(target_url) && !Dir::empty?(target_url)
31
+ UI.puts "fatal: destination path '#{project_name}' already exists and is not an empty directory.".red
32
+ else
33
+ rm! ['-rf', target_url]
34
+ if !template_url.exist?
35
+ Pod::Extension::Sandbox::update!
36
+ end
37
+ UI.section("Configuring #{project_name} template.") do
38
+ system('ruby', configure_url.to_s, template_url.to_s, target_url.to_s, project_name.to_s)
39
+ end
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,33 @@
1
+ require 'cocoapods-extension/sandbox'
2
+
3
+ module Pod
4
+ class Command
5
+ class Dev < Command
6
+ class Init < Dev
7
+
8
+ self.summary = 'Init development environment.'
9
+ self.description = 'Init development environment.'
10
+
11
+ def initialize(argv)
12
+ super
13
+ end
14
+
15
+ def run
16
+ begin
17
+ UI.puts "Initing development environment."
18
+ project_url = Pathname(Dir.pwd)
19
+ Pod::Extension::Sandbox::install!
20
+ Pod::Extension::Sandbox::podfile_exists! project_url
21
+ conf = Pod::Extension::Configurator::find_conf? project_url
22
+ conf ||= Pod::Extension::Configurator::create_conf! project_url
23
+ project = Pod::Extension::Sandbox::Project::new conf
24
+ project.install!
25
+ rescue => exception
26
+ puts "[!] #{exception}".red
27
+ end
28
+ end
29
+
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,64 @@
1
+ require 'cocoapods-extension/sandbox'
2
+
3
+ module Pod
4
+ class Command
5
+ class Dev < Command
6
+ class Open < Dev
7
+
8
+ extend Executable
9
+ executable :open
10
+
11
+ self.summary = 'Open development project or workspace.'
12
+ self.description = 'Open development project or workspace.'
13
+
14
+ def self.options
15
+ [
16
+ ['--proj', 'Open development project.'],
17
+ ['--wks', 'Open development workspace.'],
18
+ ].concat(super)
19
+ end
20
+
21
+ def initialize(argv)
22
+ @wipe_proj = argv.flag?('proj')
23
+ @wipe_wks = argv.flag?('wks')
24
+ super
25
+ end
26
+
27
+ def run
28
+ if @wipe_proj
29
+ open_proj
30
+ end
31
+
32
+ if @wipe_wks
33
+ open_wks
34
+ end
35
+
36
+ if !@wipe_proj && !@wipe_wks
37
+ help!
38
+ end
39
+ end
40
+
41
+ def open_proj
42
+ project_url = Pathname(Dir.pwd)
43
+ Pod::Extension::Sandbox::install!
44
+ Pod::Extension::Sandbox::podfile_exists! project_url
45
+ conf = Pod::Extension::Configurator::find_conf? project_url
46
+ if !conf.nil? && conf.verify?
47
+ UI.section("Opening project.") do
48
+ open! [conf::project_debug_url]
49
+ end
50
+ else
51
+ UI.puts "Please run `pod dev init`."
52
+ end
53
+ end
54
+
55
+ def open_wks
56
+ UI.section("Opening workspace.") do
57
+ open! [Pod::Extension::Sandbox::workspace::root]
58
+ end
59
+ end
60
+
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,30 @@
1
+ require 'cocoapods-extension/sandbox'
2
+
3
+ module Pod
4
+ class Command
5
+ class Dev < Command
6
+ class Update < Dev
7
+
8
+ self.summary = 'Updating development environment.'
9
+ self.description = 'Updating development environment.'
10
+
11
+ def initialize(argv)
12
+ super
13
+ end
14
+
15
+ def run
16
+
17
+ begin
18
+ UI.puts "Updating development environment."
19
+ Pod::Extension::Sandbox::update!
20
+ UI.puts "Done."
21
+ rescue => exception
22
+ puts "[!] #{exception}".red
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,16 @@
1
+ require 'cocoapods-extension/command/development/update'
2
+ require 'cocoapods-extension/command/development/init'
3
+ require 'cocoapods-extension/command/development/open'
4
+ require 'cocoapods-extension/command/development/create'
5
+
6
+ module Pod
7
+ class Command
8
+ class Dev < Command
9
+
10
+ self.abstract_command = true
11
+ self.summary = 'Cocoapods development.'
12
+
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,74 @@
1
+ module Pod
2
+ class Command
3
+ class XC < Command
4
+ class Clean < XC
5
+
6
+ self.summary = 'Remove the cache for xcode.'
7
+ self.description = <<-DESC
8
+ Remove 'Pods' 'Podfile.lock' 'DerivedData'.
9
+
10
+ If there is multiple cache for various versions of the requested item,
11
+ you will be asked which one to clean. Use `--all` to clean them all.
12
+ DESC
13
+
14
+ def self.options
15
+ [
16
+ ['--all', 'Remove all the cached without asking']
17
+ ].concat(super)
18
+ end
19
+
20
+ def initialize(argv)
21
+ @cache_files = Hash.new
22
+ @cache_files['Pods'] = File.join(Dir.pwd, 'Pods')
23
+ @cache_files['Podfile.lock'] = File.join(Dir.pwd, 'Podfile.lock')
24
+ @cache_files['DerivedData'] = File.join(File.expand_path('~'), 'Library/Developer/Xcode/DerivedData')
25
+ @wipe_all = argv.flag?('all')
26
+ super
27
+ end
28
+
29
+ def run
30
+ if @wipe_all
31
+ remove_indexs ['Pods', 'Podfile.lock', 'DerivedData']
32
+ else
33
+ begin
34
+ choices = ['Pods', 'Podfile.lock', 'DerivedData', 'Pods and Podfile.lock', 'All']
35
+ index = UI.choose_from_array(choices, 'Which item do you want to remove?')
36
+ case index
37
+ when 0
38
+ remove_indexs ['Pods']
39
+ when 1
40
+ remove_indexs ['Podfile.lock']
41
+ when 2
42
+ remove_indexs ['DerivedData']
43
+ when 3
44
+ remove_indexs ['Pods', 'Podfile.lock']
45
+ when 4
46
+ remove_indexs ['Pods', 'Podfile.lock', 'DerivedData']
47
+ end
48
+ rescue => exception
49
+ UI.puts "[!] #{exception}".red
50
+ end
51
+ end
52
+
53
+ end
54
+
55
+ private
56
+
57
+ extend Executable
58
+ executable :rm
59
+
60
+ def remove_indexs indexs
61
+ indexs.each do |index|
62
+ value = @cache_files[index]
63
+ unless value.nil?
64
+ UI.section("Removing #{index} => #{value}.") do
65
+ rm! ['-rf', value]
66
+ end
67
+ end
68
+ end
69
+ end
70
+
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,48 @@
1
+ module Pod
2
+ class Command
3
+ class XC < Command
4
+ class Open < XC
5
+
6
+ self.summary = 'Open current dir xcodeproj or xcworkspace.'
7
+ self.description = 'Open current dir xcodeproj or xcworkspace.'
8
+
9
+ def initialize(argv)
10
+ super
11
+ end
12
+
13
+ def run
14
+ urls_w = Dir[File.join(Dir.pwd, "*.xcworkspace")]
15
+ urls_p = Dir[File.join(Dir.pwd, "*.xcodeproj")]
16
+ urls = urls_w + urls_p
17
+ if urls_w.size == 1
18
+ open urls_w[0]
19
+ elsif urls_p.size == 1
20
+ open urls_p[0]
21
+ elsif urls.size > 0
22
+ choices = urls.map { |l| File.basename(l) }
23
+ begin
24
+ index = UI.choose_from_array(choices, 'Which file do you want to open?')
25
+ open urls[index]
26
+ rescue => exception
27
+ UI.puts "[!] #{exception}".red
28
+ end
29
+ else
30
+ open '/Applications/Xcode.app'
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ extend Executable
37
+ executable :open
38
+
39
+ def openxc url
40
+ UI.section("Opening #{File.basename(url)}.") do
41
+ open! [url]
42
+ end
43
+ end
44
+
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,14 @@
1
+ require 'cocoapods-extension/command/xcode/open'
2
+ require 'cocoapods-extension/command/xcode/clean'
3
+
4
+ module Pod
5
+ class Command
6
+ class XC < Command
7
+
8
+ self.abstract_command = true
9
+ self.summary = 'Xcode.'
10
+
11
+ end
12
+ end
13
+ end
14
+
@@ -0,0 +1,2 @@
1
+ require 'cocoapods-extension/command/xcode'
2
+ require 'cocoapods-extension/command/development'
@@ -0,0 +1,79 @@
1
+ require 'cocoapods-extension/sandbox'
2
+
3
+ module Pod
4
+ module Extension
5
+ class Configurator
6
+
7
+ def self.find_conf? project_url
8
+ projects = Pod::Extension::Sandbox::workspace::projects
9
+ for project_debug_url in Dir.glob(projects::root + '*') do
10
+ conf = Pod::Extension::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::Extension::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::Extension::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,76 @@
1
+
2
+ module Pod
3
+ module Extension
4
+ class SourceDefinition
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
16
+ if parent.is_a?(Pod::Extension::SourceDefinition)
17
+ parent.children << self
18
+ end
19
+ end
20
+
21
+ def source_list
22
+ list = Hash::new(@map)
23
+ for source in children do
24
+ list = list.merge(source.map)
25
+ end
26
+ list
27
+ end
28
+
29
+ def store_pod(name = nil, *requirements)
30
+ options = requirements.last || Hash.new
31
+ git = options[:git] || "#{name}.git"
32
+ group = options[:group] || name
33
+
34
+ if domain.start_with? "git@"
35
+ store_pod_git(name, group, git)
36
+ elsif domain.size > 0
37
+ store_pod_http(name, group, git)
38
+ end
39
+ end
40
+
41
+ def store_pod_git(name, group, git)
42
+ source = "#{domain}:#{group}/#{git}"
43
+ map[name] = source
44
+ end
45
+
46
+ def store_pod_http(name, group, git)
47
+ source = Pathname(domain)
48
+ source += group
49
+ source += git
50
+ map[name] = source.to_s
51
+ end
52
+
53
+ end
54
+
55
+ class PodsDefinition
56
+
57
+ attr_reader :map
58
+
59
+ def initialize
60
+ @map = Hash::new
61
+ end
62
+
63
+ def pods_list
64
+ @map
65
+ end
66
+
67
+ def store_pod(name = nil, *requirements)
68
+ options = requirements.last || Hash::new
69
+ share = options[:share].nil? ? true : options[:share]
70
+ @map[name] = share
71
+ end
72
+
73
+ end
74
+
75
+ end
76
+ end
@@ -0,0 +1,121 @@
1
+ require 'cocoapods-extension/sandbox'
2
+ require 'cocoapods-extension/configure'
3
+ require 'cocoapods-extension/development/dsl'
4
+
5
+ module Pod
6
+ module Extension
7
+ class Development
8
+
9
+ attr_reader :source_definition, :pods_definition
10
+
11
+ def self.development
12
+ @@shared ||= Pod::Extension::Development::new
13
+ @@shared
14
+ end
15
+
16
+ def initialize
17
+ @runing = false
18
+ @project = nil
19
+ @workspace = nil
20
+ @pods_list = nil
21
+ @source_list = nil
22
+ @pods_definition = Pod::Extension::Development::Pods::new
23
+ @source_definition = Pod::Extension::Development::Source::new
24
+ run
25
+ end
26
+
27
+ def runing?
28
+ @runing
29
+ end
30
+
31
+ def pods_list?
32
+ @pods_list
33
+ end
34
+
35
+ def source_list?
36
+ @source_list
37
+ end
38
+
39
+ def pod! name, source, share
40
+ unless share
41
+ repos = @project::repos
42
+ else
43
+ repos = @workspace::repos
44
+ end
45
+ repos.pod! name, source, share
46
+ end
47
+
48
+ def run
49
+ project_url = Dir.pwd
50
+ conf = Pod::Extension::Configurator::find_conf? project_url
51
+ return nil if conf.nil?
52
+
53
+ @project = Pod::Extension::Sandbox::Project::new conf
54
+ @project.install!
55
+ pod_file = @project.pod_file
56
+ return nil unless pod_file.exist?
57
+
58
+ @workspace = Pod::Extension::Sandbox::workspace
59
+ source_file = @workspace.source_file
60
+ return nil unless source_file.exist?
61
+
62
+ begin
63
+ @pods_definition::run pod_file
64
+ @source_definition::run source_file
65
+ @pods_list = @pods_definition.pods_list
66
+ @source_list = @source_definition.source_list
67
+ if @pods_list.size > 0 && @source_list.size > 0
68
+ @runing = true
69
+ UI.puts 'Pod::Extension::Development working.'.green
70
+ end
71
+ rescue => exception
72
+ puts "[!] #{exception}".red
73
+ end
74
+ end
75
+
76
+ end
77
+ end
78
+ end
79
+
80
+ module Pod
81
+ module Extension
82
+ class Development
83
+
84
+ class Source
85
+
86
+ include Pod::Extension::Development::DSL
87
+ include Pod::Extension::Development::SourceDSL
88
+
89
+ attr_reader :parent
90
+ attr_reader :current_domain_definition
91
+
92
+ def initialize
93
+ @parent = Pod::Extension::SourceDefinition::new('', nil)
94
+ end
95
+
96
+ def source_list
97
+ @parent::source_list
98
+ end
99
+
100
+ end
101
+
102
+ class Pods
103
+
104
+ include Pod::Extension::Development::DSL
105
+ include Pod::Extension::Development::PodDSL
106
+
107
+ attr_reader :current_pods_definition
108
+
109
+ def initialize
110
+ @current_pods_definition = Pod::Extension::PodsDefinition::new
111
+ end
112
+
113
+ def pods_list
114
+ @current_pods_definition::pods_list
115
+ end
116
+
117
+ end
118
+
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,69 @@
1
+ require 'cocoapods-extension/development/definition'
2
+
3
+ module Pod
4
+ module Extension
5
+ class Development
6
+
7
+ module SourceDSL
8
+
9
+ def source(domain, options = nil)
10
+ if options
11
+ raise Informative, "Unsupported options `#{options}` for domain `#{domain}`."
12
+ end
13
+
14
+ @current_domain_definition = Pod::Extension::SourceDefinition::new(domain, @parent)
15
+ yield if block_given?
16
+ ensure
17
+ @current_domain_definition = nil
18
+ end
19
+
20
+ def pod(name = nil, *requirements)
21
+ unless name
22
+ raise StandardError, 'A development requires a name.'
23
+ end
24
+ @current_domain_definition.store_pod(name, *requirements)
25
+ end
26
+
27
+ end
28
+
29
+ module PodDSL
30
+
31
+ def pod(name = nil, *requirements)
32
+ unless name
33
+ raise StandardError, 'A development requires a name.'
34
+ end
35
+ @current_pods_definition.store_pod(name, *requirements)
36
+ end
37
+
38
+ end
39
+
40
+ module DSL
41
+
42
+ def run url
43
+ contents = File.exist?(url) ? File.open(url, 'r:utf-8', &:read) : nil
44
+ # Work around for Rubinius incomplete encoding in 1.9 mode
45
+ if !contents.nil? && contents.respond_to?(:encoding) && contents.encoding.name != 'UTF-8'
46
+ contents.encode!('UTF-8')
47
+ end
48
+ if !contents.nil? && contents.tr!('“”‘’‛', %(""'''))
49
+ # Changes have been made
50
+ CoreUI.warn "Smart quotes were detected and ignored in your #{File.basename(url)}. " \
51
+ 'To avoid issues in the future, you should not use ' \
52
+ 'TextEdit for editing it. If you are not using TextEdit, ' \
53
+ 'you should turn off smart quotes in your editor of choice.'
54
+ end
55
+ unless contents.nil?
56
+ begin
57
+ eval(contents, nil, url.to_s)
58
+ rescue Exception => e
59
+ message = "Invalid `#{File.basename(url)}` file: #{e.message}"
60
+ raise DSLError.new(message, url, e, contents)
61
+ end
62
+ end
63
+ end
64
+
65
+ end
66
+
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,31 @@
1
+ require 'cocoapods-extension/development'
2
+
3
+ module Pod
4
+ class Podfile
5
+ module DSL
6
+
7
+ old_method = instance_method(:pod)
8
+ define_method(:pod) do |name, *requirements|
9
+ development = Pod::Extension::Development::development
10
+ options = requirements.last || Hash.new
11
+ path = options[:path]
12
+ if path.nil? && development.runing? && !development.pods_list?.nil? && !development.source_list?.nil?
13
+ share = development.pods_list?[name]
14
+ source = development.source_list?[name]
15
+ if !share.nil? && !source.nil?
16
+ url = development.pod! name, source, share
17
+ old_method.bind(self).(name, :path => url)
18
+ elsif !share.nil? && source.nil?
19
+ UI.puts "not configured to #{name} git source.".yellow
20
+ old_method.bind(self).(name, *requirements)
21
+ else
22
+ old_method.bind(self).(name, *requirements)
23
+ end
24
+ else
25
+ old_method.bind(self).(name, *requirements)
26
+ end
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,4 @@
1
+ require 'cocoapods-extension/development/dsl'
2
+ require 'cocoapods-extension/development/podfile'
3
+ require 'cocoapods-extension/development/definition'
4
+ require 'cocoapods-extension/development/development'
@@ -0,0 +1,3 @@
1
+ module CocoapodsExtension
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,39 @@
1
+ require 'cocoapods-extension/sandbox/repos'
2
+ require 'cocoapods-extension/sandbox/protocol'
3
+
4
+ module Pod
5
+ module Extension
6
+ class Sandbox
7
+ class Project < Pod::Sandbox
8
+
9
+ include Pod::Extension::Sandbox::Protocol
10
+
11
+ attr_reader :repos, :conf
12
+
13
+ def initialize conf
14
+ @conf = conf
15
+ super conf.project_debug_url
16
+ @repos = Pod::Extension::Sandbox::Repos::new conf::project_debug_url
17
+ end
18
+
19
+ def install!
20
+ @conf.sync
21
+ @conf.save!
22
+
23
+ unless pod_file.exist?
24
+ cp! [Pod::Extension::Sandbox::workspace::template::pod_file, pod_file]
25
+ end
26
+ end
27
+
28
+ def update!
29
+ install!
30
+ end
31
+
32
+ def pod_file
33
+ root + 'pod'
34
+ end
35
+
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,25 @@
1
+ require 'cocoapods-extension/sandbox/protocol'
2
+
3
+ module Pod
4
+ module Extension
5
+ class Sandbox
6
+ class Projects < Pod::Sandbox
7
+
8
+ include Pod::Extension::Sandbox::Protocol
9
+
10
+ def initialize url
11
+ super File.join(url, 'projects')
12
+ end
13
+
14
+ def install!
15
+
16
+ end
17
+
18
+ def update!
19
+
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ module Pod
2
+ module Extension
3
+ class Sandbox
4
+ module Protocol
5
+
6
+ extend Executable
7
+ executable :rm
8
+ executable :cp
9
+ executable :git
10
+ executable :open
11
+
12
+ def install!
13
+
14
+ end
15
+
16
+ def update!
17
+
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,50 @@
1
+ require 'cocoapods-extension/sandbox/protocol'
2
+ require 'digest'
3
+
4
+ module Pod
5
+ module Extension
6
+ class Sandbox
7
+ class Repos < Pod::Sandbox
8
+
9
+ include Pod::Extension::Sandbox::Protocol
10
+
11
+ def initialize url
12
+ super File.join(url, 'repos')
13
+ end
14
+
15
+ def install!
16
+
17
+ end
18
+
19
+ def update!
20
+
21
+ end
22
+
23
+ def pod! name, repo_url, share
24
+ md5 = Digest::MD5::new
25
+ md5.update repo_url
26
+ to = root + "#{Pathname(repo_url).basename}@#{md5.hexdigest}".gsub('.git', '')
27
+ if to.empty?
28
+ rm ['-rf', to]
29
+ end
30
+ unless to.exist?
31
+ clone_template! name, repo_url, to
32
+ end
33
+ to
34
+ end
35
+
36
+ private
37
+
38
+ def clone_template! name, repo_url, to
39
+ UI.section("Cocoapods-Extension Cloning `#{name}`.".green) do
40
+ git! ['clone', repo_url, to]
41
+ end
42
+ unless (to + '.git').exist?
43
+ raise Informative, "Clone failed."
44
+ end
45
+ end
46
+
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,73 @@
1
+ require 'cocoapods-extension/sandbox/protocol'
2
+
3
+ module Pod
4
+ module Extension
5
+ class Sandbox
6
+ class Template < Pod::Sandbox
7
+
8
+ include Pod::Extension::Sandbox::Protocol
9
+
10
+ def initialize url
11
+ super File.join(url, '.template')
12
+ end
13
+
14
+ def install!
15
+ unless verify_files
16
+ update!
17
+ end
18
+ end
19
+
20
+ def update!
21
+ rm! ['-rf', root]
22
+ clone_template! root
23
+ end
24
+
25
+ def source_file
26
+ root + 'Projects/development/source'
27
+ end
28
+
29
+ def pod_file
30
+ root + 'Projects/development/pod'
31
+ end
32
+
33
+ def ios_template
34
+ root + 'Projects/iOS'
35
+ end
36
+
37
+ def configure
38
+ root + 'configure'
39
+ end
40
+
41
+ private
42
+
43
+ def verify_files
44
+ valid = true
45
+ if !source_file.exist?
46
+ valid = false
47
+ elsif !pod_file.exist?
48
+ valid = false
49
+ elsif !ios_template.exist? || ios_template.empty?
50
+ valid = false
51
+ elsif !configure.exist?
52
+ valid = false
53
+ elsif !(root + '.git').exist? || (root + '.git').empty?
54
+ valid = false
55
+ end
56
+ valid
57
+ end
58
+
59
+ def clone_template! to
60
+ repo_url = 'https://github.com/CocoapodsExtension/project-template.git'
61
+ UI.section("Cloning `#{repo_url}`.") do
62
+ git! ['clone', '--depth=1', repo_url, to]
63
+ end
64
+
65
+ unless verify_files
66
+ raise Informative, "Clone failed."
67
+ end
68
+ end
69
+
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,46 @@
1
+ require 'cocoapods-extension/sandbox'
2
+ require 'cocoapods-extension/sandbox/protocol'
3
+
4
+ module Pod
5
+ module Extension
6
+ class Sandbox
7
+ class Workspace < Pod::Sandbox
8
+
9
+ include Pod::Extension::Sandbox::Protocol
10
+
11
+ attr_reader :repos, :template, :projects
12
+
13
+ def initialize
14
+ super File.join(File.expand_path('~'), '.cocoapods/extension')
15
+ @repos = Pod::Extension::Sandbox::Repos::new root
16
+ @template = Pod::Extension::Sandbox::Template::new root
17
+ @projects = Pod::Extension::Sandbox::Projects::new root
18
+ end
19
+
20
+ def install!
21
+ @repos.install!
22
+ @template.install!
23
+ @projects.install!
24
+
25
+ unless source_file.exist?
26
+ cp! [@template::source_file, source_file]
27
+ end
28
+ end
29
+
30
+ def update!
31
+ @repos.update!
32
+ @template.update!
33
+ @projects.update!
34
+
35
+ rm! ['-rf', source_file]
36
+ cp! [@template::source_file, source_file]
37
+ end
38
+
39
+ def source_file
40
+ root + 'source'
41
+ end
42
+
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,51 @@
1
+ require 'cocoapods-extension/sandbox/workspace'
2
+ require 'cocoapods-extension/sandbox/repos'
3
+ require 'cocoapods-extension/sandbox/template'
4
+ require 'cocoapods-extension/sandbox/project'
5
+ require 'cocoapods-extension/sandbox/projects'
6
+
7
+ module Pod
8
+ module Extension
9
+ class Sandbox
10
+
11
+ include Pod::Extension::Sandbox::Protocol
12
+
13
+ def self.workspace
14
+ @@workspace ||= Pod::Extension::Sandbox::Workspace::new
15
+ @@workspace
16
+ end
17
+
18
+ def self.install!
19
+ Pod::Extension::Sandbox::workspace::install!
20
+ end
21
+
22
+ def self.update!
23
+ Pod::Extension::Sandbox::workspace::update!
24
+ end
25
+
26
+ def self.podfile_exists! dir
27
+ if Pod::Extension::Sandbox::find_podfile(dir).nil?
28
+ raise Informative, "No `Podfile' found in the project directory."
29
+ end
30
+ end
31
+
32
+ def self.find_podfile dir
33
+ PODFILE_NAMES.each do |filename|
34
+ candidate = dir + filename
35
+ if candidate.file?
36
+ return candidate
37
+ end
38
+ end
39
+ nil
40
+ end
41
+
42
+ PODFILE_NAMES = [
43
+ 'CocoaPods.podfile.yaml',
44
+ 'CocoaPods.podfile',
45
+ 'Podfile',
46
+ 'Podfile.rb',
47
+ ].freeze
48
+
49
+ end
50
+ end
51
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-extension/gem_version'
@@ -0,0 +1,5 @@
1
+ require 'cocoapods-extension/sandbox'
2
+ require 'cocoapods-extension/configure'
3
+ require 'cocoapods-extension/development'
4
+
5
+ require 'cocoapods-extension/command'
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-extension
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - panghu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-05-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A short description of cocoapods-extension.
42
+ email:
43
+ - panghu.lee@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - LICENSE
49
+ - README.md
50
+ - lib/cocoapods-extension.rb
51
+ - lib/cocoapods-extension/command.rb
52
+ - lib/cocoapods-extension/command/development.rb
53
+ - lib/cocoapods-extension/command/development/create.rb
54
+ - lib/cocoapods-extension/command/development/init.rb
55
+ - lib/cocoapods-extension/command/development/open.rb
56
+ - lib/cocoapods-extension/command/development/update.rb
57
+ - lib/cocoapods-extension/command/xcode.rb
58
+ - lib/cocoapods-extension/command/xcode/clean.rb
59
+ - lib/cocoapods-extension/command/xcode/open.rb
60
+ - lib/cocoapods-extension/configure.rb
61
+ - lib/cocoapods-extension/development.rb
62
+ - lib/cocoapods-extension/development/definition.rb
63
+ - lib/cocoapods-extension/development/development.rb
64
+ - lib/cocoapods-extension/development/dsl.rb
65
+ - lib/cocoapods-extension/development/podfile.rb
66
+ - lib/cocoapods-extension/gem_version.rb
67
+ - lib/cocoapods-extension/sandbox.rb
68
+ - lib/cocoapods-extension/sandbox/project.rb
69
+ - lib/cocoapods-extension/sandbox/projects.rb
70
+ - lib/cocoapods-extension/sandbox/protocol.rb
71
+ - lib/cocoapods-extension/sandbox/repos.rb
72
+ - lib/cocoapods-extension/sandbox/template.rb
73
+ - lib/cocoapods-extension/sandbox/workspace.rb
74
+ - lib/cocoapods_plugin.rb
75
+ homepage: https://github.com/EXAMPLE/cocoapods-extension
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubygems_version: 3.1.2
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: A longer description of cocoapods-extension.
98
+ test_files: []