CheckSwiftGen 0.0.5 → 0.0.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03dd14e80615afa47ccbc9391e973978af22d09f4cafb4e1dcf88529e9068902
4
- data.tar.gz: 695889b148da679fe6b3b8667f44f1ab9ffaaea0a685c7390537dacf49c49555
3
+ metadata.gz: a5b368aefeb3121963a9596637ff81bac11f13a7a64be59dec05b3f6306777a2
4
+ data.tar.gz: 3f6a89237f87e8231040831084cb216fea0703fdde399b41e9e2b3852d857693
5
5
  SHA512:
6
- metadata.gz: b4ea2f2bafd254f170e691924bd3327f00bea9e1f9c977e7e54cf3890deb361f0f80d5ecb84840d198e861004c7f02bdab1197abb27fa17bc93b15cc66ad35e2
7
- data.tar.gz: 4773377b33fd2a24258135756f11c55435a477121a329fd65ac43d916793d3ea4ef8e4e36f1e1482409f291748a5e798830a5d01f783f56b368a6450c3daa290
6
+ metadata.gz: 12e02f1fe8df41e250d2aa5c386ef12c5297569a8810f32661ec3952ba4c8708c48915ed971df60787558cd43d3f989d07c8055a0497ebf7ab6edb3808703310
7
+ data.tar.gz: 3ac3d420bf460358a721b4ea8467bd49970e62cfdffd1efeb89da2044f897c758426513a88065ea578b04b10b3c0b8cacc53ba205ebb648340ee1bcde9ef60ab
data/.DS_Store ADDED
Binary file
@@ -0,0 +1,14 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'CheckSwiftGen'
3
+ s.version = '0.0.10'
4
+ s.summary = "Hola!"
5
+ s.description = "A simple checking for repeat call swiftgen"
6
+ s.authors = ["Ruslan Prokofev"]
7
+ s.email = 'mefilt@gmail.com'
8
+ s.files = `git ls-files`.split($\)
9
+ s.bindir = 'bin'
10
+ s.require_paths = ["lib", "bin"]
11
+ s.executables << 'swiftgen_check'
12
+ s.homepage = 'http://instagram.com/mefilt'
13
+ s.license = 'MIT'
14
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'check_swiftgen'
4
+ puts(CheckSwiftGen.new.swiftgen_check(ARGV[0], ARGV[1]))
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,113 @@
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 swiftgen_check(configuration_file, lock_path)
11
+
12
+ if File.file?("#{configuration_file}") == false
13
+ puts("Configuration file didn`t found")
14
+ return
15
+ end
16
+
17
+ if lock_path.nil? {}
18
+ puts("Path for save file of lock didnt found")
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
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: CheckSwiftGen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Prokofev
@@ -13,11 +13,15 @@ dependencies: []
13
13
  description: A simple checking for repeat call swiftgen
14
14
  email: mefilt@gmail.com
15
15
  executables:
16
- - cache_invalidate
16
+ - swiftgen_check
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - bin/cache_invalidate
20
+ - ".DS_Store"
21
+ - CheckSwiftGen.gemspec
22
+ - bin/swiftgen_check
23
+ - lib/.DS_Store
24
+ - lib/check_swiftgen.rb
21
25
  homepage: http://instagram.com/mefilt
22
26
  licenses:
23
27
  - MIT
@@ -26,6 +30,7 @@ post_install_message:
26
30
  rdoc_options: []
27
31
  require_paths:
28
32
  - lib
33
+ - bin
29
34
  required_ruby_version: !ruby/object:Gem::Requirement
30
35
  requirements:
31
36
  - - ">="
data/bin/cache_invalidate DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'CheckSwiftGen'
4
- puts(CheckSwiftGen.new.cache_invalidate(ARGV[0], ARGV[1]))