out << ", :element => ";
generate_field_data(out, ((t_set*)field_type)->get_elem_type());
}
+ } else {
+ if (((t_base_type*)field_type)->is_binary()) {
+ out << ", :binary => true" << endl;
+ }
}
if(optional) {
p.summary = "Ruby libraries for Thrift (a language-agnostic RPC system)"
p.url = "http://incubator.apache.org/thrift/"
p.include_rakefile = true
- p.version = "0.2.3"
+ p.version = "0.2.4"
p.rubygems_version = ">= 1.2.0"
end
inspect_collection(value, field_info)
elsif value.is_a? Set
inspect_collection(value, field_info)
+ elsif value.is_a?(String) && field_info[:binary]
+ value.unpack("H*").first
else
value.inspect
end
name, value = name.keys.first, name.values.first
end
+ if Thrift.type_checking
+ raise Exception, "#{self.class} does not contain a field named #{name}!" unless name_to_id(name.to_s)
+ end
+
if value.nil?
raise Exception, "Union #{self.class} cannot be instantiated with setfield and nil value!"
end
2: i32 i32_field;
3: i32 other_i32_field;
4: SomeEnum enum_field;
+ 5: binary binary_field;
}
struct Foo {
8: bool my_bool
}
+struct Foo2 {
+ 1: binary my_binary
+}
+
struct BoolStruct {
1: bool yesno = 1
}
StructWithEnumMap.new(:my_map => {SomeEnum::ONE => [SomeEnum::TWO]}).inspect.should == "<SpecNamespace::StructWithEnumMap my_map:{ONE (0): [TWO (1)]}>"
end
+ it "should pretty print binary fields" do
+ Foo2.new(:my_binary => "\001\002\003").inspect.should == "<SpecNamespace::Foo2 my_binary:010203>"
+ end
+
it "should offer field? methods" do
Foo.new.opt_string?.should be_false
Foo.new(:simple => 52).simple?.should be_true
My_union.new(:im_true => false).im_true?.should be_true
My_union.new(:im_true => true).im_true?.should be_true
end
+
+ it "should pretty print binary fields" do
+ TestUnion.new(:binary_field => "\001\002\003").inspect.should == "<SpecNamespace::TestUnion binary_field: 010203>"
+ end
end
end