rage_flip 1.3.0 → 2.0.0

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: e92b170728e5584120a16f6b256bbffc687dacdfb2505863d61464b81709f4af
4
- data.tar.gz: d67d434844ee3adbaebcb3b5845d4cf5d15d381a460525de2ee0139099da2722
3
+ metadata.gz: b86a366479821eab16ac2a748fd125cc50dcad7b569cf6a4cc830d903551905b
4
+ data.tar.gz: 2dd1402db10cb5b806ad32b09416ab37571e0557922663986e84d45717735914
5
5
  SHA512:
6
- metadata.gz: 3930a34c2019427562f245bc7bcb7f9b5f944e5903bcafe43a6c1c4e7c2141c9e208e86d8d86a33246a0d2199b8a3874a3a4c65548c3eb661cfbcc241bb56257
7
- data.tar.gz: 7298f2475ca9644ba1f30a66a0aa8fa00ab906f9719bdf2dac46789f6db5afe2ac5ecef7e9fa25508a28ad083e55b6253f119e9cec17a4afec12b5fcbb4cb2c8
6
+ metadata.gz: f9439a69676fb611cff1f37c5072ded2cf75abdc2ce2a68db7039ec734dac3711e0f92827c9c892dbb15c000c6cdd062127116596defd4d0b6020a919eabf8ef
7
+ data.tar.gz: b6900c7339f8cb43cd3196a588a19012871f13fa43e2d9b71ff3cb4a5f99fe5d00b6a69135ce18675e61056780e2c12e54cb52a9b49639d7c671609a1a3ca212
data/CHANGELOG.md CHANGED
@@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
15
15
  - `emote list` to display all available emotes
16
16
  - `table_flip` command with classic `(╯°□°)╯︵` and `┻━┻` emoticons
17
17
 
18
+ ### Fixed
19
+ - **Windows Unicode Support**: Fixed clipboard handling of Unicode characters on Windows by implementing proper UTF-16LE encoding with BOM. This resolves issues where Unicode characters (rage flip emoticons, flipped text characters, emoji, accented characters, etc.) would not copy correctly to the Windows clipboard.
20
+
18
21
  ## [1.0.1] - 2025-10-04
19
22
 
20
23
  ### Added
data/README.md CHANGED
@@ -194,10 +194,22 @@ The gem automatically detects your platform and uses the appropriate clipboard c
194
194
 
195
195
  - **macOS**: Uses `pbcopy`
196
196
  - **Linux**: Uses `xclip` or `xsel` (install one of these first)
197
- - **Windows**: Uses `clip`
197
+ - **Windows**: Uses `clip` with proper UTF-16LE encoding for Unicode support
198
198
 
199
199
  All commands automatically copy their output to the clipboard and display the result.
200
200
 
201
+ ### Unicode Support on Windows
202
+
203
+ The Windows clipboard implementation has been specifically enhanced to handle Unicode characters correctly. The gem automatically converts text to UTF-16LE encoding with BOM (Byte Order Mark) before passing it to the Windows `clip` command. This ensures that Unicode characters such as:
204
+
205
+ - Rage flip emoticons: `(ノಠ益ಠ)ノ彡┻━┻`
206
+ - Flipped text characters: `ʇsǝʇ`
207
+ - Emoji characters: `🐄💩`
208
+ - Accented characters: `café résumé naïve`
209
+ - International text: `こんにちは`, `测试文本`
210
+
211
+ ...are properly preserved when copied to the clipboard and can be pasted correctly into other applications.
212
+
201
213
  ## Character Mappings
202
214
 
203
215
  The flip functionality uses comprehensive character mappings including:
data/exe/emote CHANGED
@@ -7,10 +7,19 @@ if ARGV.length == 0
7
7
  exit 0
8
8
  end
9
9
 
10
- # Handle "list" command
11
- if ARGV.length == 1 && ARGV[0].downcase == "list"
12
- puts RageFlip::Emote.list_emotes
13
- exit 0
10
+ # Handle single argument commands
11
+ if ARGV.length == 1
12
+ case ARGV[0].downcase
13
+ when "list"
14
+ puts RageFlip::Emote.list_emotes
15
+ exit 0
16
+ when "list-custom"
17
+ puts RageFlip::Emote.list_custom_emotes
18
+ exit 0
19
+ when "init-custom"
20
+ puts RageFlip::Emote.init_custom_config
21
+ exit 0
22
+ end
14
23
  end
15
24
 
16
25
  # Process multiple emote arguments
@@ -14,7 +14,16 @@ module RageFlip
14
14
  return false
15
15
  end
16
16
  when /mswin|mingw|cygwin/
17
- system("echo #{text.shellescape} | clip")
17
+ # Windows requires UTF-16LE encoding for clip command to handle Unicode properly
18
+ require 'tempfile'
19
+
20
+ Tempfile.create(['clipboard', '.txt'], binmode: true) do |temp_file|
21
+ # Convert text to UTF-16LE with BOM for Windows clipboard
22
+ utf16_text = "\uFEFF#{text}".encode('UTF-16LE')
23
+ temp_file.write(utf16_text)
24
+ temp_file.flush
25
+ system("clip < \"#{temp_file.path}\"")
26
+ end
18
27
  else
19
28
  puts "Error: Unsupported platform for clipboard operations."
20
29
  return false
@@ -1,3 +1,7 @@
1
+ require 'json'
2
+ require 'yaml'
3
+ require 'fileutils'
4
+
1
5
  module RageFlip
2
6
  class Emote
3
7
  EMOTES = {
@@ -36,18 +40,76 @@ module RageFlip
36
40
  "yuno" => "ლ(ಠ益ಠლ)"
37
41
  }.freeze
38
42
 
43
+ CONFIG_DIR = File.expand_path("~/.config/rage_flip")
44
+ JSON_CONFIG_FILE = File.join(CONFIG_DIR, "emote.json")
45
+ YAML_CONFIG_FILE = File.join(CONFIG_DIR, "emote.yml")
46
+
47
+ def self.custom_config_path
48
+ return JSON_CONFIG_FILE if File.exist?(JSON_CONFIG_FILE)
49
+ return YAML_CONFIG_FILE if File.exist?(YAML_CONFIG_FILE)
50
+ nil
51
+ end
52
+
53
+ def self.load_custom_emotes
54
+ config_path = custom_config_path
55
+ return {} unless config_path
56
+
57
+ begin
58
+ content = File.read(config_path)
59
+ case File.extname(config_path)
60
+ when '.json'
61
+ JSON.parse(content)
62
+ when '.yml', '.yaml'
63
+ YAML.safe_load(content) || {}
64
+ else
65
+ {}
66
+ end
67
+ rescue => e
68
+ puts "Warning: Failed to load custom emotes from #{config_path}: #{e.message}"
69
+ {}
70
+ end
71
+ end
72
+
73
+ def self.all_emotes
74
+ @all_emotes ||= EMOTES.merge(load_custom_emotes)
75
+ end
76
+
77
+ def self.refresh_emotes
78
+ @all_emotes = nil
79
+ end
80
+
39
81
  def self.process(emote_name)
40
82
  emote_name = emote_name.downcase
41
-
42
- if EMOTES.key?(emote_name)
43
- EMOTES[emote_name]
83
+
84
+ if all_emotes.key?(emote_name)
85
+ all_emotes[emote_name]
44
86
  end
45
87
  end
46
88
 
47
89
  def self.list_emotes
48
90
  output = ["Available emotes:"]
49
91
  # Sort emotes by name for better organization
50
- sorted_emotes = EMOTES.sort_by { |name, _| name }
92
+ sorted_emotes = all_emotes.sort_by { |name, _| name }
93
+
94
+ # Calculate max name length for better alignment
95
+ max_name_length = sorted_emotes.map { |name, _| name.length }.max
96
+
97
+ sorted_emotes.each do |name, emote|
98
+ output << " #{name.ljust(max_name_length + 2)} - #{emote}"
99
+ end
100
+ output.join("\n")
101
+ end
102
+
103
+ def self.list_custom_emotes
104
+ custom_emotes = load_custom_emotes
105
+
106
+ if custom_emotes.empty?
107
+ return "No custom emotes found. Use 'emote init-custom' to create a custom emote config file."
108
+ end
109
+
110
+ output = ["Custom emotes:"]
111
+ # Sort emotes by name for better organization
112
+ sorted_emotes = custom_emotes.sort_by { |name, _| name }
51
113
 
52
114
  # Calculate max name length for better alignment
53
115
  max_name_length = sorted_emotes.map { |name, _| name.length }.max
@@ -55,15 +117,44 @@ module RageFlip
55
117
  sorted_emotes.each do |name, emote|
56
118
  output << " #{name.ljust(max_name_length + 2)} - #{emote}"
57
119
  end
120
+
121
+ config_path = custom_config_path
122
+ if config_path
123
+ output << ""
124
+ output << "Config file: #{config_path}"
125
+ end
126
+
58
127
  output.join("\n")
59
128
  end
60
129
 
130
+ def self.init_custom_config
131
+ FileUtils.mkdir_p(CONFIG_DIR) unless Dir.exist?(CONFIG_DIR)
132
+
133
+ if File.exist?(JSON_CONFIG_FILE) || File.exist?(YAML_CONFIG_FILE)
134
+ existing_file = File.exist?(JSON_CONFIG_FILE) ? JSON_CONFIG_FILE : YAML_CONFIG_FILE
135
+ return "Custom emote config already exists: #{existing_file}"
136
+ end
137
+
138
+ # Create a sample JSON config file
139
+ sample_config = {
140
+ "example" => "This is an example custom emote",
141
+ "heart" => "❤️",
142
+ "wave" => "👋"
143
+ }
144
+
145
+ File.write(JSON_CONFIG_FILE, JSON.pretty_generate(sample_config))
146
+ refresh_emotes
147
+
148
+ "Custom emote config initialized: #{JSON_CONFIG_FILE}\n" +
149
+ "Edit this file to add your custom emotes, then use 'emote list-custom' to see them."
150
+ end
151
+
61
152
  def self.emote_exists?(name)
62
- EMOTES.key?(name.downcase)
153
+ all_emotes.key?(name.downcase)
63
154
  end
64
155
 
65
156
  def self.emote_names
66
- EMOTES.keys
157
+ all_emotes.keys
67
158
  end
68
159
  end
69
160
  end
@@ -1,3 +1,3 @@
1
1
  module RageFlip
2
- VERSION = "1.3.0"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -0,0 +1,38 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe RageFlip::Clipboard do
4
+ describe ".copy" do
5
+ it "handles basic ASCII text" do
6
+ expect(RageFlip::Clipboard.copy("Hello World")).to be true
7
+ end
8
+
9
+ it "handles Unicode characters" do
10
+ unicode_text = "(ノಠ益ಠ)ノ彡┻━┻"
11
+ expect(RageFlip::Clipboard.copy(unicode_text)).to be true
12
+ end
13
+
14
+ it "handles emoji characters" do
15
+ emoji_text = "🐄💩"
16
+ expect(RageFlip::Clipboard.copy(emoji_text)).to be true
17
+ end
18
+
19
+ it "handles accented characters" do
20
+ accented_text = "café résumé naïve"
21
+ expect(RageFlip::Clipboard.copy(accented_text)).to be true
22
+ end
23
+
24
+ it "handles flipped text characters" do
25
+ flipped_text = "ʇsǝʇ"
26
+ expect(RageFlip::Clipboard.copy(flipped_text)).to be true
27
+ end
28
+
29
+ it "handles rage flip output" do
30
+ rage_text = RageFlip::Flipper.rage_flip("test")
31
+ expect(RageFlip::Clipboard.copy(rage_text)).to be true
32
+ end
33
+
34
+ it "returns true on successful copy" do
35
+ expect(RageFlip::Clipboard.copy("simple test")).to be true
36
+ end
37
+ end
38
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rage_flip
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Powell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-10-04 00:00:00.000000000 Z
11
+ date: 2025-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -88,6 +88,7 @@ files:
88
88
  - lib/rage_flip/text_substitution.rb
89
89
  - lib/rage_flip/underline.rb
90
90
  - lib/rage_flip/version.rb
91
+ - spec/clipboard_spec.rb
91
92
  - spec/rage_flip_spec.rb
92
93
  - spec/spec_helper.rb
93
94
  homepage: https://github.com/stringsn88keys/rage_flip_gem
@@ -102,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
103
  requirements:
103
104
  - - ">="
104
105
  - !ruby/object:Gem::Version
105
- version: '0'
106
+ version: 3.0.0
106
107
  required_rubygems_version: !ruby/object:Gem::Requirement
107
108
  requirements:
108
109
  - - ">="