Class: LgPodPlugin::Specification

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(work_space, podfile, name = nil, version = nil) ⇒ Specification

Returns a new instance of Specification.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/lg_pod_plugin/specification.rb', line 16

def initialize(work_space, podfile, name = nil, version = nil)
  config = Pod::Config.instance
  sources_manager = config.send(:sources_manager)
  dependency = Pod::Dependency.new(name, version)
  set = sources_manager.search(dependency)
  self.podfile = podfile
  self.work_space = work_space
  self.spec = set.send(:specification)
  self.attributes_hash = self.spec.send(:attributes_hash)
  self.dependencies = self.attributes_hash["dependencies"]
end

Instance Attribute Details

#attributes_hashObject

Returns the value of attribute attributes_hash.



14
15
16
# File 'lib/lg_pod_plugin/specification.rb', line 14

def attributes_hash
  @attributes_hash
end

#dependenciesObject

Returns the value of attribute dependencies.



15
16
17
# File 'lib/lg_pod_plugin/specification.rb', line 15

def dependencies
  @dependencies
end

#podfileObject

Returns the value of attribute podfile.



12
13
14
# File 'lib/lg_pod_plugin/specification.rb', line 12

def podfile
  @podfile
end

#specObject

Returns the value of attribute spec.



11
12
13
# File 'lib/lg_pod_plugin/specification.rb', line 11

def spec
  @spec
end

#work_spaceObject

Returns the value of attribute work_space.



13
14
15
# File 'lib/lg_pod_plugin/specification.rb', line 13

def work_space
  @work_space
end

Instance Method Details

#installObject



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/specification.rb', line 28

def install
  pod_name = self.attributes_hash["name"]
  if pod_name.include?("/")
    real_name = pod_name.split("/").first
  else
    real_name = pod_name
  end
  return if LRequest.shared.libs[real_name]
  pod_version = self.attributes_hash["version"]
  prepare_command = self.attributes_hash['prepare_command']
  return if prepare_command
  source = self.attributes_hash['source']
  return unless source.is_a?(Hash)
  git = source["git"] ||= ""
  tag = source["tag"] ||= ""
  return unless git.include?("https://github.com")
  requirements = {:git => git, :tag => tag, :spec => spec, :release_pod => true }
  LRequest.shared.checkout_options = requirements
  return unless LCache.new(self.work_space).find_pod_cache(real_name, {:git => git, :tag => tag})
  LRequest.shared.libs[real_name] = requirements
  LgPodPlugin::Installer.new(self.podfile, real_name, requirements)
end