CheckSwiftGen 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- metadata +2 -3
- data/lib/check_swiftgen.rb +0 -113
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03dd14e80615afa47ccbc9391e973978af22d09f4cafb4e1dcf88529e9068902
|
4
|
+
data.tar.gz: 695889b148da679fe6b3b8667f44f1ab9ffaaea0a685c7390537dacf49c49555
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4ea2f2bafd254f170e691924bd3327f00bea9e1f9c977e7e54cf3890deb361f0f80d5ecb84840d198e861004c7f02bdab1197abb27fa17bc93b15cc66ad35e2
|
7
|
+
data.tar.gz: 4773377b33fd2a24258135756f11c55435a477121a329fd65ac43d916793d3ea4ef8e4e36f1e1482409f291748a5e798830a5d01f783f56b368a6450c3daa290
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: CheckSwiftGen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruslan Prokofev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple checking for repeat call swiftgen
|
14
14
|
email: mefilt@gmail.com
|
@@ -18,7 +18,6 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- bin/cache_invalidate
|
21
|
-
- lib/check_swiftgen.rb
|
22
21
|
homepage: http://instagram.com/mefilt
|
23
22
|
licenses:
|
24
23
|
- MIT
|
data/lib/check_swiftgen.rb
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
require 'digest'
|
4
|
-
require 'json'
|
5
|
-
require 'find'
|
6
|
-
require 'yaml'
|
7
|
-
|
8
|
-
class CheckSwiftGen
|
9
|
-
|
10
|
-
def cache_invalidate(configuration_file, lock_path)
|
11
|
-
|
12
|
-
if File.file?("#{configuration_file}") == false
|
13
|
-
puts("Configuration File not found")
|
14
|
-
return
|
15
|
-
end
|
16
|
-
|
17
|
-
if lock_path.nil? {}
|
18
|
-
puts("Please input the lock path")
|
19
|
-
return
|
20
|
-
end
|
21
|
-
|
22
|
-
text = File.read(configuration_file)
|
23
|
-
dictionary = YAML.load(text)
|
24
|
-
|
25
|
-
assets_inputs = []
|
26
|
-
if (dictionary.has_key?('xcassets'))
|
27
|
-
xcassets = dictionary['xcassets']
|
28
|
-
if (xcassets.has_key?('inputs'))
|
29
|
-
assets_inputs = xcassets['inputs']
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
strings_inputs = []
|
34
|
-
if (dictionary.has_key?('strings'))
|
35
|
-
strings = dictionary['strings']
|
36
|
-
if (strings.has_key?('inputs'))
|
37
|
-
strings_inputs = strings['inputs']
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
return exist_new_files(
|
42
|
-
assets_hash(assets_inputs),
|
43
|
-
strings_hash(strings_inputs),
|
44
|
-
lock_path
|
45
|
-
)
|
46
|
-
end
|
47
|
-
|
48
|
-
def exist_new_files(assets_map, strings_map, lock_path)
|
49
|
-
|
50
|
-
tmp_name_file = "SwiftGen.tmp.lock"
|
51
|
-
lock_name_file = "SwiftGen.lock"
|
52
|
-
|
53
|
-
tmp_path_file = lock_path + "/" + tmp_name_file
|
54
|
-
lock_path_file = lock_path + "/" + lock_name_file
|
55
|
-
|
56
|
-
lock_file = Hash.new
|
57
|
-
lock_file["assets"] = assets_map
|
58
|
-
lock_file["strings"] = strings_map
|
59
|
-
|
60
|
-
|
61
|
-
if File.file?("#{tmp_path_file}")
|
62
|
-
File.delete(tmp_path_file)
|
63
|
-
end
|
64
|
-
|
65
|
-
File.write(tmp_path_file, lock_file.to_json)
|
66
|
-
new_hash = Digest::SHA512.file tmp_path_file
|
67
|
-
File.delete(tmp_path_file)
|
68
|
-
|
69
|
-
old_hash = ""
|
70
|
-
if File.file?("#{lock_path_file}")
|
71
|
-
old_hash = Digest::SHA512.file "#{lock_path_file}"
|
72
|
-
end
|
73
|
-
|
74
|
-
if old_hash != new_hash
|
75
|
-
old_hash = new_hash
|
76
|
-
File.write(lock_path_file, lock_file.to_json)
|
77
|
-
return true
|
78
|
-
else
|
79
|
-
return false
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def assets_hash(assets_file_paths)
|
84
|
-
assets_map = Hash.new
|
85
|
-
assets_file_paths.each do |asset_file_paths|
|
86
|
-
|
87
|
-
files = Find.find(asset_file_paths).select { |p| /.*\.json$/ =~ p }
|
88
|
-
asset_map = Hash.new
|
89
|
-
|
90
|
-
files.each do |img_file|
|
91
|
-
sha512 = Digest::SHA512.file img_file
|
92
|
-
asset_map[img_file] = sha512
|
93
|
-
end
|
94
|
-
|
95
|
-
assets_map[asset_file_paths] = asset_map
|
96
|
-
end
|
97
|
-
|
98
|
-
return assets_map
|
99
|
-
end
|
100
|
-
|
101
|
-
def strings_hash(strings_file_paths)
|
102
|
-
strings_map = Hash.new
|
103
|
-
strings_file_paths.each do |string|
|
104
|
-
keys = string.split('/')[-2] + "/" + string.split('/').last
|
105
|
-
sha512 = Digest::SHA512.file string
|
106
|
-
strings_map[keys] = sha512
|
107
|
-
end
|
108
|
-
return strings_map
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
|
113
|
-
|