Sha256: 995c95e3b5cfcd43b59135074e73dde13503def01d84cb904f0f78fc0fb872fe

Contents?: true

Size: 1.97 KB

Versions: 8

Compression:

Stored size: 1.97 KB

Contents

require 'fileutils'
require 'forwardable'
require 'json'

require 'active_support/concern'
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/hash/except'
require 'active_support/core_ext/hash/slice'
require 'active_support/core_ext/object/blank'
require 'active_support/inflector'

require 'pupa/models/concerns/indifferent_access'
require 'pupa/models/concerns/contactable'
require 'pupa/models/concerns/identifiable'
require 'pupa/models/concerns/linkable'
require 'pupa/models/concerns/nameable'
require 'pupa/models/concerns/sourceable'
require 'pupa/models/concerns/timestamps'

require 'pupa/errors'
require 'pupa/logger'
require 'pupa/processor'
require 'pupa/runner'

require 'pupa/models/foreign_object'
require 'pupa/models/model'
require 'pupa/models/contact_detail_list'
require 'pupa/models/identifier_list'
require 'pupa/models/membership'
require 'pupa/models/organization'
require 'pupa/models/person'
require 'pupa/models/post'

module Pupa
end

# ActiveSupport's String methods become bottlenecks once:
#
# - HTTP responses are cached in Memcached
# - JSON documents are dumped to Redis
# - Redis is pipelined
# - Validation is skipped
# - The runner is quiet
#
# With these optimizations, in sample scripts, garbage collection and gem
# requiring take up two-thirds of the running time.
class String
  # Alternatively, check if `inflections.acronym_regex` is equal to `/(?=a)b/`.
  # If so, to skip the substitution, which is guaranteed to fail.
  #
  # @see http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-underscore
  def underscore
    word = gsub('::', '/')
    # word.gsub!(/(?:([A-Za-z\d])|^)(#{inflections.acronym_regex})(?=\b|[^a-z])/) { "#{$1}#{$1 && '_'}#{$2.downcase}" }
    word.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
    word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
    word.tr!("-", "_")
    word.downcase!
    word
  end

  # @see http://api.rubyonrails.org/classes/String.html#method-i-blank-3F
  alias_method :blank?, :empty?
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pupa-0.1.7 lib/pupa.rb
pupa-0.1.6 lib/pupa.rb
pupa-0.1.5 lib/pupa.rb
pupa-0.1.4 lib/pupa.rb
pupa-0.1.3 lib/pupa.rb
pupa-0.1.2 lib/pupa.rb
pupa-0.1.1 lib/pupa.rb
pupa-0.1.0 lib/pupa.rb