unicodechars 0.0.1 → 0.0.2

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.
data/CHANGELOG CHANGED
@@ -0,0 +1,11 @@
1
+ 0.0.2
2
+ -----
3
+ Added credits to the readme.
4
+
5
+ 0.0.1
6
+ -----
7
+ First release
8
+ * Gemified Rails' chars
9
+ * Added kernel-level u function
10
+ * Fixed [num]
11
+ * Allowed iteration over characters via each
data/README CHANGED
@@ -1,3 +1,35 @@
1
1
  README for unicodechars
2
2
  =======================
3
+ UnicodeChars is a gemification of Rails' support for unicode via #chars.
3
4
 
5
+ The original code is at: https://fngtps.com/projects/multibyte_for_rails
6
+
7
+ It was written by:
8
+ * Julian Tarkhanov <me@julik.nl>
9
+ * Manfred Stienstra <m.stienstra@fngtps.com>
10
+ * Jan Behrens <jan.behrens@flexidesk.de>
11
+ * Thijs van der Vossen <thijs@fngtps.com>
12
+
13
+
14
+ Very little of the code is original, but there are some improvements:
15
+ * [n], in the Rails version, provides a codepoint. Since .slice(n) already
16
+ provides a codepoint, [n] is modified here so it provides the nth character.
17
+ * Updated #inspect on the Chars class so it appears to be a string in the console
18
+ * Updated is_a? so a unicode string responds true to is_a?(String)
19
+ * Added iterator methods each, collect, and inject so they iterate over the
20
+ list of characters.
21
+ * Updated to_a so it returns an array of characters
22
+ * An additional kernel-level method is added: "u", so you can do stuff like:
23
+ y = u"ᗷɭoℊẚᗰսɳᑯѲ"
24
+ y.reverse => "Ѳᑯɳսᗰẚℊoɭᗷ"
25
+ y.length => 10
26
+ y.map {|x| "#{x}, "}.join => "ᗷ, ɭ, o, ℊ, ẚ, ᗰ, ս, ɳ, ᑯ, Ѳ, "
27
+ y.to_a.join(", ") => "ᗷ, ɭ, o, ℊ, ẚ, ᗰ, ս, ɳ, ᑯ, Ѳ"
28
+ y.is_a?(String) => true
29
+ y.class => ActiveSupport::Multibyte::Chars
30
+ y.chars => "ᗷɭoℊẚᗰսɳᑯѲ"
31
+ y.normalize(:c) => "ᗷɭoℊẚᗰսɳᑯѲ"
32
+ y.normalize(:d) => "ᗷɭoℊẚᗰսɳᑯѲ"
33
+
34
+ As in the original Rails code, all of the original string methods work, and are
35
+ updated to work correctly with unicode.
@@ -72,6 +72,20 @@ module ActiveSupport::Multibyte
72
72
  split(//).each(&block)
73
73
  end
74
74
 
75
+ def inject &block
76
+ split(//).inject(&block)
77
+ end
78
+
79
+ def collect &block
80
+ split(//).collect(&block)
81
+ end
82
+
83
+ alias_method :map, :collect
84
+
85
+ def to_a
86
+ split(//)
87
+ end
88
+
75
89
  # Returns -1, 0 or +1 depending on whether the Chars object is to be sorted before, equal or after the
76
90
  # object on the right side of the operation. It accepts any object that implements +to_s+. See String.<=>
77
91
  # for more details.
@@ -2,7 +2,7 @@ module Unicodechar #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: unicodechars
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.1
7
- date: 2006-10-29 00:00:00 -04:00
6
+ version: 0.0.2
7
+ date: 2006-10-30 00:00:00 -05:00
8
8
  summary: description of gem
9
9
  require_paths:
10
10
  - lib