Class: LgPodPlugin::LockfileModel

Inherits:
Object
  • Object
show all
Defined in:
lib/lg_pod_plugin/config/lockfile_model.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLockfileModel

Returns a new instance of LockfileModel.



11
12
# File 'lib/lg_pod_plugin/config/lockfile_model.rb', line 11

def initialize
end

Instance Attribute Details

#checkout_options_dataObject

Returns the value of attribute checkout_options_data.



9
10
11
# File 'lib/lg_pod_plugin/config/lockfile_model.rb', line 9

def checkout_options_data
  @checkout_options_data
end

#external_sources_dataObject

Returns the value of attribute external_sources_data.



8
9
10
# File 'lib/lg_pod_plugin/config/lockfile_model.rb', line 8

def external_sources_data
  @external_sources_data
end

#lockfileObject

Returns the value of attribute lockfile.



6
7
8
# File 'lib/lg_pod_plugin/config/lockfile_model.rb', line 6

def lockfile
  @lockfile
end

#release_podsObject

Returns the value of attribute release_pods.



7
8
9
# File 'lib/lg_pod_plugin/config/lockfile_model.rb', line 7

def release_pods
  @release_pods
end

Class Method Details

.from_fileObject



14
15
16
17
18
19
20
21
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
# File 'lib/lg_pod_plugin/config/lockfile_model.rb', line 14

def self.from_file
  lockfile = LProject.shared.lockfile
  unless lockfile
    lockfile_model = LockfileModel.new
    lockfile_model.lockfile = nil
    lockfile_model.release_pods = {}
    lockfile_model.checkout_options_data = {}
    lockfile_model.external_sources_data = {}
    return lockfile_model
  end
  release_pods = Hash.new
  pods = lockfile.send(:generate_pod_names_and_versions)
  pods.each do |element|
    if LUtils.is_a_string?(element) || element.is_a?(Hash)
      key = element.is_a?(Hash) ? element.keys.first : element
      next unless key
      if key.include?(" ")
        pod_name = LUtils.pod_real_name(key.split(" ").first)
      else
        pod_name = key
      end
      tag = key[/(?<=\().*?(?=\))/]
      release_pods[pod_name] = tag
    else
      next
    end
  end
  lockfile_model = LockfileModel.new
  lockfile_model.lockfile = lockfile
  lockfile_model.release_pods = release_pods
  lockfile_model.checkout_options_data = lockfile.send(:checkout_options_data)
  lockfile_model.checkout_options_data = {} unless lockfile_model.checkout_options_data
  lockfile_model.external_sources_data = lockfile.send(:external_sources_data)
  lockfile_model.external_sources_data = {} unless lockfile_model.external_sources_data
  lockfile_model
end

Instance Method Details

#checkout_options_for_pod_named(name) ⇒ Object



51
52
53
54
55
# File 'lib/lg_pod_plugin/config/lockfile_model.rb', line 51

def checkout_options_for_pod_named(name)
  return {} unless @lockfile
  hash = @lockfile.checkout_options_for_pod_named(name)
  hash ? hash : {}
end