Permalink
Browse files

Fixed problem where whitespace is not stripped

  • Loading branch information...
Brad Seefeld
Brad Seefeld committed Jun 6, 2011
1 parent 0d5777b commit f055e2e17961d36d132713a60a0e58887504d470
@@ -3,6 +3,8 @@ module DataTable
class Column
def self.factory(statement)
+ statement = statement.strip
+
col = nil
if m = statement.match(/sum\((.*)\)/i)
col = Rgviz::DataTable::SumColumn.new(m[1], statement)
@@ -58,7 +58,7 @@ def self.execute_grouping(rows, raw_group, selects)
def self.parse_select(select)
selects = []
select.to_s.split(",").each do |select|
- selects << Rgviz::DataTable::Column.factory(select)
+ selects << Rgviz::DataTable::Column.factory(select.strip)
end
selects
end
@@ -1,5 +1,5 @@
module Rgviz
module DataTable
- VERSION = "0.0.1"
+ VERSION = "0.0.2"
end
end
@@ -0,0 +1,18 @@
+require "spec_helper"
+
+describe Rgviz::DataTable::Column do
+
+ it "creates a sum column" do
+ col = Rgviz::DataTable::Column.factory("sum(column)")
+ col.class.should == Rgviz::DataTable::SumColumn
+ col.column.should == "column"
+ col.label.should == "sum(column)"
+ end
+
+ it "strips extra space" do
+ col = Rgviz::DataTable::Column.factory(" some_column ")
+ col.class.should == Rgviz::DataTable::Column
+ col.column.should == "some_column"
+ col.label.should == col.column
+ end
+end

0 comments on commit f055e2e

Please sign in to comment.