gametime-helper 0.1.1 → 0.1.2
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
- data/gametime-helper.gemspec +3 -0
- data/lib/gametime/helper.rb +5 -130
- data/lib/gametime/helper/localization.rb +89 -0
- data/lib/gametime/helper/observer.rb +22 -0
- data/lib/gametime/helper/tracking.rb +53 -0
- data/lib/gametime/helper/version.rb +1 -1
- metadata +33 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94a63f82a2e4d8a9d8bd390d8089b020d5ae1981
|
4
|
+
data.tar.gz: de236b3771abe61a2d472a495ebb9aea9fdd1f60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebf160b80c89fa5f6aee9ada1991fdb4287594e2fad3525bd45d0a659cdc54b6eee2c5ed5de5515ac88679532451b1bbf4685148023e372b8d38f286f36188ee
|
7
|
+
data.tar.gz: 211780739a400866162f783b4709da80a1af56f26a62cd0b79fb896e8d0ed79eca108b712ddbf9ec0b6cf7677e40e040075e63745aa0b25919372805efecdf7a
|
data/gametime-helper.gemspec
CHANGED
@@ -20,6 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = ['gametime']
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
+
spec.add_runtime_dependency "colorize"
|
24
|
+
|
23
25
|
spec.add_development_dependency "bundler", "~> 1.9"
|
26
|
+
spec.add_development_dependency "byebug"
|
24
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
28
|
end
|
data/lib/gametime/helper.rb
CHANGED
@@ -1,137 +1,12 @@
|
|
1
|
-
require
|
1
|
+
require 'colorize'
|
2
|
+
Dir["#{File.dirname(__FILE__)}/helper/*.rb"].sort_by(&:length).reject { |file| file.match(/version/) }.each { |f| load(f) }
|
2
3
|
|
3
4
|
module Gametime
|
4
5
|
module Helper
|
5
6
|
def self.verify
|
6
|
-
VerifyTracking.new.verify
|
7
|
-
VerifyLocalization.new.verify
|
8
|
-
|
9
|
-
|
10
|
-
class VerifyLocalization
|
11
|
-
EXCEPTIONS = [
|
12
|
-
"FAQ",
|
13
|
-
"LocalNotifications"
|
14
|
-
]
|
15
|
-
|
16
|
-
def verify
|
17
|
-
puts "verifying and removing unused localization strings\n\n"
|
18
|
-
find_invalid_strings_and_remove
|
19
|
-
|
20
|
-
puts "verifying all strings in code have matching localization string\n\n"
|
21
|
-
verify_all_strings_present
|
22
|
-
end
|
23
|
-
|
24
|
-
def verify_all_strings_present
|
25
|
-
valid_lines = []
|
26
|
-
|
27
|
-
File.open('./Resources/Base.lproj/Localizable.strings').each do |line|
|
28
|
-
if line.start_with?('"')
|
29
|
-
valid_lines << line.match(/^"\S*/).to_s
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
results = `grep "stringForID" -R Classes/`.split("\n")
|
34
|
-
results.concat `grep "GTStr" -R Classes/`.split("\n")
|
35
|
-
|
36
|
-
all_strings_used = true
|
37
|
-
|
38
|
-
results.each do |result|
|
39
|
-
if matched_output = result.match(/stringForID\("\S*"/)
|
40
|
-
matched_output = matched_output.to_s.gsub(/stringForID\(/, '')
|
41
|
-
|
42
|
-
unless valid_lines.include?(matched_output)
|
43
|
-
puts "missing key: #{matched_output}"
|
44
|
-
all_strings_used = false
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
if matched_output = result.match(/GTStr\("\S*"/)
|
49
|
-
matched_output = matched_output.to_s.gsub(/GTStr\(/, '')
|
50
|
-
|
51
|
-
unless valid_lines.include?(matched_output)
|
52
|
-
puts "missing key: #{matched_output}"
|
53
|
-
all_strings_used = false
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
if all_strings_used
|
59
|
-
puts 'All strings are used and accounted for'
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def find_invalid_strings_and_remove
|
64
|
-
valid_localization = []
|
65
|
-
file_path = './Resources/Base.lproj/Localizable.strings'
|
66
|
-
|
67
|
-
File.open(file_path).each do |line|
|
68
|
-
exception_found = false
|
69
|
-
|
70
|
-
EXCEPTIONS.each do |exception|
|
71
|
-
if line.match(/#{exception}/i)
|
72
|
-
exception_found = true
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
if line.start_with?('"') && !exception_found
|
77
|
-
localizable_string_name = line.match(/^"\S*/)
|
78
|
-
search_results = `grep "#{localizable_string_name}" -R Classes/ | grep -v "Localizable.strings"`
|
79
|
-
|
80
|
-
if search_results.to_s == ""
|
81
|
-
puts "Unused Localizable String: #{localizable_string_name}"
|
82
|
-
else
|
83
|
-
valid_localization << line
|
84
|
-
end
|
85
|
-
else
|
86
|
-
valid_localization << line
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
File.open(file_path, 'w') { |file| file.write(valid_localization.join("")) }
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
class VerifyTracking
|
96
|
-
def verify
|
97
|
-
puts "verifying tracking events\n\n"
|
98
|
-
verify_no_missing_tracking_events
|
99
|
-
|
100
|
-
puts "verifying no strings used in tracking events\n\n"
|
101
|
-
verify_tracking_functions
|
102
|
-
end
|
103
|
-
|
104
|
-
def verify_no_missing_tracking_events
|
105
|
-
File.open('./Classes/GAMTrackingEvents.h').each do |line|
|
106
|
-
if line.start_with?('static')
|
107
|
-
tracking_event_name = line.match(/kTracking(\w*)/)
|
108
|
-
search_results = `grep "#{tracking_event_name}" -R Classes/ | grep -v "GAMTrackingEvents.h"`
|
109
|
-
|
110
|
-
if search_results.to_s == ""
|
111
|
-
puts "Missing Event: #{tracking_event_name}"
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def verify_tracking_functions
|
118
|
-
find_invalid_events("trackMinorEvent")
|
119
|
-
find_invalid_events("trackMajorEvent")
|
120
|
-
end
|
121
|
-
|
122
|
-
def find_invalid_events(base_string)
|
123
|
-
invalid_objective_c_events = `grep '#{base_string}:@' -R Classes/`.split("\n")
|
124
|
-
invalid_swift_events = `grep '#{base_string}("' -R Classes/`.split("\n")
|
125
|
-
|
126
|
-
invalid_events = invalid_objective_c_events.concat invalid_swift_events
|
127
|
-
|
128
|
-
invalid_events.each do |invalid_event|
|
129
|
-
invalid = invalid_event.match(/#{base_string}:@".*"\s/).to_s.gsub(/#{base_string}:/, '')
|
130
|
-
|
131
|
-
puts "Invalid minor event event: #{invalid}"
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
7
|
+
Gametime::Helper::VerifyTracking.new.verify
|
8
|
+
Gametime::Helper::VerifyLocalization.new.verify
|
9
|
+
Gametime::Helper::VerifyObservers.new.verify
|
135
10
|
end
|
136
11
|
end
|
137
12
|
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module Gametime
|
2
|
+
module Helper
|
3
|
+
class VerifyLocalization
|
4
|
+
EXCEPTIONS = [
|
5
|
+
"FAQ",
|
6
|
+
"LocalNotifications"
|
7
|
+
]
|
8
|
+
|
9
|
+
def verify
|
10
|
+
puts "verifying and removing unused localization strings".colorize(:blue)
|
11
|
+
find_invalid_strings_and_remove ? (puts 'All Good'.colorize(:green)) : (puts 'Errors Occured'.colorize(:red))
|
12
|
+
|
13
|
+
puts "Verifying all strings in code have matching localization string".colorize(:blue)
|
14
|
+
verify_all_strings_present ? (puts 'All Good'.colorize(:green)) : (puts 'Errors Occured'.colorize(:red))
|
15
|
+
end
|
16
|
+
|
17
|
+
def verify_all_strings_present
|
18
|
+
valid_lines = []
|
19
|
+
|
20
|
+
File.open('./Resources/Base.lproj/Localizable.strings').each do |line|
|
21
|
+
if line.start_with?('"')
|
22
|
+
valid_lines << line.match(/^"\S*/).to_s
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
results = `grep "StringsManager.sharedInstance().stringForID" -R Classes/`.split("\n")
|
27
|
+
results.concat `grep "GTStr" -R Classes/`.split("\n")
|
28
|
+
|
29
|
+
valid_event = true
|
30
|
+
|
31
|
+
results.each do |result|
|
32
|
+
if matched_output = result.match(/stringForID\("\S*"/)
|
33
|
+
matched_output = matched_output.to_s.gsub(/stringForID\(/, '')
|
34
|
+
|
35
|
+
unless valid_lines.include?(matched_output)
|
36
|
+
puts "missing key: #{matched_output}"
|
37
|
+
valid_event = false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
if matched_output = result.match(/GTStr\("\S*"/)
|
42
|
+
matched_output = matched_output.to_s.gsub(/GTStr\(/, '')
|
43
|
+
|
44
|
+
unless valid_lines.include?(matched_output)
|
45
|
+
puts "missing key: #{matched_output}"
|
46
|
+
valid_event = false
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
valid_event
|
52
|
+
end
|
53
|
+
|
54
|
+
def find_invalid_strings_and_remove
|
55
|
+
valid_event = true
|
56
|
+
valid_localization = []
|
57
|
+
file_path = './Resources/Base.lproj/Localizable.strings'
|
58
|
+
|
59
|
+
File.open(file_path).each do |line|
|
60
|
+
exception_found = false
|
61
|
+
|
62
|
+
EXCEPTIONS.each do |exception|
|
63
|
+
if line.match(/#{exception}/i)
|
64
|
+
exception_found = true
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
if line.start_with?('"') && !exception_found
|
69
|
+
localizable_string_name = line.match(/^"\S*/)
|
70
|
+
search_results = `grep "#{localizable_string_name}" -R Classes/ | grep -v "Localizable.strings"`
|
71
|
+
|
72
|
+
if search_results.to_s == ""
|
73
|
+
valid_event = false
|
74
|
+
puts "Unused Localizable String: #{localizable_string_name}"
|
75
|
+
else
|
76
|
+
valid_localization << line
|
77
|
+
end
|
78
|
+
else
|
79
|
+
valid_localization << line
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
File.open(file_path, 'w') { |file| file.write(valid_localization.join("")) }
|
84
|
+
|
85
|
+
return valid_event
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Gametime
|
2
|
+
module Helper
|
3
|
+
class VerifyObservers
|
4
|
+
def verify
|
5
|
+
puts 'Verifying all observers are deinit on the view'.colorize(:blue)
|
6
|
+
|
7
|
+
valid_event = true
|
8
|
+
files_with_observers = `grep 'addObserver' -R Classes/ -l`.split("\n")
|
9
|
+
files_with_observers.each do |file|
|
10
|
+
search_results = `grep removeObserver "#{file}"`
|
11
|
+
|
12
|
+
if search_results == ""
|
13
|
+
valid_event = false
|
14
|
+
puts "missing remove #{file}".colorize(:red)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
valid_event ? (puts 'All Good'.colorize(:green)) : (puts 'Errors Occured'.colorize(:red))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Gametime
|
2
|
+
module Helper
|
3
|
+
class VerifyTracking
|
4
|
+
def verify
|
5
|
+
puts "Verifying all tracking events used".colorize(:blue)
|
6
|
+
verify_no_missing_tracking_events ? (puts 'All Good'.colorize(:green)) : (puts 'Errors Occured'.colorize(:red))
|
7
|
+
|
8
|
+
puts "Verifying all constants used in tracking events".colorize(:blue)
|
9
|
+
verify_tracking_functions ? (puts 'All Good'.colorize(:green)) : (puts 'Errors Occured'.colorize(:red))
|
10
|
+
end
|
11
|
+
|
12
|
+
def verify_no_missing_tracking_events
|
13
|
+
valid_event = true
|
14
|
+
|
15
|
+
File.open('./Classes/GAMTrackingEvents.h').each do |line|
|
16
|
+
if line.start_with?('static')
|
17
|
+
tracking_event_name = line.match(/kTracking(\w*)/)
|
18
|
+
search_results = `grep "#{tracking_event_name}" -R Classes/ | grep -v "GAMTrackingEvents.h"`
|
19
|
+
|
20
|
+
if search_results.to_s == ""
|
21
|
+
valid_event = false
|
22
|
+
puts "Missing Event: #{tracking_event_name}".colorize(:red)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
return valid_event
|
28
|
+
end
|
29
|
+
|
30
|
+
def verify_tracking_functions
|
31
|
+
find_invalid_events("trackMinorEvent") && find_invalid_events("trackMajorEvent")
|
32
|
+
end
|
33
|
+
|
34
|
+
def find_invalid_events(base_string)
|
35
|
+
valid_event = true
|
36
|
+
|
37
|
+
invalid_objective_c_events = `grep '#{base_string}:@' -R Classes/`.split("\n")
|
38
|
+
invalid_swift_events = `grep '#{base_string}("' -R Classes/`.split("\n")
|
39
|
+
|
40
|
+
invalid_events = invalid_objective_c_events.concat invalid_swift_events
|
41
|
+
|
42
|
+
invalid_events.each do |invalid_event|
|
43
|
+
invalid = invalid_event.match(/#{base_string}:@".*"\s/).to_s.gsub(/#{base_string}:/, '')
|
44
|
+
|
45
|
+
puts "Invalid minor event event: #{invalid}".colorize(:red)
|
46
|
+
valid_event = false
|
47
|
+
end
|
48
|
+
|
49
|
+
return valid_event
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gametime-helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Silvis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -24,6 +38,20 @@ dependencies:
|
|
24
38
|
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '1.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: byebug
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: rake
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,6 +89,9 @@ files:
|
|
61
89
|
- bin/setup
|
62
90
|
- gametime-helper.gemspec
|
63
91
|
- lib/gametime/helper.rb
|
92
|
+
- lib/gametime/helper/localization.rb
|
93
|
+
- lib/gametime/helper/observer.rb
|
94
|
+
- lib/gametime/helper/tracking.rb
|
64
95
|
- lib/gametime/helper/version.rb
|
65
96
|
homepage: http://gametime.co
|
66
97
|
licenses:
|