Sha256: dcd0f895d969bf1a3665ca99f912adc0994fbdbea9f4aa39c8d745681e3f0b1f

Contents?: true

Size: 1.61 KB

Versions: 40

Compression:

Stored size: 1.61 KB

Contents

require 'rbconfig'

module Bake

  module Utils

    def self.flagSplit(str, removeQuotes)
      return [] if str == ""
      return [str] unless str.include?" "

      hasQuote = false
      hasDoubleQuote = false
      hadQuote = false
      ar = []
      s = ""

      str.split("").each do |i|
        hasDoubleQuote = !hasDoubleQuote if !hasQuote and i == '"'
        hasQuote = !hasQuote if !hasDoubleQuote and i == '\''
        hadQuote = true if hasDoubleQuote
        if i == ' '
          if not hasDoubleQuote and not hasQuote
            if hadQuote and removeQuotes
              ar << s[1..-2] if s.length > 2
              hadQuote = false
            else
              ar << s if s.length > 0
            end
            s = ""
            next
          end
        end
        s << i
      end
      ar << s if s.length > 0
      ar
    end

    # Simple helper query the operating system we are running in
    module OS

      # Is it windows
      def OS.windows?
        (RUBY_PLATFORM =~ /cygwin|mswin|msys|mingw|bccwin|wince|emx|emc/) != nil
      end

      def OS.name
        @os ||= (
          host_os = RbConfig::CONFIG['host_os']
          case host_os
          when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
            "Windows"
          when /darwin|mac os/
            "Mac"
          when /linux/
            "Linux"
          when /solaris|bsd/
            "Unix"
          else
            Bake.formatter.printError("Unknown OS: #{host_os.inspect}")
            ExitHelper.exit(1)
          end
        )
      end

    end

    def self.deep_copy(x)
      Marshal.load(Marshal.dump(x))
    end

  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
bake-toolkit-2.37.14 lib/common/utils.rb
bake-toolkit-2.37.13 lib/common/utils.rb
bake-toolkit-2.37.12 lib/common/utils.rb
bake-toolkit-2.37.11 lib/common/utils.rb
bake-toolkit-2.37.10 lib/common/utils.rb
bake-toolkit-2.37.8 lib/common/utils.rb
bake-toolkit-2.37.7 lib/common/utils.rb
bake-toolkit-2.37.6 lib/common/utils.rb
bake-toolkit-2.37.5 lib/common/utils.rb
bake-toolkit-2.37.4 lib/common/utils.rb
bake-toolkit-2.37.3 lib/common/utils.rb
bake-toolkit-2.37.2 lib/common/utils.rb
bake-toolkit-2.37.1 lib/common/utils.rb
bake-toolkit-2.37.0 lib/common/utils.rb
bake-toolkit-2.36.1 lib/common/utils.rb
bake-toolkit-2.36.0 lib/common/utils.rb
bake-toolkit-2.35.3 lib/common/utils.rb
bake-toolkit-2.35.2 lib/common/utils.rb
bake-toolkit-2.35.1 lib/common/utils.rb
bake-toolkit-2.35.0 lib/common/utils.rb