Rails 4 support and setup errors

173 views
Skip to first unread message

Thor Helgason

unread,
Apr 13, 2014, 7:49:03 AM4/13/14
to open...@googlegroups.com
Hi there!

I've been looking into using sportdb for creating a non-commercial app for the world cup. When trying to use it with Rails 4 I've encountered number of issues regarding multiline anchors in regular expressions in sportdb and some of the dependencies (worlddb and tagutils). Is there a plan to upgrade these libraries to support rails 4 in the near future? 

Also, I fixed these errors locally to see if it still worked, and I keep getting file parsing erros when running 'sportdb setup'  when attempting to read a file which is not located within a gem:

"[info] parsing data 'setups/all' (/home/thor/.rvm/gems/ruby-2.1.0/gems/sportdb-1.8.12/data/setups/all.txt)...
[info] parsing data 'seasons' (/home/thor/.rvm/gems/ruby-2.1.0/gems/sportdb-1.8.12/data/seasons.txt)...
[info] parsing data 'setups/all' (/setups/all.txt)...
*** error: No such file or directory @ rb_sysopen - /setups/all.txt"

Similarly when I run 'sportdb --dbname world-cup-2014.db setup --include ./world-cup --worldinclude ./world.db' I get in the end:

"[info] parsing data 'setups/all' (/home/thor/.rvm/gems/ruby-2.1.0/gems/sportdb-1.8.12/data/setups/all.txt)...
[info] parsing data 'seasons' (/home/thor/.rvm/gems/ruby-2.1.0/gems/sportdb-1.8.12/data/seasons.txt)...
[info] parsing data 'setups/all' (./world.db/setups/all.txt)...
*** error: No such file or directory @ rb_sysopen - ./world.db/setups/all.txt"

Otherwise the models seem to work fine in the sportdb/console, I just don't have any data because of these missing file errors.

Cheers,
Thor

Gerald Bauer

unread,
Apr 14, 2014, 6:59:54 AM4/14/14
to open...@googlegroups.com
Hello,

Thanks for trying the sportdb gem.

> Is there a plan to upgrade these libraries to support rails 4 in the near future?

Yes, of course. Will try to fix all regex anchors in the next
weeks. Thanks for your patience.

> Also, I fixed these errors locally to see if it still worked, and I keep getting file parsing erros when
> running 'sportdb setup' when attempting to read a file which is not located within a gem:

If you know Rails / Ruby I recommend using a build script
(Rakefile). Otherwise please try the --verbose flag and post the stack
trace.

Note, if you use sportdb setup you always need use the --include
option to point to your fixtures - the fixtures are NOT included in
the gem. You have to clone - get copies from GitHub ( see
github.com/openfootball ). Let me know if it works or what errors
you get or what questions you have.

Cheers.
> --
> You received this message because you are subscribed to the Google Groups
> "Open Sport(s) Database - football.db, formula1.db, ski.db, and Friends"
> group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to opensport+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Gerald Bauer

unread,
Apr 14, 2014, 7:08:49 AM4/14/14
to open...@googlegroups.com
Hello,

FYI: If it helps a "simplified" build script for the world cup.
Full "official" build script online @ github.com/openfootball/build
Cheers.

Rakefile:
------------------------------


BUILD_DIR = "./build"

# -- output db config
FOOTBALL_DB_PATH = "#{BUILD_DIR}/football.db"


DB_CONFIG = {
adapter: 'sqlite3',
database: FOOTBALL_DB_PATH
}


# input repo sources config

# --- world.db ---

OPENMUNDI_ROOT = "../../openmundi"
WORLD_DB_INCLUDE_PATH = "#{OPENMUNDI_ROOT}/world.db"


# --- football.db ---

OPENFOOTBALL_ROOT = ".."

# national teams
WORLD_CUP_INCLUDE_PATH = "#{OPENFOOTBALL_ROOT}/world-cup"
EURO_CUP_INCLUDE_PATH = "#{OPENFOOTBALL_ROOT}/euro-cup"
AFRICA_CUP_INCLUDE_PATH = "#{OPENFOOTBALL_ROOT}/africa-cup"
NORTH_AMERICA_GOLD_CUP_INCLUDE_PATH =
"#{OPENFOOTBALL_ROOT}/north-america-gold-cup"
COPA_AMERICA_INCLUDE_PATH = "#{OPENFOOTBALL_ROOT}/copa-america"


puts settings



task :default => :build

directory BUILD_DIR


task :clean do
rm FOOTBALL_DB_PATH if File.exists?( FOOTBALL_DB_PATH )
end


task :env => BUILD_DIR do
require 'worlddb'
require 'sportdb'
require 'logutils/db'

LogUtils::Logger.root.level = :info

pp DB_CONFIG
ActiveRecord::Base.establish_connection( DB_CONFIG )
end


task :create => :env do
LogDb.create
ConfDb.create
TagDb.create
WorldDb.create
SportDb.create
end

task :importworld => :env do
# populate world tables
WorldDb.read_setup( 'setups/sport.db.admin', WORLD_DB_INCLUDE_PATH,
skip_tags: true )
end

task :importbuiltin => :env do
SportDb.read_builtin
LogUtils::Logger.root.level = :debug
end


#####################
# national teams

task :worldcup => :importbuiltin do
SportDb.read_setup( 'setups/teams', EURO_CUP_INCLUDE_PATH )
SportDb.read_setup( 'setups/teams', AFRICA_CUP_INCLUDE_PATH )
SportDb.read_setup( 'setups/teams', NORTH_AMERICA_GOLD_CUP_INCLUDE_PATH )
SportDb.read_setup( 'setups/teams', COPA_AMERICA_INCLUDE_PATH )
SportDb.read_setup( 'setups/all', WORLD_CUP_INCLUDE_PATH )
end


task :importsport => :worldcup do
# nothing here
end


task :deletesport => :env do
SportDb.delete!
end


desc 'build football.db from scratch (default)'
task :build => [:clean, :create, :importworld, :importsport] do
puts 'Done.'
end

desc 'update football.db'
task :update => [:deletesport, :importsport] do
puts 'Done.'
end

desc 'pull (auto-update) football.db from upstream sources'
task :pull => :env do
SportDb.update!
puts 'Done.'
end



desc 'print versions of gems'
task :about => :env do
puts ''
puts 'gem versions'
puts '============'
puts "textutils #{TextUtils::VERSION} (#{TextUtils.root})"
puts "worlddb #{WorldDb::VERSION} (#{WorldDb.root})"
puts "sportdb #{SportDb::VERSION} (#{SportDb.root})"

## todo - add LogUtils LogDb ?? - check for .root too
end


desc 'print stats for football.db tables/records'
task :stats => :env do
puts ''
puts 'world.db'
puts '============'
WorldDb.tables

puts ''
puts 'football.db'
puts '==========='
SportDb.tables
end



2014-04-13 13:49 GMT+02:00 Thor Helgason <thorval...@gmail.com>:

Gerald Bauer

unread,
Apr 15, 2014, 2:27:12 AM4/15/14
to open...@googlegroups.com
Hello Thor,


> When trying to use it with Rails 4 I've encountered number of issues regarding multiline anchors in regular expressions in sportdb and some
> of the dependencies (worlddb and tagutils). Is there a plan to upgrade these libraries to support rails 4 in the near future?

  I've updated all gems to use /A/z anchors (instead of ^$) for model validations, that is, the new versions are:
 
 - worlddb v2.0.4
 - sportdb v1.8.13
 - tagutils v0.2.2

   If you still get an exception for model format regexes after the update, it's now considered a bug and please report it. Thanks. Cheers.
Reply all
Reply to author
Forward
0 new messages