multibyte 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.
Files changed (100) hide show
  1. data/.git/COMMIT_EDITMSG +57 -0
  2. data/.git/HEAD +1 -0
  3. data/.git/config +8 -0
  4. data/.git/description +1 -0
  5. data/.git/hooks/applypatch-msg +15 -0
  6. data/.git/hooks/commit-msg +21 -0
  7. data/.git/hooks/post-commit +8 -0
  8. data/.git/hooks/post-receive +16 -0
  9. data/.git/hooks/post-update +8 -0
  10. data/.git/hooks/pre-applypatch +14 -0
  11. data/.git/hooks/pre-commit +70 -0
  12. data/.git/hooks/pre-rebase +150 -0
  13. data/.git/hooks/update +107 -0
  14. data/.git/index +0 -0
  15. data/.git/info/exclude +6 -0
  16. data/.git/logs/HEAD +4 -0
  17. data/.git/logs/refs/heads/master +4 -0
  18. data/.git/logs/refs/remotes/origin/master +3 -0
  19. data/.git/objects/02/e9a792fa31b00f0f06012e0b5e3ef327c40f64 +0 -0
  20. data/.git/objects/10/0b93820ade4c16225673b4ca62bb3ade63c313 +0 -0
  21. data/.git/objects/10/aab6490174970a2349d1050882c644f8d07006 +7 -0
  22. data/.git/objects/11/cda2eaac1ae103a13bf835456de05f53b0c8ad +0 -0
  23. data/.git/objects/1d/61c71cd5cf0f4dae6305b007a6177e1cecd7ea +0 -0
  24. data/.git/objects/2c/84cd00c156ba3b46e733c7e34dd9aea0c4fa75 +0 -0
  25. data/.git/objects/2f/3a16e4a756ec7a2d32c4bd8386b855f41cae61 +0 -0
  26. data/.git/objects/2f/437425b2c085bb529379e409d6b4bc7f9f9fba +0 -0
  27. data/.git/objects/3f/9afe5eaf00ad4d2ffa2e9315b96f530b0e85d4 +2 -0
  28. data/.git/objects/42/4a5f37c6fe3a7cac54b0f85688c1cce7da9cdf +0 -0
  29. data/.git/objects/47/26f03dc598a372cb959e3cbe33334de70802fd +0 -0
  30. data/.git/objects/55/37e6b2a449fe6d6c800803d0f72ffbcf44c297 +0 -0
  31. data/.git/objects/64/334b80d5fcead16f13cb8b7a45120ea460747b +0 -0
  32. data/.git/objects/69/1ed3b65603a0d0dabfb66720e7163664be78f5 +0 -0
  33. data/.git/objects/72/141584a5836168fe912ebce5b4537bd0eafc09 +1 -0
  34. data/.git/objects/7c/e872bc55ff766e542d2fbbe00e9dde70baaa92 +2 -0
  35. data/.git/objects/93/e03faa6906892434fa9f2ad230c4ececc64055 +0 -0
  36. data/.git/objects/9d/c9a787700bafb70e1833a760b73dec26a6a56e +0 -0
  37. data/.git/objects/9f/672edccfaaa00b6584f599c3e68560e6a5bedf +0 -0
  38. data/.git/objects/ab/1cd78b02ec268ce7d2faf4b1692f4bed9273fe +0 -0
  39. data/.git/objects/ad/8866bd33ae1afe9278cf5ee833d71977af561c +0 -0
  40. data/.git/objects/af/c3ea327fa220ee42a5ebecfcc7d218be4ea1d9 +0 -0
  41. data/.git/objects/b2/56d1cf3a9ba99f308daf1b4cd0dd08f11448e0 +1 -0
  42. data/.git/objects/bc/184b885eca1bed875171bd3990433055dda3af +0 -0
  43. data/.git/objects/c2/7f6559350f7adb19d43742b55b2f91d07b6550 +0 -0
  44. data/.git/objects/c3/e7364c6e90fb80e979779cd822bc8cdc8a3790 +0 -0
  45. data/.git/objects/c9/5128ff8f94e949d796afa128f2f341ba69989c +0 -0
  46. data/.git/objects/ce/e1f5b453e86a5aa913c626641608839bb79eef +1 -0
  47. data/.git/objects/cf/6add7ea568d3d90d6a1f8afb0898b0119b14ff +0 -0
  48. data/.git/objects/d5/e18b1fd7b189fdc75dd3bc4d208323cbc01aa8 +0 -0
  49. data/.git/objects/de/6e40dc4d92c1a889f8581718a48f2fcd219442 +0 -0
  50. data/.git/objects/df/42782d610e8c714f78cf0a018c600667da795e +0 -0
  51. data/.git/objects/e0/65ff01f0883142d4901a371be8dc60998fbe04 +4 -0
  52. data/.git/objects/e1/ad06969c3d3982b06ebd7da3777a0926501e7c +0 -0
  53. data/.git/objects/e4/69154c2ae4c3c596870a5e920f197b7b5be179 +2 -0
  54. data/.git/objects/e4/8464df56bf487e96e21ea99487330266dae3c9 +0 -0
  55. data/.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
  56. data/.git/objects/e8/517350dbaadcb01282282218638c6022a20091 +0 -0
  57. data/.git/objects/eb/1bffe6adda4dc202d219cb35fe142a5e42b46b +0 -0
  58. data/.git/objects/eb/5d1c06d3a469df91dff68022b3b179e30cd127 +0 -0
  59. data/.git/objects/ec/f2f7e20cd14b0d4b5c0b7d0450aafc8c4f7066 +0 -0
  60. data/.git/objects/f1/ca0626d3e5dfcf88df23c9720d6f770fcbef73 +0 -0
  61. data/.git/objects/f2/3c73e1110a2fec82d37a1a399b9f274d30f0fe +0 -0
  62. data/.git/objects/f2/aec2820bf2f1c87c031d4abe262560392ac4b9 +0 -0
  63. data/.git/objects/f8/73dae66e0208669dbf74718181b3866647f426 +0 -0
  64. data/.git/refs/heads/master +1 -0
  65. data/.git/refs/remotes/origin/master +1 -0
  66. data/History.txt +4 -0
  67. data/License.txt +20 -0
  68. data/Manifest.txt +97 -0
  69. data/README.txt +19 -0
  70. data/Rakefile +4 -0
  71. data/config/hoe.rb +70 -0
  72. data/config/requirements.rb +17 -0
  73. data/lib/multibyte/chars.rb +135 -0
  74. data/lib/multibyte/generators/generate_tables.rb +145 -0
  75. data/lib/multibyte/handlers/passthru_handler.rb +9 -0
  76. data/lib/multibyte/handlers/utf8_handler.rb +564 -0
  77. data/lib/multibyte/handlers/utf8_handler_proc.rb +43 -0
  78. data/lib/multibyte/version.rb +9 -0
  79. data/lib/multibyte.rb +15 -0
  80. data/lib/unicode.rb +66 -0
  81. data/log/debug.log +0 -0
  82. data/script/destroy +14 -0
  83. data/script/generate +14 -0
  84. data/script/txt2html +74 -0
  85. data/setup.rb +1585 -0
  86. data/spec/multibyte_spec.rb +11 -0
  87. data/spec/spec.opts +1 -0
  88. data/spec/spec_helper.rb +7 -0
  89. data/tasks/deployment.rake +34 -0
  90. data/tasks/environment.rake +7 -0
  91. data/tasks/rspec.rake +21 -0
  92. data/tasks/website.rake +17 -0
  93. data/website/index.html +11 -0
  94. data/website/index.txt +39 -0
  95. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  96. data/website/stylesheets/screen.css +138 -0
  97. data/website/template.rhtml +48 -0
  98. data.tar.gz.sig +3 -0
  99. metadata +176 -0
  100. metadata.gz.sig +0 -0
data/.git/index ADDED
Binary file
data/.git/info/exclude ADDED
@@ -0,0 +1,6 @@
1
+ # git-ls-files --others --exclude-from=.git/info/exclude
2
+ # Lines that start with '#' are comments.
3
+ # For a project mostly in C, the following would be a good set of
4
+ # exclude patterns (uncomment them if you want to use them):
5
+ # *.[oa]
6
+ # *~
data/.git/logs/HEAD ADDED
@@ -0,0 +1,4 @@
1
+ 0000000000000000000000000000000000000000 e1ad06969c3d3982b06ebd7da3777a0926501e7c Matt Aimonetti <mattaimonetti@gmail.com> 1211959957 -0700 commit (initial): first commit
2
+ e1ad06969c3d3982b06ebd7da3777a0926501e7c d98f6f6626e3b2adfe405f696d2b805a843f110a Matt Aimonetti <mattaimonetti@gmail.com> 1211962430 -0700 commit: added unicode.rb and setup $KCODE= 'u'
3
+ d98f6f6626e3b2adfe405f696d2b805a843f110a 49b70db84e27b4600c96df53010a13f99d86c418 Matt Aimonetti <mattaimonetti@gmail.com> 1212013709 -0700 commit: first working version
4
+ 49b70db84e27b4600c96df53010a13f99d86c418 34eb733bebc3ef62abf7bae465fd7db5a6bd5b0f Matt Aimonetti <mattaimonetti@gmail.com> 1212014068 -0700 commit: added readme + github gemspec
@@ -0,0 +1,4 @@
1
+ 0000000000000000000000000000000000000000 e1ad06969c3d3982b06ebd7da3777a0926501e7c Matt Aimonetti <mattaimonetti@gmail.com> 1211959957 -0700 commit (initial): first commit
2
+ e1ad06969c3d3982b06ebd7da3777a0926501e7c d98f6f6626e3b2adfe405f696d2b805a843f110a Matt Aimonetti <mattaimonetti@gmail.com> 1211962430 -0700 commit: added unicode.rb and setup $KCODE= 'u'
3
+ d98f6f6626e3b2adfe405f696d2b805a843f110a 49b70db84e27b4600c96df53010a13f99d86c418 Matt Aimonetti <mattaimonetti@gmail.com> 1212013709 -0700 commit: first working version
4
+ 49b70db84e27b4600c96df53010a13f99d86c418 34eb733bebc3ef62abf7bae465fd7db5a6bd5b0f Matt Aimonetti <mattaimonetti@gmail.com> 1212014068 -0700 commit: added readme + github gemspec
@@ -0,0 +1,3 @@
1
+ 0000000000000000000000000000000000000000 e1ad06969c3d3982b06ebd7da3777a0926501e7c Matt Aimonetti <matta@matta.(none)> 1211959959 -0700 update by push
2
+ e1ad06969c3d3982b06ebd7da3777a0926501e7c d98f6f6626e3b2adfe405f696d2b805a843f110a Matt Aimonetti <matta@matta.(none)> 1211962460 -0700 update by push
3
+ d98f6f6626e3b2adfe405f696d2b805a843f110a 34eb733bebc3ef62abf7bae465fd7db5a6bd5b0f Matt Aimonetti <matta@matta.(none)> 1212014088 -0700 update by push
@@ -0,0 +1,7 @@
1
+ x]R[k�0޳�!O-�� ��[i���J�<�"��,y��~G�et0��w=�S÷�/_s����w��<����X��
2
+ nOp֮7��IY7��s�8� s�=ܞ}�WX�|������hZ���
3
+ �Ns=h��Q�=u=;����Q�Ga��f��7d��;d��.̠J�ݠ����{���s����%�t��,(�V��,�yg���1J���y��(��T��
4
+ Y.��C��`����+�^��R�b����͵u�x�ݟ�������k
5
+ e��;"(�
6
+ ������ %�1�\�[ 8!�{�W@�~1��}/-K��M�1���x�mS�_a�8�K�؆I$�9x�+��[E*�52�%˘������s���@A�d�6#��(�|�3��B7��'TE)�ox�rM�,H�-��_�{�^��y�R�\�(cd�ы�J2�61�dC^�;9��n���
7
+ ���ra'IΥ�c�)��Cw��1�J_�J�H��D��{�_up}���¶��%�$C.\�4��t�S
@@ -0,0 +1,2 @@
1
+ xU��
2
+ �0E]�+� �.
@@ -0,0 +1 @@
1
+ x+)JMU05e040031Q(�/�KIM�O�/�K-*���,I���K��*fX��Q�"�wNK_��s���>��7�}
@@ -0,0 +1,2 @@
1
+ x+)JMU04�`040031Q(H,..�(*��H�K�I-�+Jbx����C��ӕ R��/�$����U^Z�f��4�ػ��W�OwW�
2
+ �-I(�Ƣ4��(?d���E��H=d^h���5�A|��kȾ9�
@@ -0,0 +1 @@
1
+ xm��j�0D{�W ��
@@ -0,0 +1 @@
1
+ xMOAj�0�ٯ�(�4l��B�z�]X�$^P,g%���������̺���'�}%�X{ѡ�������n�;l�4��=�H��m�j�O�9��s� '�ʦ�y|m]�Nn�D��.��<S���ڎ��4�JI�����{I�ڐ�KDv9����$�6�üi*��`�*���U~�/�~{R�
@@ -0,0 +1,4 @@
1
+ xUOMKA �����
2
+ �Pԋ̱�"�(~�ev'�30ɲ���*$!���� � ����h���
3
+ f!��$��C��%��y�����\B
4
+ -�>�k���_ ��;E�)1��?�������Œ�S����Ÿ��Ļ���˜5
@@ -0,0 +1,2 @@
1
+ x]��
2
+ �0F�y�)4����� ��چ������ݥ��vN���x�%~U��������̱d���
@@ -0,0 +1 @@
1
+ 34eb733bebc3ef62abf7bae465fd7db5a6bd5b0f
@@ -0,0 +1 @@
1
+ 34eb733bebc3ef62abf7bae465fd7db5a6bd5b0f
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 0.0.1 2008-05-28
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/License.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2005-2008 David Heinemeier Hansson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,97 @@
1
+ .git/COMMIT_EDITMSG
2
+ .git/HEAD
3
+ .git/config
4
+ .git/description
5
+ .git/hooks/applypatch-msg
6
+ .git/hooks/commit-msg
7
+ .git/hooks/post-commit
8
+ .git/hooks/post-receive
9
+ .git/hooks/post-update
10
+ .git/hooks/pre-applypatch
11
+ .git/hooks/pre-commit
12
+ .git/hooks/pre-rebase
13
+ .git/hooks/update
14
+ .git/index
15
+ .git/info/exclude
16
+ .git/logs/HEAD
17
+ .git/logs/refs/heads/master
18
+ .git/logs/refs/remotes/origin/master
19
+ .git/objects/02/e9a792fa31b00f0f06012e0b5e3ef327c40f64
20
+ .git/objects/10/0b93820ade4c16225673b4ca62bb3ade63c313
21
+ .git/objects/10/aab6490174970a2349d1050882c644f8d07006
22
+ .git/objects/11/cda2eaac1ae103a13bf835456de05f53b0c8ad
23
+ .git/objects/1d/61c71cd5cf0f4dae6305b007a6177e1cecd7ea
24
+ .git/objects/2c/84cd00c156ba3b46e733c7e34dd9aea0c4fa75
25
+ .git/objects/2f/3a16e4a756ec7a2d32c4bd8386b855f41cae61
26
+ .git/objects/2f/437425b2c085bb529379e409d6b4bc7f9f9fba
27
+ .git/objects/3f/9afe5eaf00ad4d2ffa2e9315b96f530b0e85d4
28
+ .git/objects/42/4a5f37c6fe3a7cac54b0f85688c1cce7da9cdf
29
+ .git/objects/47/26f03dc598a372cb959e3cbe33334de70802fd
30
+ .git/objects/55/37e6b2a449fe6d6c800803d0f72ffbcf44c297
31
+ .git/objects/64/334b80d5fcead16f13cb8b7a45120ea460747b
32
+ .git/objects/69/1ed3b65603a0d0dabfb66720e7163664be78f5
33
+ .git/objects/72/141584a5836168fe912ebce5b4537bd0eafc09
34
+ .git/objects/7c/e872bc55ff766e542d2fbbe00e9dde70baaa92
35
+ .git/objects/93/e03faa6906892434fa9f2ad230c4ececc64055
36
+ .git/objects/9d/c9a787700bafb70e1833a760b73dec26a6a56e
37
+ .git/objects/9f/672edccfaaa00b6584f599c3e68560e6a5bedf
38
+ .git/objects/ab/1cd78b02ec268ce7d2faf4b1692f4bed9273fe
39
+ .git/objects/ad/8866bd33ae1afe9278cf5ee833d71977af561c
40
+ .git/objects/af/c3ea327fa220ee42a5ebecfcc7d218be4ea1d9
41
+ .git/objects/b2/56d1cf3a9ba99f308daf1b4cd0dd08f11448e0
42
+ .git/objects/bc/184b885eca1bed875171bd3990433055dda3af
43
+ .git/objects/c2/7f6559350f7adb19d43742b55b2f91d07b6550
44
+ .git/objects/c3/e7364c6e90fb80e979779cd822bc8cdc8a3790
45
+ .git/objects/c9/5128ff8f94e949d796afa128f2f341ba69989c
46
+ .git/objects/ce/e1f5b453e86a5aa913c626641608839bb79eef
47
+ .git/objects/cf/6add7ea568d3d90d6a1f8afb0898b0119b14ff
48
+ .git/objects/d5/e18b1fd7b189fdc75dd3bc4d208323cbc01aa8
49
+ .git/objects/de/6e40dc4d92c1a889f8581718a48f2fcd219442
50
+ .git/objects/df/42782d610e8c714f78cf0a018c600667da795e
51
+ .git/objects/e0/65ff01f0883142d4901a371be8dc60998fbe04
52
+ .git/objects/e1/ad06969c3d3982b06ebd7da3777a0926501e7c
53
+ .git/objects/e4/69154c2ae4c3c596870a5e920f197b7b5be179
54
+ .git/objects/e4/8464df56bf487e96e21ea99487330266dae3c9
55
+ .git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
56
+ .git/objects/e8/517350dbaadcb01282282218638c6022a20091
57
+ .git/objects/eb/1bffe6adda4dc202d219cb35fe142a5e42b46b
58
+ .git/objects/eb/5d1c06d3a469df91dff68022b3b179e30cd127
59
+ .git/objects/ec/f2f7e20cd14b0d4b5c0b7d0450aafc8c4f7066
60
+ .git/objects/f1/ca0626d3e5dfcf88df23c9720d6f770fcbef73
61
+ .git/objects/f2/3c73e1110a2fec82d37a1a399b9f274d30f0fe
62
+ .git/objects/f2/aec2820bf2f1c87c031d4abe262560392ac4b9
63
+ .git/objects/f8/73dae66e0208669dbf74718181b3866647f426
64
+ .git/refs/heads/master
65
+ .git/refs/remotes/origin/master
66
+ History.txt
67
+ License.txt
68
+ Manifest.txt
69
+ README.txt
70
+ Rakefile
71
+ config/hoe.rb
72
+ config/requirements.rb
73
+ lib/multibyte.rb
74
+ lib/multibyte/chars.rb
75
+ lib/multibyte/generators/generate_tables.rb
76
+ lib/multibyte/handlers/passthru_handler.rb
77
+ lib/multibyte/handlers/utf8_handler.rb
78
+ lib/multibyte/handlers/utf8_handler_proc.rb
79
+ lib/multibyte/version.rb
80
+ lib/unicode.rb
81
+ log/debug.log
82
+ script/destroy
83
+ script/generate
84
+ script/txt2html
85
+ setup.rb
86
+ spec/multibyte_spec.rb
87
+ spec/spec.opts
88
+ spec/spec_helper.rb
89
+ tasks/deployment.rake
90
+ tasks/environment.rake
91
+ tasks/rspec.rake
92
+ tasks/website.rake
93
+ website/index.html
94
+ website/index.txt
95
+ website/javascripts/rounded_corners_lite.inc.js
96
+ website/stylesheets/screen.css
97
+ website/template.rhtml
data/README.txt ADDED
@@ -0,0 +1,19 @@
1
+ Multibyte
2
+ ==========
3
+
4
+ Multibyte is extracted directly from Rails's ActiveSupport and offers Multibyte safety to Ruby.
5
+
6
+ Usage
7
+ =====
8
+
9
+ >> require 'multibyte'
10
+ => true
11
+ >> "新通訊錄".chars[0..1]
12
+ => #<Multibyte::Chars:0x127e3d0 @string="新通">
13
+ >> "新通訊錄".chars[0..1].to_s
14
+ => "新通"
15
+
16
+ Installation:
17
+ =============
18
+
19
+ $ sudo gem install matta-multibyte --source=http://gems.github.com
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
3
+
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
data/config/hoe.rb ADDED
@@ -0,0 +1,70 @@
1
+ require 'multibyte/version'
2
+
3
+ AUTHOR = 'FIXME full name' # can also be an array of Authors
4
+ EMAIL = "FIXME email"
5
+ DESCRIPTION = "description of gem"
6
+ GEM_NAME = 'multibyte' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = 'multibyte' # The unix name for your project
8
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
+
11
+ @config_file = "~/.rubyforge/user-config.yml"
12
+ @config = nil
13
+ RUBYFORGE_USERNAME = "unknown"
14
+ def rubyforge_username
15
+ unless @config
16
+ begin
17
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
18
+ rescue
19
+ puts <<-EOS
20
+ ERROR: No rubyforge config file found: #{@config_file}
21
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
22
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
23
+ EOS
24
+ exit
25
+ end
26
+ end
27
+ RUBYFORGE_USERNAME.replace @config["username"]
28
+ end
29
+
30
+
31
+ REV = nil
32
+ # UNCOMMENT IF REQUIRED:
33
+ # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
34
+ VERS = Multibyte::VERSION::STRING + (REV ? ".#{REV}" : "")
35
+ RDOC_OPTS = ['--quiet', '--title', 'multibyte documentation',
36
+ "--opname", "index.html",
37
+ "--line-numbers",
38
+ "--main", "README",
39
+ "--inline-source"]
40
+
41
+ class Hoe
42
+ def extra_deps
43
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
44
+ @extra_deps
45
+ end
46
+ end
47
+
48
+ # Generate all the Rake tasks
49
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
50
+ hoe = Hoe.new(GEM_NAME, VERS) do |p|
51
+ p.developer(AUTHOR, EMAIL)
52
+ p.description = DESCRIPTION
53
+ p.summary = DESCRIPTION
54
+ p.url = HOMEPATH
55
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
56
+ p.test_globs = ["test/**/test_*.rb"]
57
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
58
+
59
+ # == Optional
60
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
61
+ #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
62
+
63
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
64
+
65
+ end
66
+
67
+ CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
68
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
69
+ hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
70
+ hoe.rsync_args = '-av --delete --ignore-errors'
@@ -0,0 +1,17 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe newgem rubigen].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ puts "Installation: gem install #{req_gem} -y"
11
+ exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
16
+
17
+ require 'multibyte'
@@ -0,0 +1,135 @@
1
+ require 'multibyte/handlers/utf8_handler'
2
+ require 'multibyte/handlers/passthru_handler'
3
+
4
+ # Encapsulates all the functionality related to the Chars proxy.
5
+ module Multibyte #:nodoc:
6
+ # Chars enables you to work transparently with multibyte encodings in the Ruby String class without having extensive
7
+ # knowledge about the encoding. A Chars object accepts a string upon initialization and proxies String methods in an
8
+ # encoding safe manner. All the normal String methods are also implemented on the proxy.
9
+ #
10
+ # String methods are proxied through the Chars object, and can be accessed through the +chars+ method. Methods
11
+ # which would normally return a String object now return a Chars object so methods can be chained.
12
+ #
13
+ # "The Perfect String ".chars.downcase.strip.normalize # => "the perfect string"
14
+ #
15
+ # Chars objects are perfectly interchangeable with String objects as long as no explicit class checks are made.
16
+ # If certain methods do explicitly check the class, call +to_s+ before you pass chars objects to them.
17
+ #
18
+ # bad.explicit_checking_method "T".chars.downcase.to_s
19
+ #
20
+ # The actual operations on the string are delegated to handlers. Theoretically handlers can be implemented for
21
+ # any encoding, but the default handler handles UTF-8. This handler is set during initialization, if you want to
22
+ # use you own handler, you can set it on the Chars class. Look at the UTF8Handler source for an example how to
23
+ # implement your own handler. If you your own handler to work on anything but UTF-8 you probably also
24
+ # want to override Chars#handler.
25
+ #
26
+ # ActiveSupport::Multibyte::Chars.handler = MyHandler
27
+ #
28
+ # Note that a few methods are defined on Chars instead of the handler because they are defined on Object or Kernel
29
+ # and method_missing can't catch them.
30
+ class Chars
31
+
32
+ attr_reader :string # The contained string
33
+ alias_method :to_s, :string
34
+
35
+ include Comparable
36
+
37
+ # The magic method to make String and Chars comparable
38
+ def to_str
39
+ # Using any other ways of overriding the String itself will lead you all the way from infinite loops to
40
+ # core dumps. Don't go there.
41
+ @string
42
+ end
43
+
44
+ # Make duck-typing with String possible
45
+ def respond_to?(method)
46
+ super || @string.respond_to?(method) || handler.respond_to?(method) ||
47
+ (method.to_s =~ /(.*)!/ && handler.respond_to?($1)) || false
48
+ end
49
+
50
+ # Create a new Chars instance.
51
+ def initialize(str)
52
+ @string = str.respond_to?(:string) ? str.string : str
53
+ end
54
+
55
+ # Returns -1, 0 or +1 depending on whether the Chars object is to be sorted before, equal or after the
56
+ # object on the right side of the operation. It accepts any object that implements +to_s+. See String.<=>
57
+ # for more details.
58
+ def <=>(other); @string <=> other.to_s; end
59
+
60
+ # Works just like String#split, with the exception that the items in the resulting list are Chars
61
+ # instances instead of String. This makes chaining methods easier.
62
+ def split(*args)
63
+ @string.split(*args).map { |i| i.chars }
64
+ end
65
+
66
+ # Gsub works exactly the same as gsub on a normal string.
67
+ def gsub(*a, &b); @string.gsub(*a, &b).chars; end
68
+
69
+ # Like String.=~ only it returns the character offset (in codepoints) instead of the byte offset.
70
+ def =~(other)
71
+ handler.translate_offset(@string, @string =~ other)
72
+ end
73
+
74
+ # Try to forward all undefined methods to the handler, when a method is not defined on the handler, send it to
75
+ # the contained string. Method_missing is also responsible for making the bang! methods destructive.
76
+ def method_missing(m, *a, &b)
77
+ begin
78
+ # Simulate methods with a ! at the end because we can't touch the enclosed string from the handlers.
79
+ if m.to_s =~ /^(.*)\!$/ && handler.respond_to?($1)
80
+ result = handler.send($1, @string, *a, &b)
81
+ if result == @string
82
+ result = nil
83
+ else
84
+ @string.replace result
85
+ end
86
+ elsif handler.respond_to?(m)
87
+ result = handler.send(m, @string, *a, &b)
88
+ else
89
+ result = @string.send(m, *a, &b)
90
+ end
91
+ rescue Handlers::EncodingError
92
+ @string.replace handler.tidy_bytes(@string)
93
+ retry
94
+ end
95
+
96
+ if result.kind_of?(String)
97
+ result.chars
98
+ else
99
+ result
100
+ end
101
+ end
102
+
103
+ # Set the handler class for the Char objects.
104
+ def self.handler=(klass)
105
+ @@handler = klass
106
+ end
107
+
108
+ # Returns the proper handler for the contained string depending on $KCODE and the encoding of the string. This
109
+ # method is used internally to always redirect messages to the proper classes depending on the context.
110
+ def handler
111
+ if utf8_pragma?
112
+ @@handler
113
+ else
114
+ Multibyte::Handlers::PassthruHandler
115
+ end
116
+ end
117
+
118
+ private
119
+
120
+ # +utf8_pragma+ checks if it can send this string to the handlers. It makes sure @string isn't nil and $KCODE is
121
+ # set to 'UTF8'.
122
+ def utf8_pragma?
123
+ !@string.nil? && ($KCODE == 'UTF8')
124
+ end
125
+ end
126
+ end
127
+
128
+ # When we can load the utf8proc library, override normalization with the faster methods
129
+ begin
130
+ require 'utf8proc_native'
131
+ require 'multibyte/handlers/utf8_handler_proc'
132
+ Multibyte::Chars.handler = Multibyte::Handlers::UTF8HandlerProc
133
+ rescue LoadError
134
+ Multibyte::Chars.handler = Multibyte::Handlers::UTF8Handler
135
+ end