Sha256: d8b174c9b0817ad970cf90467dbd8d00eda6d19a477d5cc21c96269f91f2ba21

Contents?: true

Size: 1.32 KB

Versions: 9

Compression:

Stored size: 1.32 KB

Contents

require 'logger'

module Snapshot
  class Helper


    # Logging happens using this method
    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

    # @return true if the currently running program is a unit test
    def self.is_test?
      defined?SpecHelper
    end

    # @return the full path to the Xcode developer tools of the currently
    #  running system
    def self.xcode_path
      return "" if self.is_test? and not OS.mac?
      `xcode-select -p`.gsub("\n", '') + "/"
    end

    def self.fastlane_enabled?
      # This is called from the root context on the first start
      @@enabled ||= File.directory?"./fastlane"
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
snapshot-0.4.8 lib/snapshot/helper.rb
snapshot-0.4.7 lib/snapshot/helper.rb
snapshot-0.4.6 lib/snapshot/helper.rb
snapshot-0.4.5 lib/snapshot/helper.rb
snapshot-0.4.4 lib/snapshot/helper.rb
snapshot-0.4.3 lib/snapshot/helper.rb
snapshot-0.4.2 lib/snapshot/helper.rb
snapshot-0.4.1 lib/snapshot/helper.rb
snapshot-0.4.0 lib/snapshot/helper.rb