Sha256: a56be9d8a6623d9e3924500bd80a606f11874097440cfe5b842022d53848800c

Contents?: true

Size: 1.29 KB

Versions: 31

Compression:

Stored size: 1.29 KB

Contents

# encoding: UTF-8

module SportDb


class SeasonReader

  include LogUtils::Logging

## make models available by default with namespace
#  e.g. lets you use Usage instead of Model::Usage
  include Models


  attr_reader :include_path


  def initialize( include_path, opts = {} )
    @include_path = include_path
  end


  def read( name, more_attribs={} )
    reader = LineReaderV2.new( name, include_path )

####
## fix!!!!!
##   use Season.create_or_update_from_hash or similar
##   use Season.create_or_update_from_hash_reader?? or similar
#   move parsing code to model

    reader.each_line do |line|

      # for now assume single value
      logger.debug ">#{line}<"

      key = line

      logger.debug "  find season key: #{key}"
      season = Season.find_by_key( key )

      season_attribs = {}

      ## check if it exists
      if season.present?
        logger.debug "update season #{season.id}-#{season.key}:"
      else
        logger.debug "create season:"
        season = Season.new
        season_attribs[ :key ] = key
      end

      season_attribs[ :title ] = key # for now key n title are the same
     
      logger.debug season_attribs.to_json
          
      season.update_attributes!( season_attribs )
    end # each line

  end  # method read


end # class SeasonReader
end # module SportDb

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
sportdb-1.9.8 lib/sportdb/readers/season.rb
sportdb-1.9.7 lib/sportdb/readers/season.rb
sportdb-1.9.6 lib/sportdb/readers/season.rb
sportdb-1.9.5 lib/sportdb/readers/season.rb
sportdb-1.9.4 lib/sportdb/readers/season.rb
sportdb-1.9.3 lib/sportdb/readers/season.rb
sportdb-1.9.2 lib/sportdb/readers/season.rb
sportdb-1.9.1 lib/sportdb/readers/season.rb
sportdb-1.9.0 lib/sportdb/readers/season.rb
sportdb-1.8.29 lib/sportdb/readers/season.rb
sportdb-1.8.28 lib/sportdb/readers/season.rb
sportdb-1.8.27 lib/sportdb/readers/season.rb
sportdb-1.8.26 lib/sportdb/readers/season.rb
sportdb-1.8.25 lib/sportdb/readers/season.rb
sportdb-1.8.24 lib/sportdb/readers/season.rb
sportdb-1.8.23 lib/sportdb/readers/season.rb
sportdb-1.8.22 lib/sportdb/readers/season.rb
sportdb-1.8.21 lib/sportdb/readers/season.rb
sportdb-1.8.20 lib/sportdb/readers/season.rb
sportdb-1.8.19 lib/sportdb/readers/season.rb