cocoapods-localsource 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d226d2318016e6f6547c22c3f9e8d04eecca659
4
- data.tar.gz: 52498570d1b9f13f01837ddc35977ac1a989a9ab
3
+ metadata.gz: 6d475a0ff9c25be38fc36c5cd9db0bad44464f43
4
+ data.tar.gz: 1ab25d87ce28d632220a00185853e24e8243138e
5
5
  SHA512:
6
- metadata.gz: 74516cced935f8f95cfee466303175a8fba44a80da0cdaa8923f69307c3c663cdbb2aea7e4818decde9b73ae62049e6bca91e3c23065cba96eb733fdd141c4c3
7
- data.tar.gz: 43de18ec5abe0cdee7e666ba4e5501342b06929430a39b9321b1e20d9d023578f880988c1bd2f727a991ebc98dbce6ab02b9d200741294efe86ac943bbbc668f
6
+ metadata.gz: 5faf4968e1128d7d43453b524243f34889de98c7d729365af77ccc2aa1c581327b0bbb680b99872089de4f4931fb2006541fb2567100728e234fb01130b054c9
7
+ data.tar.gz: 9ee6f0b7eb24ddac6b85827e842730b09cab45ff57e125ea75b791886ff5bddf9afee933818e731938f39e22ee6b55dd07b94c996e3dc0ea2c06afa42c13eabb
@@ -1,82 +1,89 @@
1
- require 'cocoapods-core'
2
-
3
- module Pod
4
- class Podfile
5
- module DSL
6
- def local_source(*paths)
7
- paths.each do |path|
8
- LocalModuleManager.addLocalPath(path)
9
- end
10
- end
11
- end
12
- end
13
- end
1
+ class LocalModuleManager
2
+ @@all_modules = {}
3
+ @@resolved_modules = {}
4
+ @@local_paths = []
14
5
 
15
- class LocalModuleManager
16
- @@all_modules = {}
17
- @@resolved_modules = {}
6
+ def self.all_modules
7
+ @@all_modules
8
+ end
9
+
10
+ def self.resolved_modules
11
+ @@resolved_modules
12
+ end
18
13
 
19
- def self.all_modules
20
- @@all_modules
14
+ def self.local_paths
15
+ @@local_paths
16
+ end
17
+
18
+ def self.set_resolved(name)
19
+ @@resolved_modules[name] = true
20
+ end
21
+
22
+ def self.resolved?(name)
23
+ @@resolved_modules.key?(name)
24
+ end
25
+
26
+ def self.addLocalPath(path)
27
+ raise "Trying to add local path '#{path}' twice" unless !@@local_paths.include?(path)
28
+
29
+ @@local_paths << path
30
+ dependencies = findLocalModules(path)
31
+
32
+ dependencies.each do |key, value|
33
+ existingModule = @@all_modules[value.name]
34
+ raise "Duplicate local module definition for #{value.name} at #{path}. Already defined here: #{existingModule.module_podspec_path}" unless existingModule.nil?
35
+ @@all_modules[key] = value
21
36
  end
37
+ end
38
+
39
+ def self.local?(name)
40
+ !@@all_modules[name].nil?
41
+ end
22
42
 
23
- def self.set_resolved(name)
24
- @@resolved_modules[name] = true
43
+ def self.findLocalModules(path)
44
+ modules = {}
45
+ Dir.chdir(path) do
46
+ podspec_paths = Dir["*/*.podspec"]
47
+
48
+ podspec_paths.each do |p|
49
+ pathComponents = p.split("/")
50
+ moduleName = pathComponents[1].split(".podspec")[0]
51
+ foundModule = LocalModule.new(path, pathComponents[0], moduleName)
52
+
53
+ modules[moduleName] = foundModule
54
+ end
25
55
  end
26
56
 
27
- def self.resolved?(name)
28
- @@resolved_modules.key?(name)
29
- end
30
-
31
- def self.addLocalPath(path)
32
- dependencies = findLocalModules(path)
33
-
34
- dependencies.each do |key, value|
35
- existingModule = @@all_modules[value.name]
36
- raise "Duplicate local module definition for #{value.name} at #{path}. Already defined here: #{existingModule.module_podspec_path}" unless existingModule.nil?
37
- @@all_modules[key] = value
38
- end
39
- end
40
-
41
- def self.local?(name)
42
- !@@all_modules[name].nil?
43
- end
44
-
45
- def self.findLocalModules(path)
46
- modules = {}
47
- Dir.chdir(path) do
48
- podspec_paths = Dir["*/*.podspec"]
49
-
50
- podspec_paths.each do |p|
51
- pathComponents = p.split("/")
52
- moduleName = pathComponents[1].split(".podspec")[0]
53
- foundModule = LocalModule.new(path, pathComponents[0], moduleName)
54
-
55
- modules[moduleName] = foundModule
56
- end
57
- end
58
-
59
- return modules
60
- end
57
+ return modules
58
+ end
59
+
60
+ def self.clear
61
+ @@all_modules = {}
62
+ @@resolved_modules = {}
63
+ @@local_paths = []
64
+ end
61
65
  end
62
66
 
67
+ class LocalModule
68
+ def initialize(modulesPath, root, name)
69
+ @modules_path = modulesPath
70
+ @root = root
71
+ @name = name
72
+ end
63
73
 
64
- class LocalModule
65
- def initialize(modulesPath, root, name)
66
- @modules_path = modulesPath
67
- @root = root
68
- @name = name
69
- end
74
+ attr_reader :modules_path
75
+ attr_reader :root
76
+ attr_reader :name
70
77
 
71
- attr_reader :modules_path
72
- attr_reader :root
73
- attr_reader :name
74
-
75
- def module_path
76
- "#{@modules_path}/#{@root}"
77
- end
78
-
79
- def module_podspec_path
80
- "#{@modules_path}/#{@root}/#{@name}.podspec"
81
- end
82
- end
78
+ def module_path
79
+ "#{@modules_path}/#{@root}"
80
+ end
81
+
82
+ def module_podspec_path
83
+ "#{@modules_path}/#{@root}/#{@name}.podspec"
84
+ end
85
+
86
+ def ==(anOther)
87
+ module_podspec_path == anOther.module_podspec_path
88
+ end
89
+ end
@@ -1,78 +1,92 @@
1
- require 'cocoapods'
2
- require 'cocoapods-core'
3
- require_relative 'LocalModuleManager'
1
+ require "cocoapods"
2
+ require "cocoapods-core"
3
+ require_relative "LocalModuleManager"
4
4
 
5
5
  module Pod
6
- class Dependency
7
- alias_method :real_initialize, :initialize
8
- def initialize(name = nil, *requirements)
9
- # adds requirement hash if it's not present
10
- requirements << {} unless requirements.last.is_a?(Hash)
11
-
12
- pathComponents = name.split("/")
13
- baseName = pathComponents[0]
14
-
15
- if LocalModuleManager.all_modules[baseName].present?
16
- localModule = LocalModuleManager.all_modules[baseName]
17
- # remove version requirement, if local
18
- requirements = requirements[1..-1] unless requirements.first.is_a?(Hash)
19
- # add path to local dependency
20
- requirements.last[:path] = localModule.module_path
21
- end
22
-
23
- real_initialize(name, *requirements)
24
- end
25
- end
6
+ class Podfile
7
+ module DSL
8
+ def local_source(*paths)
9
+ paths.each do |path|
10
+ LocalModuleManager.addLocalPath(path)
11
+ end
12
+ end
13
+ end
14
+ end
26
15
  end
27
16
 
28
17
  module Pod
29
- class Installer
30
- class Analyzer
31
- def allDependenciesFor(name, localModules = LocalModuleManager.all_modules)
32
- if LocalModuleManager.resolved?(name)
33
- # if the local dependency has already been resolved, we don't need to resolve the dependencies again.
34
- return []
35
- end
36
-
37
- pathComponents = name.split("/")
38
- baseName = pathComponents[0]
39
- importingSubspec = pathComponents.length > 1
40
-
41
- localModule = localModules[baseName]
42
-
43
- podspec = nil
44
- # Position in the modules directory to generate the subspecs correctly
45
- Dir.chdir(localModule.module_path) do
46
- podspec = eval File.read("#{baseName}.podspec")
47
- end
48
-
49
- # Use the subspec if we're importing it
50
- if importingSubspec
51
- podspec = podspec.subspec_by_name(name)
52
- end
53
-
54
- # Get all local dependencies of the spec/subspec
55
- allDependencies = podspec.all_dependencies.select { |d| LocalModuleManager.local?(d.name) }
56
-
57
- # Get other dependencies recursively
58
- allDependencies.each do |dependency|
59
- allDependencies += allDependenciesFor(dependency.name, localModules)
60
- end
61
-
62
- LocalModuleManager.set_resolved(name)
63
- return allDependencies.uniq
64
- end
65
-
66
- alias_method :real_dependencies_to_fetch, :dependencies_to_fetch
67
- def dependencies_to_fetch(podfile_state)
68
- real_dependencies_to_fetch(podfile_state)
69
-
70
- resolvedLocalDependencies = @deps_to_fetch.map do |key, value|
71
- allDependenciesFor(key.name)
72
- end.flatten.uniq
73
-
74
- @deps_to_fetch = (@deps_to_fetch | resolvedLocalDependencies).uniq
75
- end
76
- end
77
- end
78
- end
18
+ class Dependency
19
+ alias_method :real_initialize, :initialize
20
+
21
+ def initialize(name = nil, *requirements)
22
+ # adds requirement hash if it's not present
23
+ requirements << {} unless requirements.last.is_a?(Hash)
24
+
25
+ pathComponents = name.split("/")
26
+ baseName = pathComponents[0]
27
+
28
+ if LocalModuleManager.all_modules[baseName].present?
29
+ localModule = LocalModuleManager.all_modules[baseName]
30
+ # remove version requirement, if local
31
+ requirements = requirements[1..-1] unless requirements.first.is_a?(Hash)
32
+ # add path to local dependency
33
+ requirements.last[:path] = localModule.module_path
34
+ end
35
+
36
+ real_initialize(name, *requirements)
37
+ end
38
+ end
39
+ end
40
+
41
+ module Pod
42
+ class Installer
43
+ class Analyzer
44
+ def allDependenciesFor(name, localModules = LocalModuleManager.all_modules)
45
+ if LocalModuleManager.resolved?(name)
46
+ # if the local dependency has already been resolved, we don't need to resolve the dependencies again.
47
+ return []
48
+ end
49
+
50
+ pathComponents = name.split("/")
51
+ baseName = pathComponents[0]
52
+ importingSubspec = pathComponents.length > 1
53
+
54
+ localModule = localModules[baseName]
55
+
56
+ podspec = nil
57
+ # Position in the modules directory to generate the subspecs correctly
58
+ Dir.chdir(localModule.module_path) do
59
+ podspec = eval File.read("#{baseName}.podspec")
60
+ end
61
+
62
+ # Use the subspec if we're importing it
63
+ if importingSubspec
64
+ podspec = podspec.subspec_by_name(name)
65
+ end
66
+
67
+ # Get all local dependencies of the spec/subspec
68
+ allDependencies = podspec.all_dependencies.select { |d| LocalModuleManager.local?(d.name) }
69
+
70
+ # Get other dependencies recursively
71
+ allDependencies.each do |dependency|
72
+ allDependencies += allDependenciesFor(dependency.name, localModules)
73
+ end
74
+
75
+ LocalModuleManager.set_resolved(name)
76
+ return allDependencies.uniq
77
+ end
78
+
79
+ alias_method :real_dependencies_to_fetch, :dependencies_to_fetch
80
+
81
+ def dependencies_to_fetch(podfile_state)
82
+ real_dependencies_to_fetch(podfile_state)
83
+
84
+ resolvedLocalDependencies = @deps_to_fetch.map do |key, value|
85
+ allDependenciesFor(key.name)
86
+ end.flatten.uniq
87
+
88
+ @deps_to_fetch = (@deps_to_fetch | resolvedLocalDependencies).uniq
89
+ end
90
+ end
91
+ end
92
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-localsource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Peter
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '12.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '12.3'
41
69
  description: " cocoapods-localsource allows to import local development pods without
42
70
  specifying a path.\n In your apps Podfile, require the gem and define the local
43
71
  module directory by passing the path to `local_source`.\n Using this cocoapods