emoji-regex 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/data/sorted_emoji.txt +3953 -0
- data/lib/emoji-regex.rb +0 -1
- data/lib/emoji-regex/maker.rb +1 -1
- data/lib/emoji-regex/version.rb +1 -1
- metadata +3 -3
- data/lib/emoji-regex/fetcher.rb +0 -44
data/lib/emoji-regex.rb
CHANGED
data/lib/emoji-regex/maker.rb
CHANGED
data/lib/emoji-regex/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emoji-regex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Satoshi Ohmori
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -95,10 +95,10 @@ files:
|
|
95
95
|
- README.md
|
96
96
|
- Rakefile
|
97
97
|
- bin/setup
|
98
|
+
- data/sorted_emoji.txt
|
98
99
|
- emoji-regex.gemspec
|
99
100
|
- emoji_sorted.txt
|
100
101
|
- lib/emoji-regex.rb
|
101
|
-
- lib/emoji-regex/fetcher.rb
|
102
102
|
- lib/emoji-regex/maker.rb
|
103
103
|
- lib/emoji-regex/version.rb
|
104
104
|
homepage: https://github.com/sachin21/ruby-emoji-regex
|
data/lib/emoji-regex/fetcher.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'open-uri'
|
2
|
-
|
3
|
-
module EmojiRegex
|
4
|
-
class Fetcher
|
5
|
-
SOURCE = 'https://www.unicode.org/Public/emoji/6.0/emoji-data.txt'.freeze
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
@emoji_file_path = File.join(Dir.tmpdir, 'sorted_emoji.txt')
|
9
|
-
end
|
10
|
-
|
11
|
-
def save
|
12
|
-
emoji_file = open(SOURCE, &:read)
|
13
|
-
emoji_code_lines = emoji_file.split("\n").map { |x| x.split(' ;')[0] }.compact.map(&:rstrip)
|
14
|
-
|
15
|
-
emoji_codes = emoji_code_lines.each_with_object([]) do |line, result|
|
16
|
-
case line
|
17
|
-
when /^#/
|
18
|
-
nil
|
19
|
-
when /^(0023|002A|0030)/
|
20
|
-
nil
|
21
|
-
when /^.{4,5}\.\./
|
22
|
-
start_code_hex, end_code_hex = line.split('..')
|
23
|
-
base_10_code_range = (start_code_hex.to_i(16)..end_code_hex.to_i(16))
|
24
|
-
hex_codes = base_10_code_range.to_a.map { |base_10_code| base_10_code.to_s(16).rjust(4, '0').upcase }
|
25
|
-
hex_codes.each { |code| result << code }
|
26
|
-
else
|
27
|
-
result << line
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
File.open(@emoji_file_path, 'w') do |f|
|
32
|
-
f << emoji_codes.uniq.join("\n")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
alias update save
|
37
|
-
|
38
|
-
def saved_path
|
39
|
-
save unless File.exist?(@emoji_file_path)
|
40
|
-
|
41
|
-
@emoji_file_path
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|