Sha256: 42e18fb52b07ac8b4dc361bdc409490f96827667ed0c226e765b3f3db3efd3d8

Contents?: true

Size: 1.45 KB

Versions: 9

Compression:

Stored size: 1.45 KB

Contents

module Cxxproject
  module Utils
  
    def self.flagSplit(str, removeQuotes)
      hasQuote = false
      hasDoubleQuote = false
      hadQuote = false
      ar = []
      s = ""
  
      #puts str
      
      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

      # Is it osx
      def OS.mac?
        (RUBY_PLATFORM =~ /darwin/) != nil
      end

      # Is it kind of unix
      def OS.unix?
        !OS.windows?
      end

      # Is it linux
      def OS.linux?
        OS.unix? and not OS.mac?
      end

    end

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

    def self.old_ruby?
      RUBY_VERSION[0..2] == "1.8"
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
cxxproject-0.5.76 lib/cxxproject/utils/utils.rb
cxxproject-0.5.75 lib/cxxproject/utils/utils.rb
cxxproject-0.5.74 lib/cxxproject/utils/utils.rb
cxxproject-0.5.73 lib/cxxproject/utils/utils.rb
cxxproject-0.5.72 lib/cxxproject/utils/utils.rb
cxxproject-0.5.71 lib/cxxproject/utils/utils.rb
cxxproject-0.5.70 lib/cxxproject/utils/utils.rb
cxxproject-0.5.69 lib/cxxproject/utils/utils.rb
cxxproject-0.5.68 lib/cxxproject/utils/utils.rb