Class: Pod::Meta::MetaConstants

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-modularization/meta/meta_constants.rb

Class Method Summary collapse

Class Method Details

.binary_keyObject



117
118
119
# File 'lib/cocoapods-modularization/meta/meta_constants.rb', line 117

def binary_key
  'binary'
end

.branch_cache_pathObject



81
82
83
# File 'lib/cocoapods-modularization/meta/meta_constants.rb', line 81

def branch_cache_path
  "#{pods_generator_path}/branch_cache.yml"
end

.branch_keyObject



101
102
103
# File 'lib/cocoapods-modularization/meta/meta_constants.rb', line 101

def branch_key
  'branch'
end

.configurationObject



137
138
139
# File 'lib/cocoapods-modularization/meta/meta_constants.rb', line 137

def configuration
  'configuration'
end

.data_pathObject



89
90
91
# File 'lib/cocoapods-modularization/meta/meta_constants.rb', line 89

def data_path
  "#{pods_generator_path}/data.yml"
end

.dependenciesObject



18
19
20
# File 'lib/cocoapods-modularization/meta/meta_constants.rb', line 18

def dependencies
  generate_yml_to_hash(data_path).keys
end

.force_local_keyObject



133
134
135
# File 'lib/cocoapods-modularization/meta/meta_constants.rb', line 133

def force_local_key
  'force_local'
end

.generate_yml_to_hash(path) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/cocoapods-modularization/meta/meta_constants.rb', line 8

def generate_yml_to_hash(path)
  return Hash.new unless File.exists?(path)
  _hash = YAML.load_file(path)
  if _hash.kind_of?(Hash)
    _hash
  else
    Hash.new
  end
end

.git_keyObject



105
106
107
# File 'lib/cocoapods-modularization/meta/meta_constants.rb', line 105

def git_key
  'git'
end

.local_keyObject



121
122
123
# File 'lib/cocoapods-modularization/meta/meta_constants.rb', line 121

def local_key
  'local'
end

.local_path_keyObject



125
126
127
# File 'lib/cocoapods-modularization/meta/meta_constants.rb', line 125

def local_path_key
  'local_path'
end

.meta_pathObject



85
86
87
# File 'lib/cocoapods-modularization/meta/meta_constants.rb', line 85

def meta_path
  "#{pods_generator_path}/meta.yml"
end

.podfile_local_pathObject



97
98
99
# File 'lib/cocoapods-modularization/meta/meta_constants.rb', line 97

def podfile_local_path
  'Podfile.yml'
end

.pods_generator_pathObject



77
78
79
# File 'lib/cocoapods-modularization/meta/meta_constants.rb', line 77

def pods_generator_path
  "#{pods_scripts_path}/PodfileGenerator"
end

.pods_scripts_pathObject



73
74
75
# File 'lib/cocoapods-modularization/meta/meta_constants.rb', line 73

def pods_scripts_path
  'pods-scripts'
end

.post_install_hooks_pathObject



93
94
95
# File 'lib/cocoapods-modularization/meta/meta_constants.rb', line 93

def post_install_hooks_path
  "#{pods_scripts_path}/PostInstallHooks"
end

.read_data(enable_branch = false) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/cocoapods-modularization/meta/meta_constants.rb', line 22

def read_data(enable_branch = false)
  # read data 
  data_hash = generate_yml_to_hash(data_path)

  # read Podfile.yml
  podfile_local_hash = generate_yml_to_hash(podfile_local_path)

  # cache branch if local_path is set
  if !enable_branch && !podfile_local_hash.empty?
    branch_caches = Array.new
    podfile_local_hash.each do |key, value|
      next unless value.kind_of?(Hash)
      local = value[local_key]
      next unless local

      local_path = value[local_path_key]
      next unless local_path.kind_of?(String)

      branch_cache = Pod::Private::PrivateCache::BranchCache.new(key, local_path)
      branch_caches << branch_cache
    end

    Pod::Private::PrivateCache.cache_branch(branch_caches)
  end

  # merge local data and remote data
  merged_data = Hash.new
  data_hash.each do |key, value|
    # check value
    unless value.kind_of?(Hash)
      UI.puts "data not found in data.yaml with key: #{key}"
      next
    end

    # check value in local podfile
    local_data_value = podfile_local_hash[key]
    unless value.kind_of?(Hash)
      UI.puts "data not found in Podfile.yaml with key: #{key}"
      next
    end

    if local_data_value.kind_of?(Hash)
      merged_data[key] = value.merge(local_data_value)
    else
      merged_data[key] = value
    end
  end

  merged_data
end

.source_keyObject



113
114
115
# File 'lib/cocoapods-modularization/meta/meta_constants.rb', line 113

def source_key 
  'source'
end

.version_keyObject



109
110
111
# File 'lib/cocoapods-modularization/meta/meta_constants.rb', line 109

def version_key
  'version'
end