automatic 13.4.1 → 13.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -12,6 +12,9 @@ gem 'gcalapi'
12
12
  gem 'xml-simple'
13
13
  gem 'feedbag'
14
14
  gem 'nokogiri'
15
+ gem 'twitter'
16
+ gem 'weather_hacker'
17
+ gem 'pocket-ruby'
15
18
 
16
19
  group :test do
17
20
  gem 'rspec'
data/README.md CHANGED
@@ -28,7 +28,7 @@ $ automatic -c ~/.automatic/config/example/feed2console.yml
28
28
 
29
29
  ``` html
30
30
  [Development]
31
- $ git clone git://github.com/id774/automaticruby.git
31
+ $ git clone git://github.com/automaticruby/automaticruby.git
32
32
  $ cd automaticruby
33
33
  $ bundle install --path vendor/gems
34
34
  $ bin/automatic scaffold
@@ -85,11 +85,11 @@ We need your help.
85
85
 
86
86
  **Repository**
87
87
 
88
- + https://github.com/id774/automaticruby
88
+ + https://github.com/automaticruby/automaticruby
89
89
 
90
90
  **Issues**
91
91
 
92
- + https://github.com/id774/automaticruby/issues
92
+ + https://github.com/automaticruby/automaticruby/issues
93
93
 
94
94
  **RubyFroge**
95
95
 
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # -*- mode: ruby; coding: utf-8 -*-
2
2
 
3
3
  require 'rubygems'
4
4
 
@@ -23,11 +23,13 @@ namespace :spec do
23
23
  end
24
24
  end
25
25
 
26
+ task :default => :spec
27
+
26
28
  require 'jeweler'
27
29
  Jeweler::Tasks.new do |gem|
28
30
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
29
31
  gem.name = "automatic"
30
- gem.homepage = "http://github.com/id774/automaticruby"
32
+ gem.homepage = "http://github.com/automaticruby/automaticruby"
31
33
  gem.license = "GPL"
32
34
  gem.summary = %Q{Automatic Ruby}
33
35
  gem.description = %Q{Ruby General Automation Framework}
@@ -35,9 +37,10 @@ Jeweler::Tasks.new do |gem|
35
37
  gem.authors = ["id774"]
36
38
  # dependencies defined in Gemfile
37
39
  end
40
+
38
41
  Jeweler::RubygemsDotOrgTasks.new
39
42
 
40
- unless /^1\.8\./ =~ RUBY_VERSION
43
+ if RUBY_VERSION >= '1.9.0'
41
44
  desc "Run RSpec code examples with simplecov"
42
45
  task :simplecov do
43
46
  ENV['COVERAGE'] = "on"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 13.4.1
1
+ 13.5.0
data/automatic.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "automatic"
8
- s.version = "13.4.1"
8
+ s.version = "13.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["id774"]
12
- s.date = "2013-04-10"
12
+ s.date = "2013-05-18"
13
13
  s.description = "Ruby General Automation Framework"
14
14
  s.email = "idnanashi@gmail.com"
15
15
  s.executables = ["automatic"]
@@ -46,6 +46,8 @@ Gem::Specification.new do |s|
46
46
  "plugins/filter/ignore.rb",
47
47
  "plugins/filter/image.rb",
48
48
  "plugins/filter/image_source.rb",
49
+ "plugins/filter/one.rb",
50
+ "plugins/filter/rand.rb",
49
51
  "plugins/filter/sort.rb",
50
52
  "plugins/filter/tumblr_resize.rb",
51
53
  "plugins/notify/ikachan.rb",
@@ -54,7 +56,9 @@ Gem::Specification.new do |s|
54
56
  "plugins/publish/hatena_bookmark.rb",
55
57
  "plugins/publish/instapaper.rb",
56
58
  "plugins/publish/mail.rb",
59
+ "plugins/publish/pocket.rb",
57
60
  "plugins/publish/smtp.rb",
61
+ "plugins/publish/twitter.rb",
58
62
  "plugins/store/database.rb",
59
63
  "plugins/store/full_text.rb",
60
64
  "plugins/store/permalink.rb",
@@ -62,8 +66,10 @@ Gem::Specification.new do |s|
62
66
  "plugins/subscription/feed.rb",
63
67
  "plugins/subscription/google_reader_star.rb",
64
68
  "plugins/subscription/link.rb",
69
+ "plugins/subscription/text.rb",
65
70
  "plugins/subscription/tumblr.rb",
66
71
  "plugins/subscription/twitter.rb",
72
+ "plugins/subscription/weather.rb",
67
73
  "script/build",
68
74
  "spec/fixtures/sampleRecipe.yml",
69
75
  "spec/lib/automatic/pipeline_spec.rb",
@@ -75,6 +81,8 @@ Gem::Specification.new do |s|
75
81
  "spec/plugins/filter/ignore_spec.rb",
76
82
  "spec/plugins/filter/image_source_spec.rb",
77
83
  "spec/plugins/filter/image_spec.rb",
84
+ "spec/plugins/filter/one_spec.rb",
85
+ "spec/plugins/filter/rand_spec.rb",
78
86
  "spec/plugins/filter/sort_spec.rb",
79
87
  "spec/plugins/filter/tumblr_resize_spec.rb",
80
88
  "spec/plugins/notify/ikachan_spec.rb",
@@ -83,20 +91,25 @@ Gem::Specification.new do |s|
83
91
  "spec/plugins/publish/hatena_bookmark_spec.rb",
84
92
  "spec/plugins/publish/instapaper_spec.rb",
85
93
  "spec/plugins/publish/mail_spec.rb",
94
+ "spec/plugins/publish/pocket_spec.rb",
86
95
  "spec/plugins/publish/smtp_spec.rb",
96
+ "spec/plugins/publish/twitter_spec.rb",
87
97
  "spec/plugins/store/full_text_spec.rb",
88
98
  "spec/plugins/store/permalink_spec.rb",
89
99
  "spec/plugins/store/target_link_spec.rb",
90
100
  "spec/plugins/subscription/feed_spec.rb",
91
101
  "spec/plugins/subscription/google_reader_star_spec.rb",
92
102
  "spec/plugins/subscription/link_spec.rb",
103
+ "spec/plugins/subscription/text_spec.rb",
93
104
  "spec/plugins/subscription/tumblr_spec.rb",
94
105
  "spec/plugins/subscription/twitter_spec.rb",
106
+ "spec/plugins/subscription/weather_spec.rb",
95
107
  "spec/spec_helper.rb",
96
108
  "spec/user_dir/plugins/store/mock.rb",
97
109
  "test/fixtures/sampleOPML.xml",
98
110
  "test/integration/test_absoluteurl.yml",
99
111
  "test/integration/test_activerecord.yml",
112
+ "test/integration/test_add_pocket.yml",
100
113
  "test/integration/test_fulltext.yml",
101
114
  "test/integration/test_googlealert.yml",
102
115
  "test/integration/test_googlestar.yml",
@@ -106,12 +119,16 @@ Gem::Specification.new do |s|
106
119
  "test/integration/test_image2local.yml",
107
120
  "test/integration/test_instapaper.yml",
108
121
  "test/integration/test_link2local.yml",
122
+ "test/integration/test_one.yml",
123
+ "test/integration/test_rand.yml",
109
124
  "test/integration/test_sort.yml",
110
125
  "test/integration/test_svnlog.yml",
126
+ "test/integration/test_text2feed.yml",
111
127
  "test/integration/test_tumblr2local.yml",
128
+ "test/integration/test_weather.yml",
112
129
  "vendor/.gitkeep"
113
130
  ]
114
- s.homepage = "http://github.com/id774/automaticruby"
131
+ s.homepage = "http://github.com/automaticruby/automaticruby"
115
132
  s.licenses = ["GPL"]
116
133
  s.require_paths = ["lib"]
117
134
  s.rubygems_version = "1.8.24"
@@ -130,6 +147,9 @@ Gem::Specification.new do |s|
130
147
  s.add_runtime_dependency(%q<xml-simple>, [">= 0"])
131
148
  s.add_runtime_dependency(%q<feedbag>, [">= 0"])
132
149
  s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
150
+ s.add_runtime_dependency(%q<twitter>, [">= 0"])
151
+ s.add_runtime_dependency(%q<weather_hacker>, [">= 0"])
152
+ s.add_runtime_dependency(%q<pocket-ruby>, [">= 0"])
133
153
  s.add_development_dependency(%q<cucumber>, [">= 0"])
134
154
  s.add_development_dependency(%q<bundler>, [">= 0"])
135
155
  s.add_development_dependency(%q<jeweler>, [">= 0"])
@@ -143,6 +163,9 @@ Gem::Specification.new do |s|
143
163
  s.add_dependency(%q<xml-simple>, [">= 0"])
144
164
  s.add_dependency(%q<feedbag>, [">= 0"])
145
165
  s.add_dependency(%q<nokogiri>, [">= 0"])
166
+ s.add_dependency(%q<twitter>, [">= 0"])
167
+ s.add_dependency(%q<weather_hacker>, [">= 0"])
168
+ s.add_dependency(%q<pocket-ruby>, [">= 0"])
146
169
  s.add_dependency(%q<cucumber>, [">= 0"])
147
170
  s.add_dependency(%q<bundler>, [">= 0"])
148
171
  s.add_dependency(%q<jeweler>, [">= 0"])
@@ -157,6 +180,9 @@ Gem::Specification.new do |s|
157
180
  s.add_dependency(%q<xml-simple>, [">= 0"])
158
181
  s.add_dependency(%q<feedbag>, [">= 0"])
159
182
  s.add_dependency(%q<nokogiri>, [">= 0"])
183
+ s.add_dependency(%q<twitter>, [">= 0"])
184
+ s.add_dependency(%q<weather_hacker>, [">= 0"])
185
+ s.add_dependency(%q<pocket-ruby>, [">= 0"])
160
186
  s.add_dependency(%q<cucumber>, [">= 0"])
161
187
  s.add_dependency(%q<bundler>, [">= 0"])
162
188
  s.add_dependency(%q<jeweler>, [">= 0"])
data/bin/automatic CHANGED
@@ -100,7 +100,10 @@ parser = OptionParser.new {|parser|
100
100
  parser.version = Automatic.const_get(:VERSION)
101
101
  parser.banner = "Automatic #{parser.version}
102
102
  Usage: automatic [options] [subcommand]"
103
- parser.separator "SubCommands:
103
+ parser.separator "SubCommands:"
104
+ subparsers.keys.each {|key|
105
+ parser.separator " " + key
106
+ }
104
107
  #{subparsers.keys.join(", ")}"
105
108
  parser.separator "Options:"
106
109
  parser.on('-c', '--config FILE', String,
data/doc/ChangeLog CHANGED
@@ -1,3 +1,17 @@
1
+ === 13.5.0 / 2013-05-18
2
+
3
+ * Added new plugins.
4
+
5
+ * Subscription::Text
6
+ * Subscription::Weather
7
+ * Filter::One
8
+ * Filter::Rand
9
+ * Pulish::Twitter
10
+ * Pulish::Pocket
11
+
12
+ * Move repository from id774/automaticruby to automaticruby/automaticruby.
13
+
14
+
1
15
  === 13.4.1 / 2013-04-10
2
16
 
3
17
  * Command automatic-config merged into automatic.
@@ -48,7 +62,7 @@
48
62
 
49
63
  * Bug fix
50
64
 
51
- * It should be considered the case of the feed link including nil
65
+ * It should be considered the case of the feed link including nil.
52
66
 
53
67
 
54
68
  === 12.9.0 / 2012-09-18
data/doc/PLUGINS CHANGED
@@ -94,6 +94,47 @@ SubscriptionTwitter
94
94
  retry: RETRY_COUNT
95
95
 
96
96
 
97
+ SubscriptionText
98
+ ----------------
99
+ [Path]
100
+ /plugins/subscription/text.rb
101
+
102
+ [Abstract]
103
+ Create new feeds from urls, titles, feeds on text.
104
+
105
+ [Syntax]
106
+ - module: SubscriptionText
107
+ config:
108
+ titles:
109
+ - 'title'
110
+ urls:
111
+ - 'url'
112
+ feeds:
113
+ -
114
+ title: 'title'
115
+ url: 'url'
116
+ -
117
+ title: 'title'
118
+ url: 'url'
119
+
120
+
121
+ SubscriptionWeather
122
+ -------------------
123
+ [Path]
124
+ /plugins/subscription/weather.rb
125
+
126
+ [Abstract]
127
+ Subscribe weather (using gem weather_hacker) by zipcode.
128
+
129
+ [Syntax]
130
+ - module: SubscriptionWeather
131
+ config:
132
+ zipcode: ZIPCODE (ex. 166-0003)
133
+ day: DAY (ex. 'today', 'tomorrow')
134
+ interval: INTERVAL_FOR_SCRAPING (in seconds.)
135
+ retry: RETRY_COUNT
136
+
137
+
97
138
  FilterSort
98
139
  ----------
99
140
  [Path]
@@ -154,6 +195,32 @@ FilterImageSource
154
195
  - module: FilterImageSource
155
196
 
156
197
 
198
+ FilterOne
199
+ ---------
200
+ [Path]
201
+ /plugins/filter/one.rb
202
+
203
+ [Abstract]
204
+ Select a item from items.
205
+
206
+ [Syntax]
207
+ - module: FilterOne
208
+ config:
209
+ pick: last (If none, pick the first item.)
210
+
211
+
212
+ FilterRand
213
+ ----------
214
+ [Path]
215
+ /plugins/filter/rand.rb
216
+
217
+ [Abstract]
218
+ Randomize the array of the feed items.
219
+
220
+ [Syntax]
221
+ - module: FilterRand
222
+
223
+
157
224
  FilterFullFeed
158
225
  --------------
159
226
  [Path]
@@ -279,6 +346,46 @@ PublishHatenaBookmark
279
346
  interval: INTERVAL_FOR_BOOKMARK (in seconds.)
280
347
 
281
348
 
349
+ PublishTwitter
350
+ --------------
351
+ [Path]
352
+ /plugins/publish/twitter.rb
353
+
354
+ [Abstract]
355
+ Publish to twitter.
356
+
357
+ [Syntax]
358
+ - module: PublishTwitter
359
+ config:
360
+ consumer_key: 'your_consumer_key'
361
+ consumer_secret: 'your_consumer_secret'
362
+ oauth_token: 'your_oauth_token'
363
+ oauth_token_secret: 'your_oauth_token_secret'
364
+ tweet_tmp: 'tweet text {link}'
365
+ interval: INTERVAL_FOR_RETRY (in seconds.)
366
+ retry: RETRY_COUNT
367
+
368
+
369
+ PublishPocket
370
+ -----------------
371
+ [Path]
372
+ /plugins/publish/pocket.rb
373
+
374
+ [Abstract]
375
+ Register an appointment to Pocket.
376
+
377
+ [Description]
378
+ Submission to Pocket API. (using gem pocket-ruby)
379
+
380
+ [Syntax]
381
+ - module: PublishPocket
382
+ config:
383
+ consumer_key: CONSUMER_KEY
384
+ access_token: ACCESS_TOKEN
385
+ interval: INTERVAL_FOR_RETRY (in seconds.)
386
+ retry: RETRY_COUNT
387
+
388
+
282
389
  PublishInstapaper
283
390
  -----------------
284
391
  [Path]
data/doc/PLUGINS.ja CHANGED
@@ -94,6 +94,47 @@ SubscriptionTwitter
94
94
  retry: エラー時のリトライ回数 (回数, 省略時 0)
95
95
 
96
96
 
97
+ SubscriptionWeather
98
+ -------------------
99
+ [パス]
100
+ /plugins/subscription/weather.rb
101
+
102
+ [概要]
103
+ 与えられた郵便番号に基づいて天気情報を取得する
104
+
105
+ [レシピ記法]
106
+ - module: SubscriptionWeather
107
+ config:
108
+ zipcode: 郵便番号
109
+ day: ('today' もしくは 'tomorrow')
110
+ interval: スクレイピングの間隔 (秒数, 省略可)
111
+ retry: エラー時のリトライ回数 (回数, 省略時 0)
112
+
113
+
114
+ SubscriptionText
115
+ ----------------
116
+ [パス]
117
+ /plugins/subscription/text.rb
118
+
119
+ [概要]
120
+ テキストベースの urls, titles, feeds から新規のフィードを作成する
121
+
122
+ [レシピ記法]
123
+ - module: SubscriptionText
124
+ config:
125
+ titles:
126
+ - TITLE ...
127
+ urls:
128
+ - URL
129
+ - URL ...
130
+ feeds:
131
+ -
132
+ title: TITLE
133
+ url: URL ...
134
+ interval: スクレイピングの間隔 (秒数, 省略可)
135
+ retry: エラー時のリトライ回数 (回数, 省略時 0)
136
+
137
+
97
138
  FilterSort
98
139
  ----------
99
140
  [パス]
@@ -199,6 +240,32 @@ FilterTumblrResize
199
240
  - module: FilterTumblrResize
200
241
 
201
242
 
243
+ FilterOne
244
+ ---------
245
+ [パス]
246
+ /plugins/filter/one.rb
247
+
248
+ [概要]
249
+ アイテムをフィードから 1 件だけ取り出す
250
+
251
+ [レシピ記法]
252
+ - module: FilterOne
253
+ config:
254
+ pick: last (省略時は先頭から)
255
+
256
+
257
+ FilterRand
258
+ ----------
259
+ [パス]
260
+ /plugins/filter/rand.rb
261
+
262
+ [概要]
263
+ フィードの順番をランダムにする
264
+
265
+ [レシピ記法]
266
+ - module: FilterRand
267
+
268
+
202
269
  StorePermalink
203
270
  --------------
204
271
  [パス]
@@ -279,6 +346,46 @@ PublishHatenaBookmark
279
346
  interval: はてブする間隔 (秒)
280
347
 
281
348
 
349
+ PublishTwitter
350
+ --------------
351
+ [パス]
352
+ /plugins/publish/twitter.rb
353
+
354
+ [概要]
355
+ Twitter に投稿する
356
+
357
+ [レシピ記法]
358
+ - module: PublishTwitter
359
+ config:
360
+ consumer_key: your_consumer_key
361
+ consumer_secret: your_consumer_secret
362
+ oauth_token: your_oauth_token
363
+ oauth_token_secret: your_oauth_token_secret
364
+ tweet_tmp: tweet する文章 {title} の記法で feed の値から置換
365
+ interval: 複数の予定の投稿間隔, エラー時のリトライ間隔 (秒)
366
+ retry: エラー時のリトライ回数 (回数, 省略時 0)
367
+
368
+
369
+ PublishPocket
370
+ -----------------
371
+ [パス]
372
+ /plugins/publish/pocket.rb
373
+
374
+ [概要]
375
+ Pocket に登録する
376
+
377
+ [説明]
378
+ Pocket API へ送信する(gem pocket-rubyを使用)
379
+
380
+ [レシピ記法]
381
+ - module: PublishPocket
382
+ config:
383
+ consumer_key: CONSUMER_KEY
384
+ access_token: ACCESS_TOKEN
385
+ interval: 複数の予定の投稿間隔, エラー時のリトライ間隔 (秒)
386
+ retry: エラー時のリトライ回数 (回数, 省略時 0)
387
+
388
+
282
389
  PublishInstapaper
283
390
  -----------------
284
391
  [パス]
data/doc/README CHANGED
@@ -31,7 +31,7 @@ $ automatic -c ~/.automatic/config/example/feed2console.yml
31
31
 
32
32
 
33
33
  [Development]
34
- $ git clone git://github.com/id774/automaticruby.git
34
+ $ git clone git://github.com/automaticruby/automaticruby.git
35
35
  $ cd automaticruby
36
36
  $ bundle install --path vendor/gems
37
37
  $ bin/automatic scaffold
@@ -304,10 +304,10 @@ Development
304
304
  ===========
305
305
 
306
306
  Repository
307
- https://github.com/id774/automaticruby
307
+ https://github.com/automaticruby/automaticruby
308
308
 
309
309
  Issues
310
- https://github.com/id774/automaticruby/issues
310
+ https://github.com/automaticruby/automaticruby/issues
311
311
 
312
312
  RubyForge
313
313
  http://rubyforge.org/projects/automatic/
@@ -489,7 +489,7 @@ TODO
489
489
  ====
490
490
 
491
491
  Refer to the issues of github.
492
- https://github.com/id774/automaticruby/issues
492
+ https://github.com/automaticruby/automaticruby/issues
493
493
 
494
494
 
495
495
  ===========
data/doc/README.ja CHANGED
@@ -32,7 +32,7 @@ $ automatic -c ~/.automatic/config/example/feed2console.yml
32
32
 
33
33
 
34
34
  [開発版]
35
- $ git clone git://github.com/id774/automaticruby.git
35
+ $ git clone git://github.com/automaticruby/automaticruby.git
36
36
  $ cd automaticruby
37
37
  $ bundle install --path vendor/gems
38
38
  $ bin/automatic scaffold
@@ -284,10 +284,10 @@ plugins:
284
284
  ==============
285
285
 
286
286
  リポジトリ
287
- https://github.com/id774/automaticruby
287
+ https://github.com/automaticruby/automaticruby
288
288
 
289
289
  課題
290
- https://github.com/id774/automaticruby/issues
290
+ https://github.com/automaticruby/automaticruby/issues
291
291
 
292
292
  RubyForge
293
293
  http://rubyforge.org/projects/automatic/
@@ -497,7 +497,7 @@ TODO
497
497
  ====
498
498
 
499
499
  GitHub の issues を参照
500
- https://github.com/id774/automaticruby/issues
500
+ https://github.com/automaticruby/automaticruby/issues
501
501
 
502
502
 
503
503
  ========
@@ -32,7 +32,7 @@ module Automatic
32
32
  xss = maker.xml_stylesheets.new_xml_stylesheet
33
33
  maker.channel.title = "Automatic Ruby"
34
34
  maker.channel.description = "Automatic Ruby"
35
- maker.channel.link = "https://github.com/id774/automaticruby"
35
+ maker.channel.link = "https://github.com/automaticruby/automaticruby"
36
36
  maker.items.do_sort = true
37
37
 
38
38
  unless feeds.nil?
@@ -61,7 +61,7 @@ module Automatic
61
61
  xss = maker.xml_stylesheets.new_xml_stylesheet
62
62
  maker.channel.title = "Automatic Ruby"
63
63
  maker.channel.description = "Automatic Ruby"
64
- maker.channel.link = "https://github.com/id774/automaticruby"
64
+ maker.channel.link = "https://github.com/automaticruby/automaticruby"
65
65
  maker.items.do_sort = true
66
66
 
67
67
  doc = Nokogiri::HTML(html)
data/lib/automatic.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  # Name:: Automatic::Ruby
3
3
  # Author:: 774 <http://id774.net>
4
4
  # Created:: Feb 18, 2012
5
- # Updated:: Apr 10, 2013
5
+ # Updated:: May 18, 2013
6
6
  # Copyright:: 774 Copyright (c) 2012-2013
7
7
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
8
 
@@ -13,7 +13,7 @@ module Automatic
13
13
  require 'automatic/log'
14
14
  require 'automatic/feed_parser'
15
15
 
16
- VERSION = "13.4.1"
16
+ VERSION = "13.5.0"
17
17
  USER_DIR = "/.automatic"
18
18
 
19
19
  class << self
@@ -31,6 +31,14 @@ module Automatic::Plugin
31
31
 
32
32
  def exclude(items)
33
33
  detection = false
34
+ unless @config['title'].nil?
35
+ @config['title'].each {|e|
36
+ if items.title.include?(e.chomp)
37
+ detection = true
38
+ Automatic::Log.puts("info", "Excluded by title: #{items.link}")
39
+ end
40
+ }
41
+ end
34
42
  unless @config['link'].nil?
35
43
  @config['link'].each {|e|
36
44
  if items.link.include?(e.chomp)
@@ -0,0 +1,36 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Name:: Automatic::Plugin::Filter::One
3
+ # Author:: soramugi <http://soramugi.net>
4
+ # Created:: May 8, 2013
5
+ # Updated:: May 8, 2013
6
+ # Copyright:: soramugi Copyright (c) 2013
7
+ # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
+
9
+ module Automatic::Plugin
10
+ class FilterOne
11
+
12
+ def initialize(config, pipeline=[])
13
+ @config = config
14
+ @pipeline = pipeline
15
+ end
16
+
17
+ def run
18
+ @return_feeds = []
19
+ @pipeline.each {|feed|
20
+ unless feed.nil?
21
+ item = []
22
+ unless @config.nil? or @config['pick'].nil?
23
+ if @config['pick'] == 'last'
24
+ item << feed.items.pop
25
+ end
26
+ end
27
+ if item.count == 0
28
+ item << feed.items.shift
29
+ end
30
+ @return_feeds << Automatic::FeedParser.create(item)
31
+ end
32
+ }
33
+ @return_feeds
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,28 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Name:: Automatic::Plugin::Filter::Rand
3
+ # Author:: soramugi <http://soramugi.net>
4
+ # 774 <http://id774.net>
5
+ # Created:: Mar 6, 2013
6
+ # Updated:: Mar 7, 2013
7
+ # Copyright:: soramugi Copyright (c) 2013
8
+ # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
9
+
10
+ module Automatic::Plugin
11
+ class FilterRand
12
+
13
+ def initialize(config, pipeline=[])
14
+ @config = config
15
+ @pipeline = pipeline
16
+ end
17
+
18
+ def run
19
+ @return_feeds = []
20
+ @pipeline.each {|feed|
21
+ unless feed.nil?
22
+ @return_feeds << Automatic::FeedParser.create(feed.items.shuffle)
23
+ end
24
+ }
25
+ @return_feeds
26
+ end
27
+ end
28
+ end