Sha256: 0761664ed3d109b8eb82b7250ace73f82719e10626807093ede92c68f3a11c83

Contents?: true

Size: 633 Bytes

Versions: 8

Compression:

Stored size: 633 Bytes

Contents


module Rubber
  module Util

    def self.symbolize_keys(map)
      map.inject({}) do |options, (key, value)|
        options[key.to_sym || key] = value
        options
      end
    end
    
    def self.stringify(val)
      case val
      when String
        val
      when Hash
        val.inject({}) {|h, a| h[stringify(a[0])] = stringify(a[1]); h}
      when Enumerable
        val.collect {|v| stringify(v)}
      else
        val.to_s
      end
      
    end

    # Opens the file for writing by root
    def self.sudo_open(path, perms, &block)
      open("|sudo tee #{path} > /dev/null", perms, &block)
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sml-rubber-0.9.1 lib/rubber/util.rb
sml-rubber-0.9.3 lib/rubber/util.rb
sml-rubber-0.9.4 lib/rubber/util.rb
sml-rubber-0.9.5 lib/rubber/util.rb
sml-rubber-0.9.6 lib/rubber/util.rb
sml-rubber-0.9.7 lib/rubber/util.rb
sml-rubber-0.9.8 lib/rubber/util.rb
sml-rubber-0.9.9 lib/rubber/util.rb