automatic 12.6.0 → 12.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/VERSION +1 -1
  2. data/automatic.gemspec +10 -22
  3. data/bin/automatic-config +4 -4
  4. data/doc/ChangeLog +30 -1
  5. data/doc/PLUGINS +46 -178
  6. data/doc/PLUGINS.ja +46 -177
  7. data/doc/README +2 -10
  8. data/doc/README.ja +2 -9
  9. data/lib/automatic.rb +2 -3
  10. data/plugins/custom_feed/svn_log.rb +0 -1
  11. data/plugins/filter/absolute_uri.rb +39 -0
  12. data/plugins/filter/image.rb +46 -0
  13. data/plugins/filter/reverse.rb +0 -1
  14. data/plugins/store/database.rb +8 -23
  15. data/plugins/store/full_text.rb +4 -4
  16. data/plugins/store/permalink.rb +12 -9
  17. data/plugins/store/target_link.rb +3 -2
  18. data/plugins/subscription/link.rb +55 -0
  19. data/plugins/subscription/twitter.rb +57 -0
  20. data/script/build +1 -1
  21. data/spec/lib/automatic_spec.rb +3 -2
  22. data/spec/plugins/custom_feed/svn_log_spec.rb +1 -1
  23. data/spec/plugins/filter/absolute_uri_spec.rb +61 -0
  24. data/spec/plugins/filter/image_source_spec.rb +1 -1
  25. data/spec/plugins/filter/image_spec.rb +65 -0
  26. data/spec/plugins/publish/google_calendar_spec.rb +1 -1
  27. data/spec/plugins/store/full_text_spec.rb +0 -1
  28. data/spec/plugins/store/permalink_spec.rb +52 -3
  29. data/spec/plugins/store/target_link_spec.rb +1 -2
  30. data/spec/plugins/subscription/feed_spec.rb +0 -1
  31. data/spec/plugins/subscription/{uri_spec.rb → link_spec.rb} +9 -10
  32. data/spec/plugins/subscription/twitter_spec.rb +42 -0
  33. data/spec/spec_helper.rb +12 -26
  34. data/spec/user_dir/plugins/store/mock.rb +1 -1
  35. data/test/integration/test_get_image.yml +4 -6
  36. data/test/integration/test_image2local.yml +1 -1
  37. metadata +10 -22
  38. data/config/html2console.yml +0 -16
  39. data/plugins/extract/link.rb +0 -32
  40. data/plugins/filter/image_link.rb +0 -37
  41. data/plugins/publish/dump.rb +0 -24
  42. data/plugins/store/link.rb +0 -47
  43. data/plugins/store/target.rb +0 -41
  44. data/plugins/subscription/uri.rb +0 -31
  45. data/spec/fixtures/extractLink.html +0 -14
  46. data/spec/fixtures/filterImageLink.html +0 -34
  47. data/spec/fixtures/publishDump.html +0 -14
  48. data/spec/fixtures/storeLink.html +0 -34
  49. data/spec/fixtures/storeLink2.html +0 -36
  50. data/spec/fixtures/storeTarget.html +0 -11
  51. data/spec/fixtures/storeTarget2.html +0 -11
  52. data/spec/plugins/extract/link_spec.rb +0 -38
  53. data/spec/plugins/filter/image_link_spec.rb +0 -51
  54. data/spec/plugins/publish/dump_spec.rb +0 -32
  55. data/spec/plugins/store/link_spec.rb +0 -47
  56. data/spec/plugins/store/target_spec.rb +0 -41
@@ -0,0 +1,46 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Name:: Automatic::Plugin::Filter::Image
3
+ # Author:: 774 <http://id774.net>
4
+ # Created:: Sep 18, 2012
5
+ # Updated:: Sep 18, 2012
6
+ # Copyright:: 774 Copyright (c) 2012
7
+ # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
+
9
+ module Automatic::Plugin
10
+ class FilterImage
11
+
12
+ def initialize(config, pipeline=[])
13
+ @config = config
14
+ @pipeline = pipeline
15
+ end
16
+
17
+ def run
18
+ @return_feeds = []
19
+ @pipeline.each {|feeds|
20
+ return_feed_items = []
21
+ unless feeds.nil?
22
+ feeds.items.each {|feed|
23
+ unless feed.link.nil?
24
+ image_link = nil
25
+ feed.link.scan(/(.*?\.jp.*g$)/i) { |matched|
26
+ image_link = matched.join(" ")
27
+ }
28
+ feed.link.scan(/(.*?\.png$)/i) { |matched|
29
+ image_link = matched.join(" ")
30
+ }
31
+ feed.link.scan(/(.*?\.gif$)/i) { |matched|
32
+ image_link = matched.join(" ")
33
+ }
34
+ feed.link.scan(/(.*?\.tiff$)/i) { |matched|
35
+ image_link = matched.join(" ")
36
+ }
37
+ feed.link = image_link
38
+ end
39
+ }
40
+ @return_feeds << feeds
41
+ end
42
+ }
43
+ @return_feeds
44
+ end
45
+ end
46
+ end
@@ -12,7 +12,6 @@ module Automatic::Plugin
12
12
  def initialize(config, pipeline=[])
13
13
  @config = config
14
14
  @pipeline = pipeline
15
- @output = STDOUT
16
15
  end
17
16
 
18
17
  def run
@@ -3,7 +3,7 @@
3
3
  # Author:: kzgs
4
4
  # 774 <http://id774.net>
5
5
  # Created:: Feb 27, 2012
6
- # Updated:: Jun 17, 2012
6
+ # Updated:: Sep 18, 2012
7
7
  # Copyright:: kzgs Copyright (c) 2012
8
8
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
9
9
 
@@ -11,23 +11,6 @@ require 'active_record'
11
11
 
12
12
  module Automatic::Plugin
13
13
  module Database
14
- def for_each_new_link
15
- prepare_database
16
- existing_records = model_class.find(:all)
17
- @return_html = []
18
- @pipeline.each { |link|
19
- unless link.nil?
20
- new_link = false
21
- unless existing_records.detect { |b| b.try(unique_key) == link }
22
- yield(link)
23
- new_link = true
24
- end
25
- @return_html << link if new_link
26
- end
27
- }
28
- @return_html
29
- end
30
-
31
14
  def for_each_new_feed
32
15
  prepare_database
33
16
  existing_records = model_class.find(:all)
@@ -36,9 +19,11 @@ module Automatic::Plugin
36
19
  unless feeds.nil?
37
20
  new_feed = false
38
21
  feeds.items.each { |feed|
39
- unless existing_records.detect { |b| b.try(unique_key) == feed.link }
40
- yield(feed)
41
- new_feed = true
22
+ unless feed.link.nil?
23
+ unless existing_records.detect { |b| b.try(unique_key) == feed.link }
24
+ yield(feed)
25
+ new_feed = true
26
+ end
42
27
  end
43
28
  }
44
29
  @return_feeds << feeds if new_feed
@@ -60,9 +45,9 @@ module Automatic::Plugin
60
45
  def db_dir
61
46
  dir = (File.expand_path('~/.automatic/db'))
62
47
  if File.directory?(dir)
63
- return dir
48
+ dir
64
49
  else
65
- return File.join(File.dirname(__FILE__), '..', '..', 'db')
50
+ File.join(File.dirname(__FILE__), '..', '..', 'db')
66
51
  end
67
52
  end
68
53
 
@@ -21,7 +21,7 @@ module Automatic::Plugin
21
21
  end
22
22
 
23
23
  def column_definition
24
- return {
24
+ {
25
25
  :title => :string,
26
26
  :link => :string,
27
27
  :description => :string,
@@ -31,15 +31,15 @@ module Automatic::Plugin
31
31
  end
32
32
 
33
33
  def unique_key
34
- return :link
34
+ :link
35
35
  end
36
36
 
37
37
  def model_class
38
- return Automatic::Plugin::Blog
38
+ Automatic::Plugin::Blog
39
39
  end
40
40
 
41
41
  def run
42
- return for_each_new_feed { |feed|
42
+ for_each_new_feed { |feed|
43
43
  begin
44
44
  Blog.create(
45
45
  :title => feed.title,
@@ -3,9 +3,10 @@
3
3
  # Name:: Automatic::Plugin::Store::Permalink
4
4
  # Author:: 774 <http://id774.net>
5
5
  # Created:: Feb 22, 2012
6
- # Updated:: Jun 14, 2012
6
+ # Updated:: Sep 18, 2012
7
7
  # Copyright:: 774 Copyright (c) 2012
8
8
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
9
+
9
10
  require 'plugins/store/database'
10
11
 
11
12
  module Automatic::Plugin
@@ -21,26 +22,28 @@ module Automatic::Plugin
21
22
  end
22
23
 
23
24
  def column_definition
24
- return {
25
+ {
25
26
  :url => :string,
26
27
  :created_at => :string
27
28
  }
28
29
  end
29
30
 
30
31
  def unique_key
31
- return :url
32
+ :url
32
33
  end
33
34
 
34
35
  def model_class
35
- return Automatic::Plugin::Permalink
36
+ Automatic::Plugin::Permalink
36
37
  end
37
38
 
38
39
  def run
39
- return for_each_new_feed { |feed|
40
- Permalink.create(
41
- :url => feed.link,
42
- :created_at => Time.now.strftime("%Y/%m/%d %X"))
43
- Automatic::Log.puts("info", "Saving: #{feed.link}")
40
+ for_each_new_feed {|feed|
41
+ unless feed.link.nil?
42
+ Permalink.create(
43
+ :url => feed.link,
44
+ :created_at => Time.now.strftime("%Y/%m/%d %X"))
45
+ Automatic::Log.puts("info", "Saving: #{feed.link}")
46
+ end
44
47
  }
45
48
  end
46
49
  end
@@ -7,9 +7,10 @@
7
7
  # Copyright:: 774 Copyright (c) 2012
8
8
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
9
9
 
10
+ require 'open-uri'
11
+
10
12
  module Automatic::Plugin
11
13
  class StoreTargetLink
12
- require 'open-uri'
13
14
 
14
15
  def initialize(config, pipeline=[])
15
16
  @config = config
@@ -33,11 +34,11 @@ module Automatic::Plugin
33
34
  unless feed.link.nil?
34
35
  Automatic::Log.puts("info", "Get: #{feed.link}")
35
36
  wget(feed.link)
37
+ sleep @config['interval'].to_i
36
38
  end
37
39
  rescue
38
40
  Automatic::Log.puts("error", "Error found during file download.")
39
41
  end
40
- sleep @config['interval'].to_i
41
42
  }
42
43
  end
43
44
  }
@@ -0,0 +1,55 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Name:: Automatic::Plugin::Subscription::Link
3
+ # Author:: 774 <http://id774.net>
4
+ # Created:: Sep 18, 2012
5
+ # Updated:: Sep 18, 2012
6
+ # Copyright:: 774 Copyright (c) 2012
7
+ # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
+
9
+ module Automatic::Plugin
10
+ class SubscriptionLink
11
+ require 'open-uri'
12
+ require 'nokogiri'
13
+ require 'rss'
14
+
15
+ def initialize(config, pipeline=[])
16
+ @config = config
17
+ @pipeline = pipeline
18
+ end
19
+
20
+ def run
21
+ @return_feed = []
22
+ @config['urls'].each {|url|
23
+ begin
24
+ Automatic::Log.puts("info", "Parsing: #{url}")
25
+ html = open(url).read
26
+ unless html.nil?
27
+ rss = RSS::Maker.make("2.0") {|maker|
28
+ xss = maker.xml_stylesheets.new_xml_stylesheet
29
+ xss.href = "http://www.rssboard.org/rss-specification"
30
+ maker.channel.about = "http://feeds.rssboard.org/rssboard"
31
+ maker.channel.title = "Automatic Ruby"
32
+ maker.channel.description = "Automatic Ruby"
33
+ maker.channel.link = "http://www.rssboard.org/rss-specification"
34
+ maker.items.do_sort = true
35
+ doc = Nokogiri::HTML(html)
36
+ (doc/:a).each {|link|
37
+ unless link[:href].nil?
38
+ item = maker.items.new_item
39
+ item.title = "Automatic Ruby"
40
+ item.link = link[:href]
41
+ item.date = Time.now
42
+ item.description = "Automatic::Plugin::Subscription::Link"
43
+ end
44
+ }
45
+ }
46
+ @return_feed << rss
47
+ end
48
+ rescue
49
+ Automatic::Log.puts("error", "Fault in parsing: #{url}")
50
+ end
51
+ }
52
+ @return_feed
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,57 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Name:: Automatic::Plugin::Subscription::Twitter
3
+ # Author:: 774 <http://id774.net>
4
+ # Created:: Sep 9, 2012
5
+ # Updated:: Sep 9, 2012
6
+ # Copyright:: 774 Copyright (c) 2012
7
+ # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
+
9
+ module Automatic::Plugin
10
+ class SubscriptionTwitter
11
+ require 'open-uri'
12
+ require 'nokogiri'
13
+ require 'rss'
14
+
15
+ def initialize(config, pipeline=[])
16
+ @config = config
17
+ @pipeline = pipeline
18
+ end
19
+
20
+ def run
21
+ @return_feed = []
22
+ @config['urls'].each {|url|
23
+ begin
24
+ Automatic::Log.puts("info", "Parsing: #{url}")
25
+ html = open(url).read
26
+ unless html.nil?
27
+ rss = RSS::Maker.make("2.0") {|maker|
28
+ xss = maker.xml_stylesheets.new_xml_stylesheet
29
+ xss.href = "http://twitter.com"
30
+ maker.channel.about = "http://twitter.com/index.rdf"
31
+ maker.channel.title = "Twitter"
32
+ maker.channel.description = "Twitter"
33
+ maker.channel.link = "http://twitter.com/"
34
+ maker.items.do_sort = true
35
+ doc = Nokogiri::HTML(html)
36
+ doc.xpath("/html/body/div").search('[@class="content"]').each {|content|
37
+ item = maker.items.new_item
38
+ item.title = content.search('[@class="username js-action-profile-name"]').text.to_s
39
+ content.search('[@class="tweet-timestamp js-permalink js-nav"]').each {|node|
40
+ item.link = "http://twitter.com" + node['href'].to_s
41
+ }
42
+ content.search('[@class="_timestamp js-short-timestamp js-relative-timestamp"]').each {|node|
43
+ item.date = Time.at(node['data-time'].to_i)
44
+ }
45
+ item.description = content.search('[@class="js-tweet-text"]').text.to_s
46
+ }
47
+ }
48
+ @return_feed << rss
49
+ end
50
+ rescue
51
+ Automatic::Log.puts("error", "Fault in parsing: #{url}")
52
+ end
53
+ }
54
+ @return_feed
55
+ end
56
+ end
57
+ end
data/script/build CHANGED
@@ -38,7 +38,7 @@ run_test() {
38
38
  }
39
39
 
40
40
  load_tests() {
41
- for YAML_FILE in "$RACK_ROOT/test/integration/*.yml"
41
+ for YAML_FILE in "$RACK_ROOT/test/integration/test_*.yml"
42
42
  do
43
43
  run_test $YAML_FILE
44
44
  done
@@ -3,11 +3,12 @@
3
3
  # Author:: kzgs
4
4
  # 774 <http://id774.net>
5
5
  # Created:: Mar 9, 2012
6
- # Updated:: Mar 10, 2012
6
+ # Updated:: Jun 18, 2012
7
7
  # Copyright:: kzgs Copyright (c) 2012
8
8
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
9
9
 
10
10
  require File.expand_path(File.join(File.dirname(__FILE__), '../spec_helper'))
11
+
11
12
  require 'automatic'
12
13
 
13
14
  describe Automatic do
@@ -25,7 +26,7 @@ describe Automatic do
25
26
 
26
27
  describe "#version" do
27
28
  specify {
28
- Automatic.const_get(:VERSION).should == "12.6.0"
29
+ Automatic.const_get(:VERSION).should == "12.9.1"
29
30
  }
30
31
  end
31
32
 
@@ -2,7 +2,7 @@
2
2
  # Name:: Automatic::Plugin::CustomFeed::SVNFLog
3
3
  # Author:: kzgs
4
4
  # Created:: Feb 29, 2012
5
- # Updated:: Mar 3, 2012
5
+ # Updated:: Mar 3, 2012
6
6
  # Copyright:: kzgs Copyright (c) 2012
7
7
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
8
 
@@ -0,0 +1,61 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Name:: Automatic::Plugin::Filter::AbsoluteURI
3
+ # Author:: 774 <http://id774.net>
4
+ # Created:: Jun 20, 2012
5
+ # Updated:: Sep 18, 2012
6
+ # Copyright:: 774 Copyright (c) 2012
7
+ # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
+
9
+ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
10
+
11
+ require 'filter/absolute_uri'
12
+
13
+ describe Automatic::Plugin::FilterAbsoluteURI do
14
+ context "with feed contain link tag" do
15
+ subject {
16
+ Automatic::Plugin::FilterAbsoluteURI.new({
17
+ 'url' => "http://id774.net/images/",
18
+ },
19
+ AutomaticSpec.generate_pipeline {
20
+ feed {
21
+ item "http://id774.net/images/link_1.jpg"
22
+ item "link_2.jpg"
23
+ item "link_3.JPG"
24
+ item "http://id774.net/images/link_4.png"
25
+ item "link_5.jpeg"
26
+ item "http://id774.net/images/link_6.PNG"
27
+ item "link_8.gif"
28
+ item "http://id774.net/images/link_9.GIF"
29
+ item "link_10.tiff"
30
+ item "http://id774.net/images/link_11.TIFF"
31
+ }})}
32
+
33
+ describe "#run" do
34
+ its(:run) { should have(1).feeds }
35
+
36
+ specify {
37
+ subject.run
38
+ subject.instance_variable_get(:@return_feeds)[0].items[0].link.
39
+ should == "http://id774.net/images/link_1.jpg"
40
+ subject.instance_variable_get(:@return_feeds)[0].items[1].link.
41
+ should == "http://id774.net/images/link_2.jpg"
42
+ subject.instance_variable_get(:@return_feeds)[0].items[2].link.
43
+ should == "http://id774.net/images/link_3.JPG"
44
+ subject.instance_variable_get(:@return_feeds)[0].items[3].link.
45
+ should == "http://id774.net/images/link_4.png"
46
+ subject.instance_variable_get(:@return_feeds)[0].items[4].link.
47
+ should == "http://id774.net/images/link_5.jpeg"
48
+ subject.instance_variable_get(:@return_feeds)[0].items[5].link.
49
+ should == "http://id774.net/images/link_6.PNG"
50
+ subject.instance_variable_get(:@return_feeds)[0].items[6].link.
51
+ should == "http://id774.net/images/link_8.gif"
52
+ subject.instance_variable_get(:@return_feeds)[0].items[7].link.
53
+ should == "http://id774.net/images/link_9.GIF"
54
+ subject.instance_variable_get(:@return_feeds)[0].items[8].link.
55
+ should == "http://id774.net/images/link_10.tiff"
56
+ subject.instance_variable_get(:@return_feeds)[0].items[9].link.
57
+ should == "http://id774.net/images/link_11.TIFF"
58
+ }
59
+ end
60
+ end
61
+ end
@@ -2,7 +2,7 @@
2
2
  # Name:: Automatic::Plugin::Filter::ImageSource
3
3
  # Author:: kzgs
4
4
  # 774 <http://id774.net>
5
- # Created:: Mar 1, 2012
5
+ # Created:: Mar 1, 2012
6
6
  # Updated:: Jun 14, 2012
7
7
  # Copyright:: kzgs Copyright (c) 2012
8
8
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.