crown 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/ChangeLog +4 -0
  2. data/README.rdoc +14 -11
  3. data/VERSION +1 -1
  4. data/crown.gemspec +15 -5
  5. data/example/entrylist.rb +69 -0
  6. data/example/fbcount.rb +1 -1
  7. data/example/hbentry.rb +1 -1
  8. data/example/rtcount.rb +1 -0
  9. data/example/twcount.rb +1 -1
  10. data/example/{annual.rb → urilist.rb} +21 -26
  11. data/lib/crown.rb +1 -1
  12. data/{example/hbtrace.rb → lib/crown/amazon.rb} +8 -23
  13. data/lib/crown/amazon/crawler.rb +159 -0
  14. data/lib/crown/amazon/ecs.rb +385 -0
  15. data/lib/crown/amazon/entrylist.rb +171 -0
  16. data/lib/crown/backtype.rb +2 -2
  17. data/lib/crown/buzzurl.rb +2 -2
  18. data/lib/crown/cgm.rb +8 -0
  19. data/lib/crown/cgm/countable.rb +1 -1
  20. data/lib/crown/cgm/summarizable.rb +1 -1
  21. data/lib/crown/delicious.rb +2 -2
  22. data/lib/crown/facebook.rb +4 -4
  23. data/lib/crown/facebook/entry.rb +5 -3
  24. data/lib/crown/google.rb +38 -0
  25. data/lib/crown/google/plusone.rb +65 -0
  26. data/lib/crown/google/plusone/counter.rb +102 -0
  27. data/lib/crown/hatena/bookmark.rb +7 -7
  28. data/lib/crown/hatena/bookmark/entry.rb +70 -68
  29. data/lib/crown/hatena/bookmark/entrylist.rb +98 -0
  30. data/lib/crown/hatena/bookmark/urilist.rb +349 -0
  31. data/lib/crown/http-wrapper.rb +0 -1
  32. data/lib/crown/linkedin.rb +60 -0
  33. data/lib/crown/linkedin/counter.rb +81 -0
  34. data/lib/crown/livedoor/clip.rb +2 -2
  35. data/lib/crown/livedoor/clip/counter.rb +1 -1
  36. data/lib/crown/livedoor/reader.rb +2 -2
  37. data/lib/crown/topsy.rb +2 -3
  38. data/lib/crown/tweetmeme.rb +2 -2
  39. data/lib/crown/twitter.rb +1 -1
  40. data/lib/crown/twitter/uri.rb +2 -2
  41. data/lib/crown/twitter/user.rb +4 -4
  42. data/lib/crown/twitter/user/entry.rb +26 -6
  43. data/lib/crown/yahoo/bookmark.rb +3 -7
  44. data/test/crown-test.rb +34 -12
  45. metadata +17 -7
  46. data/lib/crown/hatena/bookmark/linktrace.rb +0 -135
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crown
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - clown
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-24 00:00:00 Z
18
+ date: 2012-03-01 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: json
@@ -77,17 +77,21 @@ files:
77
77
  - Rakefile
78
78
  - VERSION
79
79
  - crown.gemspec
80
- - example/annual.rb
81
80
  - example/cgmcount.rb
81
+ - example/entrylist.rb
82
82
  - example/fbcount.rb
83
83
  - example/feedcount.rb
84
84
  - example/hbcount.rb
85
85
  - example/hbentry.rb
86
- - example/hbtrace.rb
87
86
  - example/rtcount.rb
88
87
  - example/sbmcount.rb
89
88
  - example/twcount.rb
89
+ - example/urilist.rb
90
90
  - lib/crown.rb
91
+ - lib/crown/amazon.rb
92
+ - lib/crown/amazon/crawler.rb
93
+ - lib/crown/amazon/ecs.rb
94
+ - lib/crown/amazon/entrylist.rb
91
95
  - lib/crown/backtype.rb
92
96
  - lib/crown/backtype/counter.rb
93
97
  - lib/crown/buzzurl.rb
@@ -100,12 +104,18 @@ files:
100
104
  - lib/crown/facebook.rb
101
105
  - lib/crown/facebook/counter.rb
102
106
  - lib/crown/facebook/entry.rb
107
+ - lib/crown/google.rb
108
+ - lib/crown/google/plusone.rb
109
+ - lib/crown/google/plusone/counter.rb
103
110
  - lib/crown/hatena.rb
104
111
  - lib/crown/hatena/bookmark.rb
105
112
  - lib/crown/hatena/bookmark/counter.rb
106
113
  - lib/crown/hatena/bookmark/entry.rb
107
- - lib/crown/hatena/bookmark/linktrace.rb
114
+ - lib/crown/hatena/bookmark/entrylist.rb
115
+ - lib/crown/hatena/bookmark/urilist.rb
108
116
  - lib/crown/http-wrapper.rb
117
+ - lib/crown/linkedin.rb
118
+ - lib/crown/linkedin/counter.rb
109
119
  - lib/crown/livedoor.rb
110
120
  - lib/crown/livedoor/clip.rb
111
121
  - lib/crown/livedoor/clip/counter.rb
@@ -1,135 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # --------------------------------------------------------------------------- #
3
- #
4
- # hatena/bookmark/linktrace.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
- module Crown
35
- module Hatena
36
- module Bookmark
37
- # --------------------------------------------------------------- #
38
- #
39
- # LinkTrace
40
- #
41
- # �w�肵�� Web �T�C�g�̂͂Ăȃu�b�N�}�[�N�ꗗ���珇�� URL ��
42
- # �擾����N���X�D2 �y�[�W�ڈȍ~�̌��ʂ́Chtml �̃w�b�_����
43
- # next ��������y�[�W�� URL �𐄑����Ď擾����D
44
- #
45
- # --------------------------------------------------------------- #
46
- class LinkTrace
47
- @@reserved = [ "/hotentry", "/entrylist", "/news", "/video", "/asin" ]
48
-
49
- # ----------------------------------------------------------- #
50
- # initialize
51
- # ----------------------------------------------------------- #
52
- def initialize(path, proxy_host = nil, proxy_port = nil)
53
- @session = Crown::HTTPWrapper.new("b.hatena.ne.jp", 80, proxy_host, proxy_port)
54
- @basename = String.new
55
- @basename.concat("/") if (path[0] != 47)
56
- @basename.concat(path)
57
- @basename.concat("/") if (@basename.match(/^\/[\w\-]+$/) != nil && !@@reserved.include?(@basename))
58
- @path = String.new(@basename)
59
- end
60
-
61
- # ----------------------------------------------------------- #
62
- # reset
63
- # ----------------------------------------------------------- #
64
- def reset()
65
- @path = String.new(@basename)
66
- @session.finish if (@session.active?)
67
- return self
68
- end
69
-
70
- # ----------------------------------------------------------- #
71
- #
72
- # more?
73
- #
74
- # �܂��擾�ł��� URL �����݂��邩�ǂ����𔻒肷��Dmore?()
75
- # �� html �� next �������玟�̃y�[�W�������ł��Ă��邩
76
- # �ǂ����Ŕ��肵�Ă���D
77
- #
78
- # ----------------------------------------------------------- #
79
- def more?()
80
- return @path != nil
81
- end
82
-
83
- # ----------------------------------------------------------- #
84
- #
85
- # get
86
- #
87
- # �ΏۂƂȂ�͂Ăȃu�b�N�}�[�N URL ��Ԃ��Dget() �� html ��
88
- # next �������琄�����ꂽ�u���݂̃y�[�W�v�ɗ񋓂���Ă���
89
- # �S�Ă̂͂Ăȃu�b�N�}�[�N URL ��z��Ɋi�[���ĕԂ��D
90
- #
91
- # ----------------------------------------------------------- #
92
- def get()
93
- result = Array.new
94
-
95
- return result if (@path == nil)
96
- response = @session.get(@path)
97
- return result if (response == nil || response.code.to_i != 200)
98
- guess(response.body)
99
-
100
- html = Nokogiri::HTML.parse(response.body)
101
- block = html.search('//ul[starts-with(@class, "hotentry")]')
102
- block = html.search('//ul[starts-with(@class, "videolist")]') if block.empty?
103
- return result if block.empty?
104
- block[0].search("h3/a").each { |node|
105
- result.push(node['href'])
106
- }
107
-
108
- # �������[�v����ꍇ������̂ŁC���݂̃y�[�W���� 1�������ʂ�
109
- # �擾�ł��Ȃ��Ƃ��͂���ȏ�̌������~�߂�D
110
- @path = nil if (result.empty?)
111
-
112
- return result
113
- end
114
-
115
- private
116
- # ----------------------------------------------------------- #
117
- # guess
118
- # ----------------------------------------------------------- #
119
- def guess(str)
120
- link = str.scan(/<link rel="next" href="(.+?)".*?>/m).to_s
121
- if (link.empty?)
122
- @path = nil
123
- elsif (link[0] == 47)
124
- @path = link
125
- elsif (link[0] == 63)
126
- @path.gsub!(/\?.*$/, "")
127
- @path.concat(link)
128
- else
129
- @path = @basename + link
130
- end
131
- end
132
- end # LinkTrace
133
- end # Bookmark
134
- end # Hatena
135
- end # Crown