emoji-regex 0.1.1 → 0.2.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.
@@ -2,5 +2,4 @@ module EmojiRegex
2
2
  end
3
3
 
4
4
  require 'emoji-regex/version'
5
- require 'emoji-regex/fetcher'
6
5
  require 'emoji-regex/maker'
@@ -1,7 +1,7 @@
1
1
  module EmojiRegex
2
2
  class Maker
3
3
  def initialize
4
- @input_file_path = Fetcher.new.saved_path
4
+ @input_file_path = File.join(__dir__, '../../data', 'sorted_emoji.txt')
5
5
  end
6
6
 
7
7
  def regex
@@ -1,3 +1,3 @@
1
1
  module EmojiRegex
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
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.1.1
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-10-05 00:00:00.000000000 Z
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
@@ -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