Skip to content

Commit 90348fc

Browse files
committed
218 Interval to scraping
1 parent 539e4f8 commit 90348fc

File tree

7 files changed

+18
-9
lines changed

7 files changed

+18
-9
lines changed

doc/PLUGINS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ SubscriptionLink
3232
urls:
3333
- URL
3434
- URL ...
35+
interval: INTERVAL_FOR_SCRAPING (in seconds.)
3536

3637

3738
SubscriptionTwitter
@@ -48,6 +49,7 @@ SubscriptionTwitter
4849
urls:
4950
- URL
5051
- URL ...
52+
interval: INTERVAL_FOR_SCRAPING (in seconds.)
5153

5254

5355
SubscriptionTumblr
@@ -66,6 +68,7 @@ SubscriptionTumblr
6668
- URL
6769
- URL ...
6870
pages: PAGES
71+
interval: INTERVAL_FOR_SCRAPING (in seconds.)
6972

7073

7174
FilterReverse

doc/PLUGINS.ja

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ SubscriptionLink
3232
urls:
3333
- URL
3434
- URL ...
35+
interval: スクレイピングの間隔 (秒数, 省略可)
3536

3637

3738
SubscriptionTwitter
@@ -48,6 +49,7 @@ SubscriptionTwitter
4849
urls:
4950
- URL
5051
- URL ...
52+
interval: スクレイピングの間隔 (秒数, 省略可)
5153

5254

5355
SubscriptionTumblr
@@ -66,6 +68,7 @@ SubscriptionTumblr
6668
- URL
6769
- URL ...
6870
pages: PAGES
71+
interval: スクレイピングの間隔 (秒数, 省略可)
6972

7073

7174
FilterReverse

plugins/store/database.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ def for_each_new_feed
1515
prepare_database
1616
existing_records = model_class.find(:all)
1717
@return_feeds = []
18-
@pipeline.each { |feeds|
18+
@pipeline.each {|feeds|
1919
unless feeds.nil?
2020
new_feed = false
21-
feeds.items.each { |feed|
21+
feeds.items.each {|feed|
2222
unless feed.link.nil?
23-
unless existing_records.detect { |b| b.try(unique_key) == feed.link }
23+
unless existing_records.detect {|b| b.try(unique_key) == feed.link }
2424
yield(feed)
2525
new_feed = true
2626
end
@@ -35,8 +35,8 @@ def for_each_new_feed
3535
private
3636

3737
def create_table
38-
ActiveRecord::Migration.create_table(model_class.table_name) { |t|
39-
column_definition.each_pair { |column_name, column_type|
38+
ActiveRecord::Migration.create_table(model_class.table_name) {|t|
39+
column_definition.each_pair {|column_name, column_type|
4040
t.column column_name, column_type
4141
}
4242
}

plugins/store/target_link.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def run
3434
unless feed.link.nil?
3535
Automatic::Log.puts("info", "Get: #{feed.link}")
3636
wget(feed.link)
37-
sleep @config['interval'].to_i
37+
sleep @config['interval'].to_i unless @config['internal'].nil?
3838
end
3939
rescue
4040
Automatic::Log.puts("error", "Error found during file download.")

plugins/subscription/link.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Name:: Automatic::Plugin::Subscription::Link
33
# Author:: 774 <http://id774.net>
44
# Created:: Sep 18, 2012
5-
# Updated:: Oct 16, 2012
5+
# Updated:: Oct 18, 2012
66
# Copyright:: 774 Copyright (c) 2012
77
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
88

@@ -40,6 +40,7 @@ def create_rss(url)
4040
end
4141
}
4242
}
43+
sleep @config['interval'].to_i unless @config['internal'].nil?
4344
@return_feeds << rss
4445
end
4546
end

plugins/subscription/tumblr.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Name:: Automatic::Plugin::Subscription::Tumblr
33
# Author:: 774 <http://id774.net>
44
# Created:: Oct 16, 2012
5-
# Updated:: Oct 17, 2012
5+
# Updated:: Oct 18, 2012
66
# Copyright:: 774 Copyright (c) 2012
77
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
88

@@ -40,6 +40,7 @@ def create_rss(url)
4040
end
4141
}
4242
}
43+
sleep @config['interval'].to_i unless @config['internal'].nil?
4344
@return_feeds << rss
4445
end
4546
end

plugins/subscription/twitter.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Name:: Automatic::Plugin::Subscription::Twitter
33
# Author:: 774 <http://id774.net>
44
# Created:: Sep 9, 2012
5-
# Updated:: Oct 16, 2012
5+
# Updated:: Oct 18, 2012
66
# Copyright:: 774 Copyright (c) 2012
77
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
88

@@ -42,6 +42,7 @@ def create_rss(url)
4242
item.description = content.search('[@class="js-tweet-text"]').text.to_s
4343
}
4444
}
45+
sleep @config['interval'].to_i unless @config['internal'].nil?
4546
@return_feeds << rss
4647
end
4748
end

0 commit comments

Comments
 (0)