Class: Snapshot::Helper
- Inherits:
-
Object
- Object
- Snapshot::Helper
- Defined in:
- lib/snapshot/helper.rb
Class Method Summary collapse
- .fastlane_enabled? ⇒ Boolean
-
.is_test? ⇒ Boolean
True if the currently running program is a unit test.
-
.log ⇒ Object
Logging happens using this method.
-
.xcode_path ⇒ Object
The full path to the Xcode developer tools of the currently running system.
Class Method Details
.fastlane_enabled? ⇒ Boolean
50 51 52 53 |
# File 'lib/snapshot/helper.rb', line 50 def self.fastlane_enabled? # This is called from the root context on the first start @@enabled ||= File.directory?"./fastlane" end |
.is_test? ⇒ Boolean
Returns true if the currently running program is a unit test.
39 40 41 |
# File 'lib/snapshot/helper.rb', line 39 def self.is_test? defined?SpecHelper end |
.log ⇒ Object
Logging happens using this method
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/snapshot/helper.rb', line 8 def self.log if is_test? @@log ||= Logger.new(STDOUT) # don't show any logs when running tests else @@log ||= Logger.new(STDOUT) end @@log.formatter = proc do |severity, datetime, progname, msg| string = "#{severity} [#{datetime.strftime('%Y-%m-%d %H:%M:%S.%2N')}]: " second = "#{msg}\n" if severity == "DEBUG" string = string.magenta elsif severity == "INFO" string = string.white elsif severity == "WARN" string = string.yellow elsif severity == "ERROR" string = string.red elsif severity == "FATAL" string = string.red.bold end [string, second].join("") end @@log end |
.xcode_path ⇒ Object
Returns the full path to the Xcode developer tools of the currently running system.
45 46 47 48 |
# File 'lib/snapshot/helper.rb', line 45 def self.xcode_path return "" if self.is_test? and not OS.mac? `xcode-select -p`.gsub("\n", '') + "/" end |