* Enable Rails cops * Fix Rails/DynamicFindBy * Fix Rails/HttpStatus * Fix Rails/Blank * Fix Rails/RequestReferer * Fix Rails/ActiveRecordAliases * Fix Rails/FindBy * Fix Rails/Presence * Fix Rails/Delegate * Fix Rails/Validation * Fix Rails/PluralizationGrammar * Fix Rails/Present * Fix Rails/Output * Fix Rails/Blank * Fix Rails/FilePath * Fix Rails/InverseOf * Fix Rails/LexicallyScopedActionFilter * Add Rails/OutputSafety to TODO * Add Rails/HasManyOrHasOneDependent to TODO * Add Rails/SkipsModelValidations to TODO
19 lines
357 B
Ruby
19 lines
357 B
Ruby
class EmojiConverter
|
|
attr_reader :html
|
|
|
|
def self.call(html)
|
|
new(html).convert
|
|
end
|
|
|
|
def initialize(html)
|
|
@html = html
|
|
end
|
|
|
|
def convert
|
|
html.gsub!(/:([\w+-]+):/) do |match|
|
|
emoji = Emoji.find_by_alias(Regexp.last_match(1)) # rubocop:disable Rails/DynamicFindBy
|
|
emoji.present? ? emoji.raw : match
|
|
end
|
|
html
|
|
end
|
|
end
|