Module: Pod::Meta::MetaAccessor

Defined in:
lib/cocoapods-modularization/meta/meta_accessor.rb

Class Method Summary collapse

Class Method Details

.binariesObject



68
69
70
# File 'lib/cocoapods-modularization/meta/meta_accessor.rb', line 68

def binaries
  MetaConstants.read_data.select { |key, value| value[MetaConstants.binary_key] }.keys if MetaConstants.read_data.kind_of?(Hash)
end

.cache_local_path(key, value) ⇒ Object



94
95
96
97
98
# File 'lib/cocoapods-modularization/meta/meta_accessor.rb', line 94

def cache_local_path(key, value)
  edit_podfile_local(key) do || 
    [MetaConstants.local_path_key] = value
  end
end

.dependenciesObject



72
73
74
# File 'lib/cocoapods-modularization/meta/meta_accessor.rb', line 72

def dependencies
  MetaConstants.dependencies
end

.edit_data(key) ⇒ Object



110
111
112
# File 'lib/cocoapods-modularization/meta/meta_accessor.rb', line 110

def edit_data(key)
  _edit_data(key, MetaConstants.data_path) { |e| yield e }
end

.edit_meta {|meta_hash| ... } ⇒ Object

Yields:

  • (meta_hash)


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

def edit_meta
  meta_hash = YAML.load_file(MetaConstants.meta_path)

  yield meta_hash

  File::open(MetaConstants.meta_path, "w") { |io| io.puts meta_hash.to_yaml }
end

.edit_podfile_local(key) ⇒ Object



106
107
108
# File 'lib/cocoapods-modularization/meta/meta_accessor.rb', line 106

def edit_podfile_local(key)
  _edit_data(key, MetaConstants.podfile_local_path) { |e| yield e }
end

.local_path(key) ⇒ Object



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

def local_path(key)
   = MetaConstants.read_data[key] if MetaConstants.read_data.kind_of?(Hash)
  return [MetaConstants.local_path_key] if .kind_of?(Hash)
end

.remove_binary(key) ⇒ Object



60
61
62
# File 'lib/cocoapods-modularization/meta/meta_accessor.rb', line 60

def remove_binary(key)
  edit_podfile_local(key) { || [MetaConstants.binary_key] = false }
end

.remove_dep(key) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/cocoapods-modularization/meta/meta_accessor.rb', line 38

def remove_dep(key)
  edit_data(key) do |meta|
    meta.delete(key)
  end

  edit_podfile_local(nil) do |meta|
    meta.delete(key)
  end
end

.remove_local_path(key) ⇒ Object



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

def remove_local_path(key)
  edit_podfile_local(key) do ||
    [MetaConstants.local_key] = false
  end
end

.remove_source(key) ⇒ Object



52
53
54
# File 'lib/cocoapods-modularization/meta/meta_accessor.rb', line 52

def remove_source(key)
  edit_podfile_local(key) { || [MetaConstants.binary_key] = true }
end

.set_binary(key) ⇒ Object



56
57
58
# File 'lib/cocoapods-modularization/meta/meta_accessor.rb', line 56

def set_binary(key)
  edit_podfile_local(key) { || [MetaConstants.binary_key] = true }
end

.set_dep(key, binary, version) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cocoapods-modularization/meta/meta_accessor.rb', line 16

def set_dep(key, binary, version)
  edit_data(key) do |meta|
    dep_map = Hash[
      MetaConstants.version_key => version,
      MetaConstants.binary_key => binary || true,
      MetaConstants.source_key => binary ? Private::PrivateCache.binary_repo_url(key) : Private::PrivateCache.source_repo_url(key),
    ]
  end

  edit_podfile_local(key) do |meta|
    dep_map = Hash[
      MetaConstants.binary_key => binary || true,
      MetaConstants.local_key => false,
      MetaConstants.local_path_key => Private::PrivateCache.read_local_path(key)
    ]
  end
end

.set_local_path(key, value) ⇒ Object



86
87
88
89
90
91
92
# File 'lib/cocoapods-modularization/meta/meta_accessor.rb', line 86

def set_local_path(key, value)
  # edit data
  edit_podfile_local(key) do || 
    [MetaConstants.local_key] = true
    [MetaConstants.local_path_key] = value
  end
end

.set_source(key) ⇒ Object



48
49
50
# File 'lib/cocoapods-modularization/meta/meta_accessor.rb', line 48

def set_source(key)
  edit_podfile_local(key) { || [MetaConstants.binary_key] = false }
end

.sourcesObject



64
65
66
# File 'lib/cocoapods-modularization/meta/meta_accessor.rb', line 64

def sources
  MetaConstants.read_data.select { |key, value| !value[MetaConstants.binary_key] }.keys if MetaConstants.read_data.kind_of?(Hash)
end

.update_dep(key, version) ⇒ Object



34
35
36
# File 'lib/cocoapods-modularization/meta/meta_accessor.rb', line 34

def update_dep(key, version)
  edit_data(key) { || [MetaConstants.version_key] = version }
end

.version(key) ⇒ Object



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

def version(key)
   = MetaConstants.read_data[key] if MetaConstants.read_data.kind_of?(Hash)
  return [MetaConstants.version_key] if .kind_of?(Hash)
end