Skip to content

Commit 98407ce

Browse files
author
Guanting Chen
committed
Refactor RemoveEmoji package
1 parent 35a0623 commit 98407ce

File tree

10 files changed

+144
-111
lines changed

10 files changed

+144
-111
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Ruby
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
ruby-version: ['3.0', '3.1', '3.2', '3.3', '3.4']
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Set up Ruby
19+
uses: ruby/setup-ruby@v1
20+
with:
21+
ruby-version: ${{ matrix.ruby-version }}
22+
bundler-cache: true
23+
24+
- name: Run tests
25+
run: bundle exec rspec

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@
77
/spec/reports/
88
/tmp/
99

10-
/Gemfile.lock
10+
/Gemfile.lock
11+
.rspec_status
12+
.ruby-version
13+
*.gem

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
source "https://rubygems.org"
22

3-
# git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4-
53
gemspec
4+
5+
gem "rspec", "~> 3.0"

LICENSE.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
The MIT License (MIT)
1+
MIT License
22

3-
Copyright (c) 2017-2021 Guanting Chen
3+
Copyright (c) 2025 Chen Guan-Ting
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
99
copies of the Software, and to permit persons to whom the Software is
1010
furnished to do so, subject to the following conditions:
1111

12-
The above copyright notice and this permission notice shall be included in
13-
all copies or substantial portions of the Software.
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
1414

1515
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1616
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1717
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
THE SOFTWARE.
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
Remove Emoji ( 2021 )
1+
Remove Emoji ( for Ruby )
22
=================================================
33

44
[![Gem Version](https://badge.fury.io/rb/remove_emoji.svg)](https://badge.fury.io/rb/remove_emoji)
5-
[![Build Status](https://travis-ci.org/guanting112/remove_emoji.svg?branch=master)](https://travis-ci.org/guanting112/remove_emoji)
5+
[![Ruby CI](https://github.com/guanting112/remove_emoji/actions/workflows/ci.yml/badge.svg)](https://github.com/guanting112/remove_emoji/actions)
66
[![Code Climate](https://codeclimate.com/github/guanting112/remove_emoji/badges/gpa.svg)](https://codeclimate.com/github/guanting112/remove_emoji)
77

8-
此為針對「移除」Unicode Emoji 圖示 所開發的專屬套件,
9-
您可以透過該套件移除令人困擾的 Emoji 符號。
10-
( It can remove any of the emoji supported by that package. )
8+
This is a gem developed for "removing" Unicode Emoji icons, you can use this gem to remove annoying Emoji symbols.
119

1210
![emoji](https://i.imgur.com/h1Ip0r6.png)
1311

1412

15-
Installation / 安裝方式
13+
Installation
1614
--------
1715

1816
via Rubygems
@@ -24,20 +22,20 @@ gem install remove_emoji
2422
In your Gemfile:
2523

2624
```ruby
27-
gem 'remove_emoji', '~> 3.0.0'
25+
gem 'remove_emoji', '~> 4.0.0'
2826
```
2927

30-
Usage / 使用方式
28+
Usage
3129
--------
3230

33-
使用方式很簡單,僅需要呼叫 RemoveEmoji::Sanitize.call 遞入你要過濾的字串即可過濾。
31+
Usage is simple, just call `RemoveEmoji.remove` passing in the string you want to filter.
3432

3533
```ruby
3634
require 'remove_emoji'
3735

3836
original_string = "😊😍😌🤕👿👹👧👧🏻👧🏼👧🏽🤜🏼👍🏽👌☝🏼🥝🥦🌶🌽🍎"
3937

40-
puts RemoveEmoji::Sanitize.call(original_string)
38+
puts RemoveEmoji.remove(original_string)
4139
```
4240

4341
```ruby
@@ -64,7 +62,7 @@ STRING
6462
# ==========
6563
# Output
6664
# ==========
67-
puts RemoveEmoji::Sanitize.call(original_string)
65+
puts RemoveEmoji.remove(original_string)
6866

6967
# Result:
7068
# abcdefghijklmnopqrstuvwxyz....0123456789
@@ -86,8 +84,3 @@ Demo ( Before / After )
8684
------
8785

8886
![emoji_effect](https://i.imgur.com/OzcQYWL.jpg)
89-
90-
LICENSE
91-
--------
92-
93-
本專案原始碼採 MIT LICENSE 授權 ( 詳見 LICENSE 檔案 )

lib/remove_emoji.rb

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,9 @@
22
require "remove_emoji/rules"
33

44
module RemoveEmoji
5-
class Sanitize
6-
7-
def initialize(original_string)
8-
@original_string = original_string
9-
end
10-
11-
def self.call(*args)
12-
new(*args).sanitize
13-
end
14-
15-
def sanitize
16-
@original_string.gsub(RemoveEmoji::MATCH_EMOJI_CODEPOINTS_RULE, '')
17-
end
185

6+
def self.remove(string)
7+
string.gsub(RemoveEmoji::MATCH_EMOJI_CODEPOINTS_RULE, '')
198
end
9+
2010
end

lib/remove_emoji/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module RemoveEmoji
2-
VERSION = '3.0.1'
2+
VERSION = '4.0.0'
33
end

remove_emoji.gemspec

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,20 @@
1-
2-
lib = File.expand_path("../lib", __FILE__)
3-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4-
require "remove_emoji/version"
1+
# frozen_string_literal: true
52

63
Gem::Specification.new do |spec|
7-
spec.name = "remove_emoji"
8-
spec.version = RemoveEmoji::VERSION
9-
spec.authors = ["Guanting Chen"]
10-
spec.email = ["cgt886@gmail.com"]
11-
spec.summary = %q{ Remove Emoji 😈🚫😱 ( 2021 version, for Ruby 2.x ~ 3 / Rails 4 ~ 6.x )}
12-
spec.description = %q{ Remove Emoji 😈🚫😱 ( 2021 version, for Ruby 2.x ~ 3 / Rails 4 ~ 6.x )}
13-
spec.homepage = "https://github.com/guanting112/remove_emoji"
14-
spec.license = "MIT"
15-
spec.platform = Gem::Platform::RUBY
16-
spec.required_ruby_version = '>= 2'
4+
spec.name = "remove_emoji"
5+
spec.version = "4.0.0"
6+
spec.authors = ["Guanting112"]
177

18-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
19-
# to allow pushing to a single host or delete this section to allow pushing to any host.
20-
if spec.respond_to?(:metadata)
21-
spec.metadata['allowed_push_host'] = "https://rubygems.org"
22-
else
23-
raise "RubyGems 2.0 or newer is required to protect against " \
24-
"public gem pushes."
25-
end
8+
spec.summary = %q{ Remove Emoji 🚫😱 ( for Ruby 2.x ~ 4 / Rails 4 ~ 8 )}
9+
spec.description = %q{ Remove Emoji 🚫😱 ( for Ruby 2.x ~ 4 / Rails 4 ~ 8 )}
10+
spec.homepage = "https://github.com/guanting112/remove_emoji"
11+
spec.license = "MIT"
12+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
2613

27-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
28-
f.match(%r{^(test|spec|features)/})
14+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
15+
Dir["{lib}/**/*", "LICENSE", "README.md"]
2916
end
30-
spec.bindir = "exe"
31-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
3217
spec.require_paths = ["lib"]
3318

34-
spec.add_development_dependency "bundler", "<3.0", ">=1.7"
35-
spec.add_development_dependency "rake", ">= 12.3.3"
36-
spec.add_development_dependency 'minitest', '~> 5.0'
19+
spec.add_development_dependency "rspec", "~> 3.0"
3720
end

spec/remove_emoji_spec.rb

Lines changed: 70 additions & 43 deletions
Large diffs are not rendered by default.

spec/spec_helper.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
require "remove_emoji"
4+
require "benchmark"
5+
6+
RSpec.configure do |config|
7+
config.example_status_persistence_file_path = ".rspec_status"
8+
config.disable_monkey_patching!
9+
config.expect_with :rspec do |c|
10+
c.syntax = :expect
11+
end
12+
end

0 commit comments

Comments
 (0)