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
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/crack-0.4.5/lib/crack/util.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/crack-0.4.5/lib/crack/util.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/crack-0.4.5/lib/crack/util.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/crack-0.4.5/lib/crack/util.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/crack-0.4.5/lib/crack/util.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/crack-0.4.5/lib/crack/util.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/crack-0.4.5/lib/crack/util.rb
cloudsmith-api-0.57.1 vendor/bundle/ruby/2.6.0/gems/crack-0.4.5/lib/crack/util.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/3.0.0/gems/crack-0.4.5/lib/crack/util.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/gems/crack-0.4.5/lib/crack/util.rb
logstash-output-newrelic-1.2.0 vendor/bundle/jruby/2.5.0/gems/crack-0.4.5/lib/crack/util.rb
vagrant-unbundled-2.2.14.0 vendor/bundle/ruby/2.7.0/gems/crack-0.4.5/lib/crack/util.rb
crack-0.4.5 lib/crack/util.rb
cloudsmith-api-0.54.15 vendor/bundle/ruby/2.6.0/gems/crack-0.4.4/lib/crack/util.rb
cloudsmith-api-0.53.79 vendor/bundle/ruby/2.6.0/gems/crack-0.4.4/lib/crack/util.rb
cloudsmith-api-0.53.17 vendor/bundle/ruby/2.6.0/gems/crack-0.4.4/lib/crack/util.rb
crack-0.4.4 lib/crack/util.rb
cloudsmith-api-0.53.3 vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/lib/crack/util.rb
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/crack-0.4.3/lib/crack/util.rb
cloudsmith-api-0.53.1 vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/lib/crack/util.rb