Skip to content

Commit

Permalink
Merge pull request #159 from jch/require-gemoji-2
Browse files Browse the repository at this point in the history
Drop support for gemoji ~> 1.0
  • Loading branch information
jch committed Feb 25, 2015
2 parents bddac29 + 39bba6f commit dc8f6b9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ end
group :test do
gem "minitest", "~> 5.3"
gem "rinku", "~> 1.7", :require => false
gem "gemoji", "~> 1.0", :require => false
gem "gemoji", "~> 2.0", :require => false
gem "RedCloth", "~> 4.2.9", :require => false
gem "github-markdown", "~> 0.5", :require => false
gem "email_reply_parser", "~> 0.5", :require => false
Expand Down
22 changes: 5 additions & 17 deletions lib/html/pipeline/emoji_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,12 @@ def emoji_pattern
self.class.emoji_pattern
end

# Detect gemoji v2 which has a new API
# https://github.com/jch/html-pipeline/pull/129
if Emoji.respond_to?(:all)
def self.emoji_names
Emoji.all.map(&:aliases).flatten.sort
end

def emoji_filename(name)
Emoji.find_by_alias(name).image_filename
end
else
def self.emoji_names
Emoji.names
end
def self.emoji_names
Emoji.all.map(&:aliases).flatten.sort
end

def emoji_filename(name)
"#{::CGI.escape(name)}.png"
end
def emoji_filename(name)
Emoji.find_by_alias(name).image_filename
end

# Return ancestor tags to stop the emojification.
Expand Down
4 changes: 2 additions & 2 deletions test/html/pipeline/emoji_filter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_emojify
def test_uri_encoding
filter = EmojiFilter.new("<p>:+1:</p>", {:asset_root => 'https://foo.com'})
doc = filter.call
assert_match "https://foo.com/emoji/%2B1.png", doc.search('img').attr('src').value
assert_match "https://foo.com/emoji/unicode/1f44d.png", doc.search('img').attr('src').value
end

def test_required_context_validation
Expand All @@ -25,7 +25,7 @@ def test_required_context_validation
def test_custom_asset_path
filter = EmojiFilter.new("<p>:+1:</p>", {:asset_path => ':file_name', :asset_root => 'https://foo.com'})
doc = filter.call
assert_match "https://foo.com/%2B1.png", doc.search('img').attr('src').value
assert_match "https://foo.com/unicode/1f44d.png", doc.search('img').attr('src').value
end

def test_not_emojify_in_code_tags
Expand Down

0 comments on commit dc8f6b9

Please sign in to comment.