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
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.1.1 / 2012-03-01
2
+
3
+ * add Google+1 and LinkedIn modules
4
+
1
5
  == 0.1.0 / 2012-01-24
2
6
 
3
7
  * remove Amazon modules
@@ -19,26 +19,29 @@ crown は Ruby で書かれた雑多なライブラリです.各種 Web サー
19
19
 
20
20
  == History
21
21
 
22
+ === 0.1.1 / 2012-03-01
23
+ * Google+1, LinkedIn モジュールを追加。
24
+
22
25
  === 0.1.0 / 2012-01-24
23
26
  * Amazon 関連のモジュールを削除
24
- * これまで proxy_host, proxy_port や api_key 等,使用する API によって微妙に引数が異なっていた
25
- 各種メソッドのオプション引数を options と言う引数で統一.今後は,必要なオプション情報を
26
- ハッシュ形式で作成し,そのオブジェクトを第 2 引数に指定する.
27
- * Crown::Facebook.count メソッドの返り値を「いいね!」,「シェア」の合計値のみに変更.
28
- 旧バージョンの count メソッドに当たるものは Crown::Facebook.summary メソッドとして用意している.
27
+ * これまで proxy_host, proxy_port や api_key 等、使用する API によって微妙に引数が異なっていた
28
+ 各種メソッドのオプション引数を options と言う引数で統一。今後は,必要なオプション情報を
29
+ ハッシュ形式で作成し、そのオブジェクトを第 2 引数に指定する。
30
+ * Crown::Facebook.count メソッドの返り値を「いいね!」、「シェア」の合計値のみに変更。
31
+ 旧バージョンの count メソッドに当たるものは Crown::Facebook.summary メソッドとして用意している。
29
32
  * Delicious の API の仕様変更に対応
30
33
 
31
34
  === 0.0.5 / 2011-02-24
32
- * Rakefile にライブラリの依存関係に関する記述を追加.
35
+ * Rakefile にライブラリの依存関係に関する記述を追加。
33
36
 
34
37
  === 0.0.4 / 2011-02-19
35
- * Livedoor Reader モジュールを追加.
36
- * Facebook モジュールを追加.
37
- * Topsy, TweetMeme, BackType (BackTweets) モジュールを追加.
38
+ * Livedoor Reader モジュールを追加。
39
+ * Facebook モジュールを追加。
40
+ * Topsy, TweetMeme, BackType (BackTweets) モジュールを追加。
38
41
 
39
42
  === 0.0.1 / 2011-02-18
40
- * 最初の公開バージョン.
43
+ * 最初の公開バージョン。
41
44
 
42
45
  == Copyright
43
46
 
44
- Copyright (c) 2008 - 2011 clown. See LICENSE for details.
47
+ Copyright (c) 2008 - 2012 clown. See LICENSE for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{crown}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
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{2012-01-24}
12
+ s.date = %q{2012-03-01}
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 = [
@@ -25,17 +25,21 @@ Gem::Specification.new do |s|
25
25
  "Rakefile",
26
26
  "VERSION",
27
27
  "crown.gemspec",
28
- "example/annual.rb",
29
28
  "example/cgmcount.rb",
29
+ "example/entrylist.rb",
30
30
  "example/fbcount.rb",
31
31
  "example/feedcount.rb",
32
32
  "example/hbcount.rb",
33
33
  "example/hbentry.rb",
34
- "example/hbtrace.rb",
35
34
  "example/rtcount.rb",
36
35
  "example/sbmcount.rb",
37
36
  "example/twcount.rb",
37
+ "example/urilist.rb",
38
38
  "lib/crown.rb",
39
+ "lib/crown/amazon.rb",
40
+ "lib/crown/amazon/crawler.rb",
41
+ "lib/crown/amazon/ecs.rb",
42
+ "lib/crown/amazon/entrylist.rb",
39
43
  "lib/crown/backtype.rb",
40
44
  "lib/crown/backtype/counter.rb",
41
45
  "lib/crown/buzzurl.rb",
@@ -48,12 +52,18 @@ Gem::Specification.new do |s|
48
52
  "lib/crown/facebook.rb",
49
53
  "lib/crown/facebook/counter.rb",
50
54
  "lib/crown/facebook/entry.rb",
55
+ "lib/crown/google.rb",
56
+ "lib/crown/google/plusone.rb",
57
+ "lib/crown/google/plusone/counter.rb",
51
58
  "lib/crown/hatena.rb",
52
59
  "lib/crown/hatena/bookmark.rb",
53
60
  "lib/crown/hatena/bookmark/counter.rb",
54
61
  "lib/crown/hatena/bookmark/entry.rb",
55
- "lib/crown/hatena/bookmark/linktrace.rb",
62
+ "lib/crown/hatena/bookmark/entrylist.rb",
63
+ "lib/crown/hatena/bookmark/urilist.rb",
56
64
  "lib/crown/http-wrapper.rb",
65
+ "lib/crown/linkedin.rb",
66
+ "lib/crown/linkedin/counter.rb",
57
67
  "lib/crown/livedoor.rb",
58
68
  "lib/crown/livedoor/clip.rb",
59
69
  "lib/crown/livedoor/clip/counter.rb",
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/ruby -Ku
2
+ # --------------------------------------------------------------------------- #
3
+ #
4
+ # entrylist.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/hatena/bookmark'
36
+
37
+ # --------------------------------------------------------------------------- #
38
+ #
39
+ # filters
40
+ #
41
+ # �������i���ău�b�N�}�[�N���ꗗ���擾�������ꍇ�́C
42
+ # �n�b�V���`���ŕK�v�Ȃ��̂��w�肷��D
43
+ # �w��”\�ȏ����́C:type, :category, :sort, :threshold �������݂���D
44
+ #
45
+ # --------------------------------------------------------------------------- #
46
+ filters = {
47
+ :sort => :hot,
48
+ # :threshold => 10,
49
+ # :uri => 'http://d.hatena.ne.jp/tt_clown/'
50
+ }
51
+
52
+ # --------------------------------------------------------------------------- #
53
+ # main
54
+ # --------------------------------------------------------------------------- #
55
+ n = 1
56
+ Crown::Hatena::Bookmark::EntryList.start(filters) { |session|
57
+ # �u�b�N�}�[�N���擾 API ���R�[������Ԋu��b�P�ʂŐݒ肷��D
58
+ # �T�[�o�̕��ד����l�����Č��肷�鎖�D
59
+ # �f�t�H���g�l�� 30�b
60
+ # session.interval = 10
61
+
62
+ session.get { |entry|
63
+ printf("%d %s\n", n, entry.uri)
64
+ printf(" %s\n", entry.title)
65
+ printf(" %d users\n", entry.count)
66
+ n += 1
67
+ break if (n > 5)
68
+ }
69
+ }
@@ -45,7 +45,7 @@ require 'crown'
45
45
  #
46
46
  # --------------------------------------------------------------------------- #
47
47
  ARGV.each { |uri|
48
- info = Crown::Facebook.count(uri)
48
+ info = Crown::Facebook.summary(uri)
49
49
  printf("%s\n", uri)
50
50
  printf(" + like : %8d\n", info.like)
51
51
  printf(" + total : %8d\n", info.total)
@@ -46,7 +46,7 @@ require 'crown/hatena/bookmark'
46
46
  File.open(ARGV[0]) { |file|
47
47
  file.each { |line|
48
48
  line.chomp!
49
- result = Crown::Hatena::Bookmark.get(line)
49
+ result = Crown::Hatena::Bookmark.summary(line)
50
50
  printf("%s (%d users)\n", result.uri, result.count)
51
51
 
52
52
  # ブクマした日付で昇順にソートした後,出力する.
@@ -51,6 +51,7 @@ BACKTYPE_APIKEY = "your_api_key"
51
51
  # --------------------------------------------------------------------------- #
52
52
  ARGV.each { |uri|
53
53
  printf("%s\n", uri)
54
+ printf(" + twitter : %8d\n", Crown::Twitter::URI.count(uri))
54
55
  printf(" + topsy : %8d\n", Crown::Topsy.count(uri))
55
56
  printf(" + tweetmeme : %8d\n", Crown::TweetMeme.count(uri))
56
57
  printf(" + backtype : %8d\n", Crown::BackType.count(uri, BACKTYPE_APIKEY))
@@ -45,7 +45,7 @@ require 'crown'
45
45
  #
46
46
  # --------------------------------------------------------------------------- #
47
47
  ARGV.each { |screen_name|
48
- info = Crown::Twitter.count(screen_name)
48
+ info = Crown::Twitter::User.count(screen_name)
49
49
  printf("%s\n", screen_name)
50
50
  printf(" + status : %8d\n", info.status)
51
51
  printf(" + friend : %8d\n", info.friend)
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/ruby -Ku
2
2
  # --------------------------------------------------------------------------- #
3
3
  #
4
- # annual.rb
4
+ # entrylist.rb
5
5
  #
6
6
  # Copyright (c) 2008 - 2011, clown.
7
7
  #
@@ -34,36 +34,31 @@
34
34
  require 'rubygems'
35
35
  require 'crown/hatena/bookmark'
36
36
 
37
- PREFIX = "entrylist?sort=count&url="
38
-
39
37
  # --------------------------------------------------------------------------- #
40
38
  #
41
- # 人気のエントリーから引数に指定した年の記事の URL を抽出する.
39
+ # filters
42
40
  #
43
- # Parameters
44
- # ARGV[0]: 対象とするサイトの URL
45
- # ARGV[1]: 対象とする年
46
- # ARGV[2]: 取得件数(オプション)
41
+ # 条件を絞ってブックマーク情報一覧を取得したい場合は,
42
+ # ハッシュ形式で必要なものを指定する.
43
+ # 指定可能な条件は,:type, :category, :sort, :threshold 等が存在する.
47
44
  #
48
45
  # --------------------------------------------------------------------------- #
49
- if (ARGV.length < 2)
50
- puts("usage annual.rb URL year [num_of_url]")
51
- exit
52
- end
46
+ filters = {
47
+ :sort => :hot,
48
+ # :threshold => 10,
49
+ # :uri => 'http://d.hatena.ne.jp/tt_clown/'
50
+ }
53
51
 
54
- year = ARGV[1].to_i
55
- limit = (ARGV.length > 2) ? ARGV[2].to_i : 10
56
- i = 0
57
- Crown::Hatena::Bookmark.each(PREFIX + ARGV[0]) { |entry|
58
- v = entry.users.to_a.sort { |x, y|
59
- x[1].date <=> y[1].date
52
+ # --------------------------------------------------------------------------- #
53
+ # main
54
+ # --------------------------------------------------------------------------- #
55
+ n = 1
56
+ Crown::Hatena::Bookmark::URIList.start(filters) { |session|
57
+ session.get { |entry|
58
+ printf("%d %s\n", n, entry.uri)
59
+ printf(" %s\n", entry.title)
60
+ printf(" %s\n", entry.date.to_s)
61
+ n += 1
62
+ break if (n > 10)
60
63
  }
61
-
62
- if (v != nil && !v.empty? && v[0][1].date.year == year)
63
- printf("+ %s (%d users)\n", entry.uri, entry.count)
64
- i += 1
65
- break if (i >= limit)
66
- end
67
-
68
- sleep 5
69
64
  }
@@ -37,5 +37,5 @@ require 'crown/http-wrapper'
37
37
  require 'crown/cgm'
38
38
 
39
39
  module Crown
40
- VERSION = '0.1.0'
40
+ VERSION = '0.1.1'
41
41
  end
@@ -1,9 +1,9 @@
1
- #!/usr/bin/ruby -Ku
1
+ # -*- coding: utf-8 -*-
2
2
  # --------------------------------------------------------------------------- #
3
3
  #
4
- # hbtrace.rb
4
+ # amazon.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
@@ -31,23 +31,8 @@
31
31
  # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
32
  #
33
33
  # --------------------------------------------------------------------------- #
34
- require 'rubygems'
35
- require 'crown/hatena/bookmark'
36
-
37
- # --------------------------------------------------------------------------- #
38
- #
39
- # 引数に指定されたパスに表示されている各はてなブックマーク URL の情報を
40
- # 取得して出力する.
41
- #
42
- # Parameters:
43
- # ARGV[0]: はてなブックマーク URL の一覧が記載されているパス
44
- # ARGV[1]: 最大出力件数
45
- #
46
- # --------------------------------------------------------------------------- #
47
- limit = (ARGV.length > 1) ? ARGV[1].to_i : 10
48
- i = 1
49
- Crown::Hatena::Bookmark.each(ARGV[0]) { |entry|
50
- printf("%3d %s (%d users)\n", i, entry.uri, entry.count)
51
- break if (i >= limit)
52
- i += 1
53
- }
34
+ module Crown
35
+ module Amazon
36
+ require 'crown/amazon/crawler'
37
+ end # Amazon
38
+ end # Crown
@@ -0,0 +1,159 @@
1
+ # -*- coding: utf-8 -*-
2
+ # --------------------------------------------------------------------------- #
3
+ #
4
+ # amazon/crawler.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 Amazon
36
+ require 'crown/amazon/entrylist'
37
+
38
+ # ------------------------------------------------------------------- #
39
+ #
40
+ # Crawler
41
+ #
42
+ # 指定した URL に記述されてある Amazon の ASIN コードを抽出し,
43
+ # それらの商品情報を取得するためのクラス.
44
+ #
45
+ # ------------------------------------------------------------------- #
46
+ class Crawler
47
+ # --------------------------------------------------------------- #
48
+ # structures
49
+ # --------------------------------------------------------------- #
50
+ Response = Struct.new(:asin, :title, :author, :publisher, :price, :date, :count)
51
+
52
+ # --------------------------------------------------------------- #
53
+ # accessors
54
+ # --------------------------------------------------------------- #
55
+ attr_accessor :threshold, :interval, :entries, :uri_count
56
+
57
+ # --------------------------------------------------------------- #
58
+ # initialize
59
+ # --------------------------------------------------------------- #
60
+ def initialize()
61
+ @threshold = 5
62
+ @interval = 5
63
+ @entries = Array.new
64
+ @uri_count = 0
65
+ end
66
+
67
+ # --------------------------------------------------------------- #
68
+ # clear
69
+ # --------------------------------------------------------------- #
70
+ def clear()
71
+ @entries.clear
72
+ @uri_count = 0
73
+ end
74
+
75
+ # --------------------------------------------------------------- #
76
+ #
77
+ # get
78
+ #
79
+ # 指定した URL に記述されてある Amazon の ASIN コードを抽出し,
80
+ # それらの商品情報を取得する.uris には,クロールする URL の
81
+ # 配列,または URL 一覧が記載されてあるファイルへのパスを指定
82
+ # する.
83
+ #
84
+ # --------------------------------------------------------------- #
85
+ def get(uris, options = {})
86
+ case uris
87
+ when String then v = load(uris);
88
+ when Array then v = uris;
89
+ else return [];
90
+ end
91
+
92
+ asins = Hash.new
93
+ v.each { |uri|
94
+ begin
95
+ exits = false
96
+ ::Crown::Amazon::EntryList.new.asin(uri, options) { |asin|
97
+ if (asins.include?(asin)) then asins[asin] += 1;
98
+ else asins[asin] = 1;
99
+ end
100
+ exists = true
101
+ }
102
+ @uri_count += 1 if (exists)
103
+ rescue Exception => e
104
+ next
105
+ end
106
+ }
107
+
108
+ asins.to_a.sort { |x, y| y[1] <=> x[1] }.each { |asin|
109
+ break if (asin[1] < @threshold)
110
+ response = ::Amazon::Ecs.item_lookup(asin[0], { :response_group => 'Medium' })
111
+ next if (response == nil || response.items.length == 0)
112
+
113
+ x = response.first_item
114
+ entry = Response.new
115
+ entry.asin = alternate(x.get('ASIN'), '')
116
+ entry.title = alternate(x.get('ItemAttributes/Title'), '')
117
+ entry.author = alternate(x.get_array('ItemAttributes/Author').join(','), '')
118
+ entry.publisher = alternate(x.get('ItemAttributes/Publisher'), '')
119
+ entry.price = alternate(x.get('ItemAttributes/ListPrice/Amount'), '')
120
+ entry.date = alternate(x.get('ItemAttributes/ReleaseDate'), '')
121
+ entry.date = alternate(x.get('ItemAttributes/PublicationDate'), '') if (entry.date == nil || entry.date.length == 0)
122
+ entry.count = asin[1]
123
+
124
+ yield entry if (block_given?)
125
+ @entries.push(entry)
126
+ sleep(@interval)
127
+ }
128
+
129
+ return @entries
130
+ end
131
+
132
+ private
133
+ # --------------------------------------------------------------- #
134
+ # load
135
+ # --------------------------------------------------------------- #
136
+ def load(path)
137
+ begin
138
+ v = Array.new
139
+ File.open(path) { |f|
140
+ f.each { |line|
141
+ v.push(line.chomp)
142
+ }
143
+ }
144
+ return v
145
+ rescue Exception => e
146
+ return []
147
+ end
148
+ end
149
+
150
+ # --------------------------------------------------------------- #
151
+ # alternate
152
+ # --------------------------------------------------------------- #
153
+ def alternate(value, alt)
154
+ return (value != nil) ? value : alt
155
+ end
156
+
157
+ end # Crawler
158
+ end # Amazon
159
+ end # Crown