Sha256: 829a383c1dac5ff92b550bda82391602eb0676086dabf2ea4ae59b08319e0bb8

Contents?: true

Size: 1.09 KB

Versions: 13

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require "bundler/gem_tasks"
task default: %i[]

task :emoji_table do
  require_relative "lib/discorb"

  res = {}
  Discorb::EmojiTable::DISCORD_TO_UNICODE.each do |discord, unicode|
    res[unicode] ||= []
    res[unicode] << discord
  end

  res_text = +""
  res.each do |unicode, discord|
    res_text << %(#{unicode.unpack("C*").pack("C*").inspect} => %w[#{discord.join(" ")}],\n)
  end

  table_script = File.read("lib/discorb/emoji_table.rb")

  table_script.gsub!(/(?<=UNICODE_TO_DISCORD = {\n)[\s\S]+(?=}\.freeze)/, res_text)

  File.open("lib/discorb/emoji_table.rb", "w") do |f|
    f.print(table_script)
  end
  `rubocop -A lib/discorb/emoji_table.rb`
  puts "Successfully made emoji_table.rb"
end

task :format do
  Dir.glob("**/*.rb").each do |file|
    next if file.start_with?("vendor")

    puts "Formatting #{file}"
    `rufo ./#{file}`
    content = ""
    File.open(file, "rb") do |f|
      content = f.read
    end
    content.gsub!("\r\n", "\n")
    File.open(file, "wb") do |f|
      f.print(content)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
discorb-0.2.4 Rakefile
discorb-0.2.3 Rakefile
discorb-0.2.1 Rakefile
discorb-0.2.0 Rakefile
discorb-0.1.0 Rakefile
discorb-0.0.8 Rakefile
discorb-0.0.7 Rakefile
discorb-0.0.6 Rakefile
discorb-0.0.5 Rakefile
discorb-0.0.4 Rakefile
discorb-0.0.3 Rakefile
discorb-0.0.2 Rakefile
discorb-0.0.1 Rakefile