emojidex 0.0.7 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +11 -10
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +11 -0
  5. data/.travis.yml +17 -0
  6. data/Gemfile +16 -10
  7. data/Guardfile +12 -0
  8. data/README.md +27 -5
  9. data/Rakefile +6 -32
  10. data/emoji/categories.json +64 -0
  11. data/emojidex.gemspec +13 -20
  12. data/lib/emojidex.rb +9 -4
  13. data/lib/emojidex/api/categories.rb +16 -0
  14. data/lib/emojidex/api/emoji.rb +26 -0
  15. data/lib/emojidex/api/search/emoji.rb +16 -0
  16. data/lib/emojidex/cache.rb +69 -0
  17. data/lib/emojidex/categories.rb +32 -0
  18. data/lib/emojidex/category.rb +14 -0
  19. data/lib/emojidex/client.rb +60 -0
  20. data/lib/emojidex/collection.rb +119 -0
  21. data/lib/emojidex/defaults.rb +13 -0
  22. data/lib/emojidex/emoji.rb +74 -0
  23. data/lib/emojidex/error.rb +15 -0
  24. data/lib/emojidex/extended.rb +15 -0
  25. data/lib/emojidex/service.rb +32 -0
  26. data/lib/emojidex/utf.rb +15 -0
  27. data/spec/api/categories_spec.rb +49 -0
  28. data/spec/api/emoji_spec.rb +89 -0
  29. data/spec/api/search/emoji_spec.rb +30 -0
  30. data/spec/categories_spec.rb +18 -0
  31. data/spec/client_spec.rb +24 -0
  32. data/spec/emoji_spec.rb +63 -0
  33. data/spec/extended_spec.rb +107 -0
  34. data/spec/spec_helper.rb +64 -0
  35. data/spec/support/Genshin.svg +126 -0
  36. data/spec/support/couple_kiss/0.svg +177 -0
  37. data/spec/support/couple_kiss/1.svg +177 -0
  38. data/spec/support/couple_kiss/10.svg +293 -0
  39. data/spec/support/couple_kiss/11.svg +235 -0
  40. data/spec/support/couple_kiss/12.svg +235 -0
  41. data/spec/support/couple_kiss/13.svg +235 -0
  42. data/spec/support/couple_kiss/14.svg +177 -0
  43. data/spec/support/couple_kiss/15.svg +177 -0
  44. data/spec/support/couple_kiss/2.svg +177 -0
  45. data/spec/support/couple_kiss/3.svg +235 -0
  46. data/spec/support/couple_kiss/4.svg +235 -0
  47. data/spec/support/couple_kiss/5.svg +235 -0
  48. data/spec/support/couple_kiss/6.svg +293 -0
  49. data/spec/support/couple_kiss/7.svg +235 -0
  50. data/spec/support/couple_kiss/8.svg +235 -0
  51. data/spec/support/couple_kiss/9.svg +235 -0
  52. data/spec/support/couple_kiss/animation.json +14 -0
  53. data/spec/support/fixtures/categories.json +14 -0
  54. data/spec/support/fixtures/category.json +5 -0
  55. data/spec/support/fixtures/emoji.json +28 -0
  56. data/spec/support/fixtures/emoji_detailed.json +41 -0
  57. data/spec/support/fixtures/search_emoji.json +21 -0
  58. data/spec/support/fixtures/single_emoji.json +19 -0
  59. data/spec/support/fixtures/single_emoji_detailed.json +30 -0
  60. data/spec/support/test1/animation.json +6 -0
  61. data/spec/support/test2/animation.json +6 -0
  62. data/spec/support/test3/animation.json +5 -0
  63. data/spec/utf_spec.rb +66 -0
  64. metadata +82 -104
  65. data/app/assets/images/emojidex/.keep +0 -0
  66. data/app/assets/images/emojidex/glyphicons-halflings-white.png +0 -0
  67. data/app/assets/images/emojidex/glyphicons-halflings.png +0 -0
  68. data/app/assets/javascripts/emojidex/application.js +0 -14
  69. data/app/assets/javascripts/emojidex/bootstrap.min.js +0 -7
  70. data/app/assets/javascripts/emojidex/cheat_sheet.js +0 -12
  71. data/app/assets/javascripts/emojidex/poe_pallet.js +0 -71
  72. data/app/assets/stylesheets/emojidex/application.css +0 -15
  73. data/app/assets/stylesheets/emojidex/bootstrap-responsive.min.css +0 -9
  74. data/app/assets/stylesheets/emojidex/bootstrap.min.css +0 -9
  75. data/app/assets/stylesheets/emojidex/cheat_sheet.css +0 -41
  76. data/app/controllers/emojidex/application_controller.rb +0 -7
  77. data/app/controllers/emojidex/cheat_sheet_controller.rb +0 -50
  78. data/app/helpers/emojidex/application_helper.rb +0 -4
  79. data/app/helpers/emojidex/cheat_sheet_helper.rb +0 -4
  80. data/app/views/emojidex/cheat_sheet/index.html.erb +0 -58
  81. data/app/views/layouts/emojidex/application.html.erb +0 -14
  82. data/bin/rails +0 -8
  83. data/config/routes.rb +0 -5
  84. data/lib/emojidex/engine.rb +0 -5
  85. data/lib/emojidex/version.rb +0 -3
  86. data/lib/generators/emojidex/install/install_generator.rb +0 -35
  87. data/lib/tasks/emojidex_tasks.rake +0 -4
  88. data/test/controllers/emojidex/cheat_sheet_controller_test.rb +0 -11
  89. data/test/dummy/README.rdoc +0 -28
  90. data/test/dummy/Rakefile +0 -6
  91. data/test/dummy/app/assets/images/.keep +0 -0
  92. data/test/dummy/app/assets/javascripts/application.js +0 -13
  93. data/test/dummy/app/assets/stylesheets/application.css +0 -13
  94. data/test/dummy/app/controllers/application_controller.rb +0 -5
  95. data/test/dummy/app/controllers/concerns/.keep +0 -0
  96. data/test/dummy/app/helpers/application_helper.rb +0 -2
  97. data/test/dummy/app/mailers/.keep +0 -0
  98. data/test/dummy/app/models/.keep +0 -0
  99. data/test/dummy/app/models/concerns/.keep +0 -0
  100. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  101. data/test/dummy/bin/bundle +0 -3
  102. data/test/dummy/bin/rails +0 -4
  103. data/test/dummy/bin/rake +0 -4
  104. data/test/dummy/config.ru +0 -4
  105. data/test/dummy/config/application.rb +0 -23
  106. data/test/dummy/config/boot.rb +0 -5
  107. data/test/dummy/config/database.yml +0 -25
  108. data/test/dummy/config/environment.rb +0 -5
  109. data/test/dummy/config/environments/development.rb +0 -29
  110. data/test/dummy/config/environments/production.rb +0 -80
  111. data/test/dummy/config/environments/test.rb +0 -36
  112. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  113. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  114. data/test/dummy/config/initializers/inflections.rb +0 -16
  115. data/test/dummy/config/initializers/mime_types.rb +0 -5
  116. data/test/dummy/config/initializers/secret_token.rb +0 -12
  117. data/test/dummy/config/initializers/session_store.rb +0 -3
  118. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  119. data/test/dummy/config/locales/en.yml +0 -23
  120. data/test/dummy/config/routes.rb +0 -4
  121. data/test/dummy/lib/assets/.keep +0 -0
  122. data/test/dummy/log/.keep +0 -0
  123. data/test/dummy/public/404.html +0 -58
  124. data/test/dummy/public/422.html +0 -58
  125. data/test/dummy/public/500.html +0 -57
  126. data/test/dummy/public/favicon.ico +0 -0
  127. data/test/emojidex_test.rb +0 -7
  128. data/test/helpers/emojidex/cheat_sheet_helper_test.rb +0 -6
  129. data/test/integration/navigation_test.rb +0 -10
  130. data/test/test_helper.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d4b38c501700ed3d2d7e639a8123ee9630240e8
4
- data.tar.gz: 783ac24a6aef70c3f17e6b7661dfed77b8d9cb8b
3
+ metadata.gz: 4893c39e085f721f6888fb84899b4749ef435134
4
+ data.tar.gz: 10bf72c13623c7acf1c1c98fc68da7c133559a31
5
5
  SHA512:
6
- metadata.gz: cab3827fa637dbc4fb034db5e5175f4e3fd9d02f0e458002e1a554aa2e555b06edd0c01e5d389ca094526089c172709dcce86c3e44be68ca71f50f42123cc55a
7
- data.tar.gz: 0454eee99c8ce194e940ba3460db2a60fd0626f0ee37b0e458fdbc251384f6da1c7b93cd7068303edc610b3cb49e061fe83a6057a31ed3ae386dea9c9010d1e6
6
+ metadata.gz: a11b74ed96b360150373b2a37934eaeebed32452c02dbc57b045498a8c41c37efdbd0299eb91b5076ff88e221143f6cb57602e2a3b3d7400844b68f0e76628d2
7
+ data.tar.gz: 7033d1b7719e8b99360eef165fde88f04e7ff6c60646d12f27f513bec93471b4609453ff00897847b601dfac3b2b43cc6f4c47b783a681c49731429553f022dd
data/.gitignore CHANGED
@@ -1,11 +1,12 @@
1
- .bundle/
2
- log/*.log
3
- pkg/
4
- test/dummy/db/*.sqlite3
5
- test/dummy/db/*.sqlite3-journal
6
- test/dummy/log/*.log
7
- test/dummy/tmp/
8
- test/dummy/.sass-cache
9
- .project
10
- .DS_Store
1
+ *.swp
2
+ *.swo
3
+ *.orig
11
4
  Gemfile.lock
5
+ *.gem
6
+ spec/out/
7
+ spec/support/tmpcache/
8
+ tmp/
9
+ .DS_Store
10
+ .ruby-gemset
11
+ .ruby-version
12
+ coverage
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format documentation
data/.rubocop.yml ADDED
@@ -0,0 +1,11 @@
1
+ AsciiIdentifiers:
2
+ Enabled: false
3
+
4
+ AsciiComments:
5
+ Enabled: false
6
+
7
+ AccessorMethodName:
8
+ Enabled: false
9
+
10
+ LineLength:
11
+ Max: 99
data/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.2
7
+ - jruby-19mode
8
+ - rbx-2
9
+
10
+ bundler_args: -j4 --without development
11
+
12
+ script:
13
+ - bundle exec rspec
14
+
15
+ addons:
16
+ code_climate:
17
+ repo_token: 4f9c56a5c9a2e99acd8e8f06491940f9174c6fd1e22236539bb2cbc2fefd0e30
data/Gemfile CHANGED
@@ -1,14 +1,20 @@
1
- source "https://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
 
3
- # Declare your gem's dependencies in emojidex.gemspec.
4
- # Bundler will treat runtime dependencies like base dependencies, and
5
- # development dependencies will be added by default to the :development group.
6
3
  gemspec
7
4
 
8
- # Declare any dependencies that are still in development here instead of in
9
- # your gemspec. These might include edge Rails or gems from your path or
10
- # Git. Remember to move these dependencies to your gemspec before releasing
11
- # your gem to rubygems.org.
5
+ group :development do
6
+ gem 'rb-inotify', require: false
7
+ gem 'rb-fsevent', require: false
8
+ gem 'guard'
9
+ gem 'guard-rspec'
10
+ gem 'rubocop'
11
+ gem 'guard-rubocop'
12
+ #gem 'emojidex-vectors', path: '../emojidex-vectors'
13
+ end
12
14
 
13
- # To use debugger
14
- # gem 'debugger'
15
+ group :test do
16
+ gem 'coveralls', require: false
17
+ gem 'rspec'
18
+ gem 'webmock'
19
+ gem 'emojidex-vectors', github: 'emojidex/emojidex-vectors'
20
+ end
data/Guardfile ADDED
@@ -0,0 +1,12 @@
1
+ guard :rubocop do
2
+ watch(%r{.+\.rb$})
3
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
4
+ end
5
+
6
+ guard :rspec do
7
+ watch(%r{^spec/.+_spec\.rb$})
8
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
9
+ watch('spec/spec_helper.rb') { "spec" }
10
+
11
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
12
+ end
data/README.md CHANGED
@@ -1,8 +1,30 @@
1
- Emojidex for Rails
2
- ============================
3
- Web scripts and libraries to use Emojidex in Rails apps.
4
- Includes Phantom Open Emoji for the base emoji and connects to emojidex for extended emoji.
1
+ [![Gem Version](https://badge.fury.io/rb/emojidex.png)](http://badge.fury.io/rb/emojidex)
2
+ [![Build Status](https://travis-ci.org/emojidex/emojidex.png)](https://travis-ci.org/emojidex/emojidex)
3
+ [![Code Climate](https://codeclimate.com/github/emojidex/emojidex.png)](https://codeclimate.com/github/emojidex/emojidex)
4
+ emojidex
5
+ ========
6
+ emojidex core tools and scripts in Ruby. Provides a set of tools to utilize emojidex emoji right away in Ruby. Available as the "emojidex" gem.
5
7
 
6
8
  License
7
9
  =======
8
- This library is licensed under the LGPL. You may use it freely in any project or service but you must make modifications freely and openly available.
10
+ There are three choices for licensing of emojidex libraries and assets. In each case emoji assets are Copyright Genshin Souzou Kabushiki Kaisha [Phantom Creation Inc.]. Emoji images may be used under the terms of the emojidex emoji use license. Use in digital distrobution is subject to the terms and conditions below. Emoji may not be used on commercial printed material or in any commercial physical production without a separate license.
11
+
12
+ Closed or Open Source Software with emojidex service:
13
+ -----------------------------------------------------
14
+ When used in conjuction with the emojidex service and without disabling or obstructing features or connectivity emojidex-toolkit may be used in commercial or closed source applications. In this situation all sources are considered to be licensed under the LGPL version 3. Emoji assets are not subject to the LGPL and remain copyrighted licensed works.
15
+
16
+ Closed Source software without emojidex service:
17
+ ------------------------------------------------
18
+ A separate license is required. Please contact info@genshin.org .
19
+
20
+ Open Source Software without emojidex service:
21
+ -------------------------------------------
22
+ When used with features disabled or modified to circumvent emojidex services in any way this software is dual licensed under the GPLv3 and AGPLv3 and as such you software must be licensed under the GPL v3 or your service must be licensed under the AGPL v3. Including images in any format without sources is equivilent to including sources; such that the inclusion of any image assets from emojidex will require you to apply the GPL v3 and AGPL v3 to your software/project.
23
+
24
+ Licensing of Images:
25
+ --------------------
26
+ All image assets are copyright 2013 Genshin Souzou Kabushiki Kaisha and a copyright notice must be included. Usage of these assets in printed material requires a separate license. Usage of images in software requires compliance to the licensing conditions above. Usage of images in virtual form outside of the context of software projects requires written permission from Genshin Souzou K.K. and may require a separate license.
27
+
28
+ License fees may be wholly waived for non-religiously affiliated educational institutions and parties who are working for greater social or scientific benefit. Please inquire.
29
+
30
+ For all license requests please contact info@genshin.org
data/Rakefile CHANGED
@@ -1,34 +1,8 @@
1
- begin
2
- require 'bundler/setup'
3
- rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
- end
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'rake'
4
+ require 'rspec/core/rake_task'
6
5
 
7
- require 'rdoc/task'
6
+ RSpec::Core::RakeTask.new(:spec)
8
7
 
9
- RDoc::Task.new(:rdoc) do |rdoc|
10
- rdoc.rdoc_dir = 'rdoc'
11
- rdoc.title = 'Emojidex'
12
- rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.rdoc')
14
- rdoc.rdoc_files.include('lib/**/*.rb')
15
- end
16
-
17
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
- load 'rails/tasks/engine.rake'
19
-
20
-
21
-
22
- Bundler::GemHelper.install_tasks
23
-
24
- require 'rake/testtask'
25
-
26
- Rake::TestTask.new(:test) do |t|
27
- t.libs << 'lib'
28
- t.libs << 'test'
29
- t.pattern = 'test/**/*_test.rb'
30
- t.verbose = false
31
- end
32
-
33
-
34
- task default: :test
8
+ task :default => :spec
@@ -0,0 +1,64 @@
1
+ {
2
+ "categories": [
3
+ {
4
+ "code": "faces",
5
+ "en": "Faces",
6
+ "ja": "顔"
7
+ },
8
+ {
9
+ "code": "people",
10
+ "en": "People",
11
+ "ja": "人"
12
+ },
13
+ {
14
+ "code": "food",
15
+ "en": "Food",
16
+ "ja": "食べ物"
17
+ },
18
+ {
19
+ "code": "tools",
20
+ "en": "Tools",
21
+ "ja": "道具"
22
+ },
23
+ {
24
+ "code": "objects",
25
+ "en": "Objects",
26
+ "ja": "物"
27
+ },
28
+ {
29
+ "code": "gestures",
30
+ "en": "Gestures",
31
+ "ja": "ジェスチャー"
32
+ },
33
+ {
34
+ "code": "transportation",
35
+ "en": "Transportation",
36
+ "ja": "乗り物"
37
+ },
38
+ {
39
+ "code": "places",
40
+ "en": "Places",
41
+ "ja": "場所"
42
+ },
43
+ {
44
+ "code": "nature",
45
+ "en": "Nature",
46
+ "ja": "自然"
47
+ },
48
+ {
49
+ "code": "cosmos",
50
+ "en": "Cosmos",
51
+ "ja": "宇宙"
52
+ },
53
+ {
54
+ "code": "symbols",
55
+ "en": "Symbols",
56
+ "ja": "記号"
57
+ },
58
+ {
59
+ "code": "abstract",
60
+ "en": "Abstract",
61
+ "ja": "抽象物"
62
+ }
63
+ ]
64
+ }
data/emojidex.gemspec CHANGED
@@ -1,22 +1,15 @@
1
- $:.push File.expand_path("../lib", __FILE__)
2
-
3
- # Maintain your gem's version:
4
- require "emojidex/version"
5
-
6
- # Describe your gem and declare its dependencies:
7
1
  Gem::Specification.new do |s|
8
- s.name = "emojidex"
9
- s.version = "0.0.7"
10
- s.license = "GNU GPLv3 and AGPLv3"
11
- s.authors = ['Yukiharu Nakaya', 'Rika Yoshida', 'Rei Kagetsuki']
12
- s.email = ["info@genshin.org"]
13
- s.homepage = "http://genshin.org"
14
- s.summary = "Phantom Open Emoji for Rails"
15
- s.description = "Phantom Open Emoji with utilities and resources for Rails."
16
-
17
- s.files = `git ls-files`.split("\n")
18
-
19
- s.add_dependency 'highline'
20
- s.add_dependency 'phantom_open_emoji'
21
- s.add_dependency 'phantom_open_emoji_static'
2
+ s.name = 'emojidex'
3
+ s.version = '0.0.9'
4
+ s.license = 'GPL-3, AGPL-3'
5
+ s.summary = 'emojidex Ruby tools'
6
+ s.description = 'emojidex emoji handling, search and lookup, listing and caching functionality and user info (favorites/etc).'
7
+ s.authors = ['Rei Kagetsuki', 'Jun Tohyama', 'Vassil Kalkov', 'Rika Yoshida']
8
+ s.email = 'info@emojidex.com'
9
+ s.files = `git ls-files`.split("\n")
10
+ s.require_paths = ['lib']
11
+ s.homepage = 'http://dev.emojidex.com'
12
+
13
+ s.add_dependency 'faraday', '0.8.9'
14
+ s.add_dependency 'faraday_middleware', '0.9.0'
22
15
  end
data/lib/emojidex.rb CHANGED
@@ -1,4 +1,9 @@
1
- require "emojidex/engine"
2
-
3
- module Emojidex
4
- end
1
+ require 'json'
2
+ require 'emojidex/emoji'
3
+ require 'emojidex/collection'
4
+ require 'emojidex/utf'
5
+ require 'emojidex/extended'
6
+ require 'emojidex/category'
7
+ require 'emojidex/categories'
8
+ require 'emojidex/client'
9
+ require 'emojidex/error'
@@ -0,0 +1,16 @@
1
+ module Emojidex
2
+ module API
3
+ # Get cateegories from API
4
+ module Categories
5
+ def categories(*args)
6
+ response = get('/api/v1/categories.json', args)
7
+ response[:body]['categories']
8
+ end
9
+
10
+ def category(*args)
11
+ response = get('/api/v1/categories/category.json', args)
12
+ response[:body]
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,26 @@
1
+ module Emojidex
2
+ module API
3
+ # Get emoji from API
4
+ module Emoji
5
+ def emoji(*args)
6
+ response = get('/api/v1/emoji.json', args)
7
+ response[:body]['emoji']
8
+ end
9
+
10
+ def single_emoji(*args)
11
+ response = get('/api/v1/emoji/emoji.json', args)
12
+ response[:body]
13
+ end
14
+
15
+ def emoji_detailed(*args)
16
+ response = get('/api/v1/emoji/detailed.json', args)
17
+ response[:body]
18
+ end
19
+
20
+ def single_emoji_detailed(*args)
21
+ response = get('/api/v1/emoji/1/detailed.json', args)
22
+ response[:body]
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,16 @@
1
+ module Emojidex
2
+ module API
3
+ module Search
4
+ # Search API for emoji
5
+ module Emoji
6
+ def emoji_code_cont(term, options = {})
7
+ response = get(
8
+ '/api/v1/search/emoji.json',
9
+ options.merge('q[code_cont]' => term)
10
+ )
11
+ response[:body]
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,69 @@
1
+ require 'json'
2
+ require_relative 'defaults'
3
+ require 'fileutils'
4
+
5
+ module Emojidex
6
+ # local caching functionality for collections
7
+ module Cache
8
+ attr_reader :cache_dir
9
+
10
+ def setup_cache(path = nil)
11
+ # check if cache dir is already set
12
+ return @cache_dir if @cache_dir && path.nil?
13
+ # setup cache
14
+ @cache_dir = File.expand_path(path || ENV['EMOJI_CACHE'] || "#{ENV['HOME']}/.emojidex/cache")
15
+ FileUtils.mkdir_p(@cache_dir)
16
+ Emojidex::Defaults.sizes.keys.each do |size|
17
+ FileUtils.mkdir_p(@cache_dir + "/#{size}")
18
+ end
19
+ @cache_dir
20
+ end
21
+
22
+ # Caches emoji to local emoji storage cache
23
+ # Options:
24
+ # cache_dir: manually specify cache location
25
+ # (default is ENV['EMOJI_CACHE'] or '$HOME/.emoji_cache')
26
+ # formats: formats to cache (default is SVG only)
27
+ # sizes: sizes to cache (default is px32, but this is irrelivant for SVG)
28
+ def cache!(options = {})
29
+ setup_cache options[:cache_dir]
30
+ formats = options[:formats] || [:svg, :png]
31
+ sizes = options[:sizes] || [:px32]
32
+ @emoji.values.each do |moji|
33
+ _svg_check_copy(moji) if formats.include? :svg
34
+ _raster_check_copy(moji, :png, sizes) if formats.include? :png
35
+ end
36
+ _update_index
37
+ end
38
+
39
+ private
40
+
41
+ def _svg_check_copy(moji)
42
+ src = @source_path + "/#{moji.code}"
43
+ if File.exist? "#{src}.svg"
44
+ unless File.exist?("#{@cache_dir}/#{moji.code}.svg") &&
45
+ FileUtils.compare_file("#{src}.svg", "#{@cache_dir}/#{moji.code}.svg")
46
+ FileUtils.cp("#{src}.svg", @cache_dir)
47
+ end
48
+ end
49
+ FileUtils.cp_r src, @cache_dir if File.directory? src
50
+ end
51
+
52
+ def _raster_check_copy(moji, format, sizes)
53
+ sizes.each do |size|
54
+ src = @source_path + "/#{size}/#{moji.code}"
55
+ FileUtils.cp "src.#{format}", (@cache_dir + "/#{size}") if FileTest.exist? "src.#{format}"
56
+ FileUtils.cp_r src, @cache_dir if File.directory? src
57
+ end
58
+ end
59
+
60
+ def _update_index
61
+ idx = Emojidex::Collection.new
62
+ idx.load_local_collection(@cache_dir) if FileTest.exist? "#{@cache_dir}/emoji.json"
63
+ idx.add_emoji @emoji.values
64
+ File.open("#{@cache_dir}/emoji.json", 'w') do |f|
65
+ f.write idx.emoji.values.to_json
66
+ end
67
+ end
68
+ end
69
+ end