charlock_holmes 0.6.9.3 → 0.6.9.4

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- charlock_holmes (0.6.9.3)
4
+ charlock_holmes (0.6.9.4)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -34,6 +34,47 @@ static void check_utf8_encoding(VALUE str) {}
34
34
  extern VALUE rb_mCharlockHolmes;
35
35
  static VALUE rb_cTransliterator;
36
36
 
37
+ static VALUE rb_transliterator_id_list(VALUE self) {
38
+ UErrorCode status = U_ZERO_ERROR;
39
+ StringEnumeration *id_list;
40
+ int32_t id_list_size;
41
+ const char *curr_id;
42
+ int32_t curr_id_len;
43
+ VALUE rb_ary;
44
+ VALUE rb_curr_id;
45
+
46
+ id_list_size = 0;
47
+ id_list = Transliterator::getAvailableIDs(status);
48
+ if(!U_SUCCESS(status)) {
49
+ rb_raise(rb_eArgError, "%s", u_errorName(status));
50
+ }
51
+
52
+ status = U_ZERO_ERROR;
53
+ id_list_size = id_list->count(status);
54
+ if(!U_SUCCESS(status)) {
55
+ rb_raise(rb_eArgError, "%s", u_errorName(status));
56
+ }
57
+
58
+ rb_ary = rb_ary_new2(id_list_size);
59
+
60
+ do {
61
+ curr_id_len = 0;
62
+ curr_id = id_list->next(&curr_id_len, status);
63
+ if(!U_SUCCESS(status)) {
64
+ rb_raise(rb_eArgError, "%s", u_errorName(status));
65
+ }
66
+
67
+ if (curr_id != NULL) {
68
+ rb_curr_id = charlock_new_str(curr_id, curr_id_len);
69
+ rb_ary_push(rb_ary, rb_curr_id);
70
+ }
71
+ } while(curr_id != NULL);
72
+
73
+ delete id_list;
74
+
75
+ return rb_ary;
76
+ }
77
+
37
78
  static VALUE rb_transliterator_transliterate(VALUE self, VALUE rb_txt, VALUE rb_id) {
38
79
  UErrorCode status = U_ZERO_ERROR;
39
80
  UParseError p_error;
@@ -82,6 +123,7 @@ void _init_charlock_transliterator() {
82
123
 
83
124
  rb_cTransliterator = rb_define_class_under(rb_mCharlockHolmes, "Transliterator", rb_cObject);
84
125
 
126
+ rb_define_singleton_method(rb_cTransliterator, "id_list", (VALUE(*)(...))rb_transliterator_id_list, 0);
85
127
  rb_define_singleton_method(rb_cTransliterator, "transliterate", (VALUE(*)(...))rb_transliterator_transliterate, 2);
86
128
  }
87
129
 
@@ -1,3 +1,3 @@
1
1
  module CharlockHolmes
2
- VERSION = "0.6.9.3"
2
+ VERSION = "0.6.9.4"
3
3
  end
@@ -113,7 +113,11 @@ class TransliteratorTest < MiniTest::Unit::TestCase
113
113
  end
114
114
  end
115
115
 
116
+ def test_transliterator_id_list_shouldnt_be_empty
117
+ assert !CharlockHolmes::Transliterator.id_list.empty?
118
+ end
119
+
116
120
  def trans(text, id)
117
121
  CharlockHolmes::Transliterator.transliterate(text, id)
118
122
  end
119
- end
123
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: charlock_holmes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.9.3
4
+ version: 0.6.9.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-04-02 00:00:00.000000000 Z
13
+ date: 2013-04-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake-compiler