rumojinize 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 38cbd50a557db3dcc3e60c58c19ab911552603475246382c518b7208a8084401
4
+ data.tar.gz: 85b0dbea4e3ac68eaabfa24003684f86c61afc0c795e39c7354215d314a8da0e
5
+ SHA512:
6
+ metadata.gz: 1d225f2c0347ed0b2618257d0fde5a2636ccf14b3a0f3807dd3a6eefa4209edda0d0fb961f50c90c6b5f31906c58947a086a6c10cc3597f0d14c5610fd005532
7
+ data.tar.gz: 96e400a5783b597e79d8c4ffe79148a0d8b2676d97e76aa5403f1910b03a49d4dfa92cef2771f0df3f80d0c5fdc6d898a3cd65644a4663906d060e94dfc17d32
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # 🐶Rumojinize
2
+
3
+ This is an ActiveRecord plugin make you easily store emoji to DB.
4
+
5
+ Supporting:
6
+
7
+ - Encode emoji to UTF8 text before save. `🐶`->`:dog:`
8
+ - Decode encoded emoji in the instance of model. `:dog:`->`🐶`
9
+
10
+ ## Concept
11
+
12
+ In order to store the emoji to your Database, we need following steps.
13
+
14
+ - Change the charset from `utf8` to `utf8mb4`.
15
+ - Upgrade MySQL version greater than `5.5`.
16
+
17
+ But "Rumojinize" make it simple!!
18
+
19
+ ## Usage
20
+
21
+ **Install gem:**
22
+
23
+ ```
24
+ gem 'rumojinize'
25
+ ```
26
+
27
+ ```
28
+ bundle install
29
+ ```
30
+
31
+ **Set up by `rumojinize`.**
32
+
33
+ ```
34
+ class Article < ApplicationRecord
35
+ rumojinize :body
36
+ end
37
+ ```
38
+
39
+ Also you can rumojinize multiple fields.
40
+
41
+ ```
42
+ class Article < ApplicationRecord
43
+ rumojinize :body, :title
44
+ end
45
+ ```
46
+
47
+ ## Example
48
+
49
+ **For example, Rumojinize will encode `🐶` to `:dog:` before save to DB, and decode in the instance.**
50
+
51
+ ![image](https://user-images.githubusercontent.com/3489430/41193342-a5b264de-6c45-11e8-96b4-d1818ca2779e.png)
52
+
53
+ ## Dependencies
54
+
55
+ - [rumoji](https://github.com/mwunsch/rumoji)
56
+
57
+ ## Development
58
+
59
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
60
+
61
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
62
+
63
+ ## Contributing
64
+
65
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tanakaworld/rumojinize. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
66
+
67
+ ## License
68
+
69
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
70
+
71
+ ## Code of Conduct
72
+
73
+ Everyone interacting in the Rumojinize project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/tanakaworld/rumojinize/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,33 @@
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
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Rumojinize'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'test'
28
+ t.pattern = 'test/**/*_test.rb'
29
+ t.verbose = false
30
+ end
31
+
32
+
33
+ task default: :test
@@ -0,0 +1,21 @@
1
+ require 'rumoji'
2
+
3
+ module Rumojinize::Core
4
+ extend ActiveSupport::Concern
5
+
6
+ module ClassMethods
7
+ def rumojinize(*field_names)
8
+ raise ArgumentError.new 'Need to set field names.' unless (field_names.present? && field_names.size > 0)
9
+
10
+ field_names.each do |field_name|
11
+ define_method "#{field_name}=" do |text|
12
+ write_attribute(field_name, Rumoji.encode(text))
13
+ end
14
+ define_method field_name do
15
+ text = read_attribute(field_name)
16
+ Rumoji.decode(text) if text.present?
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module Rumojinize
2
+ VERSION = '0.2.1'
3
+ end
data/lib/rumojinize.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'rumojinize/version'
2
+ require 'rumojinize/core'
3
+
4
+ module Rumojinize
5
+ end
6
+
7
+ ActiveRecord::Base.send :include, Rumojinize::Core
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :rumojinize do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rumojinize
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - tanakaworld
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-06-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
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: rumoji
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: sqlite3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: "\U0001F436ActiveRecord plugin make you easily store emoji to DB."
56
+ email:
57
+ - yutaro.tanaka.world@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - README.md
63
+ - Rakefile
64
+ - lib/rumojinize.rb
65
+ - lib/rumojinize/core.rb
66
+ - lib/rumojinize/version.rb
67
+ - lib/tasks/rumojinize_tasks.rake
68
+ homepage: http://tanakaworld.github.io/rumojinize
69
+ licenses:
70
+ - MIT
71
+ metadata: {}
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 2.7.6
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: "\U0001F436ActiveRecord plugin make you easily store emoji to DB."
92
+ test_files: []