Sha256: fc1284fcef6100d00dc03d1988eb31c628ed3bf0e3bcc0b526a691b3fb628a18

Contents?: true

Size: 1.48 KB

Versions: 14

Compression:

Stored size: 1.48 KB

Contents

# -*- coding: utf-8 -*-
#
#--
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
#
# This file is part of kramdown which is licensed under the MIT.
#++
#

module Kramdown

  # == \Utils Module
  #
  # This module contains utility class/modules/methods that can be used by both parsers and
  # converters.
  module Utils

    autoload :Entities, 'kramdown/utils/entities'
    autoload :Html, 'kramdown/utils/html'
    autoload :OrderedHash, 'kramdown/utils/ordered_hash'
    autoload :Unidecoder, 'kramdown/utils/unidecoder'
    autoload :StringScanner, 'kramdown/utils/string_scanner'
    autoload :Configurable, 'kramdown/utils/configurable'

    # Treat +name+ as if it were snake cased (e.g. snake_case) and camelize it (e.g. SnakeCase).
    def self.camelize(name)
      name.split('_').inject('') {|s,x| s << x[0..0].upcase << x[1..-1] }
    end

    # Treat +name+ as if it were camelized (e.g. CamelizedName) and snake-case it (e.g. camelized_name).
    def self.snake_case(name)
      name = name.dup
      name.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
      name.gsub!(/([a-z])([A-Z])/,'\1_\2')
      name.downcase!
      name
    end

    if RUBY_VERSION < '2.0'

      # Resolve the recursive constant +str+.
      def self.deep_const_get(str)
        names = str.split(/::/)
        names.shift if names.first.empty?
        names.inject(::Object) {|mod, s| mod.const_get(s)}
      end

    else

      def self.deep_const_get(str)
        ::Object.const_get(str)
      end

    end

  end

end

Version data entries

14 entries across 13 versions & 5 rubygems

Version Path
able-neo4j-1.0.0 vendor/bundle/jruby/1.9/gems/kramdown-1.8.0/lib/kramdown/utils.rb
kramdown-1.10.0 lib/kramdown/utils.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/kramdown-1.8.0/lib/kramdown/utils.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/kramdown-1.8.0/lib/kramdown/utils.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/kramdown-1.8.0/lib/kramdown/utils.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/kramdown-1.9.0/lib/kramdown/utils.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/logstash-codec-json-2.0.3/vendor/gems/kramdown-1.9.0/lib/kramdown/utils.rb
logstash-codec-json-2.0.3 vendor/gems/kramdown-1.9.0/lib/kramdown/utils.rb
logstash-input-beats-0.9.2 vendor/jruby/1.9/gems/kramdown-1.9.0/lib/kramdown/utils.rb
logstash-input-beats-0.9.1 vendor/jruby/1.9/gems/kramdown-1.9.0/lib/kramdown/utils.rb
kramdown-1.9.0 lib/kramdown/utils.rb
kramdown-1.8.0 lib/kramdown/utils.rb
kramdown-1.7.0 lib/kramdown/utils.rb
kramdown-1.6.0 lib/kramdown/utils.rb