tanuki_emoji 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e14e9a274c028f5da0ca9855c5ea0c15e39c67c9a555213bba590f0b72b3d072
4
- data.tar.gz: e4c90eaabfaed8eb22c87f4097162978dec6f73edcbdf21db36cb5d2c939c587
3
+ metadata.gz: 7a6ee4f67c87849b86336bc442feb7d1f5602283fd95e342b71ac21ccabae1a4
4
+ data.tar.gz: 6e89b4ccf8a3c6594cde8467e1b87c4bcfee510dcf2f4410748e0e8b51b2cb4c
5
5
  SHA512:
6
- metadata.gz: f06e63daa5501849456c2cf95d754286fdb41bc96283f11ada069cc9c97a2f6ea5f608f453c07f9138e7e19579857193c7ebb79d5413a65ff4832c053732c0c2
7
- data.tar.gz: 3b3362d115678f62563757e655121e901a26c23c674da95a6a10ae7553d6d01d00609243f0a5f591f775ecb70c3588122c127e5615de50c3e1503a05424df24f
6
+ metadata.gz: f5433abbe6cec569661761beca4b27ab922e4c39276fd42bd90e2f1c5e5e7607578e1c37f21261cf269133155195bfb827f33e4356cd6e197c63e024ea2bf72a
7
+ data.tar.gz: d647ac40d0daf77aace7f048acfcb5ef6ddc3a6d5b9087cd0f3619cf0b106a67f3d2ae29ba4a59fa023083404eb0002c7bf418d39373b66c81c7c24b01cbd56c
data/.gitignore CHANGED
@@ -9,6 +9,8 @@
9
9
  /.idea
10
10
  .rspec_status
11
11
  /*.gem
12
+ /app/assets/**/*
13
+ .DS_Store
12
14
 
13
15
  # rspec failure tracking
14
16
  .rspec_status
data/.gitlab-ci.yml CHANGED
@@ -17,20 +17,33 @@
17
17
 
18
18
  rspec:
19
19
  extends: .ruby
20
+ variables:
21
+ GIT_SUBMODULE_STRATEGY: recursive
20
22
  script:
23
+ - bundle exec rake update_assets
21
24
  - bundle exec rake spec
22
25
  artifacts:
23
26
  reports:
24
27
  junit: rspec.xml
25
28
  cobertura: coverage/coverage.xml
26
29
 
30
+ gem:
31
+ extends: .ruby
32
+ variables:
33
+ GIT_SUBMODULE_STRATEGY: recursive
34
+ script:
35
+ - bundle exec rake install
36
+ artifacts:
37
+ paths:
38
+ - pkg/*.gem
39
+
27
40
  rubocop:
28
41
  extends: .ruby
29
42
  script:
30
43
  - bundle exec rake rubocop
31
44
 
32
45
  include:
33
- - template: SAST.gitlab-ci.yml
46
+ - template: Security/SAST.gitlab-ci.yml
34
47
  - template: Dependency-Scanning.gitlab-ci.yml
35
48
  - template: Security/License-Scanning.gitlab-ci.yml
36
49
  - template: Code-Quality.gitlab-ci.yml
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "vendor/noto-emoji"]
2
+ path = vendor/noto-emoji
3
+ url = https://github.com/googlefonts/noto-emoji
data/CHANGELOG.md CHANGED
@@ -6,8 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.2.0] - 2021-07-09
10
+ ### Added
11
+ - Bundled Noto Emoji assets for each corresponding indexed Emoji
12
+ - `Character` responds to `#image_name` pointing to Noto Emoji filenames
13
+ - `TanukiEmoji` responds to `.images_path` pointing to Emoji assets folder
14
+
9
15
  ## [0.1.0] - 2021-07-04
10
16
  ### Added
11
17
  - Initial release with index and Character information support
12
18
 
13
19
  [0.1.0]:https://gitlab.com/brodock/tanuki_emoji/-/releases/v0.1.0
20
+ [0.2.0]:https://gitlab.com/brodock/tanuki_emoji/-/releases/v0.2.0
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,41 @@
1
+ ## Developer Certificate of Origin and License
2
+
3
+ By contributing to GitLab B.V., you accept and agree to the following terms and
4
+ conditions for your present and future contributions submitted to GitLab B.V.
5
+ Except for the license granted herein to GitLab B.V. and recipients of software
6
+ distributed by GitLab B.V., you reserve all right, title, and interest in and to
7
+ your Contributions.
8
+
9
+ All contributions are subject to the Developer Certificate of Origin and license set out at
10
+ [docs.gitlab.com/ce/legal/developer_certificate_of_origin](https://docs.gitlab.com/ce/legal/developer_certificate_of_origin).
11
+
12
+ <!-- This notice should stay as the first item in the CONTRIBUTING.md file. -->
13
+
14
+ ## Code of conduct
15
+
16
+ As contributors and maintainers of this project, we pledge to respect all people
17
+ who contribute through reporting issues, posting feature requests, updating
18
+ documentation, submitting pull requests or patches, and other activities.
19
+
20
+ We are committed to making participation in this project a harassment-free
21
+ experience for everyone, regardless of level of experience, gender, gender
22
+ identity and expression, sexual orientation, disability, personal appearance,
23
+ body size, race, ethnicity, age, or religion.
24
+
25
+ Examples of unacceptable behavior by participants include the use of sexual
26
+ language or imagery, derogatory comments or personal attacks, trolling, public
27
+ or private harassment, insults, or other unprofessional conduct.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject
30
+ comments, commits, code, wiki edits, issues, and other contributions that are
31
+ not aligned to this Code of Conduct. Project maintainers who do not follow the
32
+ Code of Conduct may be removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior can be
38
+ reported by emailing contact@gitlab.com.
39
+
40
+ This Code of Conduct is adapted from the [Contributor Covenant](https://contributor-covenant.org), version 1.1.0,
41
+ available at [https://contributor-covenant.org/version/1/1/0/](https://contributor-covenant.org/version/1/1/0/).
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tanuki_emoji (0.1.0)
4
+ tanuki_emoji (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -4,7 +4,10 @@ This library helps you implement Emoji support in a ruby application by providin
4
4
  information.
5
5
 
6
6
  We currently provides a pre-indexed set of Emojis, compatible with [Gemojione](https://github.com/bonusly/gemojione)
7
- index from 3.3.0. In the future we expect to cover the most recent version of Unicode.
7
+ index from 3.3.0. In the future we expect to cover the most recent version of Unicode.
8
+
9
+ This gem bundles Emoji assets from [Noto Emoji](https://github.com/googlefonts/noto-emoji), to be used as fallback when
10
+ Emoji is not available or not fully supported on target system.
8
11
 
9
12
  ## Installation
10
13
 
@@ -17,7 +20,7 @@ gem 'tanuki_emoji'
17
20
  And then execute:
18
21
 
19
22
  ```shell
20
- $ bundle install
23
+ $ bundle install
21
24
  ```
22
25
 
23
26
  ## Usage
@@ -52,6 +55,19 @@ TanukiEmoji.find_by_alpha_code('horse')
52
55
  #=> #<TanukiEmoji::Character:horse 🐴(1f434)>
53
56
  ```
54
57
 
58
+ To retrieve an alternative image for the character:
59
+ ```ruby
60
+ c = TanukiEmoji.find_by_alpha_code('horse')
61
+ #=> #<TanukiEmoji::Character:horse 🐴(1f434)>
62
+
63
+ c.image_name
64
+ #=> "emoji_u1f434.png"
65
+
66
+ # Use the image_name with bundled assets from Noto Emoji:
67
+ File.join(TanukiEmoji.images_path, c.image_name)
68
+ #=> "/path/to/tanuki_emoji/app/assets/images/tanuki_emoji/emoji_u1f434.png"
69
+ ```
70
+
55
71
  ## Development
56
72
 
57
73
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
@@ -64,8 +80,15 @@ which will create a git tag for the version, push git commits and the created ta
64
80
 
65
81
  ## Contributing
66
82
 
67
- Bug reports and pull requests are welcome on GitLab at https://gitlab.com/brodock/tanuki_emoji.
83
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
68
84
 
69
85
  ## License
70
86
 
71
87
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
88
+
89
+ Noto Emoji assets and build tools are [Apache license, version 2.0](https://github.com/googlefonts/noto-emoji/blob/main/LICENSE)
90
+ licensed.
91
+
92
+ Flag images are under
93
+ public domain or otherwise excempt from copyright
94
+ ([more info](https://github.com/googlefonts/noto-emoji/blob/main/third_party/region-flags/LICENSE)).
data/Rakefile CHANGED
@@ -3,6 +3,7 @@
3
3
  require "bundler/gem_tasks"
4
4
  require "rspec/core/rake_task"
5
5
  require "rubocop/rake_task"
6
+ require "tanuki_emoji"
6
7
 
7
8
  RSpec::Core::RakeTask.new(:spec) do |t|
8
9
  t.rspec_opts = %w[--format documentation --color --require spec_helper]
@@ -11,10 +12,44 @@ end
11
12
 
12
13
  RuboCop::RakeTask.new
13
14
 
14
- task default: %i[spec rubocop]
15
-
16
15
  desc 'Code coverage detail'
17
16
  task :simplecov do
18
17
  ENV['COVERAGE'] = 'true'
19
18
  Rake::Task['spec'].execute
20
19
  end
20
+
21
+ task default: %i[spec rubocop]
22
+
23
+ desc 'Update images from vendor/noto-emoji to app/assets folder'
24
+ task update_assets: ['noto_emoji:generate_flags'] do
25
+ png_path = File.join(__dir__, 'vendor/noto-emoji/png/72')
26
+ flag_path = File.join(__dir__, 'vendor/noto-emoji/build/flags')
27
+ TanukiEmoji.index.all.each do |emoji|
28
+ if emoji.flag?
29
+ source_flag = File.join(flag_path, emoji.image_name)
30
+ cp(source_flag, TanukiEmoji.images_path)
31
+
32
+ next
33
+ end
34
+
35
+ source_png = File.join(png_path, emoji.image_name)
36
+ cp(source_png, TanukiEmoji.images_path)
37
+ end
38
+ end
39
+
40
+ namespace :noto_emoji do
41
+ noto_emoji_path = File.join(__dir__, 'vendor/noto-emoji')
42
+
43
+ task :generate_flags do
44
+ chdir(File.expand_path(noto_emoji_path)) do
45
+ Dir['third_party/region-flags/png/*.png'].each do |file|
46
+ filename = File.basename(file)
47
+ puts filename
48
+
49
+ sh("make build/flags/#{filename}")
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ Rake::Task[:build].enhance [:update_assets]
File without changes
data/lib/tanuki_emoji.rb CHANGED
@@ -10,14 +10,6 @@ module TanukiEmoji
10
10
  autoload :Character, './lib/tanuki_emoji/character'
11
11
  autoload :Db, './lib/tanuki_emoji/db'
12
12
 
13
- # This denotes a "color" or "emoji" version
14
- EMOJI_VARIATION_SELECTOR = 0xFE0F
15
- # This denotes a "plain" (black/white) or "textual" version
16
- PLAIN_VARIATION_SELECTOR = 0xFE0E
17
- BASE_FLAG_TAG = 0x1F3F4
18
- # Zero Width Joiner is used in sequences to indicate they should all be evaluated and displayed as a single thing
19
- ZWJ_TAG = 0x200D
20
-
21
13
  # Find an Emoji by its :alpha_code:
22
14
  #
23
15
  # @param [String] alpha_code
@@ -51,4 +43,8 @@ module TanukiEmoji
51
43
 
52
44
  index.add(emoji)
53
45
  end
46
+
47
+ def self.images_path
48
+ File.expand_path(File.join(__dir__, "../app/assets/images/tanuki_emoji"))
49
+ end
54
50
  end
@@ -6,6 +6,19 @@ module TanukiEmoji
6
6
  #
7
7
  # @see https://www.unicode.org/reports/tr51/
8
8
  class Character
9
+ IMAGE_PREFIX = 'emoji_u'
10
+ IMAGE_EXTENSION = '.png'
11
+ FLAG_REGEXP = /[🇦-🇿]{2}/u.freeze
12
+
13
+ # This denotes a "color" or "emoji" version
14
+ EMOJI_VARIATION_SELECTOR = 0xFE0F
15
+
16
+ # This denotes a "plain" (black/white) or "textual" version
17
+ PLAIN_VARIATION_SELECTOR = 0xFE0E
18
+
19
+ # Zero Width Joiner is used in sequences to indicate they should all be evaluated and displayed as a single thing
20
+ ZWJ_TAG = 0x200D
21
+
9
22
  attr_reader :name, :codepoints, :codepoints_alternates, :alpha_code, :aliases, :description
10
23
 
11
24
  # @param [String] name
@@ -41,6 +54,26 @@ module TanukiEmoji
41
54
  unicode_to_hex(codepoints).join('-')
42
55
  end
43
56
 
57
+ # Generate the image name to be used as fallback for this character
58
+ #
59
+ # @return [String] image name with extension
60
+ def image_name
61
+ # Noto doesn't ship flags as part of regular hex-named files
62
+ # Flags are stored in a separate third-party folder and follow ISO-3166-1 codes
63
+ # @see http://en.wikipedia.org/wiki/ISO_3166-1
64
+ return alpha_code.tr(':', '').sub('flag_', '').upcase + IMAGE_EXTENSION if flag?
65
+
66
+ # Noto omits Emoji Variation Selector on their resources file names
67
+ IMAGE_PREFIX + unicode_to_hex(codepoints).reject { |i| i == EMOJI_VARIATION_SELECTOR.to_s(16) }.join('_') + IMAGE_EXTENSION
68
+ end
69
+
70
+ # Return whether current character represents a flag or not
71
+ #
72
+ # @return [Boolean] whether character represents a flag or not
73
+ def flag?
74
+ codepoints.match?(FLAG_REGEXP)
75
+ end
76
+
44
77
  def to_s
45
78
  codepoints
46
79
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TanukiEmoji
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/tanuki_emoji.gemspec CHANGED
@@ -11,19 +11,17 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = %q{Tanuki Emoji}
12
12
  spec.description = %q{Tanuki Emoji provides Emoji character information and metadata with support for Noto Emoji resources as fallback}
13
13
  spec.homepage = 'https://gitlab.com/brodock/tanuki_emoji'
14
- spec.license = 'MIT'
14
+ spec.licenses = %w[MIT Apache2]
15
15
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
16
16
 
17
17
  spec.metadata['homepage_uri'] = spec.homepage
18
18
  spec.metadata['source_code_uri'] = 'https://gitlab.com/brodock/tanuki_emoji'
19
- spec.metadata['changelog_uri'] = "https://gitlab.com/brodock/tanuki_emoji/-/blob/main/CHANGELOG.md"
19
+ spec.metadata['changelog_uri'] = 'https://gitlab.com/brodock/tanuki_emoji/-/blob/main/CHANGELOG.md'
20
20
 
21
21
  # Specify which files should be added to the gem when it is released.
22
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
23
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features|bin)/}) }
25
25
  end
26
- spec.bindir = 'exe'
27
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
26
  spec.require_paths = ['lib']
29
27
  end
@@ -14486,7 +14486,7 @@
14486
14486
  ],
14487
14487
  "aliases_ascii": [],
14488
14488
  "keywords": [],
14489
- "moji": "🏳🌈"
14489
+ "moji": "🏳️‍🌈"
14490
14490
  },
14491
14491
  "gemini": {
14492
14492
  "unicode": "264A",
@@ -18624,7 +18624,7 @@
18624
18624
  "keywords": [
18625
18625
 
18626
18626
  ],
18627
- "moji": "🏳🌈"
18627
+ "moji": "🏳️‍🌈"
18628
18628
  },
18629
18629
  "gemini": {
18630
18630
  "unicode": "264A",
@@ -45108,4 +45108,4 @@
45108
45108
 
45109
45109
  ]
45110
45110
  }
45111
- }
45111
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tanuki_emoji
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Mazetto
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-04 00:00:00.000000000 Z
11
+ date: 2021-08-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Tanuki Emoji provides Emoji character information and metadata with support
14
14
  for Noto Emoji resources as fallback
@@ -20,17 +20,17 @@ extra_rdoc_files: []
20
20
  files:
21
21
  - ".gitignore"
22
22
  - ".gitlab-ci.yml"
23
- - ".idea/.gitignore"
23
+ - ".gitmodules"
24
24
  - ".rspec"
25
25
  - ".rubocop.yml"
26
26
  - CHANGELOG.md
27
+ - CONTRIBUTING.md
27
28
  - Gemfile
28
29
  - Gemfile.lock
29
30
  - LICENSE.txt
30
31
  - README.md
31
32
  - Rakefile
32
- - bin/console
33
- - bin/setup
33
+ - app/assets/images/tanuki_emoji/.gitkeep
34
34
  - lib/tanuki_emoji.rb
35
35
  - lib/tanuki_emoji/character.rb
36
36
  - lib/tanuki_emoji/db.rb
@@ -56,6 +56,7 @@ files:
56
56
  homepage: https://gitlab.com/brodock/tanuki_emoji
57
57
  licenses:
58
58
  - MIT
59
+ - Apache2
59
60
  metadata:
60
61
  homepage_uri: https://gitlab.com/brodock/tanuki_emoji
61
62
  source_code_uri: https://gitlab.com/brodock/tanuki_emoji
@@ -75,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
76
  - !ruby/object:Gem::Version
76
77
  version: '0'
77
78
  requirements: []
78
- rubygems_version: 3.2.25
79
+ rubygems_version: 3.2.15
79
80
  signing_key:
80
81
  specification_version: 4
81
82
  summary: Tanuki Emoji
data/.idea/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- # Default ignored files
2
- /shelf/
3
- /workspace.xml
4
- # Datasource local storage ignored files
5
- /dataSources/
6
- /dataSources.local.xml
7
- # Editor-based HTTP Client requests
8
- /httpRequests/
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "tanuki_emoji"
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- require "irb"
15
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here