cocoapods-x 0.0.1 → 0.0.2

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 (33) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cocoapods-x/command.rb +3 -1
  3. data/lib/cocoapods-x/command/edit.rb +41 -30
  4. data/lib/cocoapods-x/command/environment/init.rb +3 -4
  5. data/lib/cocoapods-x/command/environment/install.rb +3 -3
  6. data/lib/cocoapods-x/command/environment/update.rb +3 -3
  7. data/lib/cocoapods-x/command/install.rb +35 -0
  8. data/lib/cocoapods-x/command/libary/create.rb +1 -1
  9. data/lib/cocoapods-x/command/repo.rb +91 -0
  10. data/lib/cocoapods-x/command/update.rb +28 -0
  11. data/lib/cocoapods-x/command/xcode/clean.rb +2 -2
  12. data/lib/cocoapods-x/command/xcode/open.rb +5 -30
  13. data/lib/cocoapods-x/extension.rb +2 -1
  14. data/lib/cocoapods-x/extension/configure.rb +10 -5
  15. data/lib/cocoapods-x/extension/environment.rb +0 -81
  16. data/lib/cocoapods-x/extension/installer.rb +144 -0
  17. data/lib/cocoapods-x/extension/installer/builder.rb +36 -0
  18. data/lib/cocoapods-x/extension/installer/dsl.rb +94 -0
  19. data/lib/cocoapods-x/extension/installer/podfile.rb +66 -0
  20. data/lib/cocoapods-x/extension/sandbox/project.rb +1 -1
  21. data/lib/cocoapods-x/extension/sandbox/repos.rb +48 -24
  22. data/lib/cocoapods-x/extension/sandbox/template.rb +2 -2
  23. data/lib/cocoapods-x/extension/sandbox/workspace.rb +41 -2
  24. data/lib/cocoapods-x/extension/xcode.rb +1 -0
  25. data/lib/cocoapods-x/extension/xcode/open.rb +44 -0
  26. data/lib/cocoapods-x/gem_version.rb +1 -1
  27. metadata +11 -8
  28. data/lib/cocoapods-x/command/repos.rb +0 -74
  29. data/lib/cocoapods-x/extension/environment/definition.rb +0 -90
  30. data/lib/cocoapods-x/extension/environment/dsl.rb +0 -76
  31. data/lib/cocoapods-x/extension/environment/pod.rb +0 -23
  32. data/lib/cocoapods-x/extension/environment/podfile.rb +0 -40
  33. data/lib/cocoapods-x/extension/environment/source.rb +0 -24
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32cff653b80d3343bae35af858d10331bd2d68cd024c03da3f32d7c4dfcadc91
4
- data.tar.gz: ed192ed7ae254679f47c191acc1325e6474bb6fa4b85aba514a3bab25b3b0d16
3
+ metadata.gz: a3d2e5a49fed99b47ab8e1ae181fdc5538eaaf514bdb3757b0d43b50b1a71aaa
4
+ data.tar.gz: 11e8cd16f25b9e5f5c281e988ae56bfc23b3e40656e0d0322e8fd2adea4a83dd
5
5
  SHA512:
6
- metadata.gz: 9442ee5105a037b7e272f04070b0c0737b7bf931bb2e62b96805f2f5abcbcae795cfa532348e5d4386955882f9fc914b7e02feae5bf53e36a9c6200f9cea761c
7
- data.tar.gz: 6c018a866b92ee0f43490f464f5bebfa9237248cf5c5720c8cae461ff42a630449559673462ea1bf96e93d7c91d4337b40977e60fce612854700c0552ab85d88
6
+ metadata.gz: 2397da17ff81c0a6f941b67bb678bdb3f78aa79ba996497d88c8ea3db42c2edb453d8b8cec14748631d078fda80213c27df974c15b5038eebad447569f20e77c
7
+ data.tar.gz: e844338ebb20f5e6bdeeb8afbd06d149e7324350f51c2a9c5f1b51733950ecdd79dc3fd73b42d7b45e06539d2fc8c7879540ee1ef49b34177688ee9c4712a8d4
@@ -1,7 +1,9 @@
1
1
  require 'cocoapods-x/command/edit'
2
2
  require 'cocoapods-x/command/environment'
3
+ require 'cocoapods-x/command/install'
3
4
  require 'cocoapods-x/command/libary'
4
- require 'cocoapods-x/command/repos'
5
+ require 'cocoapods-x/command/repo'
6
+ require 'cocoapods-x/command/update'
5
7
  require 'cocoapods-x/command/xcode'
6
8
 
7
9
  module Pod
@@ -7,40 +7,31 @@ module Pod
7
7
  class Edit < X
8
8
 
9
9
  self.summary = 'Cocoapods X Edit.'
10
- self.description = 'Cocoapods X Edit.'
10
+ self.description = <<-DESC
11
+ NAME is 'pods' edit pods file,\n
12
+ NAME is 'sources' edit source file,\n
13
+ NAME is 'podfile' edit Podfile file.
14
+ DESC
11
15
 
12
- def self.options
13
- [
14
- ['--pods', 'Edit source.rb file.'],
15
- ['--source', 'Edit source.rb file.'],
16
- ['--podfile', 'Edit Podfile file.']
17
- ].concat(super)
18
- end
16
+ self.arguments = [
17
+ CLAide::Argument.new('NAME', true),
18
+ ]
19
19
 
20
20
  def initialize(argv)
21
- @wipe_pods = argv.flag?('pods')
22
- @wipe_source = argv.flag?('source')
23
- @wipe_podfile = argv.flag?('podfile')
21
+ @name = argv.shift_argument
24
22
  super
25
23
  end
26
24
 
27
25
  def run
28
- begin
29
- if @wipe_pods
30
- open_pods!
31
- end
32
-
33
- if @wipe_source
34
- open_source!
35
- end
36
-
37
- if @wipe_podfile
38
- open_podfile!
39
- end
40
- rescue => exception
41
- puts "[!] Pod::X #{exception}".red
26
+ if @name == 'pods'
27
+ open_pods!
28
+ elsif @name == 'sources'
29
+ open_source!
30
+ elsif @name == 'Podfile'
31
+ open_podfile!
32
+ else
33
+ self.help!
42
34
  end
43
-
44
35
  end
45
36
 
46
37
  private
@@ -50,18 +41,38 @@ module Pod
50
41
 
51
42
  def open_pods!
52
43
  project = Pod::X::Environment::init!
53
- open! ['-a', 'Xcode', project.pods_file]
44
+ open_ide! project.pods_file
54
45
  end
55
46
 
56
47
  def open_source!
57
48
  workspace = Pod::X::Environment::install!
58
- open! ['-a', 'Xcode', workspace.source_file]
49
+ open_ide! workspace.source_file
59
50
  end
60
51
 
61
52
  def open_podfile!
62
- project_url = Pathname(Dir.pwd)
53
+ project_url = Pathname(Dir.pwd)
63
54
  podfile = Pod::X::Sandbox::podfile_exists! project_url
64
- open! ['-a', 'Xcode', podfile]
55
+ open_ide! podfile
56
+ end
57
+
58
+ private
59
+
60
+ def open_ide! url
61
+ ide = sel_ide
62
+ if ide
63
+ open! ['-a', ide, url]
64
+ else
65
+ open! [url]
66
+ end
67
+ end
68
+
69
+ def sel_ide
70
+ ides = ['/Applications/Visual Studio Code.app', '/Applications/Sublime Text.app', '/Applications/Xcode.app']
71
+ ides.each do |i|
72
+ path = Pathname(i)
73
+ return path if path.exist?
74
+ end
75
+ nil
65
76
  end
66
77
 
67
78
  end
@@ -15,12 +15,11 @@ module Pod
15
15
 
16
16
  def run
17
17
  begin
18
- UI.puts "Initing X environment."
18
+ UI.puts 'Pod::X '.blue + "Initing X environment."
19
19
  project = Pod::X::Environment::init!
20
-
21
- UI.puts "Pod::X '#{project.project_name}' initialization complete!".green
20
+ UI.puts 'Pod::X '.blue + "'#{project.project_name}' initialization complete!".green
22
21
  rescue => exception
23
- puts "[!] Pod::X #{exception}".red
22
+ UI.puts '[!] Pod::X '.blue + "#{exception}".red
24
23
  end
25
24
  end
26
25
  end
@@ -15,11 +15,11 @@ module Pod
15
15
 
16
16
  def run
17
17
  begin
18
- UI.puts "Installing X environment."
18
+ UI.puts 'Pod::X '.blue + "Installing X environment."
19
19
  Pod::X::Environment::install!
20
- UI.puts "Pod::X Env installation complete!".green
20
+ UI.puts 'Pod::X '.blue + "Env installation complete!".green
21
21
  rescue => exception
22
- puts "[!] Pod::X #{exception}".red
22
+ UI.puts '[!] Pod::X '.blue + "#{exception}".red
23
23
  end
24
24
  end
25
25
  end
@@ -15,11 +15,11 @@ module Pod
15
15
 
16
16
  def run
17
17
  begin
18
- UI.puts "Updating X environment."
18
+ UI.puts 'Pod::X '.blue + "Updating X environment."
19
19
  Pod::X::Environment::update!
20
- UI.puts "Pod::X Env installation complete!".green
20
+ UI.puts 'Pod::X '.blue + "Env installation complete!".green
21
21
  rescue => exception
22
- puts "[!] Pod::X #{exception}".red
22
+ UI.puts '[!] Pod::X '.blue + "#{exception}".red
23
23
  end
24
24
  end
25
25
 
@@ -0,0 +1,35 @@
1
+ require 'cocoapods-x/extension/xcode/open'
2
+
3
+ module Pod
4
+ class Command
5
+ class X < Command
6
+ class Install < X
7
+
8
+ self.summary = Pod::Command::Install::summary
9
+
10
+ self.description = Pod::Command::Install::description
11
+
12
+ def self.options
13
+ options = Pod::Command::Install::options
14
+ options << ['--open', 'Remove all the cached without asking']
15
+ options
16
+ end
17
+
18
+ def initialize(argv)
19
+ @wipe_all = argv.flag?('open')
20
+ @install = Pod::Command::Install::new(argv)
21
+ super
22
+ end
23
+
24
+ def run
25
+ @install::run
26
+ if @wipe_all
27
+ xcopen = Pod::X::Xcode::Open::new
28
+ xcopen.run!
29
+ end
30
+ end
31
+
32
+ end
33
+ end
34
+ end
35
+ end
@@ -29,7 +29,7 @@ module Pod
29
29
  configure_url = Pod::X::Sandbox::workspace::template::configure
30
30
  template_url = Pod::X::Sandbox::workspace::template::ios_template
31
31
  if Dir::exist?(target_url) && !Dir::empty?(target_url)
32
- UI.puts "fatal: destination path '#{project_name}' already exists and is not an empty directory.".red
32
+ UI.puts 'Pod::X '.blue + "fatal: destination path '#{project_name}' already exists and is not an empty directory.".red
33
33
  else
34
34
  rm! ['-rf', target_url]
35
35
  if !template_url.exist?
@@ -0,0 +1,91 @@
1
+ module Pod
2
+ class Command
3
+ class X < Command
4
+ class Repo < X
5
+
6
+ self.summary = 'Opens pods dir.'
7
+ self.description = <<-DESC
8
+ Opens pods.
9
+ DESC
10
+
11
+ self.arguments = [
12
+ CLAide::Argument.new('NAME', true),
13
+ ]
14
+
15
+ def self.options
16
+ [
17
+ ['--terminal', 'Use terminal open pod']
18
+ ].concat(super)
19
+ end
20
+
21
+ def initialize(argv)
22
+ @name = argv.shift_argument
23
+ @wipe_terminal = argv.flag?('terminal')
24
+ super
25
+ end
26
+
27
+ def run
28
+ pods = Pod::X::Sandbox::workspace::all_pods
29
+ if !@name.nil? && @name.size > 0
30
+ pods = pods.select{ |pod| pod.name == @name }
31
+ end
32
+ open_pods pods
33
+ end
34
+
35
+ private
36
+
37
+ extend Executable
38
+ executable :open
39
+
40
+ def open_pods pods
41
+ return if (pods.nil? || pods.size <= 0)
42
+
43
+ choices = Array::new
44
+ pods.each do |pod|
45
+ choice = pod.name
46
+ unless pod.branch.nil?
47
+ choice += " (#{pod.branch})".red
48
+ end
49
+ unless pod.project.nil?
50
+ choice += " => project: #{pod.project}"
51
+ end
52
+ choice += " => path: #{pod.location_url}"
53
+ choices << choice
54
+ end
55
+
56
+ begin
57
+ if choices.size == 1
58
+ index = 0
59
+ else
60
+ index = UI.choose_from_array(choices, 'Which item do you?')
61
+ end
62
+ url = pods[index].location_url
63
+ open_url! url
64
+ rescue => exception
65
+ UI.puts '[!] Pod::X '.blue + "#{exception}".red
66
+ end
67
+
68
+ end
69
+
70
+ def open_url! url
71
+ ter = sel_ter
72
+ if @wipe_terminal && ter
73
+ open! ['-a', ter, url]
74
+ else
75
+ open! [url]
76
+ end
77
+ end
78
+
79
+ def sel_ter
80
+ ters = ['/Applications/iTerm.app', '/System/Applications/Utilities/Terminal.app']
81
+ ters.each do |t|
82
+ path = Pathname(t)
83
+ return path if path.exist?
84
+ end
85
+ nil
86
+ end
87
+
88
+ end
89
+ end
90
+ end
91
+ end
@@ -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
@@ -17,7 +17,7 @@ module Pod
17
17
 
18
18
  def self.options
19
19
  [
20
- ['--all', 'Remove all the cached without asking']
20
+ ['--open', 'Open after Installation complete']
21
21
  ].concat(super)
22
22
  end
23
23
 
@@ -47,7 +47,7 @@ module Pod
47
47
  remove_files ['Pods', 'Podfile.lock', 'DerivedData']
48
48
  end
49
49
  rescue => exception
50
- UI.puts "[!] #{exception}".red
50
+ UI.puts '[!] Pod::X '.blue + "#{exception}".red
51
51
  end
52
52
  end
53
53
  end
@@ -1,3 +1,5 @@
1
+ require 'cocoapods-x/extension/xcode/open'
2
+
1
3
  module Pod
2
4
  class Command
3
5
  class X < Command
@@ -12,36 +14,9 @@ module Pod
12
14
  super
13
15
  end
14
16
 
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
17
+ def run
18
+ xcopen = Pod::X::Xcode::Open::new
19
+ xcopen.run!
45
20
  end
46
21
 
47
22
  end
@@ -1,3 +1,4 @@
1
1
  require 'cocoapods-x/extension/configure'
2
+ require 'cocoapods-x/extension/installer'
2
3
  require 'cocoapods-x/extension/sandbox'
3
- require 'cocoapods-x/extension/environment'
4
+ require 'cocoapods-x/extension/xcode'
@@ -19,13 +19,18 @@ module Pod
19
19
  end
20
20
 
21
21
  def self.create_conf! project_url
22
- index = 0
23
22
  name = File.basename(project_url)
24
23
  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?
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
29
34
  Pod::X::Configurator::new project_url, project_debug_url
30
35
  end
31
36
 
@@ -1,59 +1,10 @@
1
1
  require 'cocoapods-x/extension/sandbox'
2
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
3
 
9
4
  module Pod
10
5
  module X
11
6
  class Environment
12
7
 
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
8
  def self.install!
58
9
  Pod::X::Sandbox::install!
59
10
  Pod::X::Sandbox::workspace
@@ -75,38 +26,6 @@ module Pod
75
26
  project
76
27
  end
77
28
 
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
29
  end
111
30
  end
112
31
  end