cocoapods-x 0.0.4

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.
Files changed (38) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +22 -0
  3. data/README.md +36 -0
  4. data/lib/cocoapods-x.rb +1 -0
  5. data/lib/cocoapods-x/command.rb +18 -0
  6. data/lib/cocoapods-x/command/edit.rb +81 -0
  7. data/lib/cocoapods-x/command/environment.rb +17 -0
  8. data/lib/cocoapods-x/command/environment/init.rb +29 -0
  9. data/lib/cocoapods-x/command/environment/install.rb +29 -0
  10. data/lib/cocoapods-x/command/environment/update.rb +30 -0
  11. data/lib/cocoapods-x/command/install.rb +35 -0
  12. data/lib/cocoapods-x/command/libary.rb +16 -0
  13. data/lib/cocoapods-x/command/libary/build.rb +14 -0
  14. data/lib/cocoapods-x/command/libary/create.rb +49 -0
  15. data/lib/cocoapods-x/command/repo.rb +91 -0
  16. data/lib/cocoapods-x/command/update.rb +28 -0
  17. data/lib/cocoapods-x/command/xcode.rb +15 -0
  18. data/lib/cocoapods-x/command/xcode/clean.rb +75 -0
  19. data/lib/cocoapods-x/command/xcode/open.rb +26 -0
  20. data/lib/cocoapods-x/extension.rb +4 -0
  21. data/lib/cocoapods-x/extension/configure.rb +84 -0
  22. data/lib/cocoapods-x/extension/environment.rb +31 -0
  23. data/lib/cocoapods-x/extension/installer.rb +145 -0
  24. data/lib/cocoapods-x/extension/installer/builder.rb +36 -0
  25. data/lib/cocoapods-x/extension/installer/dsl.rb +94 -0
  26. data/lib/cocoapods-x/extension/installer/podfile.rb +66 -0
  27. data/lib/cocoapods-x/extension/sandbox.rb +64 -0
  28. data/lib/cocoapods-x/extension/sandbox/project.rb +51 -0
  29. data/lib/cocoapods-x/extension/sandbox/projects.rb +25 -0
  30. data/lib/cocoapods-x/extension/sandbox/protocol.rb +24 -0
  31. data/lib/cocoapods-x/extension/sandbox/repos.rb +81 -0
  32. data/lib/cocoapods-x/extension/sandbox/template.rb +77 -0
  33. data/lib/cocoapods-x/extension/sandbox/workspace.rb +84 -0
  34. data/lib/cocoapods-x/extension/xcode.rb +1 -0
  35. data/lib/cocoapods-x/extension/xcode/open.rb +44 -0
  36. data/lib/cocoapods-x/gem_version.rb +3 -0
  37. data/lib/cocoapods_plugin.rb +2 -0
  38. metadata +109 -0
@@ -0,0 +1,28 @@
1
+ module Pod
2
+ class Command
3
+ class X < Command
4
+ class Update < X
5
+
6
+ self.summary = Pod::Command::Update::summary
7
+
8
+ self.description = Pod::Command::Update::description
9
+
10
+ self.arguments = Pod::Command::Update::arguments
11
+
12
+ def self.options
13
+ Pod::Command::Update::options
14
+ end
15
+
16
+ def initialize(argv)
17
+ @update = Pod::Command::Update::new(argv)
18
+ super
19
+ end
20
+
21
+ def run
22
+ @update::run
23
+ end
24
+
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,15 @@
1
+ require 'cocoapods-x/command/xcode/clean'
2
+ require 'cocoapods-x/command/xcode/open'
3
+
4
+ module Pod
5
+ class Command
6
+ class X < Command
7
+ class XC < X
8
+
9
+ self.abstract_command = true
10
+ self.summary = 'Cocoapods X Xcode.'
11
+
12
+ end
13
+ end
14
+ end
15
+ end
@@ -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
+ ['--open', 'Open after Installation complete']
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 '[!] Pod::X '.magenta + "#{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,26 @@
1
+ require 'cocoapods-x/extension/xcode/open'
2
+
3
+ module Pod
4
+ class Command
5
+ class X < Command
6
+ class XC < X
7
+ class Open < XC
8
+
9
+ self.summary = 'Open current dir xcodeproj or xcworkspace.'
10
+
11
+ self.description = 'Open current dir xcodeproj or xcworkspace.'
12
+
13
+ def initialize(argv)
14
+ super
15
+ end
16
+
17
+ def run
18
+ xcopen = Pod::X::Xcode::Open::new
19
+ xcopen.run!
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,4 @@
1
+ require 'cocoapods-x/extension/configure'
2
+ require 'cocoapods-x/extension/installer'
3
+ require 'cocoapods-x/extension/sandbox'
4
+ require 'cocoapods-x/extension/xcode'
@@ -0,0 +1,84 @@
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
+ name = File.basename(project_url)
23
+ projects = Pod::X::Sandbox::workspace::projects
24
+ for index in 0..10000
25
+ if index == 0
26
+ project_debug_url = projects::root + name
27
+ else
28
+ project_debug_url = projects::root + "#{name}@#{index}"
29
+ end
30
+ unless project_debug_url.exist?
31
+ break
32
+ end
33
+ end
34
+ Pod::X::Configurator::new project_url, project_debug_url
35
+ end
36
+
37
+ attr_reader :conf
38
+
39
+ def initialize project_url, project_debug_url
40
+ @conf = { 'project_url' => project_url.to_s, 'project_debug_url' => project_debug_url.to_s }
41
+ end
42
+
43
+ def url
44
+ File.join(project_debug_url, '.conf')
45
+ end
46
+
47
+ def project_url
48
+ @conf['project_url']
49
+ end
50
+
51
+ def project_debug_url
52
+ @conf['project_debug_url']
53
+ end
54
+
55
+ def verify?
56
+ valid = false
57
+ unless url.nil? || project_url.nil? || project_debug_url.nil?
58
+ if File.exist?(url) && File.exist?(project_url) && File.exist?(project_debug_url)
59
+ begin json = JSON.parse(File.read(url))
60
+ rescue => exception
61
+ end
62
+ valid = @conf == json
63
+ end
64
+ end
65
+ valid
66
+ end
67
+
68
+ def sync
69
+ begin json = JSON.parse(File.read(url))
70
+ rescue => exception
71
+ end
72
+ unless json.nil?
73
+ @conf = json.merge(@conf)
74
+ end
75
+ end
76
+
77
+ def save!
78
+ return nil if verify?
79
+ File.write(url, @conf.to_json)
80
+ end
81
+
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,31 @@
1
+ require 'cocoapods-x/extension/sandbox'
2
+ require 'cocoapods-x/extension/configure'
3
+
4
+ module Pod
5
+ module X
6
+ class Environment
7
+
8
+ def self.install!
9
+ Pod::X::Sandbox::install!
10
+ Pod::X::Sandbox::workspace
11
+ end
12
+
13
+ def self.update!
14
+ Pod::X::Sandbox::update!
15
+ Pod::X::Sandbox::workspace
16
+ end
17
+
18
+ def self.init!
19
+ project_url = Pathname(Dir.pwd)
20
+ Pod::X::Sandbox::install!
21
+ Pod::X::Sandbox::podfile_exists! project_url
22
+ conf = Pod::X::Configurator::find_conf? project_url
23
+ conf ||= Pod::X::Configurator::create_conf! project_url
24
+ project = Pod::X::Sandbox::Project::new conf
25
+ project.install!
26
+ project
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,145 @@
1
+ require 'cocoapods-x/extension/sandbox'
2
+ require 'cocoapods-x/extension/configure'
3
+ require 'cocoapods-x/extension/installer/dsl'
4
+ require 'cocoapods-x/extension/installer/podfile'
5
+ require 'cocoapods-x/extension/installer/builder'
6
+
7
+ module Pod
8
+ module X
9
+ class Installer
10
+
11
+ attr_accessor :init_self, :target_self, :pod_self, :print_post_install_message_self
12
+ attr_accessor :init_method, :target_method, :pod_method, :print_post_install_message_method
13
+
14
+ attr_accessor :pods_builder, :sources_builder
15
+ attr_accessor :project, :workspace
16
+
17
+ attr_accessor :repos
18
+ attr_accessor :use_repos
19
+
20
+ extend Executable
21
+ executable :rm
22
+ executable :git
23
+
24
+ def initialize
25
+ @project = nil
26
+ @workspace = nil
27
+ @pods_builder = Pod::X::PodsBuilder::new
28
+ @sources_builder = Pod::X::SourcesBuilder::new
29
+ end
30
+
31
+ def self.installer
32
+ @@shared ||= Pod::X::Installer::new
33
+ @@shared
34
+ end
35
+
36
+ # monitor
37
+
38
+ def monitor_initialize_begin(defined_in_file = nil, internal_hash = {}, &block)
39
+ workspace = Pod::X::Sandbox::workspace
40
+ return unless workspace.source_file.exist?
41
+
42
+ conf = Pod::X::Configurator::find_conf?(Dir.pwd)
43
+ return if conf.nil?
44
+ project = Pod::X::Sandbox::Project::new(conf)
45
+ return unless project.pods_file.exist?
46
+
47
+ @project = project
48
+ @workspace = workspace
49
+ @pods_builder::build(project.pods_file)
50
+ @sources_builder::build(workspace.source_file)
51
+ @repos = build_repos()
52
+ @use_repos = Array::new
53
+ UI.puts 'Pod::X '.magenta + 'Working...'.green
54
+ end
55
+
56
+ def monitor_initialize_end(defined_in_file = nil, internal_hash = {}, &block)
57
+ return nil if @repos.nil?
58
+ return nil if @use_repos.nil?
59
+
60
+ @use_repos.each do |name|
61
+ repo = @repos[name]
62
+ repo_url = repo.repo_url
63
+ location_url = repo.location_url
64
+ if repo_url.nil? || location_url.nil?
65
+ UI.puts 'Pod::X '.magenta + "You must specify a repository to clone for '#{name}'.".yellow
66
+ elsif !Dir::exist?(location_url) || Dir::empty?(location_url)
67
+ UI.section('Pod::X '.magenta + "Cloning into '#{name}'...".green) do
68
+ UI.puts 'Pod::X '.magenta + "'#{name}' from: #{repo_url}".magenta
69
+ UI.puts 'Pod::X '.magenta + "'#{name}' to: #{location_url}".magenta
70
+ rm! ['-rf', location_url]
71
+ git! ['clone', repo_url, location_url]
72
+ end
73
+ end
74
+ end
75
+ end
76
+
77
+ def monitor_target_begin(name, options = nil, &block)
78
+
79
+ end
80
+
81
+ def monitor_target_end(name, options = nil, &block)
82
+
83
+ end
84
+
85
+ def monitor_pod_begin(name, *requirements)
86
+ return nil if @repos.nil?
87
+ return nil if @repos[name].nil?
88
+ return nil if @use_repos.nil?
89
+ unless @use_repos.include?(name)
90
+ @use_repos << name
91
+ end
92
+ @repos[name].location_url
93
+ end
94
+
95
+ def monitor_pod_end(name, *requirements)
96
+ nil
97
+ end
98
+
99
+ def monitor_print_post_install_message_begin
100
+ return nil if @repos.nil?
101
+ return nil if @use_repos.nil?
102
+ return nil if @use_repos.size <= 0
103
+
104
+ @use_repos.each do |name|
105
+ repo = @repos[name]
106
+ location_url = repo.location_url
107
+ unless location_url.nil?
108
+ Dir.chdir(location_url) do
109
+ begin
110
+ branch = git! ['rev-parse', '--abbrev-ref', 'HEAD']
111
+ branch = branch.chomp
112
+ UI.puts 'Pod::X '.magenta + "Installing #{name} (#{branch.red})".green
113
+ rescue => exception
114
+ UI.puts 'Pod::X '.magenta + "Installing #{name}".green
115
+ end
116
+ end
117
+ end
118
+ end
119
+ UI.puts 'Pod::X '.magenta + "installation complete!".green
120
+ end
121
+
122
+ def monitor_print_post_install_message_end
123
+
124
+ end
125
+
126
+ private
127
+
128
+ def build_repos
129
+ return nil if @pods_builder.nil?
130
+ return nil if @sources_builder.nil?
131
+
132
+ repos = Hash::new(nil)
133
+ @pods_builder.pods.each do | name, pod_argv |
134
+ source_argv = @sources_builder.sources[name]
135
+ repo = Pod::X::Sandbox::Repos::Repo(name, pod_argv, source_argv, @workspace, @project)
136
+ unless repo.nil?
137
+ repos[name] = repo
138
+ end
139
+ end
140
+ repos
141
+ end
142
+
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,36 @@
1
+ require 'cocoapods-x/extension/installer/dsl'
2
+
3
+ module Pod
4
+ module X
5
+ class PodsBuilder
6
+
7
+ include Pod::X::PodsDSL
8
+ include Pod::X::BuilderDSL
9
+
10
+ attr_accessor :pods
11
+
12
+ def initialize
13
+ @pods = Hash::new(nil)
14
+ end
15
+
16
+ end
17
+
18
+ class SourcesBuilder
19
+
20
+ include Pod::X::SourcesDSL
21
+ include Pod::X::BuilderDSL
22
+
23
+ attr_accessor :current_domain, :current_group
24
+ attr_accessor :sources
25
+
26
+ def initialize
27
+ @current_domain = nil
28
+ @current_group = nil
29
+ @sources = Hash::new(nil)
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+ end
36
+