Sha256: 23aeff02307f29f19af73634d91488903b1b3484768161d0c480a4494d7c7f33

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

#! /usr/bin/env ruby
# -*- coding: utf-8 -*-
#
# points.rb: getting mileages/points from shopping web sites.
#
# Copyright (C) 2012 by TADA Tadashi <t@tdtds.jp>
# Distributed under GPL.
#

require 'rubygems'
require 'points-scraper'
require 'thor'
require 'pit'

module Points::Scraper
	class App < Thor
		desc 'tpoint', 'getting current T-POINT from T-SITE.'
		def tpoint
			begin
				require 'points-scraper/tpoint'
				puts TPoint.new( *auth( 'tsite' ) ).start
			rescue Net::OpenTimeout
				$stderr.puts 'T-POINT official site has no response, trying Yahoo! JAPAN.'
				require 'points-scraper/tpoint-yahoo'
				puts TPointYahoo.new( *auth( 'yahoo-japan' ) ).start
			end
		end

		desc 'ana', 'getting current ANA Mileage.'
		def ana
			require 'points-scraper/anamileage'
			puts AnaMileage.new( *auth( 'ana' ) ).start
		end

		desc 'rakuten', 'getting current Rakuten Points.'
		def rakuten
			require 'points-scraper/rakuten'
			puts Rakuten.new( *auth( 'rakuten' ) ).start
		end

		desc 'help', 'show command help.'
		def help
			super
		end

	private
		def auth( key )
			login = Pit::get( key, :require => {
				'user' => "your ID of #{key}.",
				'pass' => "your Password of #{key}."
			} )
			[login['user'], login['pass']]
		end
	end
end

Points::Scraper::App.start

# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vim: ts=3

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
points-scraper-0.1.3 bin/points
points-scraper-0.1.2 bin/points
points-scraper-0.1.1 bin/points