Skip to content

Commit

Permalink
Send test coverage to coveralls. Allow fail jruby on travis
Browse files Browse the repository at this point in the history
  • Loading branch information
simonoff committed Nov 23, 2014
1 parent 21d8630 commit 5f5ca3f
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 112 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ rvm:
matrix:
allow_failures:
- rvm: ruby-head
- rvm: jruby-19mode
bundler_args: --without local_development
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ group :test do
gem 'shoulda'
gem 'rspec', '>= 3.0.0'
gem 'vcr'
gem 'simplecov', '>= 0.9.0', :require => false
gem 'coveralls', :require => false
gem 'simplecov', '>= 0.9.0', require: false
gem 'coveralls', require: false
end

group :local_development do
gem 'terminal-notifier-guard', require: false if RUBY_PLATFORM.downcase.include?('darwin')
gem 'guard-rspec', '>= 4.3.1' ,require: false
gem 'guard-rspec', '>= 4.3.1', require: false
gem 'guard-bundler', require: false
gem 'guard-preek', require: false
gem 'guard-rubocop', require: false
Expand Down
45 changes: 23 additions & 22 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
require "bundler/gem_tasks"

require 'rake/testtask'
require 'rspec/core/rake_task'
require 'coveralls/rake/task'

# Test unit
Rake::TestTask.new do |t|
t.libs << 'test'
t.test_files = FileList['test/test*.rb']
t.verbose = true
end

# RSpec
RSpec::Core::RakeTask.new(:spec)

# Coveralls
Coveralls::RakeTask.new

task test_with_coveralls: [:test, :spec, 'coveralls:push']

task default: [:test, :spec]
require 'bundler/gem_tasks'

require 'rake/testtask'
require 'rspec/core/rake_task'
require 'coveralls/rake/task'

# Test unit
Rake::TestTask.new do |t|
t.libs << 'test'
t.test_files = FileList['test/test*.rb']
t.verbose = true
end

# RSpec
RSpec::Core::RakeTask.new(:spec)

# Coveralls
Coveralls::RakeTask.new

default_task = [:test, :spec]
default_task << 'coveralls:push' if ENV['TRAVIS']

task default: default_task
59 changes: 28 additions & 31 deletions examples/roo_soap_client.rb
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
require 'soap/rpc/driver'

def ferien_fuer_region(proxy, region, year=nil)
proxy.first_row.upto(proxy.last_row) { |row|
if proxy.cell(row, 2) == region
jahr = proxy.cell(row,1).to_i
if year == nil || jahr == year
bis_datum = proxy.cell(row,5)
if DateTime.now > bis_datum
print '('
end
print jahr.to_s+" "
print proxy.cell(row,2)+" "
print proxy.cell(row,3)+" "
print proxy.cell(row,4).to_s+" "
print bis_datum.to_s+" "
print (proxy.cell(row,6) || '')+" "
if DateTime.now > bis_datum
print ')'
end
puts
def ferien_fuer_region(proxy, region, year = nil)
proxy.first_row.upto(proxy.last_row) do |row|
if proxy.cell(row, 2) == region
jahr = proxy.cell(row, 1).to_i
if year.nil? || jahr == year
bis_datum = proxy.cell(row, 5)
if DateTime.now > bis_datum
print '('
end
end
}
print jahr.to_s + ' '
print proxy.cell(row, 2) + ' '
print proxy.cell(row, 3) + ' '
print proxy.cell(row, 4).to_s + ' '
print bis_datum.to_s + ' '
print (proxy.cell(row, 6) || '') + ' '
if DateTime.now > bis_datum
print ')'
end
puts
end
end
end
end

proxy = SOAP::RPC::Driver.new("http://localhost:12321","spreadsheetserver")
proxy.add_method('cell','row','col')
proxy = SOAP::RPC::Driver.new('http://localhost:12321', 'spreadsheetserver')
proxy.add_method('cell', 'row', 'col')
proxy.add_method('officeversion')
proxy.add_method('last_row')
proxy.add_method('last_column')
proxy.add_method('first_row')
proxy.add_method('first_column')
proxy.add_method('sheets')
proxy.add_method('set_default_sheet','s')
proxy.add_method('set_default_sheet', 's')
proxy.add_method('ferien_fuer_region', 'region')

sheets = proxy.sheets
Expand All @@ -42,12 +42,9 @@ def ferien_fuer_region(proxy, region, year=nil)
puts "first column: #{proxy.first_column}"
puts "last row: #{proxy.last_row}"
puts "last column: #{proxy.last_column}"
puts "cell: #{proxy.cell('C',8)}"
puts "cell: #{proxy.cell('F',12)}"
puts "cell: #{proxy.cell('C', 8)}"
puts "cell: #{proxy.cell('F', 12)}"
puts "officeversion: #{proxy.officeversion}"
puts "Berlin:"

ferien_fuer_region(proxy, "Berlin")


puts 'Berlin:'

ferien_fuer_region(proxy, 'Berlin')
10 changes: 4 additions & 6 deletions examples/roo_soap_server.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
require 'roo'
require 'soap/rpc/standaloneServer'

NS = "spreadsheetserver" # name of your service = namespace
NS = 'spreadsheetserver' # name of your service = namespace
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')
add_method(spreadsheet, 'last_row')
add_method(spreadsheet, 'first_column')
add_method(spreadsheet, 'last_column')
add_method(spreadsheet, 'sheets')
#add_method(spreadsheet, 'default_sheet=', 's')
# add_method(spreadsheet, 'default_sheet=', 's')
# method with '...=' did not work? alias method 'set_default_sheet' created
add_method(spreadsheet, 'set_default_sheet', 's')
end

end

PORT = 12321
PORT = 12_321
puts "serving at port #{PORT}"
svr = Server2.new('Roo', NS, '0.0.0.0', PORT)

Expand Down
19 changes: 9 additions & 10 deletions examples/write_me.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,27 @@
MAXTRIES = 1000
print "what's your name? "
my_name = gets.chomp
print "where do you live? "
print 'where do you live? '
my_location = gets.chomp
print "your message? (if left blank, only your name and location will be inserted) "
print 'your message? (if left blank, only your name and location will be inserted) '
my_message = gets.chomp
spreadsheet = Google.new('ptu6bbahNZpY0N0RrxQbWdw')
spreadsheet.default_sheet = 'Sheet1'
success = false
MAXTRIES.times do
col = rand(10)+1
row = rand(10)+1
if spreadsheet.empty?(row,col)
col = rand(10) + 1
row = rand(10) + 1
if spreadsheet.empty?(row, col)
if my_message.empty?
text = Time.now.to_s+" "+"Greetings from #{my_name} (#{my_location})"
text = Time.now.to_s + ' ' + "Greetings from #{my_name} (#{my_location})"
else
text = Time.now.to_s+" "+"#{my_message} from #{my_name} (#{my_location})"
text = Time.now.to_s + ' ' + "#{my_message} from #{my_name} (#{my_location})"
end
spreadsheet.set_value(row,col,text)
spreadsheet.set_value(row, col, text)
puts "message written to row #{row}, column #{col}"
success = true
break
end
puts "Row #{row}, column #{col} already occupied, trying again..."
end
puts "no empty cell found within #{MAXTRIES} tries" if !success

puts "no empty cell found within #{MAXTRIES} tries" unless success
22 changes: 11 additions & 11 deletions roo.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'roo/version'

Gem::Specification.new do |spec|
spec.name = "roo"
spec.name = 'roo'
spec.version = Roo::VERSION
spec.authors = ["Thomas Preymesser", "Hugh McGowan", "Ben Woosley"]
spec.email = ["[email protected]"]
spec.summary = "Roo can access the contents of various spreadsheet files."
spec.authors = ['Thomas Preymesser', 'Hugh McGowan', 'Ben Woosley']
spec.email = ['[email protected]']
spec.summary = 'Roo can access the contents of various spreadsheet files.'
spec.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"
spec.homepage = "http://github.com/Empact/roo"
spec.license = "MIT"
spec.homepage = 'http://github.com/Empact/roo'
spec.license = 'MIT'

spec.files = `git ls-files -z`.split("\x0")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.require_paths = ['lib']

spec.add_dependency "nokogiri"
spec.add_dependency "rubyzip"
spec.add_dependency 'nokogiri'
spec.add_dependency 'rubyzip'

spec.add_development_dependency "bundler", ">= 1.7"
spec.add_development_dependency "rake", ">= 10.0"
spec.add_development_dependency 'bundler', '>= 1.7'
spec.add_development_dependency 'rake', '>= 10.0'
spec.add_development_dependency 'minitest', '>= 5.4.3'
end
10 changes: 5 additions & 5 deletions spec/lib/roo/csv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
end

describe '#parse' do
subject {
subject do
csv.parse(options)
}
end
context 'with headers: true' do
let(:options) { {headers: true} }
let(:options) { { headers: true } }

it "doesn't blow up" do
expect { subject }.to_not raise_error
Expand All @@ -25,12 +25,12 @@

describe '#csv_options' do
context 'when created with the csv_options option' do
let(:options) {
let(:options) do
{
col_sep: '\t',
quote_char: "'"
}
}
end

it 'returns the csv options' do
csv = Roo::CSV.new(path, csv_options: options)
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/roo/excelx/format_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
'0%' => :percentage,
'0.00%' => :percentage,
'0.00E+00' => :float,
'# ?/?' => :float, #??? TODO:
'# ??/??' => :float, #??? TODO:
'# ?/?' => :float, # ??? TODO:
'# ??/??' => :float, # ??? TODO:
'mm-dd-yy' => :date,
'd-mmm-yy' => :date,
'd-mmm' => :date,
Expand All @@ -33,10 +33,10 @@
'##0.0E+0' => :float,
'@' => :float,
#-- zusaetzliche Formate, die nicht standardmaessig definiert sind:
"yyyy\\-mm\\-dd" => :date,
'yyyy\\-mm\\-dd' => :date,
'dd/mm/yy' => :date,
'hh:mm:ss' => :time,
"dd/mm/yy\\ hh:mm" => :datetime,
'dd/mm/yy\\ hh:mm' => :datetime,
'dd/mmm/yy\\ hh:mm' => :datetime,
'dd/mmm/yy' => :date, # 2011-05-21
'yyyy-mm-dd' => :date, # 2011-09-16
Expand Down
19 changes: 9 additions & 10 deletions spec/lib/roo/excelx_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
require 'spec_helper'

describe Roo::Excelx do
subject(:xlsx) {
subject(:xlsx) do
Roo::Excelx.new(path)
}

end

describe '.new' do
let(:path) { 'test/files/numeric-link.xlsx' }
Expand All @@ -27,13 +26,13 @@
context 'with numeric contents' do
let(:path) { 'test/files/numeric-link.xlsx' }

subject {
subject do
xlsx.cell('A', 1)
}
end

it 'returns a link with the number as a string value' do
expect(subject).to be_a(Roo::Link)
expect(subject).to eq("8675309.0")
expect(subject).to eq('8675309.0')
end
end
end
Expand All @@ -45,12 +44,12 @@
context 'with a columns hash' do
context 'when not present in the sheet' do
it 'does not raise' do
expect {
expect do
xlsx.sheet(0).parse(
this: "This",
that: "That"
this: 'This',
that: 'That'
)
}.to raise_error("Couldn't find header row.")
end.to raise_error("Couldn't find header row.")
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/roo/libreoffice_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

describe Roo::LibreOffice do
describe '.new' do
subject {
subject do
Roo::LibreOffice.new('test/files/numbers1.ods')
}
end

it 'creates an instance' do
expect(subject).to be_a(Roo::LibreOffice)
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/roo/openoffice_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

describe Roo::OpenOffice do
describe '.new' do
subject {
subject do
Roo::OpenOffice.new('test/files/numbers1.ods')
}
end

it 'creates an instance' do
expect(subject).to be_a(Roo::OpenOffice)
Expand Down
Loading

0 comments on commit 5f5ca3f

Please sign in to comment.