Sha256: 27f9b7d5464a6fbfdacd9549232f05e76b5997578d8e9a6b791b2e05e62762a9

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

# -*- coding: utf-8 -*-
require 'net/http'
require 'consadole_aggregator/nikkan_sports'
require 'consadole_aggregator/live'

if RUBY_VERSION < '1.9'
  # strptime は1.9 features なので、1.8 対応のモンキーパッチ
  class Time
    def Time.strptime(base, format)
      ary = base.split(/[^\d]/).delete_if{ |x| x.empty? }
      case ary.size
      when 3
        Time.mktime(Time.now.year, Time.now.month, ary[0], ary[1], ary[2], 0, 0)
      when 5
        Time.mktime(ary[0], ary[1], ary[2], ary[3], ary[4], 0, 0)
      else
        Time.now
      end
    end
  end
end

module ConsadoleAggregator
  Image = Struct.new :src, :alt, :binary do
    def binary
      self['binary'] ||= Net::HTTP.get(self['src']).encode(Encoding::BINARY)
    end

    def to_html
      %Q{<image src="#{self.src}" alt="#{self.alt}">}
    end
  end
end

if __FILE__ == $0
  DataMapper.setup(:default, 'sqlite3:db/test.sqlite3')
  DataMapper.auto_migrate!

  ConsadoleAggregator::NikkanSports.save
  print ConsadoleAggregator::NikkanSports.rss
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
consadole_aggregator-0.0.3 lib/consadole_aggregator.rb
consadole_aggregator-0.0.1 lib/consadole_aggregator.rb