Permalink
Browse files

Rename Openoffice -> OpenOffice, Libreoffice -> LibreOffice, Csv -> CSV,

and redirect the old names to the new constants
  • Loading branch information...
Empact committed Aug 7, 2013
1 parent 989949a commit 6f250cf126c08ce50ff0f5d17c3df2d994125478
View
@@ -1,10 +1,12 @@
-== 2.0.0 (unreleased)
+== 1.12.0 (unreleased)
* 3 enhancements
* Add Roo::Excelx#load_xml so that people can customize to their data, e.g. https://github.com/Empact/roo/pull/23
* Enable passing csv_options to Roo::Csv, which are passed through to the underlying CSV call.
* Enable passing options through from Roo::Spreadsheet to Roo::Csv and Roo::Google.
* Switch from google-spreadsheet-ruby to google_drive for Roo::Google access https://github.com/Empact/roo/pull/40
+ * Rename Openoffice -> OpenOffice, Libreoffice -> LibreOffice, Csv -> CSV,
+ and redirect the old names to the new constants
* 1 bugfix
* Fix that Roo::Csv#parse(headers: true) would blow up. https://github.com/Empact/roo/pull/37
View
@@ -2,11 +2,11 @@
Roo implements read access for all spreadsheet types and read/write access for
Google spreadsheets. It can handle
-* Openoffice
+* OpenOffice
* Excel
* Google spreadsheets
* Excelx
-* Libreoffice
+* LibreOffice
* CSV
Using Roo to access Google spreadsheets requires you install the 'google-spreadsheet-ruby' gem separately.
@@ -23,7 +23,7 @@ While Roo is licensed under the MIT / Expat license, please note that the 'sprea
require 'roo'
- s = Roo::Openoffice.new("myspreadsheet.ods") # creates an Openoffice Spreadsheet instance
+ s = Roo::OpenOffice.new("myspreadsheet.ods") # creates an OpenOffice Spreadsheet instance
s = Roo::Excel.new("myspreadsheet.xls") # creates an Excel Spreadsheet instance
s = Roo::Google.new("myspreadsheetkey_at_google") # creates an Google Spreadsheet instance
s = Roo::Excelx.new("myspreadsheet.xlsx") # creates an Excel Spreadsheet instance for Excel .xlsx files
View
@@ -4,7 +4,7 @@ Jeweler::Tasks.new do |gem|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
gem.name = "roo"
gem.summary = "Roo can access the contents of various spreadsheet files."
- gem.description = "Roo can access the contents of various spreadsheet files. It can handle\n* Openoffice\n* Excel\n* Google spreadsheets\n* Excelx\n* Libreoffice\n* CSV"
+ gem.description = "Roo can access the contents of various spreadsheet files. It can handle\n* OpenOffice\n* Excel\n* Google spreadsheets\n* Excelx\n* LibreOffice\n* CSV"
gem.email = "ruby.ruby.ruby.roo@gmail.com"
gem.homepage = "http://github.com/Empact/roo"
gem.authors = ['Thomas Preymesser', 'Hugh McGowan', 'Ben Woosley']
@@ -5,7 +5,7 @@
class Server2 < SOAP::RPC::StandaloneServer
def on_init
- spreadsheet = Openoffice.new("./Ferien-de.ods")
+ spreadsheet = OpenOffice.new("./Ferien-de.ods")
add_method(spreadsheet, 'cell', 'row', 'col')
add_method(spreadsheet, 'officeversion')
add_method(spreadsheet, 'first_row')
View
@@ -2,14 +2,30 @@ module Roo
VERSION = '1.10.3'
+ def self.const_missing(const_name)
+ case const_name
+ when :Libreoffice
+ warn "`Roo::Libreoffice` has been deprecated. Use `Roo::LibreOffice` instead."
+ LibreOffice
+ when :Openoffice
+ warn "`Roo::Openoffice` has been deprecated. Use `Roo::OpenOffice` instead."
+ OpenOffice
+ when :Csv
+ warn "`Roo::Csv` has been deprecated. Use `Roo::CSV` instead."
+ CSV
+ else
+ super
+ end
+ end
+
autoload :Spreadsheet, 'roo/spreadsheet'
autoload :GenericSpreadsheet, 'roo/generic_spreadsheet'
- autoload :Openoffice, 'roo/openoffice'
- autoload :Libreoffice, 'roo/openoffice'
+ autoload :OpenOffice, 'roo/openoffice'
+ autoload :LibreOffice, 'roo/openoffice'
autoload :Excel, 'roo/excel'
autoload :Excelx, 'roo/excelx'
autoload :Excel2003XML, 'roo/excel2003xml'
autoload :Google, 'roo/google'
- autoload :Csv, 'roo/csv'
+ autoload :CSV, 'roo/csv'
end
View
@@ -1,17 +1,17 @@
require 'csv'
require 'time'
-# The Csv class can read csv files (must be separated with commas) which then
+# The CSV class can read csv files (must be separated with commas) which then
# can be handled like spreadsheets. This means you can access cells like A5
# within these files.
-# The Csv class provides only string objects. If you want conversions to other
+# The CSV class provides only string objects. If you want conversions to other
# types you have to do it yourself.
#
# You can pass options to the underlying CSV parse operation, via the
# :csv_options option.
#
-class Roo::Csv < Roo::GenericSpreadsheet
+class Roo::CSV < Roo::GenericSpreadsheet
def initialize(filename, options = {})
@filename = filename
@options = options
@@ -27,7 +27,7 @@ def initialize(filename, options = {})
attr_reader :filename
- # Returns an array with the names of the sheets. In Csv class there is only
+ # Returns an array with the names of the sheets. In CSV class there is only
# one dummy sheet, because a csv file cannot have more than one sheet.
def sheets
['default']
@@ -122,4 +122,4 @@ def read_cells(sheet=nil)
@last_column[sheet] -= 1
end
end
-end # class Csv
+end
@@ -514,10 +514,10 @@ def longest_sheet
def file_type_check(filename, ext, name, warning_level, packed=nil)
new_expression = {
- '.ods' => 'Roo::Openoffice.new',
+ '.ods' => 'Roo::OpenOffice.new',
'.xls' => 'Roo::Excel.new',
'.xlsx' => 'Roo::Excelx.new',
- '.csv' => 'Roo::Csv.new',
+ '.csv' => 'Roo::CSV.new',
'.xml' => 'Roo::Excel2003XML.new',
}
if packed == :zip
View
@@ -3,7 +3,7 @@
require 'nokogiri'
require 'cgi'
require 'pp' #TODO
-class Roo::Openoffice < Roo::GenericSpreadsheet
+class Roo::OpenOffice < Roo::GenericSpreadsheet
class << self
def extract_content(tmpdir, filename)
@@ -33,7 +33,7 @@ def process_zipfile(tmpdir, zip, path='')
# initialization and opening of a spreadsheet file
# values for packed: :zip
def initialize(filename, packed=nil, file_warning=:error, tmpdir_root=nil)
- file_type_check(filename,'.ods','an Roo::Openoffice', file_warning, packed)
+ file_type_check(filename,'.ods','an Roo::OpenOffice', file_warning, packed)
make_tmpdir(tmpdir_root) do |tmpdir|
filename = open_from_uri(filename, tmpdir) if uri?(filename)
filename = unzip(filename, tmpdir) if packed == :zip
@@ -187,7 +187,7 @@ def sheets
return_sheets
end
- # version of the Roo::Openoffice document
+ # version of the Roo::OpenOffice document
# at 2007 this is always "1.0"
def officeversion
oo_version
@@ -277,7 +277,7 @@ def oo_version
def set_cell_values(sheet,x,y,i,v,value_type,formula,table_cell,str_v,style_name)
key = [y,x+i]
@cell_type[sheet] = {} unless @cell_type[sheet]
- @cell_type[sheet][key] = Roo::Openoffice.oo_type_2_roo_type(value_type)
+ @cell_type[sheet][key] = Roo::OpenOffice.oo_type_2_roo_type(value_type)
@formula[sheet] = {} unless @formula[sheet]
if formula
['of:', 'oooc:'].each do |prefix|
@@ -437,7 +437,7 @@ def read_cells(sheet=nil)
end
# Only calls read_cells because Roo::GenericSpreadsheet calls read_comments
- # whereas the reading of comments is done in read_cells for Roo::Openoffice-objects
+ # whereas the reading of comments is done in read_cells for Roo::OpenOffice-objects
def read_comments(sheet=nil)
read_cells(sheet)
end
@@ -456,12 +456,12 @@ def read_labels
end
def read_styles(style_elements)
- @style_definitions['Default'] = Roo::Openoffice::Font.new
+ @style_definitions['Default'] = Roo::OpenOffice::Font.new
style_elements.each do |style|
next unless style.name == 'style'
style_name = attr(style,'name')
style.each do |properties|
- font = Roo::Openoffice::Font.new
+ font = Roo::OpenOffice::Font.new
font.bold = attr(properties,'font-weight')
font.italic = attr(properties,'font-style')
font.underline = attr(properties,'text-underline-style')
@@ -515,6 +515,6 @@ def attr(node, attr_name)
end # class
-# Libreoffice is just an alias for Roo::Openoffice class
-class Roo::Libreoffice < Roo::Openoffice
+# LibreOffice is just an alias for Roo::OpenOffice class
+class Roo::LibreOffice < Roo::OpenOffice
end
View
@@ -9,13 +9,13 @@ def open(file, options = {})
when '.xlsx'
Roo::Excelx.new(file)
when '.ods'
- Roo::Openoffice.new(file)
+ Roo::OpenOffice.new(file)
when '.xml'
Roo::Excel2003XML.new(file)
when ''
Roo::Google.new(file, options)
when '.csv'
- Roo::Csv.new(file, options)
+ Roo::CSV.new(file, options)
else
raise ArgumentError, "Don't know how to open file #{file}"
end
View
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Thomas Preymesser", "Hugh McGowan", "Ben Woosley"]
s.date = "2013-08-07"
- s.description = "Roo can access the contents of various spreadsheet files. It can handle\n* Openoffice\n* Excel\n* Google spreadsheets\n* Excelx\n* Libreoffice\n* CSV"
+ s.description = "Roo can access the contents of various spreadsheet files. It can handle\n* OpenOffice\n* Excel\n* Google spreadsheets\n* Excelx\n* LibreOffice\n* CSV"
s.email = "ruby.ruby.ruby.roo@gmail.com"
s.extra_rdoc_files = [
"LICENSE",
View
@@ -1,12 +1,12 @@
require 'spec_helper'
-describe Roo::Csv do
+describe Roo::CSV do
let(:path) { 'test/files/csvtypes.csv' }
- let(:csv) { Roo::Csv.new(path) }
+ let(:csv) { Roo::CSV.new(path) }
describe '.new' do
it 'creates an instance' do
- expect(csv).to be_a(Roo::Csv)
+ expect(csv).to be_a(Roo::CSV)
end
end
@@ -33,16 +33,22 @@
}
it 'returns the csv options' do
- csv = Roo::Csv.new(path, csv_options: options)
+ csv = Roo::CSV.new(path, csv_options: options)
csv.csv_options.should == options
end
end
context 'when created without the csv_options option' do
it 'returns a hash' do
- csv = Roo::Csv.new(path)
+ csv = Roo::CSV.new(path)
csv.csv_options.should == {}
end
end
end
end
+
+describe Roo::Csv do
+ it 'is an alias of LibreOffice' do
+ expect(Roo::Csv).to eq(Roo::CSV)
+ end
+end
@@ -1,13 +1,19 @@
require 'spec_helper'
-describe Roo::Libreoffice do
+describe Roo::LibreOffice do
describe '.new' do
subject {
- Roo::Libreoffice.new('test/files/numbers1.ods')
+ Roo::LibreOffice.new('test/files/numbers1.ods')
}
it 'creates an instance' do
- expect(subject).to be_a(Roo::Libreoffice)
+ expect(subject).to be_a(Roo::LibreOffice)
end
end
end
+
+describe Roo::Libreoffice do
+ it 'is an alias of LibreOffice' do
+ expect(Roo::Libreoffice).to eq(Roo::LibreOffice)
+ end
+end
@@ -1 +1,21 @@
-# Openoffice is an alias of Libreoffice. See libreoffice_spec.
+require 'spec_helper'
+
+describe Roo::OpenOffice do
+ describe '.new' do
+ subject {
+ Roo::OpenOffice.new('test/files/numbers1.ods')
+ }
+
+ it 'creates an instance' do
+ expect(subject).to be_a(Roo::OpenOffice)
+ end
+ end
+
+ # OpenOffice is an alias of LibreOffice. See libreoffice_spec.
+end
+
+describe Roo::Openoffice do
+ it 'is an alias of LibreOffice' do
+ expect(Roo::Openoffice).to eq(Roo::OpenOffice)
+ end
+end
@@ -17,7 +17,7 @@
context 'with options' do
it 'passes the options through' do
- Roo::Csv.should_receive(:new).with(filename, options)
+ Roo::CSV.should_receive(:new).with(filename, options)
Roo::Spreadsheet.open(filename, options)
end
end
View
@@ -1,7 +1,7 @@
require 'roo'
Dir.glob("test/files/*.ods").each do |fn|
begin
- oo = Roo::Openoffice.new fn
+ oo = Roo::OpenOffice.new fn
print File.basename(fn) + " "
puts oo.officeversion
rescue Zip::ZipError, Errno::ENOENT => e
View
@@ -2,7 +2,7 @@
require 'roo'
oo = Excel.new("tmp.xls")
-#oo = Openoffice.new("tmp.ods")
+#oo = OpenOffice.new("tmp.ods")
oo.default_sheet = oo.sheets.first
oo.first_row.upto(oo.last_row) do |row|
oo.first_column.upto(oo.last_column) do |col|
Oops, something went wrong.

0 comments on commit 6f250cf

Please sign in to comment.