Sha256: 192f0e9ac7208b1fa6e69d896c6dd984f412763471051baa012cfecd83662d31

Contents?: true

Size: 1.18 KB

Versions: 42

Compression:

Stored size: 1.18 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

42 entries across 42 versions & 1 rubygems

Version Path
bake-toolkit-2.20.4 lib/common/utils.rb
bake-toolkit-2.20.3 lib/common/utils.rb
bake-toolkit-2.20.2 lib/common/utils.rb
bake-toolkit-2.20.1 lib/common/utils.rb
bake-toolkit-2.19.2 lib/common/utils.rb
bake-toolkit-2.19.1 lib/common/utils.rb
bake-toolkit-2.19.0 lib/common/utils.rb
bake-toolkit-2.18.0 lib/common/utils.rb
bake-toolkit-2.17.4 lib/common/utils.rb
bake-toolkit-2.17.3 lib/common/utils.rb
bake-toolkit-2.17.2 lib/common/utils.rb
bake-toolkit-2.17.1 lib/common/utils.rb
bake-toolkit-2.16.1 lib/common/utils.rb
bake-toolkit-2.15.0 lib/common/utils.rb
bake-toolkit-2.14.0 lib/common/utils.rb
bake-toolkit-2.13.1 lib/common/utils.rb
bake-toolkit-2.13.0 lib/common/utils.rb
bake-toolkit-2.12.2 lib/common/utils.rb
bake-toolkit-2.12.1 lib/common/utils.rb
bake-toolkit-2.12.0 lib/common/utils.rb