discourse-emojis 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f8bd0d836e90228a4d4c6eab90bbb2db31b85a93c7357daee246021d01b7ff1
4
- data.tar.gz: b9afb8ed807d4ecfaaf37c5947d77c1f922db871d7a16956cceaa6c659e4545d
3
+ metadata.gz: 93129574be47db8ef174e6651bffa0e7738b2d2b183eaecc860d50b8c1cef7a7
4
+ data.tar.gz: 5ca53f21cf04a2e106eb79f69fe79e6e71c6492eade52b265c7a83285100bc1f
5
5
  SHA512:
6
- metadata.gz: b95f4349797ce7c710a360110a110f5a274b0c207758d5762f0b11400440384592578d9068088e5f7755d647920d1f7d2283956c9593a92467bc05304146ffea
7
- data.tar.gz: f97c639bd6f0c0e01223c113b69914b0c0cd1f14c01e0c7f81a3bc6b535bca97400bbd23405a4440773d115a9540f8e74e47c04ee59a16b47ea85f1b5f60802d
6
+ metadata.gz: 9df5a01ec357a9d2e5dd4bca84a8b87df0641dd5893dd8b1083679825c16d3cc47918c587f05e44aa91eb4eba3859efde5ab8a872b6bea3560cbcba9bc5d03ea
7
+ data.tar.gz: 1c7edc68c776e35a470643fd0288f310bd99584e1f55f4291192b5694d315247f7dc39dddd0a3b71c9c49a95c7885ee8df1dd8b2b475611dbb1da841f0ef80d5
@@ -82,7 +82,7 @@ module DiscourseEmojis
82
82
  emoji = convert_to_emoji(base_codepoints)
83
83
  emoji_name = supported_emojis[emoji]
84
84
 
85
- return unless emoji_name
85
+ return if !emoji_name
86
86
  return if fitzpatrick_level && !tonable_emojis.include?(emoji_name)
87
87
 
88
88
  save_emoji_image(file, output_dir, emoji_name, fitzpatrick_level)
@@ -752,6 +752,4 @@ module DiscourseEmojis
752
752
  ":$" => "blush",
753
753
  ":-$" => "blush",
754
754
  }
755
-
756
- EMOJI_DIST_PATH = "dist/emoji".freeze
757
755
  end
@@ -22,7 +22,7 @@ module DiscourseEmojis
22
22
  private
23
23
 
24
24
  def emoji_dirs
25
- Dir.glob("#{EMOJI_DIST_PATH}/*").select { |d| File.directory?(d) }
25
+ Dir.glob("#{DiscourseEmojis.path_for_emojis}/*").select { |d| File.directory?(d) }
26
26
  end
27
27
 
28
28
  def create_aliases_for_directory(dir)
@@ -45,7 +45,7 @@ module DiscourseEmojis
45
45
  FileUtils.cp(source_file, target_file)
46
46
 
47
47
  variations_dir = File.join(dir, original_name)
48
- return unless File.directory?(variations_dir)
48
+ return if !File.directory?(variations_dir)
49
49
 
50
50
  create_tone_variations(dir, variations_dir, alias_name)
51
51
  end
@@ -54,7 +54,7 @@ module DiscourseEmojis
54
54
  base_name = File.basename(unicode_file, ".png")
55
55
  unicode_variations_dir = File.join(UNICODE_DIR, base_name)
56
56
 
57
- return unless File.directory?(unicode_variations_dir)
57
+ return if !File.directory?(unicode_variations_dir)
58
58
 
59
59
  target_variations_dir = File.join(target_dir, base_name)
60
60
  FileUtils.mkdir_p(target_variations_dir)
@@ -52,7 +52,7 @@ module DiscourseEmojis
52
52
  metadata = load_metadata(emoji_dir)
53
53
  emoji_name = valid_metadata?(metadata)
54
54
 
55
- return unless emoji_name
55
+ return if !emoji_name
56
56
 
57
57
  if supports_skin_tones?(emoji_dir)
58
58
  process_skin_tone_emoji(emoji_dir, emoji_name)
@@ -63,7 +63,7 @@ module DiscourseEmojis
63
63
 
64
64
  def load_metadata(emoji_dir)
65
65
  metadata_path = File.join(emoji_dir, "metadata.json")
66
- return unless File.exist?(metadata_path)
66
+ return if !File.exist?(metadata_path)
67
67
 
68
68
  JSON.parse(File.read(metadata_path))
69
69
  rescue JSON::ParserError
@@ -72,7 +72,7 @@ module DiscourseEmojis
72
72
 
73
73
  def valid_metadata?(metadata)
74
74
  return false if metadata.nil?
75
- return false unless metadata["glyph"]
75
+ return false if !metadata["glyph"]
76
76
  @supported_emojis[DiscourseEmojis::Utils.force_emoji_presentation(metadata["glyph"])]
77
77
  end
78
78
 
@@ -94,7 +94,7 @@ module DiscourseEmojis
94
94
 
95
95
  SKIN_TONE_LEVELS.each do |tone, level|
96
96
  svg_path = Dir.glob(File.join(emoji_dir, tone, "Color", "*.svg")).first
97
- next unless File.exist?(svg_path)
97
+ next if !File.exist?(svg_path)
98
98
 
99
99
  output_path = File.join(base_output_dir, "#{level}.png")
100
100
  convert_svg_to_png(svg_path, output_path)
@@ -103,7 +103,7 @@ module DiscourseEmojis
103
103
 
104
104
  def process_regular_emoji(emoji_dir, emoji_name)
105
105
  svg_path = Dir.glob(File.join(emoji_dir, "Color", "*.svg")).first
106
- return unless File.exist?(svg_path)
106
+ return if !File.exist?(svg_path)
107
107
 
108
108
  output_path = File.join(OUTPUT_DIR, "#{emoji_name}.png")
109
109
  FileUtils.mkdir_p(File.dirname(output_path))
@@ -124,14 +124,14 @@ module DiscourseEmojis
124
124
  svg_path,
125
125
  )
126
126
 
127
- unless step1_result
127
+ if !step1_result
128
128
  status = $?.nil? ? "unknown" : $?.exitstatus
129
129
  puts "Conversion step 1 failed with status: #{status}"
130
130
  return
131
131
  end
132
132
 
133
133
  step2_result = system("magick", intermediate_png, "-resize", "72x72", output_png)
134
- unless step2_result
134
+ if !step2_result
135
135
  status = $?.nil? ? "unknown" : $?.exitstatus
136
136
  puts "Conversion step 2 (resize) failed with status: #{status}"
137
137
  return
@@ -39,13 +39,13 @@ module DiscourseEmojis
39
39
 
40
40
  process_file(EMOJI_LIST_FILE) do |row|
41
41
  codepoint = extract_codepoint(row)
42
- next unless codepoint
42
+ next if !codepoint
43
43
 
44
44
  emoji_char = extract_emoji_char(row)
45
- next unless emoji_char
45
+ next if !emoji_char
46
46
 
47
47
  image_data = extract_image_data(row)
48
- next unless image_data
48
+ next if !image_data
49
49
 
50
50
  base_emojis[codepoint] = { char: emoji_char, image: image_data }
51
51
  end
@@ -58,14 +58,14 @@ module DiscourseEmojis
58
58
 
59
59
  process_file(EMOJI_MODIFIER_FILE) do |row|
60
60
  full_codepoint = extract_codepoint(row)
61
- next unless full_codepoint&.include?("_")
61
+ next if !full_codepoint&.include?("_")
62
62
 
63
63
  parts = full_codepoint.split("_")
64
64
  modifier = parts.find { |part| DiscourseEmojis::FITZPATRICK_SCALE.key?(part) }
65
65
  base = parts.reject { |part| part == modifier }.join("_")
66
66
 
67
67
  image_data = extract_image_data(row)
68
- next unless image_data
68
+ next if !image_data
69
69
 
70
70
  variations << { base:, modifier:, image: image_data }
71
71
  end
@@ -84,7 +84,7 @@ module DiscourseEmojis
84
84
 
85
85
  def extract_codepoint(row)
86
86
  code_td = row.xpath("./td[2]").first
87
- return unless code_td
87
+ return if !code_td
88
88
 
89
89
  link = code_td.at_xpath(".//a")
90
90
  link&.[]("name")
@@ -97,13 +97,13 @@ module DiscourseEmojis
97
97
 
98
98
  def extract_image_data(row)
99
99
  img_td = row.xpath("./td[4]").first
100
- return unless img_td
100
+ return if !img_td
101
101
 
102
102
  img = img_td.at_xpath(".//img")
103
- return unless img
103
+ return if !img
104
104
 
105
105
  src = img["src"]
106
- return unless src&.start_with?("data:image/png;base64,")
106
+ return if !src&.start_with?("data:image/png;base64,")
107
107
 
108
108
  Base64.decode64(src.split(",").last)
109
109
  end
@@ -112,7 +112,7 @@ module DiscourseEmojis
112
112
  base_emojis.each do |codepoint, data|
113
113
  emoji_char = data[:char]
114
114
  emoji_name = @supported_emojis[DiscourseEmojis::Utils.force_emoji_presentation(emoji_char)]
115
- next unless emoji_name
115
+ next if !emoji_name
116
116
 
117
117
  save_base_emoji(emoji_name, data[:image])
118
118
  save_variations(emoji_name, codepoint, variations)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DiscourseEmojis
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
@@ -31,10 +31,6 @@ module DiscourseEmojis
31
31
  File.join(root, "dist")
32
32
  end
33
33
 
34
- def self.emoji_dist_path
35
- File.join(dist_path, "emoji")
36
- end
37
-
38
34
  def self.paths
39
35
  {
40
36
  emojis: File.join(dist_path, "emojis.json"),
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discourse-emojis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joffrey Jaffeux
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-19 00:00:00.000000000 Z
10
+ date: 2025-02-20 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rake