lib/kramdown/utils.rb in kramdown-1.4.2 vs lib/kramdown/utils.rb in kramdown-1.5.0
- old
+ new
@@ -18,10 +18,11 @@
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
@@ -31,9 +32,26 @@
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