Sha256: 2654e4f9d20429ca6cf7c3db2aeae87d311d34c588b24aa6adaab4160347992e

Contents?: true

Size: 793 Bytes

Versions: 27

Compression:

Stored size: 793 Bytes

Contents

module ZendeskAPI
  # @private
  module Helpers
    # From https://github.com/rubyworks/facets/blob/master/lib/core/facets/string/modulize.rb
    def self.modulize_string(string)
      # gsub('__','/').  # why was this ever here?
      string.gsub(/__(.?)/) { "::#{$1.upcase}" }.
        gsub(/\/(.?)/) { "::#{$1.upcase}" }.
        gsub(/(?:_+|-+)([a-z])/) { $1.upcase }.
        gsub(/(\A|\s)([a-z])/) { $1 + $2.upcase }
    end

    # From https://github.com/rubyworks/facets/blob/master/lib/core/facets/string/snakecase.rb
    def self.snakecase_string(string)
      # gsub(/::/, '/').
      string.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
        gsub(/([a-z\d])([A-Z])/, '\1_\2').
        tr('-', '_').
        gsub(/\s/, '_').
        gsub(/__+/, '_').
        downcase
    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
zendesk_api-1.34.0 lib/zendesk_api/helpers.rb
discourse_zendesk_api-1.0.1 lib/zendesk_api/helpers.rb
discourse_zendesk_api-1.0.0 lib/zendesk_api/helpers.rb
zendesk_api-1.33.0 lib/zendesk_api/helpers.rb
zendesk_api-1.32.0 lib/zendesk_api/helpers.rb
zendesk_api-1.31.0 lib/zendesk_api/helpers.rb
zendesk_api-1.30.0 lib/zendesk_api/helpers.rb
zendesk_api-1.29.0 lib/zendesk_api/helpers.rb
zendesk_api-1.28.0 lib/zendesk_api/helpers.rb
zendesk_api-1.27.0 lib/zendesk_api/helpers.rb
zendesk_api-1.26.0 lib/zendesk_api/helpers.rb
zendesk_api-1.25.0 lib/zendesk_api/helpers.rb
zendesk_api-1.24.0 lib/zendesk_api/helpers.rb
zendesk_api-1.23.0 lib/zendesk_api/helpers.rb
zendesk_api-1.22.0 lib/zendesk_api/helpers.rb
zendesk_api-1.21.0 lib/zendesk_api/helpers.rb
zendesk_api-1.20.0 lib/zendesk_api/helpers.rb
zendesk_api-1.19.1 lib/zendesk_api/helpers.rb
zendesk_api-1.19.0 lib/zendesk_api/helpers.rb
zendesk_api-1.18.0 lib/zendesk_api/helpers.rb