cocoapods-x 0.0.3

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,94 @@
1
+ module Pod
2
+ module X
3
+
4
+ module PodsDSL
5
+
6
+ def pod(name = nil, *requirements)
7
+ unless name
8
+ raise StandardError, 'A development requires a name.'
9
+ end
10
+
11
+ pod = Hash::new(nil)
12
+ pod[:name] = name
13
+ pod[:share] = true
14
+ options = requirements.last
15
+ if options && options.is_a?(Hash)
16
+ pod = pod.merge(options.dup)
17
+ end
18
+
19
+ @pods[name] = pod
20
+ end
21
+
22
+ end
23
+
24
+ module SourcesDSL
25
+
26
+ def source(domain, *requirements)
27
+ @current_domain = domain
28
+ options = requirements.last
29
+ if options && options.is_a?(Hash) && options[:group]
30
+ @current_group = options[:group]
31
+ end
32
+
33
+ yield if block_given?
34
+ ensure
35
+ @current_domain = nil
36
+ @current_group = nil
37
+ end
38
+
39
+ def pod(name = nil, *requirements)
40
+ unless name
41
+ raise StandardError, 'A development requires a name.'
42
+ end
43
+
44
+ return if @current_domain.nil?
45
+
46
+ source = Hash::new(nil)
47
+ source[:domain] = @current_domain
48
+ source[:git] = name + '.git'
49
+ source[:name] = name
50
+ if @current_group
51
+ source[:group] = @current_group
52
+ else
53
+ source[:group] = name
54
+ end
55
+
56
+ options = requirements.last
57
+ if options && options.is_a?(Hash)
58
+ source = source.merge(options.dup)
59
+ end
60
+
61
+ @sources[name] = source
62
+ end
63
+
64
+ end
65
+
66
+ module BuilderDSL
67
+
68
+ def build url
69
+ contents = File.exist?(url) ? File.open(url, 'r:utf-8', &:read) : nil
70
+ # Work around for Rubinius incomplete encoding in 1.9 mode
71
+ if !contents.nil? && contents.respond_to?(:encoding) && contents.encoding.name != 'UTF-8'
72
+ contents.encode!('UTF-8')
73
+ end
74
+ if !contents.nil? && contents.tr!('“”‘’‛', %(""'''))
75
+ # Changes have been made
76
+ CoreUI.warn "Smart quotes were detected and ignored in your #{File.basename(url)}. " \
77
+ 'To avoid issues in the future, you should not use ' \
78
+ 'TextEdit for editing it. If you are not using TextEdit, ' \
79
+ 'you should turn off smart quotes in your editor of choice.'
80
+ end
81
+ unless contents.nil?
82
+ begin
83
+ eval(contents, nil, url.to_s)
84
+ rescue Exception => e
85
+ message = "Invalid `#{File.basename(url)}` file: #{e.message}"
86
+ raise DSLError.new(message, url, e, contents)
87
+ end
88
+ end
89
+ end
90
+
91
+ end
92
+
93
+ end
94
+ end
@@ -0,0 +1,66 @@
1
+ module Pod
2
+ class Podfile
3
+
4
+ xold_podfile_init_method = instance_method(:initialize)
5
+ define_method(:initialize) do |defined_in_file = nil, internal_hash = {}, &block|
6
+ installer = Pod::X::Installer::installer
7
+ installer.init_self = self
8
+ installer.init_method = xold_podfile_init_method
9
+
10
+ installer::monitor_initialize_begin(defined_in_file, internal_hash, &block)
11
+ result = xold_podfile_init_method.bind(self).(defined_in_file, internal_hash, &block)
12
+ installer::monitor_initialize_end(defined_in_file, internal_hash, &block)
13
+ result
14
+ end
15
+
16
+ module DSL
17
+
18
+ xold_target_method = instance_method(:target)
19
+ define_method(:target) do |name, options = nil, &block|
20
+ installer = Pod::X::Installer::installer
21
+ installer.target_self = self
22
+ installer.target_method = xold_target_method
23
+
24
+ installer::monitor_target_begin(name, options, &block)
25
+ result = xold_target_method.bind(self).(name, options, &block)
26
+ installer::monitor_target_end(name, options, &block)
27
+ result
28
+ end
29
+
30
+ xold_pod_method = instance_method(:pod)
31
+ define_method(:pod) do |name, *requirements|
32
+ installer = Pod::X::Installer::installer
33
+ installer.pod_self = self
34
+ installer.pod_method = xold_pod_method
35
+
36
+ path = installer::monitor_pod_begin(name, *requirements)
37
+ if path
38
+ result = xold_pod_method.bind(self).(name, :path => path)
39
+ else
40
+ result = xold_pod_method.bind(self).(name, *requirements)
41
+ end
42
+ installer::monitor_pod_end(name, *requirements)
43
+ result
44
+ end
45
+
46
+ end
47
+ end
48
+ end
49
+
50
+ module Pod
51
+ class Installer
52
+
53
+ xold_print_post_install_message_method = instance_method(:print_post_install_message)
54
+ define_method(:print_post_install_message) do
55
+ installer = Pod::X::Installer::installer
56
+ installer.print_post_install_message_self = self
57
+ installer.print_post_install_message_method = xold_print_post_install_message_method
58
+
59
+ installer::monitor_print_post_install_message_begin()
60
+ result = xold_print_post_install_message_method.bind(self).()
61
+ installer::monitor_print_post_install_message_end()
62
+ result
63
+ end
64
+
65
+ end
66
+ 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 + 'sources'
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,81 @@
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
+ Repo = Struct::new(:name, :repo_url, :location_url)
11
+
12
+ def initialize url
13
+ super File.join(url, 'repos')
14
+ end
15
+
16
+ def install!
17
+
18
+ end
19
+
20
+ def update!
21
+
22
+ end
23
+
24
+ def self.Repo name, pod_argv, source_argv, workspace, project
25
+ return nil if pod_argv.nil?
26
+
27
+ location_url = pod_argv[:path]
28
+ return Repo::new(name, nil, location_url) unless location_url.nil?
29
+
30
+ repo_url = pod_argv[:source]
31
+ return Repo::new(name, repo_url, LocationUrl(name, repo_url, pod_argv, workspace, project)) unless repo_url.nil?
32
+
33
+ return Repo::new(name, nil, nil) if source_argv.nil?
34
+
35
+ git_name = source_argv[:git]
36
+ return Repo::new(name, nil, nil) if git_name.nil?
37
+
38
+ group_name = source_argv[:group]
39
+ return Repo::new(name, nil, nil) if group_name.nil?
40
+
41
+ domain_name = source_argv[:domain]
42
+ return Repo::new(name, nil, nil) if domain_name.nil?
43
+
44
+ if domain_name.start_with? "git@"
45
+ repo_url = RepoGitUrl(domain_name, group_name, git_name)
46
+ else
47
+ repo_url = RepoHttpUrl(domain_name, group_name, git_name)
48
+ end
49
+
50
+ Repo::new(name, repo_url, LocationUrl(name, repo_url, pod_argv, workspace, project))
51
+ end
52
+
53
+ private
54
+
55
+ def self.LocationUrl name, repo_url, pod_argv, workspace, project
56
+ hostname = Hostname(repo_url)
57
+ root = pod_argv[:share] ? workspace::repos::root : project::repos::root
58
+ (root + "#{hostname}/#{name}").to_s
59
+ end
60
+
61
+ def self.Hostname repo_url
62
+ url = repo_url
63
+ if url.start_with? 'git@'
64
+ url = url.gsub ':', '/'
65
+ url = url.gsub 'git@', 'https://'
66
+ end
67
+ URI(url).hostname
68
+ end
69
+
70
+ def self.RepoGitUrl domain_name, group_name, git_name
71
+ "#{domain_name}:#{group_name}/#{git_name}"
72
+ end
73
+
74
+ def self.RepoHttpUrl domain_name, group_name, git_name
75
+ "#{domain_name}/#{group_name}/#{git_name}"
76
+ end
77
+
78
+ end
79
+ end
80
+ end
81
+ 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/sources'
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('Pod::X '.blue + "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