Sha256: 34e5ebeec4cf5748dc6363689ce4be316f7e538b8e21a17ca730ecd18c470b91

Contents?: true

Size: 424 Bytes

Versions: 141

Compression:

Stored size: 424 Bytes

Contents

module Crack
  module Util
    def snake_case(str)
      return str.downcase if str =~ /^[A-Z]+$/
      str.gsub(/([A-Z]+)(?=[A-Z][a-z]?)|\B[A-Z]/, '_\&') =~ /_*(.*)/
      return $+.downcase
    end

    def to_xml_attributes(hash)
      hash.map do |k,v|
        %{#{Crack::Util.snake_case(k.to_s).sub(/^(.{1,1})/) { |m| m.downcase }}="#{v.to_s.gsub('"', '"')}"}
      end.join(' ')
    end

    extend self
  end
end

Version data entries

141 entries across 132 versions & 18 rubygems

Version Path
cloudsmith-api-0.52.121 vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/lib/crack/util.rb
cloudsmith-api-0.52.92 vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/lib/crack/util.rb
cloudsmith-api-0.52.79 vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/lib/crack/util.rb
cloudsmith-api-0.52.5 vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/lib/crack/util.rb
cloudsmith-api-0.52.0 vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/lib/crack/util.rb
cloudsmith-api-0.51.93 vendor/bundle/ruby/2.3.0/gems/crack-0.4.3/lib/crack/util.rb
cloudsmith-api-0.51.38 vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/lib/crack/util.rb
cloudsmith-api-0.51.37 vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/lib/crack/util.rb
cloudsmith-api-0.51.34 vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/lib/crack/util.rb
cloudsmith-api-0.51.22 vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/lib/crack/util.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/crack-0.4.3/lib/crack/util.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/crack-0.4.3/lib/crack/util.rb
cloudsmith-api-0.49.118 vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/lib/crack/util.rb
cloudsmith-api-0.49.98 vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/lib/crack/util.rb
cloudsmith-api-0.49.94 vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/lib/crack/util.rb
cloudsmith-api-0.49.21 vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/lib/crack/util.rb
cloudsmith-api-0.49.15 vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/lib/crack/util.rb
cloudsmith-api-0.49.13 vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/lib/crack/util.rb
cloudsmith-api-0.49.9 vendor/bundle/ruby/2.3.0/gems/crack-0.4.3/lib/crack/util.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/lib/crack/util.rb