emojidex-static-collector 0.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 912cbd47de163e05167f0d834b7a69cc9c0365a0
4
+ data.tar.gz: 60e67d9accdb2d9a0c4ceb3ee86131744e262248
5
+ SHA512:
6
+ metadata.gz: 6c00316b25db04a5841f57def1e2134a7ef788862a94d1f97b011f1e1451e91033d0f34b3a110d2cfdc16201a2ffb272ed2802beb343b8d206b1e7e027eb4791
7
+ data.tar.gz: 9822f9cbe2928894eb15a82b619ab433af6820f8d9834591a6dd519c9183aa5e7be25022b0d4befc3f499155327838b71197c3dd5a6e35474352215dca0ce451
data/.gitignore ADDED
@@ -0,0 +1,39 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ Gemfile.lock
30
+ .ruby-version
31
+ .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
35
+
36
+ *.swp
37
+ *.swo
38
+
39
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format documentation
data/.rubocop.yml ADDED
@@ -0,0 +1,18 @@
1
+ AsciiIdentifiers:
2
+ Enabled: false
3
+
4
+ AsciiComments:
5
+ Enabled: false
6
+
7
+ AccessorMethodName:
8
+ Enabled: false
9
+
10
+ LineLength:
11
+ Max: 99
12
+
13
+ Style/FileName:
14
+ Enabled: false
15
+
16
+ AllCops:
17
+ Excludes:
18
+ - 'Guardfile'
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'rspec'
7
+ gem 'rubocop'
8
+ gem 'guard'
9
+ gem 'guard-rspec'
10
+ gem 'guard-rubocop'
11
+ end
data/Guardfile ADDED
@@ -0,0 +1,10 @@
1
+ guard :rubocop do
2
+ watch(%r{.+\.rb$})
3
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
4
+ end
5
+
6
+ guard :rspec, cmd: 'bundle exec 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
+ end
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ emojidex-static-collector
2
+ =========================
3
+ Generates static collections of emoji from emojidex
4
+
5
+ Installation
6
+ ============
7
+ CLI/General use:
8
+ ```
9
+ gem install emojidex-static-collector
10
+ ```
11
+
12
+ Or add to your Gemfile if using as a library:
13
+ ```
14
+ gem 'emojidex-static-collector'
15
+ ```
16
+
17
+ Usage
18
+ =====
19
+
20
+ Standalone Tool
21
+ ---------------
22
+ After installing the gem, type:
23
+ ```
24
+ emojidex-static-collector -h
25
+ ```
26
+ for usage instructions.
27
+
28
+ As a Library/Module
29
+ -------------------
30
+ Check the source - the actual module is extremely simple.
31
+
32
+ License
33
+ =======
34
+ emojidex and emojidex tools are licensed under the [emojidex Open License](https://www.emojidex.com/emojidex/emojidex_open_license).
35
+
36
+ ©2013 the emojidex project / Genshin Souzou K.K. [Phantom Creation Inc.]
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+ require 'optparse'
3
+ require 'fileutils'
4
+ require_relative '../lib/emojidex_static_collector'
5
+
6
+ puts '⊂ em😜 jidex Static Collector⊃'
7
+
8
+ # s:size, t:type, o:output
9
+ params = ARGV.getopts('s:t:o:h', 'utf-only', 'clean-cache')
10
+
11
+ # Set params.
12
+ params['s'] = '256' if params['s'].nil?
13
+ params['t'] = 'en' if params['t'].nil?
14
+ params['o'] = './' if params['o'].nil?
15
+ params['h'] = false if params['h'].nil?
16
+
17
+ if params['h']
18
+ puts "Usage:\n" \
19
+ "-h help\n" \
20
+ "-o output path [defaults to current path \"./\"]\n" \
21
+ "-s size [defaults to \"256\"]\n" \
22
+ "-t type:\n" \
23
+ " \"en\" (standard English codes)\n" \
24
+ " \"ja\" (Japanese codes)\n" \
25
+ " \"char\" (raw character codes)\n" \
26
+ " \"moji\" (moji code (:char with Japanese category directories))\n" \
27
+ "--utf-only UTF/Unicode only (does not export Extended)" \
28
+ else
29
+ # Create folder.
30
+ out_dir = File.expand_path(params['o'], __FILE__)
31
+ FileUtils.mkdir_p(out_dir) if Dir.exist?(out_dir)
32
+
33
+ # Generate
34
+ collector = EmojidexStaticCollector.new
35
+ collector.generate(params['o'], params['s'].to_i, params['utf-only'],
36
+ params['t'].to_sym)
37
+ end
@@ -0,0 +1,20 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'emojidex-static-collector'
3
+ s.version = '0.0.1'
4
+ s.license = 'emojiOL'
5
+ s.summary = 'Create static collections from emojidex assets'
6
+ s.description = 'Generates PNG rasters from emojidex vectors in a ' \
7
+ 'specified size and manually sorts them into ' \
8
+ 'categorized folders.'
9
+ s.authors = ['Rei Kagetsuki']
10
+ s.email = 'info@emojidex.com'
11
+ s.files = `git ls-files`.split("\n")
12
+ s.require_paths = ['lib']
13
+ s.bindir = 'bin'
14
+ s.executables << 'emojidex-static-collector'
15
+ s.homepage = 'http://developer.emojidex.com'
16
+
17
+ s.add_dependency 'emojidex'
18
+ s.add_dependency 'emojidex-vectors'
19
+ s.add_dependency 'emojidex-converter'
20
+ end
@@ -0,0 +1,78 @@
1
+ require 'emojidex-vectors'
2
+ require 'emojidex_converter'
3
+ require 'emojidex/categories'
4
+
5
+ require 'fileutils'
6
+
7
+ # Generates static collections of emojidex assets
8
+ class EmojidexStaticCollector
9
+ def initialize
10
+ @utf = Emojidex::UTF.new
11
+ @extended = Emojidex::Extended.new
12
+ @categories = Emojidex::Categories.new
13
+ end
14
+
15
+ # Generates a static collection
16
+ # Args:
17
+ # path: path to export to
18
+ # size: export size
19
+ # utf_only: weather or not to limit to unicode standard emoji
20
+ # code_type: can be
21
+ # :en (standard English codes)
22
+ # :ja (Japanese codes)
23
+ # :char (raw character codes)
24
+ # :moji (moji code (:char with Japanese category directories))
25
+ def generate(path = './', size = 64, utf_only = false, code_type = :en, clean_cache = true)
26
+ cache_dir = File.join(path, '.cache')
27
+ @utf.cache!(cache_path: cache_dir, formats: [:svg])
28
+ @extended.cache!(cache_path: cache_dir, formats: [:svg]) unless utf_only
29
+ collection = Emojidex::Collection.new(nil, cache_dir)
30
+ _generate_categories(collection, path, size, utf_only, code_type)
31
+ FileUtils.rm_rf(cache_dir) if clean_cache
32
+ end
33
+
34
+ private
35
+
36
+ def _generate_categories(collection, path, size, _utf_only, code_type)
37
+ @categories.categories.each_value do |category|
38
+ cat_path = set_path(path, code_type, category)
39
+ FileUtils.mkdir_p cat_path
40
+
41
+ puts "Processing Category: #{category.code}"
42
+ cat_collection = collection.category(category.code.to_sym)
43
+ puts "Category emoji Count: #{cat_collection.emoji.count}"
44
+ cat_collection.source_path = collection.source_path
45
+ _write_emoji(cat_path, cat_collection, size, code_type)
46
+ end
47
+ end
48
+
49
+ def set_path(path, code_type, category)
50
+ cat_path = ''
51
+ if code_type == :ja || code_type == :moji
52
+ cat_path = File.join(path, category.ja)
53
+ elsif code_type == :en || code_type == :char
54
+ cat_path = File.join(path, category.en)
55
+ end
56
+ cat_path
57
+ end
58
+
59
+ def _write_emoji(path, collection, size, code_type)
60
+ converter = Emojidex::Converter.new(sizes: { working: size }, destination: path,
61
+ noisy: true)
62
+ converter.rasterize_collection collection
63
+
64
+ _rename_files(path, collection, code_type)
65
+ end
66
+
67
+ def _rename_files(path, collection, code_type)
68
+ collection.each do |emoji|
69
+ case code_type
70
+ when :ja then FileUtils.mv "#{path}/working/#{emoji.code}.png", "#{path}/#{emoji.code_ja}.png"
71
+ when :moji then FileUtils.mv "#{path}/working/#{emoji.code}.png", "#{path}/#{emoji.moji}.png"
72
+ when :en then FileUtils.mv "#{path}/working/#{emoji.code}.png", "#{path}/#{emoji.code}.png"
73
+ when :char then FileUtils.mv "#{path}/working/#{emoji.code}.png", "#{path}/#{emoji.moji}.png"
74
+ end
75
+ end
76
+ FileUtils.rm_rf "#{path}/working/"
77
+ end
78
+ end
@@ -0,0 +1,38 @@
1
+ require 'emojidex_static_collector'
2
+
3
+ require 'fileutils'
4
+
5
+ describe EmojidexStaticCollector do
6
+ let(:collector) { EmojidexStaticCollector.new }
7
+
8
+ before(:all) do
9
+ @tmpdir = File.expand_path('../../tmp', __FILE__)
10
+ FileUtils.rm_rf @tmpdir if Dir.exist? @tmpdir
11
+ Dir.mkdir @tmpdir
12
+ end
13
+
14
+ describe '.generate' do
15
+ it 'generates a collection' do
16
+ collector.generate(@tmpdir + '/emojidex', 512)
17
+ expect(File.exist?(@tmpdir + '/emojidex/')).to be_truthy
18
+ end
19
+
20
+ it 'generates a collection of UTF only' do
21
+ expect(collector.generate(@tmpdir + '/UTF', 512, false)).to be_truthy
22
+ end
23
+
24
+ it '日本語のコードを使ってコレクションを作成する' do
25
+ expect(collector.generate(@tmpdir + '/日本語', 8, true, :ja)).to be_truthy
26
+ end
27
+
28
+ it 'generates a collection using moji character codes' do
29
+ expect(collector.generate(@tmpdir + '/moji', 8, true, :moji)).to be_truthy
30
+ end
31
+
32
+ it 'generates a collection of UTF only, extended emoji is not exist' do
33
+ collector.generate(@tmpdir + '/UTF_only', 8, true, :en)
34
+ expect(File.exist?(@tmpdir + '/UTF_only/Faces/angry.png')).to be_truthy
35
+ expect(File.exist?(@tmpdir + '/UTF_only/Faces/angry(bk).png')).to be_falsey
36
+ end
37
+ end
38
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: emojidex-static-collector
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Rei Kagetsuki
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: emojidex
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: emojidex-vectors
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: emojidex-converter
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Generates PNG rasters from emojidex vectors in a specified size and manually
56
+ sorts them into categorized folders.
57
+ email: info@emojidex.com
58
+ executables:
59
+ - emojidex-static-collector
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".rubocop.yml"
66
+ - Gemfile
67
+ - Guardfile
68
+ - README.md
69
+ - bin/emojidex-static-collector
70
+ - emojidex-static-collector.gemspec
71
+ - lib/emojidex_static_collector.rb
72
+ - spec/emojidex_static_collector_spec.rb
73
+ homepage: http://developer.emojidex.com
74
+ licenses:
75
+ - emojiOL
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.4.2
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Create static collections from emojidex assets
97
+ test_files: []