mmunicode_rails 0.4.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.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +58 -0
- data/README.md +121 -0
- data/Rakefile +6 -0
- data/lib/generators/mmunicode_rails/initializer_generator.rb +15 -0
- data/lib/generators/templates/mmunicode_rails.rb +2 -0
- data/lib/mmunicode_rails.rb +320 -0
- data/lib/mmunicode_rails/version.rb +3 -0
- data/mmunicode_rails.gemspec +28 -0
- data/spec/mmunicode_rails_spec.rb +54 -0
- data/spec/spec_helper.rb +28 -0
- metadata +144 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 851aa6872815f4a6280dcd5d36555b3998411d1c
|
4
|
+
data.tar.gz: a1677a42aba26483a2f990d94f4fd74339fd4a59
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 313413de303506071e04e8d8758757e1e9f354285f54cb080ea9a46842e7c4112ec9d5c723f8f0e3747fc7f1b501c301b190ff648dcd1a5aa63c8d9b0ad98a88
|
7
|
+
data.tar.gz: 3008f477b83854a7110be42d4f4e6c834d53377b0a864fd125398fe6f4b7b679d59b3990173fb901fe252bae28454e15b30614402e3b31c7e1bfb4d701eaca2d
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
|
2
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
3
|
+
|
4
|
+
Version 3, 29 June 2007
|
5
|
+
|
6
|
+
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
7
|
+
|
8
|
+
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
9
|
+
|
10
|
+
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
|
11
|
+
|
12
|
+
0. Additional Definitions.
|
13
|
+
As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
|
14
|
+
|
15
|
+
“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
|
16
|
+
|
17
|
+
An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
|
18
|
+
|
19
|
+
A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
|
20
|
+
|
21
|
+
The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
|
22
|
+
|
23
|
+
The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
|
24
|
+
|
25
|
+
1. Exception to Section 3 of the GNU GPL.
|
26
|
+
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
|
27
|
+
|
28
|
+
2. Conveying Modified Versions.
|
29
|
+
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
|
30
|
+
|
31
|
+
a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
|
32
|
+
b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
|
33
|
+
3. Object Code Incorporating Material from Library Header Files.
|
34
|
+
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
|
35
|
+
|
36
|
+
a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
|
37
|
+
b) Accompany the object code with a copy of the GNU GPL and this license document.
|
38
|
+
4. Combined Works.
|
39
|
+
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
|
40
|
+
|
41
|
+
a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
|
42
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
|
43
|
+
c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
|
44
|
+
d) Do one of the following:
|
45
|
+
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
|
46
|
+
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
|
47
|
+
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
|
48
|
+
5. Combined Libraries.
|
49
|
+
You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
|
50
|
+
|
51
|
+
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
|
52
|
+
b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
|
53
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
54
|
+
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
55
|
+
|
56
|
+
Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
|
57
|
+
|
58
|
+
If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
|
data/README.md
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
# mmunicode-rails
|
2
|
+
|
3
|
+
The gem aims for Myanmar language users who suffered in a never Ending war between Zawgyi and Unicode fonts for Myanmar language.
|
4
|
+
|
5
|
+
This is by no means a complete solution. It's just a convenient helper gem.
|
6
|
+
|
7
|
+
"mmunicode_rails" lets you convert you rails app input data to Myanmar Unicode regardless of which fonts the users used.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'mmunicode_rails'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install mmunicode_rails
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Currently mmunicode_rails supports two approach:
|
28
|
+
1. Inserting as a middleware that intercepts all params and convert it to Myanmar Unicode
|
29
|
+
2. Adding an ActiveRecord class macro that will convert specify string or text fields before saving a model
|
30
|
+
|
31
|
+
### Middleware Example
|
32
|
+
|
33
|
+
After bundling the gem, a rails generator for mmunicode_rails will be added to your rails app.
|
34
|
+
|
35
|
+
Run the generator:
|
36
|
+
```sh
|
37
|
+
rails generate mmunicode_rails:initializer
|
38
|
+
```
|
39
|
+
This will produce `config/initializers/mmunicode_rails.rb` file. The file include code for inserting `RackMmunicode` middleware when your rails app is initialized.
|
40
|
+
|
41
|
+
And that's it. Now every request parameters(including query string parameters) will get converted to unicode in the rack layer.
|
42
|
+
|
43
|
+
### ActiveRecord Example
|
44
|
+
|
45
|
+
If there is an ActiveRecord model with schema like this:
|
46
|
+
```ruby
|
47
|
+
ActiveRecord::Schema.define(:version => 0) do
|
48
|
+
create_table :posts do |t|
|
49
|
+
t.text :body
|
50
|
+
t.string :title
|
51
|
+
t.integer :view_count
|
52
|
+
end
|
53
|
+
end
|
54
|
+
```
|
55
|
+
You can specify the field you would like to convert to unicode before saving to database like this:
|
56
|
+
```ruby
|
57
|
+
class Post < ActiveRecord::Base
|
58
|
+
mmunicode_convert :title,:body
|
59
|
+
end
|
60
|
+
```
|
61
|
+
This will register a before_save hook that converts the incoming input to unicode if it's written in zawgyi. That way you can let your users enter data in Zawgyi font while still using Unicode in your site.
|
62
|
+
|
63
|
+
The conversion is supported only for :string and :text type. Specifying any other types will raise an `NotSupportedForNonStringTypesError`.
|
64
|
+
eg:
|
65
|
+
```ruby
|
66
|
+
class Post < ActiveRecord::Base
|
67
|
+
mmunicode_convert :title,:body,:view_count
|
68
|
+
end
|
69
|
+
```
|
70
|
+
The above code will raise Error.
|
71
|
+
|
72
|
+
### Custommizing
|
73
|
+
|
74
|
+
If you don't like both approach, you can include `MmunicodeRails::Core` module for converter methods.(for zg to unicode => `zg12uni51,for unicode to zg => `uni512zg1 , detecting_font => `detect_font`) All accepts an input string. converter methods produce converted output string. `detect_font` returns :unicode, :zawgyi depending on fonts. If it's not Myanmar Font it will return `nil`. If it's unsure of which font, it will prefer :zawgyi.
|
75
|
+
|
76
|
+
For example, if you want to register as a controller before_filter:
|
77
|
+
```ruby
|
78
|
+
class PersonController < ApplicationController
|
79
|
+
include MmunicodeRails::Core
|
80
|
+
before_filter :change_name_to_unicode
|
81
|
+
|
82
|
+
private
|
83
|
+
def change_name_to_unicode
|
84
|
+
zg12uni51(person_params[:name]) if person_params[:name]
|
85
|
+
end
|
86
|
+
end
|
87
|
+
```
|
88
|
+
|
89
|
+
## TODO
|
90
|
+
- To add client side js support for font users' convenience
|
91
|
+
- To add font embed files in generator.
|
92
|
+
- To add helper functions for myanmar word processing(Long Term goal)
|
93
|
+
|
94
|
+
## Contributing
|
95
|
+
|
96
|
+
Any form of feedback or contribution is welcome. Please do post an issue if there is something you would like to add as a feature or if you find a bug.
|
97
|
+
An issue/pull request can make the contributors of the project very happy. Don't be shy or afraid!
|
98
|
+
|
99
|
+
If you would like to contribute then
|
100
|
+
|
101
|
+
1. Fork it ( https://github.com/dreamingblackcat/mmunicode_rails/fork )
|
102
|
+
|
103
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
104
|
+
|
105
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
106
|
+
|
107
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
108
|
+
|
109
|
+
5. Create a new Pull Request
|
110
|
+
|
111
|
+
## Credits
|
112
|
+
|
113
|
+
- [Ye Lin Aung](https://github.com/yelinaung) for his awesome [mmfont](https://githubcom/yelinaung/mmfont) gem.
|
114
|
+
|
115
|
+
- [Thura Hlaing](https://github.com/trhura) for his excellent [paytan](https://github.com/trhura/paytan) converter generator.
|
116
|
+
|
117
|
+
- [Green Like Orange](https://github.com/greenlikeorange) for his great font detection code in [knayi](https://github.com/greenlikeorange/knayi-myscript) script.
|
118
|
+
|
119
|
+
##LICENSE
|
120
|
+
|
121
|
+
The project is under GNU LESSER GENERAL PUBLIC LICENSE. You can view the license terms [here](LICENSE.txt).
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module MmunicodeRails
|
2
|
+
module Generators
|
3
|
+
class InitializerGenerator < ::Rails::Generators::Base
|
4
|
+
|
5
|
+
source_root File.expand_path("../../templates", __FILE__)
|
6
|
+
|
7
|
+
desc 'Creates MmunicodeRails initializer.'
|
8
|
+
|
9
|
+
def copy_initializer
|
10
|
+
copy_file 'mmunicode_rails.rb', 'config/initializers/mmunicode_rails.rb'
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,320 @@
|
|
1
|
+
require "mmunicode_rails/version"
|
2
|
+
require 'rack'
|
3
|
+
|
4
|
+
module MmunicodeRails
|
5
|
+
|
6
|
+
module Core
|
7
|
+
def uni512zg1(input_text)
|
8
|
+
return input_text unless detect_font(input_text) == :uni
|
9
|
+
output_text = input_text
|
10
|
+
output_text = output_text.gsub(/\u104e\u1004\u103a\u1038/ ,"\u104e")
|
11
|
+
output_text = output_text.gsub(/\u102b\u103a/ ,"\u105a")
|
12
|
+
output_text = output_text.gsub(/\u102d\u1036/ ,"\u108e")
|
13
|
+
output_text = output_text.gsub(/\u103f/ ,"\u1086")
|
14
|
+
output_text = output_text.gsub(/(?<=\u102f)\u1037/ ,"\u1094")
|
15
|
+
output_text = output_text.gsub(/(?<=\u102f\u1036)\u1037/ ,"\u1094")
|
16
|
+
output_text = output_text.gsub(/(?<=\u1030)\u1037/ ,"\u1094")
|
17
|
+
output_text = output_text.gsub(/(?<=\u1030\u1036)\u1037/ ,"\u1094")
|
18
|
+
output_text = output_text.gsub(/(?<=\u1014)\u1037/ ,"\u1094")
|
19
|
+
output_text = output_text.gsub(/(?<=\u1014[\u103a\u1032])\u1037/ ,"\u1094")
|
20
|
+
output_text = output_text.gsub(/(?<=\u103b)\u1037/ ,"\u1095")
|
21
|
+
output_text = output_text.gsub(/(?<=\u103b[\u1032\u1036])\u1037/ ,"\u1095")
|
22
|
+
output_text = output_text.gsub(/(?<=\u103d)\u1037/ ,"\u1095")
|
23
|
+
output_text = output_text.gsub(/(?<=\u103d[\u1032])\u1037/ ,"\u1095")
|
24
|
+
output_text = output_text.gsub(/(?<=[\u103b\u103c\u103d])\u102f/ ,"\u1033")
|
25
|
+
output_text = output_text.gsub(/(?<=[\u103b\u103c\u103d][\u102d\u1036])\u102f/ ,"\u1033")
|
26
|
+
output_text = output_text.gsub(/(?<=(\u1039[\u1000-\u1021]))\u102f/ ,"\u1033")
|
27
|
+
output_text = output_text.gsub(/(?<=(\u1039[\u1000-\u1021])[\u102d\u1036])\u102f/ ,"\u1033")
|
28
|
+
output_text = output_text.gsub(/(?<=[\u100a\u100c\u1020\u1025\u1029])\u102f/ ,"\u1033")
|
29
|
+
output_text = output_text.gsub(/(?<=[\u100a\u100c\u1020\u1025\u1029][\u102d\u1036])\u102f/ ,"\u1033")
|
30
|
+
output_text = output_text.gsub(/(?<=[\u103b\u103c])\u1030/ ,"\u1034")
|
31
|
+
output_text = output_text.gsub(/(?<=[\u103b\u103c][\u103d])\u1030/ ,"\u1034")
|
32
|
+
output_text = output_text.gsub(/(?<=[\u103b\u103c][\u103e])\u1030/ ,"\u1034")
|
33
|
+
output_text = output_text.gsub(/(?<=[\u103b\u103c][\u102d\u1036])\u1030/ ,"\u1034")
|
34
|
+
output_text = output_text.gsub(/(?<=[\u103b\u103c][\u103d][\u103e])\u1030/ ,"\u1034")
|
35
|
+
output_text = output_text.gsub(/(?<=[\u103b\u103c][\u103d][\u102d\u1036])\u1030/ ,"\u1034")
|
36
|
+
output_text = output_text.gsub(/(?<=[\u103b\u103c][\u103e][\u102d\u1036])\u1030/ ,"\u1034")
|
37
|
+
output_text = output_text.gsub(/(?<=[\u103b\u103c][\u103d][\u103e][\u102d\u1036])\u1030/ ,"\u1034")
|
38
|
+
output_text = output_text.gsub(/(?<=(\u1039[\u1000-\u1021]))\u1030/ ,"\u1034")
|
39
|
+
output_text = output_text.gsub(/(?<=(\u1039[\u1000-\u1021])[\u102d\u1036])\u1030/ ,"\u1034")
|
40
|
+
output_text = output_text.gsub(/(?<=[\u100a\u100c\u1020\u1025\u1029])\u1030/ ,"\u1034")
|
41
|
+
output_text = output_text.gsub(/(?<=[\u100a\u100c\u1020\u1025\u1029][\u102d\u1036])\u1030/ ,"\u1034")
|
42
|
+
output_text = output_text.gsub(/(?<=\u103c)\u103e/ ,"\u1087")
|
43
|
+
output_text = output_text.gsub(/\u1009(?=[\u103a])/ ,"\u1025")
|
44
|
+
output_text = output_text.gsub(/\u1009(?=\u1039[\u1000-\u1021])/ ,"\u1025")
|
45
|
+
output_text = output_text.gsub(/([\u1000-\u1021\u1029])((?:\u1039[\u1000-\u1021])?)((?:[\u103b-\u103e\u1087]*)?)\u1031/ ,"\u1031\\1\\2\\3")
|
46
|
+
output_text = output_text.gsub(/([\u1000-\u1021\u1029])((?:\u1039[\u1000-\u1021\u1000-\u1021])?)(\u103c)/ ,"\\3\\1\\2")
|
47
|
+
output_text = output_text.gsub(/\u1004\u103a\u1039/ ,"\u1064")
|
48
|
+
output_text = output_text.gsub(/(\u1064)((?:\u1031)?)((?:\u103c)?)([\u1000-\u1021])\u102d/ ,"\\2\\3\\4\u108b")
|
49
|
+
output_text = output_text.gsub(/(\u1064)((?:\u1031)?)((?:\u103c)?)([\u1000-\u1021])\u102e/ ,"\\2\\3\\4\u108c")
|
50
|
+
output_text = output_text.gsub(/(\u1064)((?:\u1031)?)((?:\u103c)?)([\u1000-\u1021])\u1036/ ,"\\2\\3\\4\u108d")
|
51
|
+
output_text = output_text.gsub(/(\u1064)((?:\u1031)?)((?:\u103c)?)([\u1000-\u1021])/ ,"\\2\\3\\4\u1064")
|
52
|
+
output_text = output_text.gsub(/\u100a(?=[\u1039\u102f\u1030])/ ,"\u106b")
|
53
|
+
output_text = output_text.gsub(/\u100a/ ,"\u100a")
|
54
|
+
output_text = output_text.gsub(/\u101b(?=[\u102f\u1030])/ ,"\u1090")
|
55
|
+
output_text = output_text.gsub(/\u101b/ ,"\u101b")
|
56
|
+
output_text = output_text.gsub(/\u1014(?=[\u1039\u103d\u103e\u102f\u1030])/ ,"\u108f")
|
57
|
+
output_text = output_text.gsub(/\u1014/ ,"\u1014")
|
58
|
+
output_text = output_text.gsub(/\u1039\u1000/ ,"\u1060")
|
59
|
+
output_text = output_text.gsub(/\u1039\u1001/ ,"\u1061")
|
60
|
+
output_text = output_text.gsub(/\u1039\u1002/ ,"\u1062")
|
61
|
+
output_text = output_text.gsub(/\u1039\u1003/ ,"\u1063")
|
62
|
+
output_text = output_text.gsub(/\u1039\u1005/ ,"\u1065")
|
63
|
+
output_text = output_text.gsub(/\u1039\u1006/ ,"\u1066")
|
64
|
+
output_text = output_text.gsub(/(?<=[\u1001\u1002\u1004\u1005\u1007\u1012\u1013\u108f\u1015\u1016\u1017\u1019\u101d])\u1066/ ,"\u1067")
|
65
|
+
output_text = output_text.gsub(/\u1039\u1007/ ,"\u1068")
|
66
|
+
output_text = output_text.gsub(/\u1039\u1008/ ,"\u1069")
|
67
|
+
output_text = output_text.gsub(/\u1039\u100f/ ,"\u1070")
|
68
|
+
output_text = output_text.gsub(/\u1039\u1010/ ,"\u1071")
|
69
|
+
output_text = output_text.gsub(/(?<=[\u1001\u1002\u1004\u1005\u1007\u1012\u1013\u108f\u1015\u1016\u1017\u1019\u101d])\u1071/ ,"\u1072")
|
70
|
+
output_text = output_text.gsub(/\u1039\u1011/ ,"\u1073")
|
71
|
+
output_text = output_text.gsub(/(?<=[\u1001\u1002\u1004\u1005\u1007\u1012\u1013\u108f\u1015\u1016\u1017\u1019\u101d])\u1073/ ,"\u1074")
|
72
|
+
output_text = output_text.gsub(/\u1039\u1012/ ,"\u1075")
|
73
|
+
output_text = output_text.gsub(/\u1039\u1013/ ,"\u1076")
|
74
|
+
output_text = output_text.gsub(/\u1039\u1014/ ,"\u1077")
|
75
|
+
output_text = output_text.gsub(/\u1039\u1015/ ,"\u1078")
|
76
|
+
output_text = output_text.gsub(/\u1039\u1016/ ,"\u1079")
|
77
|
+
output_text = output_text.gsub(/\u1039\u1017/ ,"\u107a")
|
78
|
+
output_text = output_text.gsub(/\u1039\u1018/ ,"\u107b")
|
79
|
+
output_text = output_text.gsub(/\u1039\u1019/ ,"\u107c")
|
80
|
+
output_text = output_text.gsub(/\u1039\u101c/ ,"\u1085")
|
81
|
+
output_text = output_text.gsub(/\u100f\u1039\u100d/ ,"\u1091")
|
82
|
+
output_text = output_text.gsub(/\u100b\u1039\u100c/ ,"\u1092")
|
83
|
+
output_text = output_text.gsub(/\u1039\u100c/ ,"\u106d")
|
84
|
+
output_text = output_text.gsub(/\u100b\u1039\u100b/ ,"\u1097")
|
85
|
+
output_text = output_text.gsub(/\u1039\u100b/ ,"\u106c")
|
86
|
+
output_text = output_text.gsub(/\u100e\u1039\u100d/ ,"\u106f")
|
87
|
+
output_text = output_text.gsub(/\u100d\u1039\u100d/ ,"\u106e")
|
88
|
+
output_text = output_text.gsub(/\u1009(?=\u103a)/ ,"\u1025")
|
89
|
+
output_text = output_text.gsub(/\u1025(?=[\u1039\u102f\u1030])/ ,"\u106a")
|
90
|
+
output_text = output_text.gsub(/\u1025/ ,"\u1025")
|
91
|
+
output_text = output_text.gsub(/\u103a/ ,"\u1039")
|
92
|
+
output_text = output_text.gsub(/\u103b\u103d\u103e/ ,"\u107d\u108a")
|
93
|
+
output_text = output_text.gsub(/\u103d\u103e/ ,"\u108a")
|
94
|
+
output_text = output_text.gsub(/\u103b/ ,"\u103a")
|
95
|
+
output_text = output_text.gsub(/\u103c/ ,"\u103b")
|
96
|
+
output_text = output_text.gsub(/\u103d/ ,"\u103c")
|
97
|
+
output_text = output_text.gsub(/\u103e/ ,"\u103d")
|
98
|
+
output_text = output_text.gsub(/\u103a(?=[\u103c\u103d\u108a])/ ,"\u107d")
|
99
|
+
output_text = output_text.gsub(/(?<=\u100a(?:[\u102d\u102e\u1036\u108b\u108c\u108d\u108e]))\u103d/ ,"\u1087")
|
100
|
+
output_text = output_text.gsub(/(?<=\u100a)\u103d/ ,"\u1087")
|
101
|
+
output_text = output_text.gsub(/\u103b(?=[\u1000\u1003\u1006\u100f\u1010\u1011\u1018\u101a\u101c\u101e\u101f\u1021])/ ,"\u107e")
|
102
|
+
output_text = output_text.gsub(/\u107e([\u1000-\u1021\u108f])(?=[\u102d\u102e\u1036\u108b\u108c\u108d\u108e])/ ,"\u1080\\1")
|
103
|
+
output_text = output_text.gsub(/\u107e([\u1000-\u1021\u108f])(?=[\u103c\u108a])/ ,"\u1082\\1")
|
104
|
+
output_text = output_text.gsub(/\u103b([\u1000-\u1021\u108f])(?=[\u102d\u102e\u1036\u108b\u108c\u108d\u108e])/ ,"\u107f\\1")
|
105
|
+
output_text = output_text.gsub(/\u103b([\u1000-\u1021\u108f])(?=[\u103c\u108a])/ ,"\u1081\\1")
|
106
|
+
output_text = output_text.gsub(/(?<=\u1014)\u1037/ ,"\u1094")
|
107
|
+
output_text = output_text.gsub(/(?<=\u1014[\u103a\u1032])\u1037/ ,"\u1094")
|
108
|
+
output_text = output_text.gsub(/(?<=\u1033)\u1094/ ,"\u1095")
|
109
|
+
output_text = output_text.gsub(/(?<=\u1033[\u1036])\u1094/ ,"\u1095")
|
110
|
+
output_text = output_text.gsub(/(?<=\u1034)\u1094/ ,"\u1095")
|
111
|
+
output_text = output_text.gsub(/(?<=\u1034[\u1036])\u1094/ ,"\u1095")
|
112
|
+
output_text = output_text.gsub(/(?<=[\u103c\u103d\u108a])\u1037/ ,"\u1095")
|
113
|
+
output_text = output_text.gsub(/(?<=[\u103c\u103d\u108a][\u1032])\u1037/ ,"\u1095")
|
114
|
+
# "return" is not necessary but it"s there to prevent "end" from auto-indent
|
115
|
+
return output_text
|
116
|
+
end
|
117
|
+
|
118
|
+
def zg12uni51(input_text)
|
119
|
+
return input_text unless detect_font(input_text) == :zawgyi
|
120
|
+
output_text = input_text
|
121
|
+
output_text = output_text.gsub(/\u106a/ ,"\u1009")
|
122
|
+
output_text = output_text.gsub(/\u1025(?=[\u1039\u102c])/ ,"\u1009")
|
123
|
+
output_text = output_text.gsub(/\u1025\u102e/ ,"\u1026")
|
124
|
+
output_text = output_text.gsub(/\u106b/ ,"\u100a")
|
125
|
+
output_text = output_text.gsub(/\u1090/ ,"\u101b")
|
126
|
+
output_text = output_text.gsub(/\u1040/ ,"\u1040")
|
127
|
+
output_text = output_text.gsub(/\u108f/ ,"\u1014")
|
128
|
+
output_text = output_text.gsub(/\u1012/ ,"\u1012")
|
129
|
+
output_text = output_text.gsub(/\u1013/ ,"\u1013")
|
130
|
+
output_text = output_text.gsub(/[\u103d\u1087]/ ,"\u103d")
|
131
|
+
output_text = output_text.gsub(/\u103c/ ,"\u103d")
|
132
|
+
output_text = output_text.gsub(/[\u103b\u107e\u107f\u1080\u1081\u1082\u1083\u1084]/ ,"\u103c")
|
133
|
+
output_text = output_text.gsub(/[\u103a\u107d]/ ,"\u103b")
|
134
|
+
output_text = output_text.gsub(/\u103d\u103b/ ,"\u103b\u103d")
|
135
|
+
output_text = output_text.gsub(/\u108a/ ,"\u103d\u103d")
|
136
|
+
output_text = output_text.gsub(/\u103d\u103d/ ,"\u103d\u103d")
|
137
|
+
output_text = output_text.gsub(/((?:\u1031)?)((?:\u103c)?)([\u1000-\u1021])\u1064/ ,"\u1064\\1\\2\\3")
|
138
|
+
output_text = output_text.gsub(/((?:\u1031)?)((?:\u103c)?)([\u1000-\u1021])\u108b/ ,"\u1064\\1\\2\\3\u102d")
|
139
|
+
output_text = output_text.gsub(/((?:\u1031)?)((?:\u103c)?)([\u1000-\u1021])\u108c/ ,"\u1064\\1\\2\\3\u102e")
|
140
|
+
output_text = output_text.gsub(/((?:\u1031)?)((?:\u103c)?)([\u1000-\u1021])\u108d/ ,"\u1064\\1\\2\\3\u1036")
|
141
|
+
output_text = output_text.gsub(/\u105a/ ,"\u102b\u103a")
|
142
|
+
output_text = output_text.gsub(/\u108e/ ,"\u102d\u1036")
|
143
|
+
output_text = output_text.gsub(/\u1033/ ,"\u102f")
|
144
|
+
output_text = output_text.gsub(/\u1034/ ,"\u1030")
|
145
|
+
output_text = output_text.gsub(/\u1088/ ,"\u103d\u102f")
|
146
|
+
output_text = output_text.gsub(/\u1089/ ,"\u103d\u1030")
|
147
|
+
output_text = output_text.gsub(/\u1039/ ,"\u103a")
|
148
|
+
output_text = output_text.gsub(/[\u1094\u1095]/ ,"\u1037")
|
149
|
+
output_text = output_text.gsub(/([\u1000-\u1021])([\u102c\u102d\u102e\u1032\u1036]){1,2}([\u1060\u1061\u1062\u1063\u1065\u1066\u1067\u1068\u1069\u1070\u1071\u1072\u1073\u1074\u1075\u1076\u1077\u1078\u1079\u107a\u107b\u107c\u1085])/ ,"\\1\\3\\2")
|
150
|
+
output_text = output_text.gsub(/\u1064/ ,"\u1004\u103a\u1039")
|
151
|
+
output_text = output_text.gsub(/\u104e/ ,"\u104e\u1004\u103a\u1038")
|
152
|
+
output_text = output_text.gsub(/\u1086/ ,"\u103f")
|
153
|
+
output_text = output_text.gsub(/\u1060/ ,"\u1039\u1000")
|
154
|
+
output_text = output_text.gsub(/\u1061/ ,"\u1039\u1001")
|
155
|
+
output_text = output_text.gsub(/\u1062/ ,"\u1039\u1002")
|
156
|
+
output_text = output_text.gsub(/\u1063/ ,"\u1039\u1003")
|
157
|
+
output_text = output_text.gsub(/\u1065/ ,"\u1039\u1005")
|
158
|
+
output_text = output_text.gsub(/[\u1066\u1067]/ ,"\u1039\u1006")
|
159
|
+
output_text = output_text.gsub(/\u1068/ ,"\u1039\u1007")
|
160
|
+
output_text = output_text.gsub(/\u1069/ ,"\u1039\u1008")
|
161
|
+
output_text = output_text.gsub(/\u106c/ ,"\u1039\u100b")
|
162
|
+
output_text = output_text.gsub(/\u1070/ ,"\u1039\u100f")
|
163
|
+
output_text = output_text.gsub(/[\u1071\u1072]/ ,"\u1039\u1010")
|
164
|
+
output_text = output_text.gsub(/[\u1073\u1074]/ ,"\u1039\u1011")
|
165
|
+
output_text = output_text.gsub(/\u1075/ ,"\u1039\u1012")
|
166
|
+
output_text = output_text.gsub(/\u1076/ ,"\u1039\u1013")
|
167
|
+
output_text = output_text.gsub(/\u1077/ ,"\u1039\u1014")
|
168
|
+
output_text = output_text.gsub(/\u1078/ ,"\u1039\u1015")
|
169
|
+
output_text = output_text.gsub(/\u1079/ ,"\u1039\u1016")
|
170
|
+
output_text = output_text.gsub(/\u107a/ ,"\u1039\u1017")
|
171
|
+
output_text = output_text.gsub(/\u107b/ ,"\u1039\u1018")
|
172
|
+
output_text = output_text.gsub(/\u107c/ ,"\u1039\u1019")
|
173
|
+
output_text = output_text.gsub(/\u1085/ ,"\u1039\u101c")
|
174
|
+
output_text = output_text.gsub(/\u106d/ ,"\u1039\u100c")
|
175
|
+
output_text = output_text.gsub(/\u1091/ ,"\u100f\u1039\u100d")
|
176
|
+
output_text = output_text.gsub(/\u1092/ ,"\u100b\u1039\u100c")
|
177
|
+
output_text = output_text.gsub(/\u1097/ ,"\u100b\u1039\u100b")
|
178
|
+
output_text = output_text.gsub(/\u106f/ ,"\u100e\u1039\u100d")
|
179
|
+
output_text = output_text.gsub(/\u106e/ ,"\u100d\u1039\u100d")
|
180
|
+
output_text = output_text.gsub(/(\u103c)([\u1000-\u1021])((?:\u1039[\u1000-\u1021])?)/ ,"\\2\\3\\1")
|
181
|
+
output_text = output_text.gsub(/(\u103d)(\u103d)([\u103b\u103c])/ ,"\\3\\2\\1")
|
182
|
+
output_text = output_text.gsub(/(\u103d)([\u103b\u103c])/ ,"\\2\\1")
|
183
|
+
output_text = output_text.gsub(/(\u103d)([\u103b\u103c])/ ,"\\2\\1")
|
184
|
+
output_text = output_text.gsub(/(?<=([\u1000-\u101c\u101e-\u102a\u102c\u102e-\u103d\u104c-\u109f]))(\u1040)(?=\s)?/ ,"\u101d")
|
185
|
+
output_text = output_text.gsub(/(?<=(\u101d))(\u1040)(?=\s)?/ ,"\u101d")
|
186
|
+
output_text = output_text.gsub(/(?<=([\u1000-\u101c\u101e-\u102a\u102c\u102e-\u103d\u104c-\u109f\s]))(\u1047)/ ,"\u101b")
|
187
|
+
output_text = output_text.gsub(/(\u1047)(?=[\u1000-\u101c\u101e-\u102a\u102c\u102e-\u103d\u104c-\u109f\s])/ ,"\u101b")
|
188
|
+
output_text = output_text.gsub(/((?:\u1031)?)([\u1000-\u1021])((?:\u1039[\u1000-\u1021])?)((?:[\u102d\u102e\u1032])?)([\u1036\u1037\u1038]{0,2})([\u103b-\u103d]{0,3})((?:[\u102f\u1030])?)([\u1036\u1037\u1038]{0,2})((?:[\u102d\u102e\u1032])?)/ ,"\\2\\3\\6\\1\\4\\9\\7\\5\\8")
|
189
|
+
output_text = output_text.gsub(/\u1036\u102f/ ,"\u102f\u1036")
|
190
|
+
output_text = output_text.gsub(/(\u103a)(\u1037)/ ,"\\2\\1")
|
191
|
+
# "return" is not necessary but it"s there to prevent "end" from auto-indent
|
192
|
+
return output_text
|
193
|
+
end
|
194
|
+
|
195
|
+
def detect_font(input_text)
|
196
|
+
return nil if input_text.nil?
|
197
|
+
whitespace = "[\s\t\n]"
|
198
|
+
priorities = {zawgyi: 2, uni: 1, eng: 3}
|
199
|
+
#Font Detecting Library
|
200
|
+
detect = {
|
201
|
+
uni: [
|
202
|
+
"ှ", "ဿ", "ည်", "န်", "င်", "ေး", "ော",
|
203
|
+
"်း", "ဵ", "[ၐ-ၙ]", "^([က-အ]ြ|[က-အ]ေ)"
|
204
|
+
],
|
205
|
+
zawgyi: [
|
206
|
+
"ာ္", "်ာ", whitespace+"(ျ|ေ|[ၾ-ႄ])[က-အ]",
|
207
|
+
"^(ျ|ေ|[ၾ-ႄ])[က-အ]", "[က-အ]္[^က-အ]", "ဥ္",
|
208
|
+
"္း" ,"[ါ-ူေ်း](ျ|[ၾ-ႄ])[က-အ]" ,"ံု",
|
209
|
+
"[က-အ]္ေ" , "ၤ","္"+whitespace, "ာေ",
|
210
|
+
"[ါ-ူ်း]ေ[က-အ]", "ေေ", "ုိ", "္$"
|
211
|
+
],
|
212
|
+
eng: ["A-Za-z0-9"]
|
213
|
+
}
|
214
|
+
# With codepoints
|
215
|
+
# detect = {
|
216
|
+
# unicode: [
|
217
|
+
# "\\u103e", "\\u103f", "\\u100a\\u103a", "\\u1014\\u103a", "\\u1004\\u103a", "\\u1031\\u1038", "\\u1031\\u102c",
|
218
|
+
# "\\u103a\\u1038", "\\u1035", "[\\u1050-\\u1059]", "^([\\u1000-\\u1021]\\u103c|[\\u1000-\\u1021]\\u1031)"
|
219
|
+
# ],
|
220
|
+
# zawgyi: [
|
221
|
+
# "\\u102c\\u1039", "\\u103a\\u102c", whitespace+"(\\u103b|\\u1031|[\\u107e-\\u1084])[\\u1000-\\u1021]","^(\\u103b|\\u1031|[\\u107e-\\u1084])[\\u1000-\\u1021]", "[\\u1000-\\u1021]\\u1039[^\\u1000-\\u1021]", "\\u1025\\u1039","\\u1039\\u1038" ,"[\\u102b-\\u1030\\u1031\\u103a\\u1038](\\u103b|[\\u107e-\\u1084])[\\u1000-\\u1021]" ,"\\u1036\\u102f","[\\u1000-\\u1021]\\u1039\\u1031" , "\\u1064","\\u1039"+whitespace, "\\u102c\\u1031","[\\u102b-\\u1030\\u103a\\u1038]\\u1031[\\u1000-\\u1021]", "\\u1031\\u1031", "\\u102f\\u102d", "\\u1039"
|
222
|
+
# ]
|
223
|
+
# };
|
224
|
+
|
225
|
+
match = input_text.match(/[\u1000-\u1097]/);
|
226
|
+
|
227
|
+
return nil unless match
|
228
|
+
|
229
|
+
result = []
|
230
|
+
detect.each_key do|font_name|
|
231
|
+
count = 0
|
232
|
+
detect[font_name].each do|rule|
|
233
|
+
match_data = input_text.match(/#{rule}/).to_a
|
234
|
+
count += match_data.count if match_data
|
235
|
+
end
|
236
|
+
result.push({name: font_name, count: count,priority: priorities[font_name]})
|
237
|
+
end
|
238
|
+
result.sort_by! {|p| [p[:count],p[:priority]]}.reverse!
|
239
|
+
result.first[:name]
|
240
|
+
end
|
241
|
+
end
|
242
|
+
module ActiveRecordMacro
|
243
|
+
module ClassMethods
|
244
|
+
def mmunicode_convert(*fields)
|
245
|
+
fields.each do |field|
|
246
|
+
field_type = self.columns_hash[field.to_s].type
|
247
|
+
unless field_type == :string || field_type == :text then
|
248
|
+
raise NotSupportedForNonStringTypesError.new(field_type),"#{field_type} is not supported.Supported types are :string and :text"
|
249
|
+
end
|
250
|
+
end
|
251
|
+
before_save do
|
252
|
+
fields.each do|field|
|
253
|
+
zg = self.send(field.to_sym)
|
254
|
+
self.send("#{field}=".to_sym,zg12uni51(zg))
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
class NotSupportedForNonStringTypesError < StandardError
|
261
|
+
def initialize(object)
|
262
|
+
@object = object
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
def self.included(receiver)
|
267
|
+
receiver.extend ClassMethods
|
268
|
+
receiver.send :include, MmunicodeRails::Core
|
269
|
+
end
|
270
|
+
|
271
|
+
if defined?(Rails::Railtie)
|
272
|
+
class Railtie < Rails::Railtie
|
273
|
+
initializer 'mmunicode_rails.insert_into_active_record' do
|
274
|
+
ActiveSupport.on_load :active_record do
|
275
|
+
ActiveRecord::Base.send(:include, MmunicodeRails::ActiveRecordMacro)
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
else
|
280
|
+
ActiveRecord::Base.send(:include, MmunicodeRails::ActiveRecordMacro) if defined?(ActiveRecord)
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
class RackMmunicode
|
285
|
+
include MmunicodeRails::Core
|
286
|
+
|
287
|
+
def initialize(app)
|
288
|
+
@app = app
|
289
|
+
end
|
290
|
+
|
291
|
+
def call(env)
|
292
|
+
request = Rack::Request.new env
|
293
|
+
converted_params = []
|
294
|
+
request.params.each_pair do|key,value|
|
295
|
+
puts "#{key}: #{value}"
|
296
|
+
end
|
297
|
+
converted_params = nested_param_traversal(request.params)
|
298
|
+
|
299
|
+
converted_params.each_pair do|key,value|
|
300
|
+
puts "#{key}: #{value}"
|
301
|
+
request.update_param(key, value)
|
302
|
+
end
|
303
|
+
@app.call(env)
|
304
|
+
end
|
305
|
+
|
306
|
+
private
|
307
|
+
def nested_param_traversal(param,&block)
|
308
|
+
if param.respond_to? :each_pair
|
309
|
+
param.each_pair do|k,v|
|
310
|
+
param[k] = nested_param_traversal(v)
|
311
|
+
end
|
312
|
+
else
|
313
|
+
zg12uni51(param)
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
|
320
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mmunicode_rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "mmunicode_rails"
|
8
|
+
spec.version = MmunicodeRails::VERSION
|
9
|
+
spec.authors = ["dreamingblackcat"]
|
10
|
+
spec.email = ["dreamingblackcat10@gmail.com"]
|
11
|
+
spec.summary = %q{A gem that provide converting of your rails app input contents from zawgyi to unicode(conflicted fonts in myanmar country)}
|
12
|
+
spec.description = %q{mmunicode_rails lets you convert you rails app input data to Myanmar Unicode regardless of which fonts the users used.}
|
13
|
+
spec.homepage = "https://github.com/dreamingblackcat/mmunicode_rails"
|
14
|
+
spec.license = "GPL"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "minitest", "~>5.0"
|
24
|
+
spec.add_development_dependency 'activerecord', '~> 3.0'
|
25
|
+
spec.add_development_dependency 'sqlite3', "~>1.3.5"
|
26
|
+
spec.add_runtime_dependency 'rack', ">1.4.5"
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require_relative "spec_helper.rb"
|
2
|
+
require "minitest/autorun"
|
3
|
+
|
4
|
+
|
5
|
+
describe MmunicodeRails::ActiveRecordMacro do
|
6
|
+
|
7
|
+
let(:data) do
|
8
|
+
{
|
9
|
+
zawgyi_title: "ဒါဟာေဇာ္ဂ်ီ",
|
10
|
+
unicode_title: "ဒါဟာဇော်ဂျီ",
|
11
|
+
mixed_title: "ဒဒါဟာေဇာ္ဂ်ီါဟာဇော်ဂျီ",
|
12
|
+
zawgyi_body: "ယူနီကုတ္လားဗ်",
|
13
|
+
unicode_body: "ယူနီကုတ်လားဗျ",
|
14
|
+
mixed_body: "ယူနီကုတ္လားဗ်ယူနီကုတ်လားဗျ"
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:post) {Post.new({title: data[:zawgyi_title],body: data[:unicode_body]})}
|
19
|
+
|
20
|
+
it "adds the #mmunicode_convert method to the included class" do
|
21
|
+
Post.must_respond_to :mmunicode_convert
|
22
|
+
end
|
23
|
+
|
24
|
+
it "raise error if the field_types are not text or string" do
|
25
|
+
-> {
|
26
|
+
class Book < ActiveRecord::Base
|
27
|
+
mmunicode_convert :age
|
28
|
+
end
|
29
|
+
}.must_raise MmunicodeRails::ActiveRecordMacro::NotSupportedForNonStringTypesError
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "Converting Inputs" do
|
33
|
+
it "converts zawgyi inputs correctly" do
|
34
|
+
Post.new({title: data[:zawgyi_title],body: data[:unicode_body]})
|
35
|
+
post.save!
|
36
|
+
post.title.must_equal data[:unicode_title]
|
37
|
+
post.body.must_equal data[:unicode_body]
|
38
|
+
end
|
39
|
+
it "converts unicode inputs correctly" do
|
40
|
+
Post.new({title: data[:unicode_title],body: data[:unicode_body]})
|
41
|
+
post.save!
|
42
|
+
post.title.must_equal data[:unicode_title]
|
43
|
+
post.body.must_equal data[:unicode_body]
|
44
|
+
end
|
45
|
+
it "converts mixed zawgyi and unicode inputs correctly" do
|
46
|
+
Post.new({title: data[:mixed_title],body: data[:mixed_body]})
|
47
|
+
post.save!
|
48
|
+
post.title.must_equal data[:unicode_title]
|
49
|
+
post.body.must_equal data[:unicode_body]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require_relative "../lib/mmunicode_rails.rb"
|
3
|
+
require 'sqlite3'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
|
7
|
+
|
8
|
+
# Create a demo table
|
9
|
+
ActiveRecord::Schema.define(:version => 0) do
|
10
|
+
create_table :posts do |t|
|
11
|
+
t.text :body
|
12
|
+
t.string :title
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
ActiveRecord::Schema.define(:version => 0) do
|
17
|
+
create_table :books do |t|
|
18
|
+
t.text :author
|
19
|
+
t.string :title
|
20
|
+
t.integer :age
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Post < ActiveRecord::Base
|
25
|
+
|
26
|
+
mmunicode_convert :title,:body
|
27
|
+
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mmunicode_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- dreamingblackcat
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activerecord
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sqlite3
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.3.5
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.3.5
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rack
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.4.5
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.4.5
|
97
|
+
description: mmunicode_rails lets you convert you rails app input data to Myanmar
|
98
|
+
Unicode regardless of which fonts the users used.
|
99
|
+
email:
|
100
|
+
- dreamingblackcat10@gmail.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- lib/generators/mmunicode_rails/initializer_generator.rb
|
111
|
+
- lib/generators/templates/mmunicode_rails.rb
|
112
|
+
- lib/mmunicode_rails.rb
|
113
|
+
- lib/mmunicode_rails/version.rb
|
114
|
+
- mmunicode_rails.gemspec
|
115
|
+
- spec/mmunicode_rails_spec.rb
|
116
|
+
- spec/spec_helper.rb
|
117
|
+
homepage: https://github.com/dreamingblackcat/mmunicode_rails
|
118
|
+
licenses:
|
119
|
+
- GPL
|
120
|
+
metadata: {}
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 2.4.5
|
138
|
+
signing_key:
|
139
|
+
specification_version: 4
|
140
|
+
summary: A gem that provide converting of your rails app input contents from zawgyi
|
141
|
+
to unicode(conflicted fonts in myanmar country)
|
142
|
+
test_files:
|
143
|
+
- spec/mmunicode_rails_spec.rb
|
144
|
+
- spec/spec_helper.rb
|