debian-mirror-gitlab/lib/award_emoji.rb

52 lines
1.1 KiB
Ruby
Raw Normal View History

2015-11-26 14:37:03 +05:30
class AwardEmoji
CATEGORIES = {
other: "Other",
objects: "Objects",
places: "Places",
travel_places: "Travel",
emoticons: "Emoticons",
objects_symbols: "Symbols",
nature: "Nature",
celebration: "Celebration",
people: "People",
activity: "Activity",
flags: "Flags",
food_drink: "Food"
2015-12-23 02:04:40 +05:30
}.with_indifferent_access
def self.normilize_emoji_name(name)
aliases[name] || name
2015-11-26 14:37:03 +05:30
end
2015-12-23 02:04:40 +05:30
def self.emoji_by_category
unless @emoji_by_category
@emoji_by_category = {}
emojis.each do |emoji_name, data|
data["name"] = emoji_name
@emoji_by_category[data["category"]] ||= []
@emoji_by_category[data["category"]] << data
end
@emoji_by_category = @emoji_by_category.sort.to_h
end
@emoji_by_category
end
def self.emojis
@emojis ||= begin
json_path = File.join(Rails.root, 'fixtures', 'emojis', 'index.json' )
JSON.parse(File.read(json_path))
end
end
def self.aliases
@aliases ||= begin
json_path = File.join(Rails.root, 'fixtures', 'emojis', 'aliases.json' )
JSON.parse(File.read(json_path))
end
2015-12-23 02:04:40 +05:30
end
2015-11-26 14:37:03 +05:30
end