Sha256: 4e9a554482c1b067afbd3f414e712baf144ef7e50105fe3b5fc0e085202bbb4a

Contents?: true

Size: 1.11 KB

Versions: 22

Compression:

Stored size: 1.11 KB

Contents

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|mingw|bccwin|wince|emx/) != nil
      end

    end

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

  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
bake-toolkit-2.26.1 lib/common/utils.rb
bake-toolkit-2.26.0 lib/common/utils.rb
bake-toolkit-2.25.1 lib/common/utils.rb
bake-toolkit-2.25.0 lib/common/utils.rb
bake-toolkit-2.24.6 lib/common/utils.rb
bake-toolkit-2.24.5 lib/common/utils.rb
bake-toolkit-2.24.4 lib/common/utils.rb
bake-toolkit-2.24.3 lib/common/utils.rb
bake-toolkit-2.24.2 lib/common/utils.rb
bake-toolkit-2.24.1 lib/common/utils.rb
bake-toolkit-2.24.0 lib/common/utils.rb
bake-toolkit-2.23.12 lib/common/utils.rb
bake-toolkit-2.23.8 lib/common/utils.rb
bake-toolkit-2.23.7 lib/common/utils.rb
bake-toolkit-2.23.6 lib/common/utils.rb
bake-toolkit-2.23.5 lib/common/utils.rb
bake-toolkit-2.23.4 lib/common/utils.rb
bake-toolkit-2.23.3 lib/common/utils.rb
bake-toolkit-2.23.2 lib/common/utils.rb
bake-toolkit-2.23.1 lib/common/utils.rb