Module: E9Tags

Defined in:
lib/e9_tags.rb,
lib/e9_tags/model.rb,
lib/e9_tags/helper.rb,
lib/e9_tags/version.rb,
lib/e9_tags/controller.rb,
lib/e9_tags/tagging_extension.rb,
lib/generators/e9_tags/install_generator.rb

Defined Under Namespace

Modules: Controller, Generators, Helper, Model, Rack, TaggingExtension Classes: Engine

Constant Summary collapse

ESCAPED_DASH =
'__d__'
ESCAPED_DASH_REGEX =
Regexp.new(Regexp.escape(ESCAPED_DASH), true)
ESCAPED_SPACE =
'__s__'
ESCAPED_SPACE_REGEX =
Regexp.new(Regexp.escape(ESCAPED_SPACE), true)
ESCAPED_PRIVATE =
'__h__'
ESCAPED_PRIVATE_REGEX =
Regexp.new(Regexp.escape(ESCAPED_PRIVATE), true)
PRIVATE_TAG_SUFFIX =
'*'
PRIVATE_TAG_SUFFIX_REGEX =
Regexp.new(Regexp.escape(PRIVATE_TAG_SUFFIX), true)
VERSION =
"0.0.14"
@@controllers =
[]
@@models =
[]

Class Method Summary collapse

Class Method Details

.escape_context(context) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/e9_tags.rb', line 41

def E9Tags.escape_context(context)
  context.to_s.strip.
          downcase.
          gsub(/\s+/, ESCAPED_SPACE).
          gsub(/-/, ESCAPED_DASH).
          sub(PRIVATE_TAG_SUFFIX_REGEX, ESCAPED_PRIVATE)
end

.setup!Object



58
59
60
61
62
63
# File 'lib/e9_tags.rb', line 58

def E9Tags.setup!
  ActsAsTaggableOn::Tagging.send(:include, E9Tags::TaggingExtension)

  E9Tags.models.each {|m| m.send(:include, E9Tags::Model) }
  E9Tags.controllers.each {|m| m.send(:include, E9Tags::Controller) }
end

.unescape_context(context) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/e9_tags.rb', line 49

def E9Tags.unescape_context(context)
  context.to_s.strip.
          gsub(ESCAPED_SPACE_REGEX, ' ').
          gsub(ESCAPED_DASH_REGEX, '-').
          sub(ESCAPED_PRIVATE_REGEX, PRIVATE_TAG_SUFFIX).
          downcase.
          titleize
end