lg_pod_plugin 1.1.7.3 → 1.1.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,266 +0,0 @@
1
- require 'cocoapods'
2
- require 'cocoapods-core'
3
-
4
- module LgPodPlugin
5
-
6
- class PodSpec
7
- attr_reader :spec
8
- attr_accessor :json_files
9
- attr_accessor :source_files
10
-
11
- public
12
- def self.form_file(path)
13
- begin
14
- spec = Pod::Specification.from_file(path)
15
- return PodSpec.new(spec)
16
- rescue
17
- return nil
18
- end
19
- end
20
-
21
- public
22
- def prepare_command
23
- json = self.to_pretty_json
24
- return nil unless json
25
- hash = JSON.parse json
26
- hash["prepare_command"]
27
- end
28
-
29
- public
30
- def to_pretty_json(*a)
31
- require 'json'
32
- JSON.pretty_generate(self.spec.to_hash, *a) << "\n"
33
- end
34
-
35
-
36
- public
37
- def self.form_string(string, path)
38
- begin
39
- #Work around for Rubinius incomplete encoding in 1.9 mode
40
- if string.respond_to?(:encoding) && string.encoding.name != 'UTF-8'
41
- string = string.force_encoding("gb2312").force_encoding("utf-8")
42
- end
43
- spec = Pod::Specification.from_string string, path
44
- return PodSpec.new(spec)
45
- rescue
46
- return nil
47
- end
48
- end
49
-
50
- def self.form_pod_spec(spec)
51
- return PodSpec.new(spec)
52
- end
53
-
54
- def self.form_json(object)
55
- begin
56
- spec = Pod::Specification.from_json(object)
57
- return PodSpec.new(spec)
58
- rescue
59
- return nil
60
- end
61
- end
62
-
63
- def initialize(spec)
64
- if spec == nil
65
- @spec = nil
66
- @json_files = Hash.new
67
- @source_files = Hash.new
68
- return
69
- end
70
- set = Set[]
71
- @spec = spec
72
- attributes_hash = spec.send(:attributes_hash)
73
- return unless attributes_hash.is_a?(Hash)
74
- license = attributes_hash["license"]
75
- if license.is_a?(Hash)
76
- license_file = license["file"]
77
- set.add(license_file) if license_file
78
- else
79
- set.add("LICENSE")
80
- end
81
- # 解析主模块依赖信息
82
- set.merge(parse_subspec_with(attributes_hash))
83
- subspecs = spec.subspecs
84
- unless subspecs.is_a?(Array)
85
- self.source_files = parse_with_set set
86
- if self.source_files.has_key?("*")
87
- self.source_files.delete("*")
88
- self.source_files["All"] = "All"
89
- end
90
- self.json_files = spec.to_pretty_json
91
- return
92
- end
93
- subspecs.each do |sub_spec|
94
- sub_attributes_hash = sub_spec.send(:attributes_hash)
95
- next unless sub_attributes_hash && sub_attributes_hash.is_a?(Hash)
96
- sub_set = self.parse_subspec_with(sub_attributes_hash)
97
- next if sub_set.empty?
98
- set.merge(sub_set)
99
- end
100
- self.source_files = parse_with_set set
101
- if self.source_files.has_key?("*")
102
- self.source_files.delete("*")
103
- self.source_files["All"] = "All"
104
- end
105
- self.json_files = spec.to_pretty_json
106
- end
107
-
108
- public
109
- def write_to_file(path)
110
- LCache.write_spec(@spec, path)
111
- end
112
-
113
- def parse_with_set(set)
114
- new_hash = Hash.new
115
- set.each do |element|
116
- if element.start_with?("**/")
117
- new_hash["All"] = "All"
118
- elsif element.include?("/")
119
- str = element.split("/", 0).first
120
- new_hash[str] = str unless str.empty?
121
- elsif element.start_with?("**.") || element.start_with?("*.")
122
- new_hash["All"] = "All"
123
- elsif element.start_with?("*.framework") || element.include?("*.a")
124
- new_hash["All"] = "All"
125
- else
126
- new_hash[element] = element unless element.empty?
127
- end
128
- end
129
- new_hash
130
- end
131
-
132
- # 公共解析解析subspec
133
- def parse_subspec_with(hash)
134
- set = Set[]
135
- source_files = self.parse_source_files(hash["source_files"])
136
- set.merge(source_files) unless source_files.empty?
137
- resources = self.parse_resource_files(hash["resource"] ||= hash["resources"])
138
- set.merge(resources) unless resources.empty?
139
- resource_bundles = self.parse_resource_bundles(hash["resource_bundle"] ||= hash["resource_bundles"])
140
- set.merge(resource_bundles) unless resource_bundles.empty?
141
- project_header_files = self.parse_project_header_files(hash["project_header_files"])
142
- set.merge(resource_bundles) unless project_header_files.empty?
143
- private_header_files = self.parse_private_header_files(hash["private_header_files"])
144
- set.merge(private_header_files) unless private_header_files.empty?
145
- vendored_frameworks = self.parse_vendored_frameworks(hash["vendored_frameworks"])
146
- set.merge(vendored_frameworks) unless vendored_frameworks.empty?
147
- vendored_library = self.parse_vendored_library(hash["vendored_library"] ||= hash["vendored_libraries"])
148
- set.merge(vendored_library) unless vendored_library.empty?
149
- #parse_preserve_path
150
- preserve_paths = self.parse_preserve_path(hash["preserve_path"] ||= hash["preserve_paths"])
151
- set.merge(preserve_paths) unless preserve_paths.empty?
152
- module_map = self.parse_module_map(hash["module_map"])
153
- set.merge(module_map) unless module_map.empty?
154
- ios_hash = hash["ios"]
155
- if ios_hash && ios_hash.is_a?(Hash)
156
-
157
- ios_source_files = self.parse_source_files(ios_hash["source_files"])
158
- set.merge(ios_source_files) unless ios_source_files.empty?
159
-
160
- ios_resources = self.parse_resource_files(ios_hash["resource"] ||= ios_hash["resources"])
161
- set.merge(ios_resources) unless ios_resources.empty?
162
-
163
- ios_resource_bundles = self.parse_resource_bundles(ios_hash["resource_bundle"] ||= ios_hash["resource_bundles"])
164
- set.merge(ios_resource_bundles) unless ios_resource_bundles.empty?
165
-
166
- ios_project_header_files = self.parse_project_header_files(ios_hash["project_header_files"])
167
- set.merge(ios_project_header_files) unless ios_project_header_files.empty?
168
-
169
- ios_private_header_files = self.parse_private_header_files(ios_hash["private_header_files"])
170
- set.merge(ios_private_header_files) unless ios_private_header_files.empty?
171
-
172
- ios_vendored_frameworks = self.parse_vendored_frameworks(ios_hash["vendored_frameworks"])
173
- set.merge(ios_vendored_frameworks) unless ios_vendored_frameworks.empty?
174
-
175
- ios_vendored_library = self.parse_vendored_library(ios_hash["vendored_library"] ||= ios_hash["vendored_libraries"])
176
- set.merge(ios_vendored_library) unless ios_vendored_library.empty?
177
-
178
- ios_preserve_paths = self.parse_preserve_path(ios_hash["preserve_path"] ||= ios_hash["preserve_paths"])
179
- set.merge(ios_preserve_paths) unless ios_preserve_paths.empty?
180
-
181
- ios_module_map = self.parse_module_map(ios_hash["module_map"])
182
- set.merge(ios_module_map) unless ios_module_map.empty?
183
-
184
- end
185
- set
186
- end
187
-
188
- # 公共解析文件路径的方法
189
- def parse_public_source_files(source_files)
190
- return Array.new unless source_files
191
- array = Array.new
192
- if LUtils.is_a_string?(source_files)
193
- array.append(source_files) unless source_files.empty?
194
- elsif source_files.is_a?(Array)
195
- source_files.each do |element|
196
- next unless LUtils.is_a_string?(element)
197
- array.append(element) unless element.empty?
198
- end
199
- elsif source_files.is_a?(Hash)
200
- source_files.each do |_, val|
201
- if LUtils.is_a_string?(val)
202
- array.append(val) unless val.empty?
203
- elsif val.is_a?(Array)
204
- val.each do |element|
205
- next unless LUtils.is_a_string?(element)
206
- array.append(element) unless element.empty?
207
- end
208
- end
209
- end
210
- end
211
- array
212
- end
213
-
214
- # 解析source_files路径
215
- def parse_source_files(source_files)
216
- self.parse_public_source_files(source_files)
217
- end
218
-
219
- # 解析 resource所在路径
220
- def parse_resource_files(source_files)
221
- self.parse_public_source_files(source_files)
222
- end
223
-
224
- # 解析public_header_files字段的值
225
- def parse_public_header_files(source_files)
226
- self.parse_public_source_files(source_files)
227
- end
228
-
229
- # 解析 parse_resource_bundles
230
- def parse_resource_bundles(source_files)
231
- self.parse_public_source_files(source_files)
232
- end
233
-
234
- # 解析 project_header_files
235
- def parse_project_header_files(source_files)
236
- self.parse_public_source_files(source_files)
237
- end
238
-
239
- # 解析 private_header_files
240
- def parse_private_header_files(source_files)
241
- self.parse_public_source_files(source_files)
242
- end
243
-
244
- # 解析 vendored_frameworks
245
- def parse_vendored_frameworks(source_files)
246
- self.parse_public_source_files(source_files)
247
- end
248
-
249
- # 解析 parse_vendored_library
250
- def parse_vendored_library(source_files)
251
- self.parse_public_source_files(source_files)
252
- end
253
-
254
- # 解析 parse_preserve_path
255
- def parse_preserve_path(source_files)
256
- self.parse_public_source_files(source_files)
257
- end
258
-
259
- # 解析 module_map
260
- def parse_module_map(source_files)
261
- self.parse_public_source_files(source_files)
262
- end
263
-
264
- end
265
-
266
- end
@@ -1,82 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- # The encrypt_data and decrypt_data methods are Copyright (c) 2007 Brent Sowers
4
- # and have been included with prior permission.
5
- #
6
- # Copyright (c) 2012 Gurpartap Singh
7
- #
8
- # MIT License
9
- #
10
- # Permission is hereby granted, free of charge, to any person obtaining
11
- # a copy of this software and associated documentation files (the
12
- # "Software"), to deal in the Software without restriction, including
13
- # without limitation the rights to use, copy, modify, merge, publish,
14
- # distribute, sublicense, and/or sell copies of the Software, and to
15
- # permit persons to whom the Software is furnished to do so, subject to
16
- # the following conditions:
17
- #
18
- # The above copyright notice and this permission notice shall be
19
- # included in all copies or substantial portions of the Software.
20
- #
21
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
-
29
- require 'openssl'
30
-
31
- module AESCrypt
32
- def self.encrypt(message, password)
33
- Base64.encode64(self.encrypt_data(message.to_s.strip, password, nil, "AES-256-ECB"))
34
- end
35
-
36
- def self.decrypt(message, password)
37
- base64_decoded = Base64.decode64(message.to_s.strip)
38
- self.decrypt_data(base64_decoded, password, nil, "AES-256-ECB")
39
- end
40
-
41
- def self.key_digest(password)
42
- OpenSSL::Digest::SHA256.new(password).digest
43
- end
44
-
45
- # Decrypts a block of data (encrypted_data) given an encryption key
46
- # and an initialization vector (iv). Keys, iv's, and the data
47
- # returned are all binary strings. Cipher_type should be
48
- # "AES-256-CBC", "AES-256-ECB", or any of the cipher types
49
- # supported by OpenSSL. Pass nil for the iv if the encryption type
50
- # doesn't use iv's (like ECB).
51
- #:return: => String
52
- #:arg: encrypted_data => String
53
- #:arg: key => String
54
- #:arg: iv => String
55
- #:arg: cipher_type => String
56
- def self.decrypt_data(encrypted_data, key, iv, cipher_type)
57
- aes = OpenSSL::Cipher::Cipher.new(cipher_type)
58
- aes.decrypt
59
- aes.key = key
60
- aes.iv = iv if iv != nil
61
- aes.update(encrypted_data) + aes.final
62
- end
63
-
64
- # Encrypts a block of data given an encryption key and an
65
- # initialization vector (iv). Keys, iv's, and the data returned
66
- # are all binary strings. Cipher_type should be "AES-256-CBC",
67
- # "AES-256-ECB", or any of the cipher types supported by OpenSSL.
68
- # Pass nil for the iv if the encryption type doesn't use iv's (like
69
- # ECB).
70
- #:return: => String
71
- #:arg: data => String
72
- #:arg: key => String
73
- #:arg: iv => String
74
- #:arg: cipher_type => String
75
- def self.encrypt_data(data, key, iv, cipher_type)
76
- aes = OpenSSL::Cipher::Cipher.new(cipher_type)
77
- aes.encrypt
78
- aes.key = key
79
- aes.iv = iv if iv != nil
80
- aes.update(data) + aes.final
81
- end
82
- end