lib/roo/google.rb in roo-0.8.5 vs lib/roo/google.rb in roo-0.9.0
- old
+ new
@@ -1,6 +1,6 @@
-require 'rubygems' #TODO:
+#require 'rubygems' #TODO:
require 'gdata/spreadsheet'
#require 'log4r'
# overwrite some methods from the gdata-gem:
module GData
@@ -24,17 +24,10 @@
result << elem.inner_html
}
result
end
- # #-- new (testing only)
- # def raw_url(url)
- # path = "/feeds/worksheets/#{@spreadsheet_id}/private/basic"
- # path = url
- # doc = Hpricot(request(path))
- # end
-
#-- new
def save_entry_roo(entry)
path = "/feeds/cells/#{@spreadsheet_id}/1/#{@headers ? 'private' : 'public'}/full"
post(path, entry)
end
@@ -125,23 +118,10 @@
# returns an array of sheet names in the spreadsheet
def sheets
return @gs.sheetlist
end
- # set the working sheet in the document
- #--
- # TODO: eigenlich identisch mit Openoffice => refactoring
- def default_sheet=(sheet)
- if ! sheet.kind_of?(String)
- raise TypeError, "what are you trying to set as default sheet?"
- end
- @default_sheet = sheet
- check_default_sheet
- @first_row[sheet] = @last_row[sheet] = @first_column[sheet] = @last_column[sheet] = nil
- #--TODO: @cells_read[sheet] = false
- end
-
# is String a date with format DD/MM/YYYY
def Google.date?(string)
return false if string.class == Float
return true if string.class == Date
return string.strip =~ /^([0-9]+)\/([0-9]+)\/([0-9]+)$/
@@ -162,15 +142,19 @@
yyyy,mm,dd = @cell[sheet]["#{row},#{col}"].split('-')
# $log.debug(yyyy)
# $log.debug(mm)
# $log.debug(dd)
#TODO:
- if dd.to_i < 1 or dd.to_i >31 or mm.to_i < 1 or mm.to_i > 12 or yyyy.to_i < 1900 or yyyy.to_i > 3000
+ #if dd.to_i < 1 or dd.to_i >31 or mm.to_i < 1 or mm.to_i > 12 or yyyy.to_i < 1900 or yyyy.to_i > 3000
+ # raise "Invalid date parameter: #{yyyy}, #{mm}, #{dd}"
+ #end
+ begin
+ return Date.new(yyyy.to_i,mm.to_i,dd.to_i)
+ rescue ArgumentError
raise "Invalid date parameter: #{yyyy}, #{mm}, #{dd}"
end
- return Date.new(yyyy.to_i,mm.to_i,dd.to_i)
- end
+ end # celltype date
return @cell[sheet]["#{row},#{col}"]
end
# returns the type of a cell:
# * :float
@@ -455,22 +439,9 @@
# $log.debug("#{@formula[sheet][key]}") if formula
}
@cells_read[sheet] = true
- end
-
- # Checks if the default_sheet exists. Otherwise a RangeError exception is
- # raised
- def check_default_sheet
- sheet_found = false
- raise ArgumentError, "Error: default_sheet not set" if @default_sheet == nil
- if sheets.index(@default_sheet)
- sheet_found = true
- end
- if ! sheet_found
- raise RangeError, "sheet '#{@default_sheet}' not found"
- end
end
def numeric?(string)
string =~ /^[0-9]+[\.]*[0-9]*$/
end