crown 0.0.11 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +11 -3
- data/README.rdoc +23 -1
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/crown.gemspec +28 -7
- data/example/cgmcount.rb +65 -0
- data/example/feedcount.rb +50 -0
- data/example/sbmcount.rb +5 -1
- data/lib/crown.rb +4 -14
- data/lib/crown/backtype.rb +29 -25
- data/lib/crown/backtype/counter.rb +79 -0
- data/lib/crown/buzzurl.rb +15 -28
- data/lib/crown/buzzurl/counter.rb +88 -0
- data/lib/crown/cgm.rb +98 -0
- data/lib/crown/cgm/countable.rb +130 -0
- data/lib/crown/cgm/summarizable.rb +130 -0
- data/lib/crown/delicious.rb +14 -29
- data/lib/crown/delicious/counter.rb +88 -0
- data/lib/crown/facebook.rb +32 -27
- data/lib/crown/facebook/counter.rb +76 -0
- data/lib/crown/facebook/entry.rb +86 -0
- data/lib/crown/hatena/bookmark.rb +26 -168
- data/lib/crown/hatena/bookmark/counter.rb +82 -0
- data/lib/crown/hatena/bookmark/entry.rb +108 -0
- data/lib/crown/hatena/bookmark/linktrace.rb +135 -0
- data/lib/crown/http-wrapper.rb +201 -0
- data/lib/crown/livedoor/clip.rb +15 -18
- data/lib/crown/livedoor/clip/counter.rb +96 -0
- data/lib/crown/livedoor/reader.rb +16 -19
- data/lib/crown/livedoor/reader/counter.rb +82 -0
- data/lib/crown/topsy.rb +20 -21
- data/lib/crown/topsy/counter.rb +78 -0
- data/lib/crown/tweetmeme.rb +20 -21
- data/lib/crown/tweetmeme/counter.rb +78 -0
- data/lib/crown/twitter.rb +14 -31
- data/lib/crown/{http.rb → twitter/uri.rb} +24 -39
- data/lib/crown/twitter/uri/counter.rb +86 -0
- data/lib/crown/twitter/user.rb +76 -0
- data/lib/crown/twitter/user/counter.rb +85 -0
- data/lib/crown/twitter/user/entry.rb +96 -0
- data/lib/crown/yahoo.rb +7 -3
- data/lib/crown/yahoo/bookmark.rb +23 -28
- data/lib/crown/yahoo/bookmark/counter.rb +84 -0
- data/test/{crown_test.rb → crown-test.rb} +46 -21
- data/test/{test_helper.rb → test-helper.rb} +1 -1
- metadata +30 -9
- data/lib/crown/amazon.rb +0 -157
- data/lib/crown/amazon/ecs.rb +0 -385
@@ -0,0 +1,78 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# --------------------------------------------------------------------------- #
|
3
|
+
#
|
4
|
+
# tweetmeme/counter.rb
|
5
|
+
#
|
6
|
+
# Copyright (c) 2008 - 2012, clown.
|
7
|
+
#
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
9
|
+
# modification, are permitted provided that the following conditions
|
10
|
+
# are met:
|
11
|
+
#
|
12
|
+
# - Redistributions of source code must retain the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer.
|
14
|
+
# - Redistributions in binary form must reproduce the above copyright
|
15
|
+
# notice, this list of conditions and the following disclaimer in the
|
16
|
+
# documentation and/or other materials provided with the distribution.
|
17
|
+
# - No names of its contributors may be used to endorse or promote
|
18
|
+
# products derived from this software without specific prior written
|
19
|
+
# permission.
|
20
|
+
#
|
21
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
22
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
23
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
24
|
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
25
|
+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
26
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
27
|
+
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
28
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
29
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
30
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
31
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
#
|
33
|
+
# --------------------------------------------------------------------------- #
|
34
|
+
module Crown
|
35
|
+
class TweetMeme
|
36
|
+
class URICounter
|
37
|
+
require 'cgi'
|
38
|
+
require 'crown/cgm/countable'
|
39
|
+
require 'rubygems'
|
40
|
+
require 'json'
|
41
|
+
|
42
|
+
# ------------------------------------------------------------------- #
|
43
|
+
# Mix-in modules
|
44
|
+
# ------------------------------------------------------------------- #
|
45
|
+
include Crown::CGM::Countable
|
46
|
+
|
47
|
+
private
|
48
|
+
# --------------------------------------------------------------- #
|
49
|
+
# address
|
50
|
+
# --------------------------------------------------------------- #
|
51
|
+
def address()
|
52
|
+
return 'api.tweetmeme.com'
|
53
|
+
end
|
54
|
+
|
55
|
+
# --------------------------------------------------------------- #
|
56
|
+
# path
|
57
|
+
# --------------------------------------------------------------- #
|
58
|
+
def path()
|
59
|
+
return '/url_info.json'
|
60
|
+
end
|
61
|
+
|
62
|
+
# --------------------------------------------------------------- #
|
63
|
+
# query
|
64
|
+
# --------------------------------------------------------------- #
|
65
|
+
def query(uri, options)
|
66
|
+
return '?url=' + CGI.escape(uri)
|
67
|
+
end
|
68
|
+
|
69
|
+
# --------------------------------------------------------------- #
|
70
|
+
# parse
|
71
|
+
# --------------------------------------------------------------- #
|
72
|
+
def parse(body)
|
73
|
+
json = JSON.parse(body)
|
74
|
+
return json["story"]["url_count"].to_i
|
75
|
+
end
|
76
|
+
end # URICounter
|
77
|
+
end # TweetMeme
|
78
|
+
end # Crown
|
data/lib/crown/twitter.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# twitter.rb
|
5
5
|
#
|
6
|
-
# Copyright (c) 2008 -
|
6
|
+
# Copyright (c) 2008 - 2012, clown.
|
7
7
|
#
|
8
8
|
# Redistribution and use in source and binary forms, with or without
|
9
9
|
# modification, are permitted provided that the following conditions
|
@@ -33,39 +33,22 @@
|
|
33
33
|
# --------------------------------------------------------------------------- #
|
34
34
|
module Crown
|
35
35
|
module Twitter
|
36
|
-
require '
|
37
|
-
require '
|
38
|
-
require 'crown/http'
|
39
|
-
require 'rubygems'
|
40
|
-
require 'json'
|
41
|
-
Net::HTTP.version_1_2
|
36
|
+
require 'crown/twitter/user'
|
37
|
+
require 'crown/twitter/uri'
|
42
38
|
|
43
39
|
# ------------------------------------------------------------------- #
|
44
|
-
#
|
40
|
+
#
|
41
|
+
# count (deprecated)
|
42
|
+
#
|
43
|
+
# あるユーザに関する各種情報を取得する.
|
44
|
+
# Crown::Twitter::User.summary(screen_name, options) と等しい.
|
45
|
+
#
|
46
|
+
# NOTE: このメソッドは将来的に削除される予定なので,
|
47
|
+
# 代替のメソッドを使用する事.
|
48
|
+
#
|
45
49
|
# ------------------------------------------------------------------- #
|
46
|
-
|
47
|
-
|
48
|
-
# ------------------------------------------------------------------- #
|
49
|
-
# count
|
50
|
-
# ------------------------------------------------------------------- #
|
51
|
-
def count(screen_name, proxy_host = nil, proxy_port = nil)
|
52
|
-
begin
|
53
|
-
session = Net::HTTP.new('api.twitter.com', 80, proxy_host, proxy_port)
|
54
|
-
path = '/1/users/show.json?screen_name=' + CGI.escape(screen_name)
|
55
|
-
response = Crown::HTTP.get(session, path)
|
56
|
-
return nil if (response == nil || response.code.to_i != 200)
|
57
|
-
|
58
|
-
json = JSON.parse(response.body)
|
59
|
-
result = Counter.new
|
60
|
-
result.status = json["statuses_count"].to_i
|
61
|
-
result.favorite = json["favourites_count"].to_i
|
62
|
-
result.friend = json["friends_count"].to_i
|
63
|
-
result.follower = json["followers_count"].to_i
|
64
|
-
result.list = json["listed_count"].to_i
|
65
|
-
return result
|
66
|
-
rescue Exception
|
67
|
-
return nil
|
68
|
-
end
|
50
|
+
def count(screen_name, options = nil)
|
51
|
+
return Crown::Twitter::User.summary(screen_name, options)
|
69
52
|
end
|
70
53
|
|
71
54
|
module_function :count
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
# --------------------------------------------------------------------------- #
|
3
3
|
#
|
4
|
-
#
|
4
|
+
# twitter/uri.rb
|
5
5
|
#
|
6
|
-
# Copyright (c) 2008 -
|
6
|
+
# Copyright (c) 2008 - 2012, clown.
|
7
7
|
#
|
8
8
|
# Redistribution and use in source and binary forms, with or without
|
9
9
|
# modification, are permitted provided that the following conditions
|
@@ -32,45 +32,30 @@
|
|
32
32
|
#
|
33
33
|
# --------------------------------------------------------------------------- #
|
34
34
|
module Crown
|
35
|
-
module
|
36
|
-
|
37
|
-
Net::HTTP.version_1_2
|
38
|
-
|
39
|
-
# ------------------------------------------------------------------- #
|
35
|
+
module Twitter
|
36
|
+
# --------------------------------------------------------------- #
|
40
37
|
#
|
41
|
-
#
|
38
|
+
# URI
|
42
39
|
#
|
43
|
-
#
|
44
|
-
# を試す.session には Net::HTTP クラス,またはその派生クラスの
|
45
|
-
# インスタンスを指定する.
|
40
|
+
# Twitter API 経由である URL に対する各種情報を取得するクラス.
|
46
41
|
#
|
47
|
-
#
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
session = Net::HTTP.new(uri.host, uri.port, session.proxy_address, session.proxy_port)
|
57
|
-
path = String.new(uri.path)
|
58
|
-
if (uri.query != nil)
|
59
|
-
path.concat("?")
|
60
|
-
path.concat(uri.query)
|
61
|
-
end
|
62
|
-
response = session.get(path)
|
63
|
-
end
|
64
|
-
return response
|
65
|
-
rescue Exception
|
66
|
-
session.finish if (session.active?)
|
67
|
-
if (n < limit)
|
68
|
-
n += 1
|
69
|
-
retry
|
70
|
-
end
|
71
|
-
return nil
|
42
|
+
# --------------------------------------------------------------- #
|
43
|
+
class URI
|
44
|
+
require 'crown/twitter/uri/counter'
|
45
|
+
|
46
|
+
# ----------------------------------------------------------- #
|
47
|
+
# URI.count
|
48
|
+
# ----------------------------------------------------------- #
|
49
|
+
def URI.count(uri, options = nil)
|
50
|
+
return Crown::Twitter::URICounter.new.count(uri, options)
|
72
51
|
end
|
73
|
-
|
74
|
-
|
75
|
-
|
52
|
+
|
53
|
+
# ----------------------------------------------------------- #
|
54
|
+
# count
|
55
|
+
# ----------------------------------------------------------- #
|
56
|
+
def count(uri, options = nil)
|
57
|
+
return Crown::Twitter::URICounter.new.count(uri, options)
|
58
|
+
end
|
59
|
+
end # URI
|
60
|
+
end # Twitter
|
76
61
|
end # Crown
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# --------------------------------------------------------------------------- #
|
3
|
+
#
|
4
|
+
# twitter/uri/counter.rb
|
5
|
+
#
|
6
|
+
# Copyright (c) 2008 - 2012, clown.
|
7
|
+
#
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
9
|
+
# modification, are permitted provided that the following conditions
|
10
|
+
# are met:
|
11
|
+
#
|
12
|
+
# - Redistributions of source code must retain the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer.
|
14
|
+
# - Redistributions in binary form must reproduce the above copyright
|
15
|
+
# notice, this list of conditions and the following disclaimer in the
|
16
|
+
# documentation and/or other materials provided with the distribution.
|
17
|
+
# - No names of its contributors may be used to endorse or promote
|
18
|
+
# products derived from this software without specific prior written
|
19
|
+
# permission.
|
20
|
+
#
|
21
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
22
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
23
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
24
|
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
25
|
+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
26
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
27
|
+
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
28
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
29
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
30
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
31
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
#
|
33
|
+
# --------------------------------------------------------------------------- #
|
34
|
+
module Crown
|
35
|
+
module Twitter
|
36
|
+
# --------------------------------------------------------------- #
|
37
|
+
#
|
38
|
+
# URICounter
|
39
|
+
#
|
40
|
+
# 指定した URL へのツイート数を取得するクラス.
|
41
|
+
#
|
42
|
+
# --------------------------------------------------------------- #
|
43
|
+
class URICounter
|
44
|
+
require 'cgi'
|
45
|
+
require 'crown/cgm/countable'
|
46
|
+
require 'rubygems'
|
47
|
+
require 'json'
|
48
|
+
|
49
|
+
# --------------------------------------------------------------- #
|
50
|
+
# Mix-in modules
|
51
|
+
# --------------------------------------------------------------- #
|
52
|
+
include Crown::CGM::Countable
|
53
|
+
|
54
|
+
private
|
55
|
+
# --------------------------------------------------------------- #
|
56
|
+
# address
|
57
|
+
# --------------------------------------------------------------- #
|
58
|
+
def address()
|
59
|
+
return 'urls.api.twitter.com'
|
60
|
+
end
|
61
|
+
|
62
|
+
# --------------------------------------------------------------- #
|
63
|
+
# path
|
64
|
+
# --------------------------------------------------------------- #
|
65
|
+
def path()
|
66
|
+
return '/1/urls/count.json'
|
67
|
+
end
|
68
|
+
|
69
|
+
# --------------------------------------------------------------- #
|
70
|
+
# query
|
71
|
+
# --------------------------------------------------------------- #
|
72
|
+
def query(uri, options)
|
73
|
+
return '?url=' + CGI.escape(uri)
|
74
|
+
end
|
75
|
+
|
76
|
+
# --------------------------------------------------------------- #
|
77
|
+
# parse
|
78
|
+
# --------------------------------------------------------------- #
|
79
|
+
def parse(body)
|
80
|
+
json = JSON.parse(body)
|
81
|
+
return json['count'].to_i
|
82
|
+
return error_value()
|
83
|
+
end
|
84
|
+
end # URICounter
|
85
|
+
end # Twitter
|
86
|
+
end # Crown
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# --------------------------------------------------------------------------- #
|
3
|
+
#
|
4
|
+
# twitter/user.rb
|
5
|
+
#
|
6
|
+
# Copyright (c) 2008 - 2012, clown.
|
7
|
+
#
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
9
|
+
# modification, are permitted provided that the following conditions
|
10
|
+
# are met:
|
11
|
+
#
|
12
|
+
# - Redistributions of source code must retain the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer.
|
14
|
+
# - Redistributions in binary form must reproduce the above copyright
|
15
|
+
# notice, this list of conditions and the following disclaimer in the
|
16
|
+
# documentation and/or other materials provided with the distribution.
|
17
|
+
# - No names of its contributors may be used to endorse or promote
|
18
|
+
# products derived from this software without specific prior written
|
19
|
+
# permission.
|
20
|
+
#
|
21
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
22
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
23
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
24
|
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
25
|
+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
26
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
27
|
+
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
28
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
29
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
30
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
31
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
#
|
33
|
+
# --------------------------------------------------------------------------- #
|
34
|
+
module Crown
|
35
|
+
module Twitter
|
36
|
+
# --------------------------------------------------------------- #
|
37
|
+
#
|
38
|
+
# User
|
39
|
+
#
|
40
|
+
# Twitter API 経由であるユーザに対する各種情報を取得するクラス.
|
41
|
+
#
|
42
|
+
# --------------------------------------------------------------- #
|
43
|
+
class User
|
44
|
+
require 'crown/twitter/user/counter'
|
45
|
+
require 'crown/twitter/user/entry'
|
46
|
+
|
47
|
+
# ----------------------------------------------------------- #
|
48
|
+
# User.count
|
49
|
+
# ----------------------------------------------------------- #
|
50
|
+
def User.count(screen_name, options = nil)
|
51
|
+
return Crown::Twitter::TweetCounter.new.count(screen_name, options)
|
52
|
+
end
|
53
|
+
|
54
|
+
# ----------------------------------------------------------- #
|
55
|
+
# User.summary
|
56
|
+
# ----------------------------------------------------------- #
|
57
|
+
def User.summary(screen_name, options = nil)
|
58
|
+
return Crown::Twitter::UserEntry.new.summary(screen_name, options)
|
59
|
+
end
|
60
|
+
|
61
|
+
# ----------------------------------------------------------- #
|
62
|
+
# count
|
63
|
+
# ----------------------------------------------------------- #
|
64
|
+
def count(screen_name, options = nil)
|
65
|
+
return Crown::Twitter::TweetCounter.new.count(screen_name, options)
|
66
|
+
end
|
67
|
+
|
68
|
+
# ----------------------------------------------------------- #
|
69
|
+
# summary
|
70
|
+
# ----------------------------------------------------------- #
|
71
|
+
def summary(screen_name, options = nil)
|
72
|
+
return Crown::Twitter::UserEntry.new.summary(screen_name, options)
|
73
|
+
end
|
74
|
+
end # User
|
75
|
+
end # Twitter
|
76
|
+
end # Crown
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# --------------------------------------------------------------------------- #
|
3
|
+
#
|
4
|
+
# twitter/user/counter.rb
|
5
|
+
#
|
6
|
+
# Copyright (c) 2008 - 2012, clown.
|
7
|
+
#
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
9
|
+
# modification, are permitted provided that the following conditions
|
10
|
+
# are met:
|
11
|
+
#
|
12
|
+
# - Redistributions of source code must retain the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer.
|
14
|
+
# - Redistributions in binary form must reproduce the above copyright
|
15
|
+
# notice, this list of conditions and the following disclaimer in the
|
16
|
+
# documentation and/or other materials provided with the distribution.
|
17
|
+
# - No names of its contributors may be used to endorse or promote
|
18
|
+
# products derived from this software without specific prior written
|
19
|
+
# permission.
|
20
|
+
#
|
21
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
22
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
23
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
24
|
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
25
|
+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
26
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
27
|
+
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
28
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
29
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
30
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
31
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
#
|
33
|
+
# --------------------------------------------------------------------------- #
|
34
|
+
module Crown
|
35
|
+
module Twitter
|
36
|
+
# --------------------------------------------------------------- #
|
37
|
+
#
|
38
|
+
# TweetCounter
|
39
|
+
#
|
40
|
+
# ���郆�[�U�̃c�C�[�g�����擾����N���X�D
|
41
|
+
#
|
42
|
+
# --------------------------------------------------------------- #
|
43
|
+
class TweetCounter
|
44
|
+
require 'cgi'
|
45
|
+
require 'crown/cgm/countable'
|
46
|
+
require 'rubygems'
|
47
|
+
require 'json'
|
48
|
+
|
49
|
+
# --------------------------------------------------------------- #
|
50
|
+
# Mix-in modules
|
51
|
+
# --------------------------------------------------------------- #
|
52
|
+
include Crown::CGM::Countable
|
53
|
+
|
54
|
+
private
|
55
|
+
# --------------------------------------------------------------- #
|
56
|
+
# address
|
57
|
+
# --------------------------------------------------------------- #
|
58
|
+
def address()
|
59
|
+
return 'api.twitter.com'
|
60
|
+
end
|
61
|
+
|
62
|
+
# --------------------------------------------------------------- #
|
63
|
+
# path
|
64
|
+
# --------------------------------------------------------------- #
|
65
|
+
def path()
|
66
|
+
return '/1/users/show.json'
|
67
|
+
end
|
68
|
+
|
69
|
+
# --------------------------------------------------------------- #
|
70
|
+
# query
|
71
|
+
# --------------------------------------------------------------- #
|
72
|
+
def query(screen_name, options)
|
73
|
+
return '?screen_name=' + CGI.escape(screen_name)
|
74
|
+
end
|
75
|
+
|
76
|
+
# --------------------------------------------------------------- #
|
77
|
+
# parse
|
78
|
+
# --------------------------------------------------------------- #
|
79
|
+
def parse(body)
|
80
|
+
json = JSON.parse(body)
|
81
|
+
return json["statuses_count"].to_i
|
82
|
+
end
|
83
|
+
end # TweetCounter
|
84
|
+
end # Twitter
|
85
|
+
end # Crown
|