ws-aboutme 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README +30 -0
- data/Rakefile +62 -0
- data/lib/webservice/aboutme.rb +32 -0
- data/lib/webservice/aboutme/api.rb +505 -0
- data/lib/webservice/aboutme/version.rb +22 -0
- data/lib/webservice/aboutme/xmlobjectmapping.rb +110 -0
- data/test/tc_config.rb +54 -0
- data/test/tc_search_answer_response.rb +59 -0
- data/test/tc_search_answer_response.xml +40 -0
- data/test/tc_search_question_response.rb +56 -0
- data/test/tc_search_question_response.xml +65 -0
- data/test/tc_search_user_response.rb +52 -0
- data/test/tc_search_user_response.xml +27 -0
- data/test/tc_show_answer_digest_response.rb +51 -0
- data/test/tc_show_answer_digest_response.xml +26 -0
- data/test/tc_show_answer_response.rb +38 -0
- data/test/tc_show_answer_response.xml +20 -0
- data/test/tc_show_question_response.rb +63 -0
- data/test/tc_show_question_response.xml +34 -0
- data/test/tc_show_user_response.rb +64 -0
- data/test/tc_show_user_response.xml +37 -0
- data/test/test_helper.rb +14 -0
- metadata +73 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
+
<response>
|
3
|
+
<status>
|
4
|
+
<code>200</code>
|
5
|
+
<message>OK</message>
|
6
|
+
<language>ja</language>
|
7
|
+
</status>
|
8
|
+
<result>
|
9
|
+
<summary>
|
10
|
+
<total>99</total>
|
11
|
+
<page>2</page>
|
12
|
+
<page_count>10</page_count>
|
13
|
+
</summary>
|
14
|
+
<users>
|
15
|
+
<user>
|
16
|
+
<id>123</id>
|
17
|
+
<nickname>test-user123</nickname>
|
18
|
+
<url>http://test-user123.aboutme.jp/</url>
|
19
|
+
</user>
|
20
|
+
<user>
|
21
|
+
<id>9876</id>
|
22
|
+
<nickname>test-user9876</nickname>
|
23
|
+
<url>http://test-user9876.aboutme.jp/</url>
|
24
|
+
</user>
|
25
|
+
</users>
|
26
|
+
</result>
|
27
|
+
</response>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
#
|
4
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
5
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'webservice', 'aboutme', 'api')
|
6
|
+
|
7
|
+
require 'date'
|
8
|
+
require 'test/unit'
|
9
|
+
|
10
|
+
class ShowAnswerDigestResponseTest < Test::Unit::TestCase
|
11
|
+
|
12
|
+
include TestHelper
|
13
|
+
include WebService::Aboutme
|
14
|
+
|
15
|
+
def test_unmarshal
|
16
|
+
xml = parse_xml('tc_show_answer_digest_response.xml')
|
17
|
+
response = ShowAnswerDigestResponse.unmarshal(xml.root)
|
18
|
+
assert_not_nil response
|
19
|
+
|
20
|
+
# response.status.*
|
21
|
+
s = response.status
|
22
|
+
assert_not_nil s
|
23
|
+
assert_equal 200, s.code
|
24
|
+
assert_equal 'OK', s.message
|
25
|
+
assert_equal 'ja', s.language
|
26
|
+
|
27
|
+
# response.digest.*
|
28
|
+
d = response.digest
|
29
|
+
assert_not_nil d
|
30
|
+
assert_equal 123456, d.id
|
31
|
+
assert_equal 98, d.count
|
32
|
+
|
33
|
+
# response.digest.choices
|
34
|
+
choices = d.choices
|
35
|
+
assert_not_nil choices
|
36
|
+
assert_equal 2, choices.size
|
37
|
+
|
38
|
+
# response.digest.choices[0].*
|
39
|
+
ch = choices[0]
|
40
|
+
assert_equal 1, ch.priority
|
41
|
+
assert_equal 'choice1', ch.title
|
42
|
+
assert_equal 76, ch.answer_count
|
43
|
+
|
44
|
+
# response.digest.choices[1].*
|
45
|
+
ch = choices[1]
|
46
|
+
assert_equal 2, ch.priority
|
47
|
+
assert_equal 'choice2', ch.title
|
48
|
+
assert_equal 54, ch.answer_count
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
+
<response>
|
3
|
+
<status>
|
4
|
+
<code>200</code>
|
5
|
+
<message>OK</message>
|
6
|
+
<language>ja</language>
|
7
|
+
</status>
|
8
|
+
<result>
|
9
|
+
<answers_digest>
|
10
|
+
<id>123456</id>
|
11
|
+
<answers_count>98</answers_count>
|
12
|
+
<options>
|
13
|
+
<option>
|
14
|
+
<priority>1</priority>
|
15
|
+
<title>choice1</title>
|
16
|
+
<answers_count>76</answers_count>
|
17
|
+
</option>
|
18
|
+
<option>
|
19
|
+
<priority>2</priority>
|
20
|
+
<title>choice2</title>
|
21
|
+
<answers_count>54</answers_count>
|
22
|
+
</option>
|
23
|
+
</options>
|
24
|
+
</answers_digest>
|
25
|
+
</result>
|
26
|
+
</response>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
#
|
4
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
5
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'webservice', 'aboutme', 'api')
|
6
|
+
|
7
|
+
require 'date'
|
8
|
+
require 'test/unit'
|
9
|
+
|
10
|
+
class ShowAnswerResponseTest < Test::Unit::TestCase
|
11
|
+
|
12
|
+
include TestHelper
|
13
|
+
include WebService::Aboutme
|
14
|
+
|
15
|
+
def test_unmarshal
|
16
|
+
xml = parse_xml('tc_show_answer_response.xml')
|
17
|
+
response = ShowAnswerResponse.unmarshal(xml.root)
|
18
|
+
assert_not_nil response
|
19
|
+
|
20
|
+
# response.status.*
|
21
|
+
s = response.status
|
22
|
+
assert_not_nil s
|
23
|
+
assert_equal 200, s.code
|
24
|
+
assert_equal 'OK', s.message
|
25
|
+
assert_equal 'ja', s.language
|
26
|
+
|
27
|
+
# response.answer.*
|
28
|
+
a = response.answer
|
29
|
+
assert_not_nil a
|
30
|
+
assert_equal 1234, a.id
|
31
|
+
assert_equal 'テスト', a.title
|
32
|
+
assert_equal 987654, a.question_id
|
33
|
+
assert_equal DateTime.parse('2007-07-31T10:20:30+09:00'), a.updated_at
|
34
|
+
assert_equal 999, a.answerer.id
|
35
|
+
assert_equal 'test-user999', a.answerer.nickname
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
+
<response>
|
3
|
+
<status>
|
4
|
+
<code>200</code>
|
5
|
+
<message>OK</message>
|
6
|
+
<language>ja</language>
|
7
|
+
</status>
|
8
|
+
<result>
|
9
|
+
<answer>
|
10
|
+
<id>1234</id>
|
11
|
+
<title>テスト</title>
|
12
|
+
<question_id>987654</question_id>
|
13
|
+
<updated_at>2007-07-31T10:20:30+09:00</updated_at>
|
14
|
+
<answerer>
|
15
|
+
<id>999</id>
|
16
|
+
<nickname>test-user999</nickname>
|
17
|
+
</answerer>
|
18
|
+
</answer>
|
19
|
+
</result>
|
20
|
+
</response>
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
#
|
4
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
5
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'webservice', 'aboutme', 'api')
|
6
|
+
|
7
|
+
require 'date'
|
8
|
+
require 'test/unit'
|
9
|
+
|
10
|
+
class ShowQuestionResponseTest < Test::Unit::TestCase
|
11
|
+
|
12
|
+
include TestHelper
|
13
|
+
include WebService::Aboutme
|
14
|
+
|
15
|
+
def test_unmarshal
|
16
|
+
xml = parse_xml('tc_show_question_response.xml')
|
17
|
+
response = ShowQuestionResponse.unmarshal(xml.root)
|
18
|
+
assert_not_nil response
|
19
|
+
|
20
|
+
# response.status.*
|
21
|
+
s = response.status
|
22
|
+
assert_not_nil s
|
23
|
+
assert_equal 200, s.code
|
24
|
+
assert_equal 'OK', s.message
|
25
|
+
assert_equal 'ja', s.language
|
26
|
+
|
27
|
+
# response.question.*
|
28
|
+
q = response.question
|
29
|
+
assert_not_nil q
|
30
|
+
assert_equal 987654, q.id
|
31
|
+
assert_equal 'テスト', q.title
|
32
|
+
assert_equal DateTime.parse('2007-07-31T12:34:56+09:00'), q.created_at
|
33
|
+
assert_instance_of DateTime, q.created_at
|
34
|
+
|
35
|
+
# response.question.creator.*
|
36
|
+
creator = q.creator
|
37
|
+
assert_not_nil creator
|
38
|
+
assert_equal 12345, creator.id
|
39
|
+
assert_equal 'test-user12345', creator.nickname
|
40
|
+
|
41
|
+
# response.question.choices
|
42
|
+
choices = q.choices
|
43
|
+
assert_not_nil choices
|
44
|
+
assert_equal 3, choices.size
|
45
|
+
|
46
|
+
# response.question.choices[0]
|
47
|
+
c = choices[0]
|
48
|
+
assert_equal 1, c.priority
|
49
|
+
assert_equal 'test1', c.title
|
50
|
+
|
51
|
+
# response.question.choices[1]
|
52
|
+
c = choices[1]
|
53
|
+
assert_equal 2, c.priority
|
54
|
+
assert_equal 'test2', c.title
|
55
|
+
|
56
|
+
# response.question.choices[2]
|
57
|
+
c = choices[2]
|
58
|
+
assert_equal 3, c.priority
|
59
|
+
assert_equal 'test3', c.title
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
+
<response>
|
3
|
+
<status>
|
4
|
+
<code>200</code>
|
5
|
+
<message>OK</message>
|
6
|
+
<language>ja</language>
|
7
|
+
</status>
|
8
|
+
<result>
|
9
|
+
<question>
|
10
|
+
<id>987654</id>
|
11
|
+
<title>テスト</title>
|
12
|
+
<url>http://aboutme.jp/question/show/987654</url>
|
13
|
+
<creator>
|
14
|
+
<id>12345</id>
|
15
|
+
<nickname>test-user12345</nickname>
|
16
|
+
</creator>
|
17
|
+
<created_at>2007-07-31T12:34:56+09:00</created_at>
|
18
|
+
<options>
|
19
|
+
<option>
|
20
|
+
<priority>1</priority>
|
21
|
+
<title>test1</title>
|
22
|
+
</option>
|
23
|
+
<option>
|
24
|
+
<priority>2</priority>
|
25
|
+
<title>test2</title>
|
26
|
+
</option>
|
27
|
+
<option>
|
28
|
+
<priority>3</priority>
|
29
|
+
<title>test3</title>
|
30
|
+
</option>
|
31
|
+
</options>
|
32
|
+
</question>
|
33
|
+
</result>
|
34
|
+
</response>
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
#
|
4
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
5
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'webservice', 'aboutme', 'api')
|
6
|
+
|
7
|
+
require 'date'
|
8
|
+
require 'test/unit'
|
9
|
+
|
10
|
+
class ShowUserResponseTest < Test::Unit::TestCase
|
11
|
+
|
12
|
+
include TestHelper
|
13
|
+
include WebService::Aboutme
|
14
|
+
|
15
|
+
def test_unmarshal
|
16
|
+
xml = parse_xml('tc_show_user_response.xml')
|
17
|
+
response = ShowUserResponse.unmarshal(xml.root)
|
18
|
+
assert_not_nil response
|
19
|
+
|
20
|
+
# response.status.*
|
21
|
+
s = response.status
|
22
|
+
assert_not_nil s
|
23
|
+
assert_equal 200, s.code
|
24
|
+
assert_equal 'OK', s.message
|
25
|
+
assert_equal 'ja', s.language
|
26
|
+
|
27
|
+
#response.user.*
|
28
|
+
user = response.user
|
29
|
+
assert_not_nil user
|
30
|
+
assert_equal 123, user.id
|
31
|
+
assert_equal 'test-user', user.nickname
|
32
|
+
assert_equal 'http://testuser.aboutme.jp/', user.url
|
33
|
+
assert_equal 'M', user.gender
|
34
|
+
assert_equal 26, user.age
|
35
|
+
assert_equal '山羊座', user.horoscope
|
36
|
+
assert_equal 'B', user.blood_type
|
37
|
+
assert_equal '北海道', user.prefecture
|
38
|
+
assert_equal '札幌市', user.area
|
39
|
+
assert_equal 'テスト。', user.introduction
|
40
|
+
|
41
|
+
# response.user.images.*
|
42
|
+
images = user.images
|
43
|
+
assert_not_nil images
|
44
|
+
assert_equal 'http://aboutme.jp/user/image/icon.jpg', images.icon
|
45
|
+
assert_equal 'http://aboutme.jp/user/image/small.jpg', images.small
|
46
|
+
assert_equal 'http://aboutme.jp/user/image/medium.jpg', images.medium
|
47
|
+
assert_equal 'http://aboutme.jp/user/image/large.jpg', images.large
|
48
|
+
|
49
|
+
# response.user.birthday.*
|
50
|
+
birthday = user.birthday
|
51
|
+
assert_not_nil birthday
|
52
|
+
assert_equal 1980, birthday.year
|
53
|
+
assert_equal 12, birthday.month
|
54
|
+
assert_equal 31, birthday.day
|
55
|
+
|
56
|
+
# response.user.interests[*]
|
57
|
+
interests = user.interests
|
58
|
+
assert_not_nil interests
|
59
|
+
assert_equal 2, interests.size
|
60
|
+
assert_equal 'test', interests[0]
|
61
|
+
assert_equal 'テスト', interests[1]
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
+
<response>
|
3
|
+
<status>
|
4
|
+
<code>200</code>
|
5
|
+
<message>OK</message>
|
6
|
+
<language>ja</language>
|
7
|
+
</status>
|
8
|
+
<result>
|
9
|
+
<user>
|
10
|
+
<id>123</id>
|
11
|
+
<nickname>test-user</nickname>
|
12
|
+
<url>http://testuser.aboutme.jp/</url>
|
13
|
+
<images>
|
14
|
+
<icon>http://aboutme.jp/user/image/icon.jpg</icon>
|
15
|
+
<small>http://aboutme.jp/user/image/small.jpg</small>
|
16
|
+
<medium>http://aboutme.jp/user/image/medium.jpg</medium>
|
17
|
+
<large>http://aboutme.jp/user/image/large.jpg</large>
|
18
|
+
</images>
|
19
|
+
<gender>M</gender>
|
20
|
+
<birthday>
|
21
|
+
<year>1980</year>
|
22
|
+
<month>12</month>
|
23
|
+
<day>31</day>
|
24
|
+
</birthday>
|
25
|
+
<age>26</age>
|
26
|
+
<horoscope>山羊座</horoscope>
|
27
|
+
<blood_type>B</blood_type>
|
28
|
+
<prefecture>北海道</prefecture>
|
29
|
+
<area>札幌市</area>
|
30
|
+
<introduction>テスト。</introduction>
|
31
|
+
<interests>
|
32
|
+
<interest>test</interest>
|
33
|
+
<interest>テスト</interest>
|
34
|
+
</interests>
|
35
|
+
</user>
|
36
|
+
</result>
|
37
|
+
</response>
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
|
5
|
+
module TestHelper
|
6
|
+
def parse_xml(filename)
|
7
|
+
xml_source = load_xml(filename)
|
8
|
+
REXML::Document.new(xml_source)
|
9
|
+
end
|
10
|
+
|
11
|
+
def load_xml(filename)
|
12
|
+
IO.read(File.join(File.dirname(__FILE__), filename))
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.4
|
3
|
+
specification_version: 1
|
4
|
+
name: ws-aboutme
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.5.1
|
7
|
+
date: 2007-08-27 00:00:00 +09:00
|
8
|
+
summary: API client Library for @nifty Aboutme web service
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: moc.liamg.cesare+ws-aboutme@gmail.com
|
12
|
+
homepage:
|
13
|
+
rubyforge_project:
|
14
|
+
description:
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.8.2
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- SAWADA Tadashi
|
31
|
+
files:
|
32
|
+
- test/tc_config.rb
|
33
|
+
- test/tc_search_answer_response.rb
|
34
|
+
- test/tc_search_answer_response.xml
|
35
|
+
- test/tc_search_question_response.rb
|
36
|
+
- test/tc_search_question_response.xml
|
37
|
+
- test/tc_search_user_response.rb
|
38
|
+
- test/tc_search_user_response.xml
|
39
|
+
- test/tc_show_answer_digest_response.rb
|
40
|
+
- test/tc_show_answer_digest_response.xml
|
41
|
+
- test/tc_show_answer_response.rb
|
42
|
+
- test/tc_show_answer_response.xml
|
43
|
+
- test/tc_show_question_response.rb
|
44
|
+
- test/tc_show_question_response.xml
|
45
|
+
- test/tc_show_user_response.rb
|
46
|
+
- test/tc_show_user_response.xml
|
47
|
+
- test/test_helper.rb
|
48
|
+
- lib/webservice
|
49
|
+
- lib/webservice/aboutme
|
50
|
+
- lib/webservice/aboutme/api.rb
|
51
|
+
- lib/webservice/aboutme/version.rb
|
52
|
+
- lib/webservice/aboutme/xmlobjectmapping.rb
|
53
|
+
- lib/webservice/aboutme.rb
|
54
|
+
- Rakefile
|
55
|
+
- MIT-LICENSE
|
56
|
+
- README
|
57
|
+
test_files: []
|
58
|
+
|
59
|
+
rdoc_options:
|
60
|
+
- --charset
|
61
|
+
- UTF-8
|
62
|
+
- --main
|
63
|
+
- README
|
64
|
+
extra_rdoc_files:
|
65
|
+
- README
|
66
|
+
executables: []
|
67
|
+
|
68
|
+
extensions: []
|
69
|
+
|
70
|
+
requirements: []
|
71
|
+
|
72
|
+
dependencies: []
|
73
|
+
|