Commit d229bbf9 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Update tanuki_emoji rake to better display progress

parent 09cff847
# frozen_string_literal: true # frozen_string_literal: true
namespace :tanuki_emoji do namespace :tanuki_emoji do
desc 'Generates Emoji SHA256 digests' desc 'Generates Emoji aliases fixtures'
task aliases: :environment do task aliases: :environment do
aliases = {} aliases = {}
...@@ -18,6 +17,7 @@ namespace :tanuki_emoji do ...@@ -18,6 +17,7 @@ namespace :tanuki_emoji do
end end
end end
desc 'Generates Emoji SHA256 digests'
task digests: :environment do task digests: :environment do
require 'digest/sha2' require 'digest/sha2'
...@@ -84,15 +84,15 @@ namespace :tanuki_emoji do ...@@ -84,15 +84,15 @@ namespace :tanuki_emoji do
end end
puts puts
puts "Done!" puts 'Done!'
end end
# This task will generate a standard and Retina sprite of all of the current # This task will generate a standard and Retina sprite of all of the current
# Gemojione Emojis, with the accompanying SCSS map. # TanukiEmoji Emojis, with the accompanying SCSS map.
# #
# It will not appear in `rake -T` output, and the dependent gems are not # It will not appear in `rake -T` output, and the dependent gems are not
# included in the Gemfile by default, because this task will only be needed # included in the Gemfile by default, because this task will only be needed
# occasionally, such as when new Emojis are added to Gemojione. # occasionally, such as when new Emojis are added to TanukiEmoji.
task sprite: :environment do task sprite: :environment do
begin begin
require 'sprite_factory' require 'sprite_factory'
...@@ -124,15 +124,16 @@ namespace :tanuki_emoji do ...@@ -124,15 +124,16 @@ namespace :tanuki_emoji do
Dir["**/*.png"].each do |png| Dir["**/*.png"].each do |png|
tmp_image_path = File.join(tmpdir, png) tmp_image_path = File.join(tmpdir, png)
resize!(tmp_image_path, SIZE) resize!(tmp_image_path, SIZE)
print emoji.codepoints print '.'
end end
end end
puts ' Done!'
puts puts "\n"
style_path = Rails.root.join(*%w(app assets stylesheets emoji_sprites.scss)) style_path = Rails.root.join(*%w(app assets stylesheets emoji_sprites.scss))
puts "Compiling sprites regular sprites..." print 'Compiling sprites regular sprites... '
# Combine the resized assets into a packed sprite and re-generate the SCSS # Combine the resized assets into a packed sprite and re-generate the SCSS
SpriteFactory.cssurl = "image-url('$IMAGE')" SpriteFactory.cssurl = "image-url('$IMAGE')"
...@@ -179,25 +180,29 @@ namespace :tanuki_emoji do ...@@ -179,25 +180,29 @@ namespace :tanuki_emoji do
CSS CSS
end end
end end
puts 'Done!'
puts "\n"
puts "Preparing sprites for HiDPI size: #{RETINA}px..." puts "Preparing sprites for HiDPI size: #{RETINA}px..."
# Now do it again but for Retina # Now do it again but for Retina
Dir.mktmpdir do |tmpdir| Dir.mktmpdir do |tmpdir|
# Copy the Gemojione assets to the temporary folder for resizing # Copy the TanukiEmoji assets to the temporary folder for resizing
FileUtils.cp_r(File.join(emoji_dir, '.'), tmpdir) FileUtils.cp_r(File.join(emoji_dir, '.'), tmpdir)
Dir.chdir(tmpdir) do Dir.chdir(tmpdir) do
Dir["**/*.png"].each do |png| Dir["**/*.png"].each do |png|
tmp_image_path = File.join(tmpdir, png) tmp_image_path = File.join(tmpdir, png)
resize!(tmp_image_path, RETINA) resize!(tmp_image_path, RETINA)
print emoji.codepoints print '.'
end end
end end
puts ' Done!'
puts puts "\n"
puts "Compiling HiDPI sprites..." print 'Compiling HiDPI sprites...'
# Combine the resized assets into a packed sprite and re-generate the SCSS # Combine the resized assets into a packed sprite and re-generate the SCSS
SpriteFactory.run!(tmpdir, { SpriteFactory.run!(tmpdir, {
...@@ -209,7 +214,7 @@ namespace :tanuki_emoji do ...@@ -209,7 +214,7 @@ namespace :tanuki_emoji do
}) })
end end
puts "Done!" puts ' Done!'
end end
def check_requirements! def check_requirements!
......
...@@ -6,7 +6,7 @@ RSpec.describe EmojiHelper do ...@@ -6,7 +6,7 @@ RSpec.describe EmojiHelper do
describe '#emoji_icon' do describe '#emoji_icon' do
let(:options) { {} } let(:options) { {} }
let(:emoji_text) { 'rocket' } let(:emoji_text) { 'rocket' }
let(:emoji_version) { '6.0' } let(:unicode_version) { '6.0' }
let(:aria_hidden_option) { "aria-hidden=\"true\"" } let(:aria_hidden_option) { "aria-hidden=\"true\"" }
subject { helper.emoji_icon(emoji_text, options) } subject { helper.emoji_icon(emoji_text, options) }
...@@ -15,7 +15,7 @@ RSpec.describe EmojiHelper do ...@@ -15,7 +15,7 @@ RSpec.describe EmojiHelper do
is_expected.to include('<gl-emoji', is_expected.to include('<gl-emoji',
"title=\"#{emoji_text}\"", "title=\"#{emoji_text}\"",
"data-name=\"#{emoji_text}\"", "data-name=\"#{emoji_text}\"",
"data-unicode-version=\"#{emoji_version}\"") "data-unicode-version=\"#{unicode_version}\"")
is_expected.not_to include(aria_hidden_option) is_expected.not_to include(aria_hidden_option)
end end
...@@ -26,7 +26,7 @@ RSpec.describe EmojiHelper do ...@@ -26,7 +26,7 @@ RSpec.describe EmojiHelper do
is_expected.to include('<gl-emoji', is_expected.to include('<gl-emoji',
"title=\"#{emoji_text}\"", "title=\"#{emoji_text}\"",
"data-name=\"#{emoji_text}\"", "data-name=\"#{emoji_text}\"",
"data-unicode-version=\"#{emoji_version}\"", "data-unicode-version=\"#{unicode_version}\"",
aria_hidden_option) aria_hidden_option)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment