google_hash 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/ext/template/google_hash.cpp.erb +4 -1
- data/spec/spec.google_hash.rb +7 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.1
|
@@ -316,7 +316,8 @@ static VALUE rb_ghash_combination_2(VALUE cb) {
|
|
316
316
|
void init_<%= type %>_<%= english_key_type %>_to_<%= english_value_type %>() {
|
317
317
|
|
318
318
|
VALUE rb_cGoogleHashLocal;
|
319
|
-
|
319
|
+
<% class_name = "GoogleHash#{type.capitalize + english_key_type.capitalize}To#{english_value_type.capitalize}" %>
|
320
|
+
rb_cGoogleHashLocal = rb_define_class("<%= class_name %>", rb_cObject);
|
320
321
|
|
321
322
|
rb_define_alloc_func(rb_cGoogleHashLocal, callback_alloc); // I guess it calls this for us, pre initialize...
|
322
323
|
|
@@ -332,6 +333,8 @@ void init_<%= type %>_<%= english_key_type %>_to_<%= english_value_type %>() {
|
|
332
333
|
rb_define_method(rb_cGoogleHashLocal, "include?", RUBY_METHOD_FUNC(rb_ghash_get_present), 1);
|
333
334
|
rb_define_method(rb_cGoogleHashLocal, "keys_combination_2", RUBY_METHOD_FUNC(rb_ghash_combination_2), 0);
|
334
335
|
rb_define_method(rb_cGoogleHashLocal, "length", RUBY_METHOD_FUNC(rb_ghash_size), 0);
|
336
|
+
// add a higher quality #inspect...
|
337
|
+
rb_eval_string("class <%= class_name %>;def inspect;all = '<%= class_name %> {'; join = []; self.each{|k, v| join << (k.to_s + '=>' + v.to_s)}; all << join.join(',') << '}'; end; end");
|
335
338
|
id_eql = rb_intern("eql?");
|
336
339
|
id_hash = rb_intern("hash");
|
337
340
|
}
|
data/spec/spec.google_hash.rb
CHANGED
@@ -248,6 +248,13 @@ describe "google_hash" do
|
|
248
248
|
a.each_key {}
|
249
249
|
end
|
250
250
|
|
251
|
+
it "should have nice inspect" do
|
252
|
+
a = GoogleHashSparseIntToRuby.new
|
253
|
+
a[3] = 4
|
254
|
+
a[4] = 5
|
255
|
+
a.inspect.should == "GoogleHashSparseIntToRuby {3=>4,4=>5}"
|
256
|
+
end
|
257
|
+
|
251
258
|
it "should have sets, too, not just hashes"
|
252
259
|
|
253
260
|
it "should skip GC when native to native" do
|