Sha256: f02421091769b2084d97f0fd6a926d2e41a661423b62723e5cd47cb28648fafa

Contents?: true

Size: 1.38 KB

Versions: 22

Compression:

Stored size: 1.38 KB

Contents

#!/usr/bin/env ruby


#########################################
# renamer
#
# changes full_name file names to to code 
#########################################

require 'rubygems'

gem 'emojidex'

require 'fileutils'
require 'emojidex'

emoji_root = File.expand_path('../../emoji/', __FILE__)
utf_path = File.expand_path('utf', emoji_root)
extended_path = File.expand_path('extended', emoji_root)

utf = Emojidex::Collection.new
utf.load_local_collection utf_path

extended = Emojidex::Collection.new
extended.load_local_collection extended_path

variants = ['(br)', '(bk)']
# check if variant extended emoji contain UTF full_name
utf.each do |moji|
  h = moji.to_hash
  if h['full_name']
    variants.each do |variant|
      check = extended.emoji[(h['full_name'] + variant).to_sym]
      next if check.nil?
      puts "Moving: #{check.to_hash['code']}.svg to " + 
            "#{(h['code'] + variant).to_s}.svg"
      if File.exist? "#{extended_path}/#{check.to_hash['code']}.svg"
        FileUtils.mv("#{extended_path}/#{check.to_hash['code']}.svg",
                     "#{extended_path}/#{(h['code'] + variant).to_s}.svg")
      end
      check.code = (h['code'] + variant).to_s
      extended.write_index("#{extended_path}")
      json = JSON.parse(IO.read("#{extended_path}/emoji.json"))
      File.open("#{extended_path}/emoji.json", 'w') { |f| f.write JSON::pretty_generate(json) }
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
emojidex-vectors-1.0.8 util/renamer.rb
emojidex-vectors-1.0.7 util/renamer.rb
emojidex-vectors-1.0.6 util/renamer.rb
emojidex-vectors-1.0.5 util/renamer.rb
emojidex-vectors-1.0.4 util/renamer.rb
emojidex-vectors-1.0.3 util/renamer.rb
emojidex-vectors-1.0.2 util/renamer.rb
emojidex-vectors-1.0.1 util/renamer.rb
emojidex-vectors-1.0.0 util/renamer.rb
emojidex-vectors-0.1.4 util/renamer.rb
emojidex-vectors-0.1.3 util/renamer.rb
emojidex-vectors-0.1.2 util/renamer.rb
emojidex-vectors-0.1.1 util/renamer.rb
emojidex-vectors-0.1.0 util/renamer.rb
emojidex-vectors-0.0.10 util/renamer.rb
emojidex-vectors-0.0.9 util/renamer.rb
emojidex-vectors-0.0.8 util/renamer.rb
emojidex-vectors-0.0.7 util/renamer.rb
emojidex-vectors-0.0.6 util/renamer.rb
emojidex-vectors-0.0.5 util/renamer.rb