Sha256: 4a8ce278c6df1029c3b74b79c901dc544f8a1384ea0004bf7f55352acc53dcad

Contents?: true

Size: 669 Bytes

Versions: 29

Compression:

Stored size: 669 Bytes

Contents

class Miam::Utils
  class << self
    def unbrace(str)
      str.sub(/\A\s*\{/, '').sub(/\}\s*\z/, '')
    end

    def camelize(str)
      str.slice(0, 1).upcase + str.slice(1..-1).downcase
    end

    def bytesize(str)
      if str.respond_to?(:bytesize)
        str.bytesize
      else
        str.length
      end
    end

    def diff(obj1, obj2, options = {})
      diffy = Diffy::Diff.new(
        obj1.pretty_inspect,
        obj2.pretty_inspect,
        :diff => '-u'
      )

      out = diffy.to_s(options[:color] ? :color : :text).gsub(/\s+\z/m, '')
      out.gsub!(/^/, options[:indent]) if options[:indent]
      out
    end
  end # of class methods
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
miam-0.2.5.beta1 lib/miam/utils.rb
miam-0.2.4 lib/miam/utils.rb
miam-0.2.4.beta18 lib/miam/utils.rb
miam-0.2.4.beta17 lib/miam/utils.rb
miam-0.2.4.beta16 lib/miam/utils.rb
miam-0.2.4.beta15 lib/miam/utils.rb
miam-0.2.4.beta14 lib/miam/utils.rb
miam-0.2.4.beta13 lib/miam/utils.rb
miam-0.2.4.beta12 lib/miam/utils.rb
miam-0.2.4.beta11 lib/miam/utils.rb
miam-0.2.4.beta10 lib/miam/utils.rb
miam-0.2.4.beta9 lib/miam/utils.rb
miam-0.2.4.beta8 lib/miam/utils.rb
miam-0.2.4.beta7 lib/miam/utils.rb
miam-0.2.4.beta6 lib/miam/utils.rb
miam-0.2.4.beta5 lib/miam/utils.rb
miam-0.2.4.beta4 lib/miam/utils.rb
miam-0.2.4.beta3 lib/miam/utils.rb
miam-0.2.4.beta2 lib/miam/utils.rb
miam-0.2.4.beta lib/miam/utils.rb