diff --git a/lib/monotable/local_store.rb b/lib/monotable/local_store.rb index 672389f..facad2f 100644 --- a/lib/monotable/local_store.rb +++ b/lib/monotable/local_store.rb @@ -26,9 +26,6 @@ journal_manager compaction_manager - column - columns - record index_block diff --git a/lib/monotable/local_store/column.rb b/lib/monotable/local_store/column.rb deleted file mode 100644 index fdd6db5..0000000 --- a/lib/monotable/local_store/column.rb +++ /dev/null @@ -1,24 +0,0 @@ -module Monotable - class Column < Hash - attr_accessor :name, :properties - - # props can just be a string - the name of the column - # or a hash with at least the "name" field set - def initialize(props={}) - case props - when String then - props = {"name" => props} - when Hash then - else - raise ArgumentError.new("string or hash required. got: #{props.inspect} (#{props.class})") - end - self.merge! props - self.name=self["name"] - raise ArgumentError.new("name property required") unless self.name - end - - def to_s; name; end - - def inspect; "Column:#{name.inspect}";end - end -end diff --git a/lib/monotable/local_store/columns.rb b/lib/monotable/local_store/columns.rb deleted file mode 100644 index 2f8e8f2..0000000 --- a/lib/monotable/local_store/columns.rb +++ /dev/null @@ -1,52 +0,0 @@ -module Monotable - class Columns - attr_reader :columns,:columns_by_id - - def initialize(from_xbd=nil) - @columns={} - @columns_by_id=[] - load_xbd(from_xbd) if from_xbd - end - - def load_xbd(xbd_tag) - xbd_tag.each_tag do |tag| - col_info={} - tag.each_attribute do |k,v| - col_info[k]=v - end - self << col_info - end - end - - def <<(column_properties) - column = Column.new column_properties - @columns[column]||= begin - id = @columns_by_id.length - @columns_by_id< test_name - col.name.should == test_name - end - - it "should respond to to_s" do - col = Column.new test_name - col.to_s.should == test_name - end - - it "should be equal if as long as name is squal" do - col1 = Column.new "name" => test_name, "Content-Type" => "image/jpeg" - col2 = Column.new "name" => test_name, "Content-Type" => "image/jpeg" - col1.should==col2 - - col1 = Column.new "name" => test_name+"A", "Content-Type" => "image/jpeg" - col2 = Column.new "name" => test_name+"B", "Content-Type" => "image/jpeg" - col1.should_not==col2 - end - - it "should be possible to use as a Hash-key; any different property means a different hash-key" do - hash = {} - hash[Column.new("name"=>"col1", "Content-Type" => "image/jpeg")]="val1" - hash[Column.new("name"=>"col1", "Content-Type" => "image/img")]="val2" - - hash[Column.new("name"=>"col1", "Content-Type" => "image/jpeg")].should=="val1" - hash[Column.new("name"=>"col1", "Content-Type" => "image/img")].should=="val2" - end - - it "should be comparable to a matching Hash of properties" do - Column.new("name"=>"col1", "Content-Type" => "image/jpeg").should == {"name"=>"col1", "Content-Type" => "image/jpeg"} - Column.new("name"=>"col1", "Content-Type" => "image/jpeg").should_not == {"name"=>"col1", "Content-Type" => "image/png"} - end - -end -end diff --git a/spec/columns_spec.rb b/spec/columns_spec.rb deleted file mode 100644 index 9671d87..0000000 --- a/spec/columns_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -require File.join(File.dirname(__FILE__),"mono_table_helper_methods") - -module Monotable -describe Monotable::Columns do - include MonotableHelperMethods - - it "should work with one column" do - cols = Columns.new - col_info = {"name" => "col_nam", "Content-Type" => "image/jpeg"} - cols << col_info - cols.length.should == 1 - cols[0].should == col_info - cols[col_info].should == 0 - end - - it "should ignore adding the same column twice" do - cols = Columns.new - col_info = {"name" => "col_name", "Content-Type" => "image/jpeg"} - cols << col_info - cols << col_info - cols.length.should == 1 - end - - it "should allow two columns with the same name but different properties" do - cols = Columns.new - col_info = {"name" => "col_name", "Content-Type" => "image/jpeg"} - cols << col_info - col_info = {"name" => "col_name", "Content-Type" => "image/gif"} - cols << col_info - cols.length.should == 2 - end - - it "should convert to xbd" do - cols = Columns.new - col_info = {"name" => "col_name", "Content-Type" => "image/jpeg"} - cols << col_info - xbd_tag = cols.xbd_tag - bin = xbd_tag.to_binary - cols2 = Columns.new Xbd.parse(bin) - cols2.should == cols - end -end -end