madowu 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,74 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require 'pp'
5
- #Amazon::Ecs.debug = true
6
-
7
- #
8
- #
9
- #
10
- class Madowu::Isbn
11
-
12
- ROOT_KEY_FILE = ENV['HOME'] + '/.aws/rootkey.csv'
13
- ASSOCIATEID_FILE = ENV['HOME'] + '/.aws/associateid'
14
-
15
- class AccountFileError < StandardError; end
16
-
17
- #
18
- def initialize(isbn)
19
- @isbn = isbn
20
- [ROOT_KEY_FILE, ASSOCIATEID_FILE].each do |file|
21
- raise AccountFileError, "Not found #{file}" unless File.exist? file
22
- end
23
-
24
- hash = {}
25
- hash[:associate_tag] = File.open(ASSOCIATEID_FILE, 'r').gets.chomp
26
- File.open(ROOT_KEY_FILE, 'r').readlines.each do |i|
27
- /(.*)=(.*)/ =~ i
28
- key, val = $1, $2
29
- hash[:AWS_access_key_id] = val.chomp if key == 'AWSAccessKeyId'
30
- hash[:AWS_secret_key] = val.chomp if key == 'AWSSecretKey'
31
- end
32
-
33
- Amazon::Ecs.options = hash
34
- #pp Amazon::Ecs.options
35
- #exit
36
-
37
- @info = Amazon::Ecs.item_search(
38
- isbn,
39
- {:search_index => 'Books', :response_group => 'Medium', :country => 'jp'}
40
- )
41
- #pp @info
42
- #exit
43
- end
44
-
45
- def title
46
- @info.items.each { |item| return item.get('ItemAttributes/Title') }
47
- end
48
-
49
- def author
50
- @info.items.each { |item| return item.get('ItemAttributes/Author') }
51
- end
52
-
53
- def isbn
54
- @info.items.each { |item| return item.get('ItemAttributes/ISBN') }
55
- end
56
-
57
- def publisher
58
- @info.items.each { |item| return item.get('ItemAttributes/Publisher') }
59
- end
60
-
61
- def publication_date
62
- @info.items.each { |item| return item.get('ItemAttributes/PublicationDate') }
63
- end
64
-
65
- def url
66
- @info.items.each { |item| return item.get('DetailPageURL') }
67
- end
68
-
69
- def img_url
70
- @info.items.each { |item| return item.get('SmallImage/URL') }
71
- end
72
-
73
- end
74
-
@@ -1,56 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- ## This test depends on Amazon Web Service...
5
-
6
- require "pp"
7
- require "helper"
8
- #require "test/unit"
9
- #require "pkg/klass.rb"
10
-
11
-
12
- class Madowu::Isbn
13
- attr_accessor :info
14
- end
15
-
16
- #I00 = Madowu::Isbn.new('479803925X')
17
-
18
- class TC_Isbn < Test::Unit::TestCase
19
- #def setup
20
- # #@i00 = Madowu::Isbn.new('', 'test/isbn/479803925X.xml')
21
- #end
22
-
23
- #def test_title
24
- # assert_equal('プログラムはこうして作られるプログラマの頭の中をのぞいてみよう',
25
- # I00.title)
26
- #end
27
-
28
- #def test_author
29
- # assert_equal('平山 尚(株式会社セガ)', I00.author)
30
- #end
31
-
32
- #def test_isbn
33
- # assert_equal('479803925X', I00.isbn)
34
- #end
35
-
36
- #def test_publisher
37
- # assert_equal('秀和システム', I00.publisher)
38
- #end
39
-
40
- #def test_publicationDate
41
- # assert_equal('2013-09-25', I00.publication_date)
42
- #end
43
- #
44
- #
45
-
46
- # def test_url
47
- # assert_equal("http://www.amazon.co.jp/%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%81%AF%E3%81%93%E3%81%86%E3%81%97%E3%81%A6%E4%BD%9C%E3%82%89%E3%82%8C%E3%82%8B%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9E%E3%81%AE%E9%A0%AD%E3%81%AE%E4%B8%AD%E3%82%92%E3%81%AE%E3%81%9E%E3%81%84%E3%81%A6%E3%81%BF%E3%82%88%E3%81%86-%E5%B9%B3%E5%B1%B1-%E5%B0%9A-%E6%A0%AA%E5%BC%8F%E4%BC%9A%E7%A4%BE%E3%82%BB%E3%82%AC/dp/479803925X%3FSubscriptionId%3DAKIAIRDYXYLFLVKUASUQ%26tag%3Dippei94da-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D479803925X", I00.url)
48
- # end
49
- #
50
- # def test_img_url
51
- # assert_equal("http://ecx.images-amazon.com/images/I/41td-P03xmL._SL75_.jpg",
52
- # I00.img_url)
53
- #
54
- # end
55
- end
56
-