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.
Files changed (35) 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 +16 -0
  6. data/lib/cocoapods-x/command/edit.rb +70 -0
  7. data/lib/cocoapods-x/command/environment.rb +17 -0
  8. data/lib/cocoapods-x/command/environment/init.rb +30 -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/libary.rb +16 -0
  12. data/lib/cocoapods-x/command/libary/build.rb +14 -0
  13. data/lib/cocoapods-x/command/libary/create.rb +49 -0
  14. data/lib/cocoapods-x/command/repos.rb +74 -0
  15. data/lib/cocoapods-x/command/xcode.rb +15 -0
  16. data/lib/cocoapods-x/command/xcode/clean.rb +75 -0
  17. data/lib/cocoapods-x/command/xcode/open.rb +51 -0
  18. data/lib/cocoapods-x/extension.rb +3 -0
  19. data/lib/cocoapods-x/extension/configure.rb +79 -0
  20. data/lib/cocoapods-x/extension/environment.rb +112 -0
  21. data/lib/cocoapods-x/extension/environment/definition.rb +90 -0
  22. data/lib/cocoapods-x/extension/environment/dsl.rb +76 -0
  23. data/lib/cocoapods-x/extension/environment/pod.rb +23 -0
  24. data/lib/cocoapods-x/extension/environment/podfile.rb +40 -0
  25. data/lib/cocoapods-x/extension/environment/source.rb +24 -0
  26. data/lib/cocoapods-x/extension/sandbox.rb +64 -0
  27. data/lib/cocoapods-x/extension/sandbox/project.rb +51 -0
  28. data/lib/cocoapods-x/extension/sandbox/projects.rb +25 -0
  29. data/lib/cocoapods-x/extension/sandbox/protocol.rb +24 -0
  30. data/lib/cocoapods-x/extension/sandbox/repos.rb +57 -0
  31. data/lib/cocoapods-x/extension/sandbox/template.rb +77 -0
  32. data/lib/cocoapods-x/extension/sandbox/workspace.rb +45 -0
  33. data/lib/cocoapods-x/gem_version.rb +3 -0
  34. data/lib/cocoapods_plugin.rb +2 -0
  35. metadata +106 -0
@@ -0,0 +1,23 @@
1
+ require 'cocoapods-x/extension/environment/dsl'
2
+ require 'cocoapods-x/extension/environment/definition'
3
+
4
+ module Pod
5
+ module X
6
+ class Pods
7
+
8
+ include Pod::X::Pods::DSL
9
+ include Pod::X::DSLBuilder
10
+
11
+ attr_reader :current_pods_definition
12
+
13
+ def initialize
14
+ @current_pods_definition = Pod::X::Pods::Definition::new
15
+ end
16
+
17
+ def list
18
+ @current_pods_definition::list
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,40 @@
1
+
2
+ module Pod
3
+ class Podfile
4
+ module DSL
5
+
6
+ xold_pod_method = instance_method(:pod)
7
+ define_method(:pod) do |name, *requirements|
8
+ environment = Pod::X::Environment::environment
9
+ if environment.runing?
10
+ version = requirements.first
11
+ version ||= ''
12
+ version = version.is_a?(String) ? version : '';
13
+
14
+ options = requirements.last
15
+ options ||= Hash::new
16
+ options = options.is_a?(Hash) ? options : Hash::new(nil);
17
+
18
+ if options[:path].nil?
19
+ podinfo = environment.podinfo?(name, version)
20
+ if !podinfo.nil? && !podinfo.repo_url.nil?
21
+ path = environment.pod_path? podinfo
22
+ UI.puts "pod '#{name}', :path => '#{path}'".green
23
+ xold_pod_method.bind(self).(name, :path => path)
24
+ elsif !podinfo.nil? && podinfo.repo_url.nil?
25
+ UI.puts "Pod::X You must specify a repository to clone for `#{name}`.".yellow
26
+ xold_pod_method.bind(self).(name, *requirements)
27
+ else
28
+ xold_pod_method.bind(self).(name, *requirements)
29
+ end
30
+ else
31
+ xold_pod_method.bind(self).(name, *requirements)
32
+ end
33
+ else
34
+ xold_pod_method.bind(self).(name, *requirements)
35
+ end
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,24 @@
1
+ require 'cocoapods-x/extension/environment/dsl'
2
+ require 'cocoapods-x/extension/environment/definition'
3
+
4
+ module Pod
5
+ module X
6
+ class Source
7
+
8
+ include Pod::X::Source::DSL
9
+ include Pod::X::DSLBuilder
10
+
11
+ attr_reader :parent
12
+ attr_reader :current_domain_definition
13
+
14
+ def initialize
15
+ @parent = Pod::X::Source::Definition::new('', nil)
16
+ end
17
+
18
+ def list
19
+ @parent::list
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,64 @@
1
+ require 'cocoapods-x/extension/sandbox/project'
2
+ require 'cocoapods-x/extension/sandbox/projects'
3
+ require 'cocoapods-x/extension/sandbox/protocol'
4
+ require 'cocoapods-x/extension/sandbox/repos'
5
+ require 'cocoapods-x/extension/sandbox/template'
6
+ require 'cocoapods-x/extension/sandbox/workspace'
7
+
8
+ module Pod
9
+ module X
10
+ class Sandbox
11
+
12
+ include Pod::X::Sandbox::Protocol
13
+
14
+ def self.workspace
15
+ @@workspace ||= Pod::X::Sandbox::Workspace::new
16
+ @@workspace
17
+ end
18
+
19
+ def self.install!
20
+ Pod::X::Sandbox::workspace::install!
21
+ end
22
+
23
+ def self.update!
24
+ Pod::X::Sandbox::workspace::update!
25
+ end
26
+
27
+ def self.podfile_exists! dir
28
+ podfile = Pod::X::Sandbox::find_podfile(dir)
29
+ if podfile.nil?
30
+ raise Informative, "No `Podfile' found in the project directory."
31
+ end
32
+ podfile
33
+ end
34
+
35
+ def self.find_podfile dir
36
+ PODFILE_NAMES.each do |filename|
37
+ candidate = dir + filename
38
+ if candidate.file?
39
+ return candidate
40
+ end
41
+ end
42
+ nil
43
+ end
44
+
45
+ def self.xcode_cachefiles
46
+ XCODE_POD_CACHEFILE
47
+ end
48
+
49
+ PODFILE_NAMES = [
50
+ 'CocoaPods.podfile.yaml',
51
+ 'CocoaPods.podfile',
52
+ 'Podfile',
53
+ 'Podfile.rb',
54
+ ].freeze
55
+
56
+ XCODE_POD_CACHEFILE = {
57
+ 'Pods' => File.join(Dir.pwd, 'Pods'),
58
+ 'Podfile.lock' => File.join(Dir.pwd, 'Podfile.lock'),
59
+ 'DerivedData' => File.join(File.expand_path('~'), 'Library/Developer/Xcode/DerivedData'),
60
+ }.freeze
61
+
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,51 @@
1
+ require 'cocoapods-x/extension/sandbox/protocol'
2
+
3
+ module Pod
4
+ module X
5
+ class Sandbox
6
+ class Project < Pod::Sandbox
7
+
8
+ include Pod::X::Sandbox::Protocol
9
+
10
+ attr_reader :repos, :conf
11
+
12
+ def initialize conf
13
+ @conf = conf
14
+ super conf.project_debug_url
15
+ @repos = Pod::X::Sandbox::Repos::new conf::project_debug_url
16
+ end
17
+
18
+ def install!
19
+ @conf.sync
20
+ @conf.save!
21
+
22
+ unless pods_file.exist?
23
+ cp! [Pod::X::Sandbox::workspace::template::pods_file, pods_file]
24
+ end
25
+
26
+ unless source_file.exist?
27
+ ln! ['-s', Pod::X::Sandbox::workspace::source_file, source_file]
28
+ end
29
+
30
+ end
31
+
32
+ def update!
33
+ install!
34
+ end
35
+
36
+ def pods_file
37
+ root + 'pods'
38
+ end
39
+
40
+ def source_file
41
+ root + 'source'
42
+ end
43
+
44
+ def project_name
45
+ File.basename(@conf.project_url)
46
+ end
47
+
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,25 @@
1
+ require 'cocoapods-x/extension/sandbox/protocol'
2
+
3
+ module Pod
4
+ module X
5
+ class Sandbox
6
+ class Projects < Pod::Sandbox
7
+
8
+ include Pod::X::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,24 @@
1
+ module Pod
2
+ module X
3
+ class Sandbox
4
+ module Protocol
5
+
6
+ extend Executable
7
+ executable :rm
8
+ executable :cp
9
+ executable :ln
10
+ executable :git
11
+ executable :open
12
+
13
+ def install!
14
+
15
+ end
16
+
17
+ def update!
18
+
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,57 @@
1
+ require 'cocoapods-x/extension/sandbox/protocol'
2
+
3
+ module Pod
4
+ module X
5
+ class Sandbox
6
+ class Repos < Pod::Sandbox
7
+
8
+ include Pod::X::Sandbox::Protocol
9
+
10
+ def initialize url
11
+ super File.join(url, 'repos')
12
+ end
13
+
14
+ def install!
15
+
16
+ end
17
+
18
+ def update!
19
+
20
+ end
21
+
22
+ def pod_path! name, version, share, repo_url
23
+ host = hostname(repo_url)
24
+ to = root + "#{host}/#{name}"
25
+ to
26
+ end
27
+
28
+ def pod_path_clone! name, version, share, repo_url
29
+ to = pod_path!(name, version, share, repo_url)
30
+ rm! ['-rf', to]
31
+ pod_clone!(name, repo_url, to)
32
+ to
33
+ end
34
+
35
+ private
36
+
37
+ def pod_clone! name, repo_url, to
38
+ UI.section("Pod::X Cloning #{name}.".green) do
39
+ git! ['clone', repo_url, to]
40
+ end
41
+ unless (to + '.git').exist?
42
+ raise Informative, "Clone failed."
43
+ end
44
+ end
45
+
46
+ def hostname source
47
+ if source.start_with? 'git@'
48
+ source = source.gsub ':', '/'
49
+ source = source.gsub 'git@', 'https://'
50
+ end
51
+ URI(source).hostname
52
+ end
53
+
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,77 @@
1
+ require 'cocoapods-x/extension/sandbox/protocol'
2
+
3
+ module Pod
4
+ module X
5
+ class Sandbox
6
+ class Template < Pod::Sandbox
7
+
8
+ include Pod::X::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/podfile/source'
27
+ end
28
+
29
+ def pods_file
30
+ root + 'Projects/podfile/pods'
31
+ end
32
+
33
+ def ios_template
34
+ root + 'Projects/ios'
35
+ end
36
+
37
+ def xcbuild
38
+ root + 'Projects/xcbuild'
39
+ end
40
+
41
+ def configure
42
+ root + 'configure'
43
+ end
44
+
45
+ private
46
+
47
+ def verify_files
48
+ valid = true
49
+ if !source_file.exist?
50
+ valid = false
51
+ elsif !pods_file.exist?
52
+ valid = false
53
+ elsif !ios_template.exist? || ios_template.empty?
54
+ valid = false
55
+ elsif !configure.exist?
56
+ valid = false
57
+ elsif !(root + '.git').exist? || (root + '.git').empty?
58
+ valid = false
59
+ end
60
+ valid
61
+ end
62
+
63
+ def clone_template! to
64
+ repo_url = 'https://github.com/CocoaPodsX/project-template.git'
65
+ UI.section("Cloning `#{repo_url}`.") do
66
+ git! ['clone', '--depth=1', repo_url, to]
67
+ end
68
+
69
+ unless verify_files
70
+ raise Informative, "Clone failed."
71
+ end
72
+ end
73
+
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,45 @@
1
+ require 'cocoapods-x/extension/sandbox/protocol'
2
+
3
+ module Pod
4
+ module X
5
+ class Sandbox
6
+ class Workspace < Pod::Sandbox
7
+
8
+ include Pod::X::Sandbox::Protocol
9
+
10
+ attr_reader :repos, :template, :projects
11
+
12
+ def initialize
13
+ super File.join(File.expand_path('~'), '.cocoapods/x')
14
+ @repos = Pod::X::Sandbox::Repos::new root
15
+ @template = Pod::X::Sandbox::Template::new root
16
+ @projects = Pod::X::Sandbox::Projects::new root
17
+ end
18
+
19
+ def install!
20
+ @repos.install!
21
+ @template.install!
22
+ @projects.install!
23
+
24
+ unless source_file.exist?
25
+ cp! [@template::source_file, source_file]
26
+ end
27
+ end
28
+
29
+ def update!
30
+ @repos.update!
31
+ @template.update!
32
+ @projects.update!
33
+
34
+ rm! ['-rf', source_file]
35
+ cp! [@template::source_file, source_file]
36
+ end
37
+
38
+ def source_file
39
+ root + 'source'
40
+ end
41
+
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,3 @@
1
+ module CocoapodsX
2
+ VERSION = "0.0.1"
3
+ end