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-2.0.15 vendor/bundle/ruby/2.6.0/gems/crack-1.0.0/lib/crack/util.rb
cloudsmith-api-2.0.14 vendor/bundle/ruby/2.6.0/gems/crack-1.0.0/lib/crack/util.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/crack-1.0.0/lib/crack/util.rb
cloudsmith-api-2.0.13 vendor/bundle/ruby/2.6.0/gems/crack-1.0.0/lib/crack/util.rb
cloudsmith-api-2.0.12 vendor/bundle/ruby/2.6.0/gems/crack-1.0.0/lib/crack/util.rb
cloudsmith-api-2.0.11 vendor/bundle/ruby/2.6.0/gems/crack-1.0.0/lib/crack/util.rb
cloudsmith-api-2.0.10 vendor/bundle/ruby/2.6.0/gems/crack-1.0.0/lib/crack/util.rb
cloudsmith-api-2.0.9 vendor/bundle/ruby/2.6.0/gems/crack-1.0.0/lib/crack/util.rb
cloudsmith-api-2.0.8 vendor/bundle/ruby/2.6.0/gems/crack-1.0.0/lib/crack/util.rb
crack-1.0.0 lib/crack/util.rb
crack-0.4.6 lib/crack/util.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/crack-0.4.5/lib/crack/util.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/crack-0.4.5/lib/crack/util.rb
cloudsmith-api-2.0.7 vendor/bundle/ruby/2.6.0/gems/crack-0.4.5/lib/crack/util.rb
cloudsmith-api-2.0.6 vendor/bundle/ruby/2.6.0/gems/crack-0.4.5/lib/crack/util.rb
cloudsmith-api-2.0.5 vendor/bundle/ruby/2.6.0/gems/crack-0.4.5/lib/crack/util.rb
cloudsmith-api-2.0.4 vendor/bundle/ruby/2.6.0/gems/crack-0.4.5/lib/crack/util.rb
cloudsmith-api-2.0.3 vendor/bundle/ruby/2.6.0/gems/crack-0.4.5/lib/crack/util.rb
cloudsmith-api-2.0.2 vendor/bundle/ruby/2.6.0/gems/crack-0.4.5/lib/crack/util.rb
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/crack-0.4.5/lib/crack/util.rb