Class: Gametime::Helper::VerifyTracking
- Inherits:
-
Object
- Object
- Gametime::Helper::VerifyTracking
- Defined in:
- lib/gametime/helper/tracking.rb
Instance Method Summary collapse
- #find_invalid_events(base_string) ⇒ Object
- #verify ⇒ Object
- #verify_no_missing_tracking_events ⇒ Object
- #verify_tracking_functions ⇒ Object
Instance Method Details
#find_invalid_events(base_string) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/gametime/helper/tracking.rb', line 34 def find_invalid_events(base_string) valid_event = true invalid_objective_c_events = `grep '#{base_string}:@' -R Classes/`.split("\n") invalid_swift_events = `grep '#{base_string}("' -R Classes/`.split("\n") invalid_events = invalid_objective_c_events.concat invalid_swift_events invalid_events.each do |invalid_event| invalid = invalid_event.match(/#{base_string}:@".*"\s/).to_s.gsub(/#{base_string}:/, '') puts "Invalid minor event event: #{invalid}".colorize(:red) valid_event = false end return valid_event end |
#verify ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/gametime/helper/tracking.rb', line 4 def verify puts "Verifying all tracking events used".colorize(:blue) verify_no_missing_tracking_events ? (puts 'All Good'.colorize(:green)) : (puts 'Errors Occured'.colorize(:red)) puts "Verifying all constants used in tracking events".colorize(:blue) verify_tracking_functions ? (puts 'All Good'.colorize(:green)) : (puts 'Errors Occured'.colorize(:red)) end |
#verify_no_missing_tracking_events ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gametime/helper/tracking.rb', line 12 def verify_no_missing_tracking_events valid_event = true File.open('./Classes/GAMTrackingEvents.h').each do |line| if line.start_with?('static') tracking_event_name = line.match(/kTracking(\w*)/) search_results = `grep "#{tracking_event_name}" -R Classes/ | grep -v "GAMTrackingEvents.h"` if search_results.to_s == "" valid_event = false puts "Missing Event: #{tracking_event_name}".colorize(:red) end end end return valid_event end |
#verify_tracking_functions ⇒ Object
30 31 32 |
# File 'lib/gametime/helper/tracking.rb', line 30 def verify_tracking_functions find_invalid_events("trackMinorEvent") && find_invalid_events("trackMajorEvent") && find_invalid_events("trackErrorEvent") end |