Class: LgPodPlugin::PodSpec

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec) ⇒ PodSpec

Returns a new instance of PodSpec.



13
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
# File 'lib/lg_pod_plugin/podspec.rb', line 13

def initialize(spec)
  set = Set[]
  attributes_hash = spec.send(:attributes_hash)
  return nil unless attributes_hash.is_a?(Hash)
  license = attributes_hash["license"]
  if license.is_a?(Hash)
    license_file = license["file"]
    set.add(license_file) if license_file
  else
    set.add("LICENSE")
  end
  # 解析主模块依赖信息
  set.merge(parse_subspec_with(attributes_hash))
  subspecs = spec.subspecs
  unless subspecs.is_a?(Array)
    self.source_files = set
    return
  end
  subspecs.each do |sub_spec|
    next unless sub_attributes_hash = sub_spec.send(:attributes_hash)
    next unless sub_attributes_hash.is_a?(Hash)
    sub_set = self.parse_subspec_with(sub_attributes_hash)
    next if sub_set.empty?
    set.merge(sub_set)
  end
  self.source_files = set
end

Instance Attribute Details

#source_filesObject

Returns the value of attribute source_files.



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

def source_files
  @source_files
end

Class Method Details

.form_file(path) ⇒ Object



8
9
10
11
# File 'lib/lg_pod_plugin/podspec.rb', line 8

def self.form_file(path)
  spec = Pod::Specification.from_file(path)
  return PodSpec.new(spec)
end

Instance Method Details

#parse_module_map(source_files) ⇒ Object

解析 module_map



150
151
152
# File 'lib/lg_pod_plugin/podspec.rb', line 150

def parse_module_map(source_files)
  return self.parse_public_source_filse(source_files)
end

#parse_preserve_path(source_files) ⇒ Object

解析 parse_preserve_path



145
146
147
# File 'lib/lg_pod_plugin/podspec.rb', line 145

def parse_preserve_path(source_files)
  return self.parse_public_source_filse(source_files)
end

#parse_private_header_files(source_files) ⇒ Object

解析 private_header_files



132
133
134
# File 'lib/lg_pod_plugin/podspec.rb', line 132

def parse_private_header_files(source_files)
  return self.parse_public_source_filse(source_files)
end

#parse_project_header_files(source_files) ⇒ Object

解析 project_header_files



127
128
129
# File 'lib/lg_pod_plugin/podspec.rb', line 127

def parse_project_header_files(source_files)
  return self.parse_public_source_filse(source_files)
end

#parse_public_header_files(source_files) ⇒ Object

解析public_header_files字段的值



119
120
121
# File 'lib/lg_pod_plugin/podspec.rb', line 119

def parse_public_header_files(source_files)
  return self.parse_public_source_filse(source_files)
end

#parse_public_source_filse(source_files) ⇒ Object

公共解析文件路径的方法



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/lg_pod_plugin/podspec.rb', line 67

def parse_public_source_filse(source_files)
  return [] unless source_files
  array = []
  if LUtils.is_string(source_files)
    if source_files.include?("/")
      array.append(source_files.split("/").first)
    else
      array.append(source_files)
    end
  elsif source_files.is_a?(Array)
    source_files.each do |element|
      next unless LUtils.is_string(element)
      if element.include?("/")
        array.append(element.split("/").first)
      else
        array.append(element)
      end
    end
  elsif source_files.is_a?(Hash)
    source_files.each do |key,val|
      if LUtils.is_string(val)
        if val.include?("/")
          array.append(val.split("/").first)
        else
          array.append(val)
        end
      elsif val.is_a?(Array)
        val.each do |element|
          next unless LUtils.is_string(element)
          if element.include?("/")
            array.append(element.split("/").first)
          else
            array.append(element)
          end
        end
      end
    end
  end
  return array
end

#parse_resource_bundles(source_files) ⇒ Object

解析 parse_resource_bundles



123
124
125
# File 'lib/lg_pod_plugin/podspec.rb', line 123

def parse_resource_bundles(source_files)
  return self.parse_public_source_filse(source_files)
end

#parse_resource_files(source_files) ⇒ Object

解析 resource所在路径



114
115
116
# File 'lib/lg_pod_plugin/podspec.rb', line 114

def parse_resource_files(source_files)
  return self.parse_public_source_filse(source_files)
end

#parse_source_files(source_files) ⇒ Object

解析source_fils路径



109
110
111
# File 'lib/lg_pod_plugin/podspec.rb', line 109

def parse_source_files(source_files)
  return self.parse_public_source_filse(source_files)
end

#parse_subspec_with(hash) ⇒ Object

公共解析解析subspec



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/lg_pod_plugin/podspec.rb', line 42

def parse_subspec_with(hash)
  set = Set[]
  source_files = self.parse_source_files(hash["source_files"])
  set.merge(source_files) unless source_files.empty?
  resources = self.parse_resource_files(hash["resource"] ||= hash["resources"])
  set.merge(resources) unless resources.empty?
  resource_bundles = self.parse_resource_bundles(hash["resource_bundle"] ||= hash["resource_bundles"])
  set.merge(resource_bundles) unless resource_bundles.empty?
  project_header_files = self.parse_project_header_files(hash["project_header_files"])
  set.merge(resource_bundles) unless project_header_files.empty?
  private_header_files = self.parse_private_header_files(hash["private_header_files"])
  set.merge(private_header_files) unless private_header_files.empty?
  vendored_frameworks = self.parse_vendored_frameworks(hash["vendored_frameworks"])
  set.merge(vendored_frameworks) unless vendored_frameworks.empty?
  vendored_library = self.parse_vendored_library(hash["vendored_library"] ||= hash["vendored_libraries"])
  set.merge(vendored_library) unless vendored_library.empty?
  #parse_preserve_path
  preserve_paths = self.parse_preserve_path(hash["preserve_path"] ||= hash["preserve_paths"])
  set.merge(preserve_paths) unless preserve_paths.empty?
  module_map = self.parse_module_map(hash["module_map"])
  set.merge(module_map) unless module_map.empty?
  return set
end

#parse_vendored_frameworks(source_files) ⇒ Object

解析 vendored_frameworks



136
137
138
# File 'lib/lg_pod_plugin/podspec.rb', line 136

def parse_vendored_frameworks(source_files)
  return self.parse_public_source_filse(source_files)
end

#parse_vendored_library(source_files) ⇒ Object

解析 parse_vendored_library



140
141
142
# File 'lib/lg_pod_plugin/podspec.rb', line 140

def parse_vendored_library(source_files)
  return self.parse_public_source_filse(source_files)
end