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.
Files changed (48) hide show
  1. data/ChangeLog +11 -3
  2. data/README.rdoc +23 -1
  3. data/Rakefile +1 -1
  4. data/VERSION +1 -1
  5. data/crown.gemspec +28 -7
  6. data/example/cgmcount.rb +65 -0
  7. data/example/feedcount.rb +50 -0
  8. data/example/sbmcount.rb +5 -1
  9. data/lib/crown.rb +4 -14
  10. data/lib/crown/backtype.rb +29 -25
  11. data/lib/crown/backtype/counter.rb +79 -0
  12. data/lib/crown/buzzurl.rb +15 -28
  13. data/lib/crown/buzzurl/counter.rb +88 -0
  14. data/lib/crown/cgm.rb +98 -0
  15. data/lib/crown/cgm/countable.rb +130 -0
  16. data/lib/crown/cgm/summarizable.rb +130 -0
  17. data/lib/crown/delicious.rb +14 -29
  18. data/lib/crown/delicious/counter.rb +88 -0
  19. data/lib/crown/facebook.rb +32 -27
  20. data/lib/crown/facebook/counter.rb +76 -0
  21. data/lib/crown/facebook/entry.rb +86 -0
  22. data/lib/crown/hatena/bookmark.rb +26 -168
  23. data/lib/crown/hatena/bookmark/counter.rb +82 -0
  24. data/lib/crown/hatena/bookmark/entry.rb +108 -0
  25. data/lib/crown/hatena/bookmark/linktrace.rb +135 -0
  26. data/lib/crown/http-wrapper.rb +201 -0
  27. data/lib/crown/livedoor/clip.rb +15 -18
  28. data/lib/crown/livedoor/clip/counter.rb +96 -0
  29. data/lib/crown/livedoor/reader.rb +16 -19
  30. data/lib/crown/livedoor/reader/counter.rb +82 -0
  31. data/lib/crown/topsy.rb +20 -21
  32. data/lib/crown/topsy/counter.rb +78 -0
  33. data/lib/crown/tweetmeme.rb +20 -21
  34. data/lib/crown/tweetmeme/counter.rb +78 -0
  35. data/lib/crown/twitter.rb +14 -31
  36. data/lib/crown/{http.rb → twitter/uri.rb} +24 -39
  37. data/lib/crown/twitter/uri/counter.rb +86 -0
  38. data/lib/crown/twitter/user.rb +76 -0
  39. data/lib/crown/twitter/user/counter.rb +85 -0
  40. data/lib/crown/twitter/user/entry.rb +96 -0
  41. data/lib/crown/yahoo.rb +7 -3
  42. data/lib/crown/yahoo/bookmark.rb +23 -28
  43. data/lib/crown/yahoo/bookmark/counter.rb +84 -0
  44. data/test/{crown_test.rb → crown-test.rb} +46 -21
  45. data/test/{test_helper.rb → test-helper.rb} +1 -1
  46. metadata +30 -9
  47. data/lib/crown/amazon.rb +0 -157
  48. data/lib/crown/amazon/ecs.rb +0 -385
data/ChangeLog CHANGED
@@ -1,14 +1,22 @@
1
+ == 0.1.0 / 2012-01-24
2
+
3
+ * remove Amazon modules
4
+ * changed interfaces about options (proxy_host and proxy_port can be set in options variable)
5
+ * changed return value of the Crown::Facebook.count method
6
+ * add Crown::Facebook.summary method (, same as old version of Crown::Facebook.count)
7
+ * fixed modules to the change in Delicious API specifications
8
+
1
9
  == 0.0.11 / 2011-11-11
2
10
 
3
- * bugfix. add amazon/ecs.rb in the project and modify the Line 141 for character corruption.
11
+ * bugfix. add amazon/ecs.rb in the project and modify the Line 141 for character corruption
4
12
 
5
13
  == 0.0.10 / 2011-05-13
6
14
 
7
- * bugfix.
15
+ * bugfix
8
16
 
9
17
  == 0.0.9 / 2011-04-04
10
18
 
11
- * bugfix.
19
+ * bugfix
12
20
 
13
21
  == 0.0.8 / 2011-04-03
14
22
 
data/README.rdoc CHANGED
@@ -7,7 +7,7 @@ crown は Ruby で書かれた雑多なライブラリです.各種 Web サー
7
7
 
8
8
  == Install
9
9
 
10
- gem install crown
10
+ gem install crown
11
11
 
12
12
  == Note on Patches/Pull Requests
13
13
 
@@ -17,6 +17,28 @@ crown は Ruby で書かれた雑多なライブラリです.各種 Web サー
17
17
  * Commit, do not mess with rakefile, version, or history.(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
18
18
  * Send me a pull request. Bonus points for topic branches.
19
19
 
20
+ == History
21
+
22
+ === 0.1.0 / 2012-01-24
23
+ * Amazon 関連のモジュールを削除
24
+ * これまで proxy_host, proxy_port や api_key 等,使用する API によって微妙に引数が異なっていた
25
+ 各種メソッドのオプション引数を options と言う引数で統一.今後は,必要なオプション情報を
26
+ ハッシュ形式で作成し,そのオブジェクトを第 2 引数に指定する.
27
+ * Crown::Facebook.count メソッドの返り値を「いいね!」,「シェア」の合計値のみに変更.
28
+ 旧バージョンの count メソッドに当たるものは Crown::Facebook.summary メソッドとして用意している.
29
+ * Delicious の API の仕様変更に対応
30
+
31
+ === 0.0.5 / 2011-02-24
32
+ * Rakefile にライブラリの依存関係に関する記述を追加.
33
+
34
+ === 0.0.4 / 2011-02-19
35
+ * Livedoor Reader モジュールを追加.
36
+ * Facebook モジュールを追加.
37
+ * Topsy, TweetMeme, BackType (BackTweets) モジュールを追加.
38
+
39
+ === 0.0.1 / 2011-02-18
40
+ * 最初の公開バージョン.
41
+
20
42
  == Copyright
21
43
 
22
44
  Copyright (c) 2008 - 2011 clown. See LICENSE for details.
data/Rakefile CHANGED
@@ -22,7 +22,7 @@ end
22
22
  require 'rake/testtask'
23
23
  Rake::TestTask.new(:test) do |test|
24
24
  test.libs << 'lib' << 'test'
25
- test.pattern = 'test/**/*_test.rb'
25
+ test.pattern = 'test/**/*-test.rb'
26
26
  test.verbose = true
27
27
  end
28
28
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.11
1
+ 0.1.0
data/crown.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{crown}
8
- s.version = "0.0.11"
8
+ s.version = "0.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{clown}]
12
- s.date = %q{2011-11-10}
12
+ s.date = %q{2012-01-24}
13
13
  s.description = %q{crown is uncategorized ruby libraries, which is added according to author's mood :-D}
14
14
  s.email = %q{tt.clown@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -26,7 +26,9 @@ Gem::Specification.new do |s|
26
26
  "VERSION",
27
27
  "crown.gemspec",
28
28
  "example/annual.rb",
29
+ "example/cgmcount.rb",
29
30
  "example/fbcount.rb",
31
+ "example/feedcount.rb",
30
32
  "example/hbcount.rb",
31
33
  "example/hbentry.rb",
32
34
  "example/hbtrace.rb",
@@ -34,25 +36,44 @@ Gem::Specification.new do |s|
34
36
  "example/sbmcount.rb",
35
37
  "example/twcount.rb",
36
38
  "lib/crown.rb",
37
- "lib/crown/amazon.rb",
38
- "lib/crown/amazon/ecs.rb",
39
39
  "lib/crown/backtype.rb",
40
+ "lib/crown/backtype/counter.rb",
40
41
  "lib/crown/buzzurl.rb",
42
+ "lib/crown/buzzurl/counter.rb",
43
+ "lib/crown/cgm.rb",
44
+ "lib/crown/cgm/countable.rb",
45
+ "lib/crown/cgm/summarizable.rb",
41
46
  "lib/crown/delicious.rb",
47
+ "lib/crown/delicious/counter.rb",
42
48
  "lib/crown/facebook.rb",
49
+ "lib/crown/facebook/counter.rb",
50
+ "lib/crown/facebook/entry.rb",
43
51
  "lib/crown/hatena.rb",
44
52
  "lib/crown/hatena/bookmark.rb",
45
- "lib/crown/http.rb",
53
+ "lib/crown/hatena/bookmark/counter.rb",
54
+ "lib/crown/hatena/bookmark/entry.rb",
55
+ "lib/crown/hatena/bookmark/linktrace.rb",
56
+ "lib/crown/http-wrapper.rb",
46
57
  "lib/crown/livedoor.rb",
47
58
  "lib/crown/livedoor/clip.rb",
59
+ "lib/crown/livedoor/clip/counter.rb",
48
60
  "lib/crown/livedoor/reader.rb",
61
+ "lib/crown/livedoor/reader/counter.rb",
49
62
  "lib/crown/topsy.rb",
63
+ "lib/crown/topsy/counter.rb",
50
64
  "lib/crown/tweetmeme.rb",
65
+ "lib/crown/tweetmeme/counter.rb",
51
66
  "lib/crown/twitter.rb",
67
+ "lib/crown/twitter/uri.rb",
68
+ "lib/crown/twitter/uri/counter.rb",
69
+ "lib/crown/twitter/user.rb",
70
+ "lib/crown/twitter/user/counter.rb",
71
+ "lib/crown/twitter/user/entry.rb",
52
72
  "lib/crown/yahoo.rb",
53
73
  "lib/crown/yahoo/bookmark.rb",
54
- "test/crown_test.rb",
55
- "test/test_helper.rb"
74
+ "lib/crown/yahoo/bookmark/counter.rb",
75
+ "test/crown-test.rb",
76
+ "test/test-helper.rb"
56
77
  ]
57
78
  s.homepage = %q{http://github.com/clown/crown}
58
79
  s.require_paths = [%q{lib}]
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/ruby -Ku
2
+ # --------------------------------------------------------------------------- #
3
+ #
4
+ # sbmcount.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
+ require 'rubygems'
35
+ require 'crown'
36
+
37
+ services = [
38
+ :twitter_uri, # Twitter
39
+ :topsy, # Topsy
40
+ :tweetmeme, # TweetMeme
41
+ # :backtype, # BackTweets (要 API key)
42
+ :facebook, # Facebook
43
+ :hatena_bookmark, # はてなブックマーク
44
+ :livedoor_clip, # Livedoor クリップ
45
+ :delicious, # Delicious
46
+ :buzzurl, # Buzzurl
47
+ :yahoo_bookmark, # Yahoo! ブックマーク
48
+ ]
49
+
50
+ # --------------------------------------------------------------------------- #
51
+ #
52
+ # 指定された URL に関する各種 CGM のカウント情報を取得する.
53
+ #
54
+ # Parameters:
55
+ # ARGV[0]: URL1
56
+ # ARGV[1]: URL2
57
+ # ...
58
+ #
59
+ # --------------------------------------------------------------------------- #
60
+ ARGV.each { |uri|
61
+ printf("%s\n", uri)
62
+ services.each { |service|
63
+ printf(" + %-20s : %6d\n", service, Crown::CGM.proxy(service).count(uri))
64
+ }
65
+ }
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/ruby -Ku
2
+ # --------------------------------------------------------------------------- #
3
+ #
4
+ # feedcount.rb
5
+ #
6
+ # Copyright (c) 2008 - 2011, 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
+ require 'rubygems'
35
+ require 'crown'
36
+
37
+ # --------------------------------------------------------------------------- #
38
+ #
39
+ # 指定された URL に関する Twitter 検索関連から提供されるの呟き数を取得する.
40
+ #
41
+ # Parameters:
42
+ # ARGV[0]: URL1
43
+ # ARGV[1]: URL2
44
+ # ...
45
+ #
46
+ # --------------------------------------------------------------------------- #
47
+ ARGV.each { |uri|
48
+ printf("%s\n", uri)
49
+ printf(" + livedoor Reader : %8d\n", Crown::Livedoor::Reader.count(uri))
50
+ }
data/example/sbmcount.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # sbmcount.rb
5
5
  #
6
- # Copyright (c) 2008 - 2011, clown.
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
@@ -37,6 +37,10 @@ require 'crown'
37
37
  # --------------------------------------------------------------------------- #
38
38
  #
39
39
  # 指定された URL に関する各種 SBM カウント情報を取得する.
40
+ # 各種クラスの count メソッドを直接記述する代わりに CGM.proxy() メソッド
41
+ # を介して実行する方法もある.
42
+ #
43
+ # see also: cgmcount.rb
40
44
  #
41
45
  # Parameters:
42
46
  # ARGV[0]: URL1
data/lib/crown.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # --------------------------------------------------------------------------- #
3
3
  #
4
- # buzzurl.rb
4
+ # crown.rb
5
5
  #
6
6
  # Copyright (c) 2008 - 2011, clown.
7
7
  #
@@ -33,19 +33,9 @@
33
33
  # --------------------------------------------------------------------------- #
34
34
  $:.unshift(File.dirname(__FILE__))
35
35
 
36
- require 'crown/http'
37
- require 'crown/amazon'
38
- require 'crown/delicious'
39
- require 'crown/hatena'
40
- require 'crown/livedoor'
41
- require 'crown/buzzurl'
42
- require 'crown/yahoo'
43
- require 'crown/twitter'
44
- require 'crown/topsy'
45
- require 'crown/tweetmeme'
46
- require 'crown/backtype'
47
- require 'crown/facebook'
36
+ require 'crown/http-wrapper'
37
+ require 'crown/cgm'
48
38
 
49
39
  module Crown
50
- VERSION = '0.0.10'
40
+ VERSION = '0.1.0'
51
41
  end
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # backtype.rb
5
5
  #
6
- # Copyright (c) 2008 - 2011, clown.
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,33 +32,37 @@
32
32
  #
33
33
  # --------------------------------------------------------------------------- #
34
34
  module Crown
35
- module BackType
36
- require 'cgi'
37
- require 'net/http'
38
- require 'crown/http'
39
- require 'rubygems'
40
- require 'json'
41
- Net::HTTP.version_1_2
35
+ class BackType
36
+ require 'crown/backtype/counter'
42
37
 
43
38
  # ------------------------------------------------------------------- #
44
- # count
39
+ #
40
+ # BackType.count
41
+ #
42
+ # BackType (BackTweets) の API を介して,指定した URL への
43
+ # ツイート数を取得する.尚,BackType の API を使用する際には,
44
+ # API key を求められるので options に { :api_key = "your api key" }
45
+ # と言うパラメータを指定する必要がある("your api key" の部分は,
46
+ # BackType で取得した API key).
47
+ #
45
48
  # ------------------------------------------------------------------- #
46
- def count(uri, api_key, proxy_host = nil, proxy_port = nil)
47
- return 0 if (api_key == nil)
48
-
49
- begin
50
- session = Net::HTTP.new('api.backtype.com', 80, proxy_host, proxy_port)
51
- path = '/tweetcount.json?q=' + CGI.escape(uri) + '&key=' + api_key
52
- response = Crown::HTTP.get(session, path)
53
- return nil if (response == nil || response.code.to_i != 200)
54
-
55
- json = JSON.parse(response.body)
56
- return json["tweetcount"].to_i
57
- rescue Exception
58
- return 0
59
- end
49
+ def Topsy.count(uri, options = nil)
50
+ return Crown::BackType::URICounter.new.count(uri, options)
60
51
  end
61
52
 
62
- module_function :count
63
- end # BackTweets
53
+ # ------------------------------------------------------------------- #
54
+ #
55
+ # count
56
+ #
57
+ # BackType (BackTweets) の API を介して,指定した URL への
58
+ # ツイート数を取得する.尚,BackType の API を使用する際には,
59
+ # API key を求められるので options に { :api_key = "your api key" }
60
+ # と言うパラメータを指定する必要がある("your api key" の部分は,
61
+ # BackType で取得した API key).
62
+ #
63
+ # ------------------------------------------------------------------- #
64
+ def count(uri, options = nil)
65
+ return Crown::BackType::URICounter.new.count(uri, options)
66
+ end
67
+ end # BackType
64
68
  end # Crown
@@ -0,0 +1,79 @@
1
+ # -*- coding: utf-8 -*-
2
+ # --------------------------------------------------------------------------- #
3
+ #
4
+ # backtype/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 BackType
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.backtype.com'
53
+ end
54
+
55
+ # --------------------------------------------------------------- #
56
+ # path
57
+ # --------------------------------------------------------------- #
58
+ def path()
59
+ return '/tweetcount.json'
60
+ end
61
+
62
+ # --------------------------------------------------------------- #
63
+ # query
64
+ # --------------------------------------------------------------- #
65
+ def query(uri, options)
66
+ return error_value() if (options.class != Hash || options.has_key?(:api_key))
67
+ return '?q=' + CGI.escape(uri) + '&key=' + options[:api_key]
68
+ end
69
+
70
+ # --------------------------------------------------------------- #
71
+ # parse
72
+ # --------------------------------------------------------------- #
73
+ def parse(body)
74
+ json = JSON.parse(body)
75
+ return json["tweetcount"].to_i
76
+ end
77
+ end # URICounter
78
+ end # BackType
79
+ end # Crown