automatic 12.3.0 → 12.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -0
- data/README.md +54 -36
- data/Rakefile +14 -0
- data/VERSION +1 -1
- data/automatic.gemspec +17 -5
- data/bin/automatic +37 -3
- data/bin/automatic-config +77 -0
- data/config/default.yml +9 -12
- data/doc/ChangeLog +32 -8
- data/doc/PLUGINS +205 -0
- data/doc/PLUGINS.ja +2 -3
- data/doc/README +488 -0
- data/doc/README.ja +195 -131
- data/lib/automatic/feed_parser.rb +1 -9
- data/lib/automatic/log.rb +1 -9
- data/lib/automatic/opml.rb +239 -0
- data/lib/automatic/pipeline.rb +16 -10
- data/lib/automatic/recipe.rb +3 -4
- data/lib/automatic.rb +32 -38
- data/lib/config/validator.rb +83 -0
- data/plugins/custom_feed/svn_log.rb +1 -1
- data/plugins/filter/ignore.rb +9 -1
- data/plugins/notify/ikachan.rb +7 -6
- data/plugins/publish/hatena_bookmark.rb +6 -9
- data/script/build +63 -0
- data/spec/lib/automatic/pipeline_spec.rb +55 -0
- data/spec/lib/automatic_spec.rb +77 -0
- data/spec/lib/pipeline_spec.rb +67 -0
- data/spec/plugins/filter/ignore_spec.rb +16 -0
- data/spec/plugins/filter/image_spec.rb +4 -4
- data/spec/plugins/filter/tumblr_resize_spec.rb +4 -4
- data/spec/plugins/notify/ikachan_spec.rb +30 -0
- data/spec/plugins/publish/console_spec.rb +1 -2
- data/spec/plugins/publish/hatena_bookmark_spec.rb +36 -1
- data/spec/plugins/store/full_text_spec.rb +0 -2
- data/spec/plugins/store/permalink_spec.rb +0 -1
- data/spec/plugins/store/target_link_spec.rb +0 -1
- data/spec/plugins/subscription/feed_spec.rb +0 -1
- data/spec/spec_helper.rb +6 -4
- data/spec/user_dir/plugins/store/mock.rb +12 -0
- data/test/fixtures/sampleOPML.xml +11 -0
- data/test/integration/test_activerecord.yml +2 -2
- data/test/integration/test_fulltext.yml +3 -3
- data/test/integration/test_hatenabookmark.yml +6 -2
- data/test/integration/test_ignore.yml +4 -1
- data/test/integration/test_ignore2.yml +1 -4
- data/test/integration/test_image2local.yml +3 -5
- data/test/integration/test_svnlog.yml +2 -1
- data/test/integration/test_tumblr2local.yml +3 -3
- metadata +43 -22
- data/utils/auto_discovery.rb +0 -18
- data/utils/opml_parser.rb +0 -247
data/lib/automatic/pipeline.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Name:: Automatic::Pipeline
|
4
4
|
# Author:: 774 <http://id774.net>
|
5
5
|
# Created:: Feb 22, 2012
|
6
|
-
# Updated:: Mar
|
6
|
+
# Updated:: Mar 10, 2012
|
7
7
|
# Copyright:: 774 Copyright (c) 2012
|
8
8
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
9
9
|
|
@@ -11,23 +11,29 @@ require 'active_support/core_ext'
|
|
11
11
|
|
12
12
|
module Automatic
|
13
13
|
module Plugin end
|
14
|
+
class NoPluginError < StandardError; end
|
15
|
+
class NoRecipeError < StandardError; end
|
14
16
|
|
15
17
|
module Pipeline
|
16
18
|
def self.load_plugin(module_name)
|
17
|
-
Dir
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
Dir[Automatic.user_plugins_dir + "/*",
|
20
|
+
Automatic.plugins_dir + "/*"].each{ |dir|
|
21
|
+
subdir = File.basename dir
|
22
|
+
if /#{subdir}_(.*)$/ =~ module_name.underscore
|
23
|
+
path = dir + "/#{$1}.rb"
|
24
|
+
return Automatic::Plugin.autoload module_name.to_sym, path.to_s if File.exists? path
|
21
25
|
end
|
22
|
-
|
26
|
+
}
|
27
|
+
raise NoPluginError, "unknown plugin named #{module_name}"
|
23
28
|
end
|
24
|
-
|
29
|
+
|
25
30
|
def self.run(recipe)
|
26
|
-
raise
|
31
|
+
raise NoRecipeError if recipe.nil?
|
27
32
|
pipeline = []
|
28
33
|
recipe.each_plugin { |plugin|
|
29
|
-
|
30
|
-
|
34
|
+
mod = plugin.module
|
35
|
+
load_plugin(mod)
|
36
|
+
klass = Automatic::Plugin.const_get(mod)
|
31
37
|
pipeline = klass.new(plugin.config, pipeline).run
|
32
38
|
}
|
33
39
|
end
|
data/lib/automatic/recipe.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Name:: Automatic::Recipe
|
2
|
-
# Author::
|
2
|
+
# Author:: ainame
|
3
3
|
# Version:: 12.02-devel
|
4
4
|
# Created:: Feb 18, 2012
|
5
|
-
# Updated::
|
5
|
+
# Updated:: Mar 12, 2012
|
6
6
|
# Copyright:: 774 Copyright (c) 2012
|
7
7
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
8
8
|
|
@@ -13,8 +13,7 @@ module Automatic
|
|
13
13
|
class Recipe
|
14
14
|
attr_reader :procedure
|
15
15
|
|
16
|
-
def initialize(path)
|
17
|
-
path = Automatic.config_dir + 'default.yml' if path.to_s.empty?
|
16
|
+
def initialize(path = "")
|
18
17
|
load_recipe(path)
|
19
18
|
end
|
20
19
|
|
data/lib/automatic.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# Name:: Automatic::Ruby
|
3
3
|
# Author:: 774 <http://id774.net>
|
4
|
-
# Version:: 12.
|
4
|
+
# Version:: 12.3.1
|
5
5
|
# Created:: Feb 18, 2012
|
6
|
-
# Updated:: Mar
|
6
|
+
# Updated:: Mar 15, 2012
|
7
7
|
# Copyright:: 774 Copyright (c) 2012
|
8
8
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
9
9
|
|
@@ -14,47 +14,41 @@ module Automatic
|
|
14
14
|
require 'automatic/log'
|
15
15
|
require 'automatic/feed_parser'
|
16
16
|
|
17
|
-
VERSION = "12.
|
17
|
+
VERSION = "12.3.1"
|
18
|
+
USER_DIR = "/.automatic"
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
end
|
20
|
+
class << self
|
21
|
+
attr_accessor :root_dir
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
def run(args = { })
|
24
|
+
self.root_dir = args[:root_dir]
|
25
|
+
self.user_dir = args[:user_dir]
|
26
|
+
Automatic::Pipeline.run(args[:recipe])
|
27
|
+
end
|
28
|
+
|
29
|
+
def plugins_dir
|
30
|
+
File.join(@root_dir, "plugins")
|
31
|
+
end
|
26
32
|
|
27
|
-
|
28
|
-
|
29
|
-
|
33
|
+
def config_dir
|
34
|
+
File.join(@root_dir, "config")
|
35
|
+
end
|
36
|
+
|
37
|
+
def user_dir
|
38
|
+
@user_dir
|
39
|
+
end
|
30
40
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
parser.version = VERSION
|
38
|
-
parser.separator "options:"
|
39
|
-
parser.on('-c', '--config FILE', String,
|
40
|
-
"recipe YAML file"){|c| recipe_path = c}
|
41
|
-
parser.on('-h', '--help', "show this message") {
|
42
|
-
puts parser
|
43
|
-
exit
|
44
|
-
}
|
45
|
-
}
|
46
|
-
|
47
|
-
begin
|
48
|
-
parser.parse!
|
49
|
-
print "Loading #{recipe_path}\n" unless recipe_path == ""
|
50
|
-
rescue OptionParser::ParseError => err
|
51
|
-
$stderr.puts err.message
|
52
|
-
$stderr.puts parser.help
|
53
|
-
exit 1
|
41
|
+
def user_dir=(_user_dir)
|
42
|
+
if ENV["AUTOMATIC_RUBY_ENV"] == "test" && !(_user_dir.nil?)
|
43
|
+
@user_dir = _user_dir
|
44
|
+
else
|
45
|
+
@user_dir = File.expand_path("~/") + USER_DIR
|
46
|
+
end
|
54
47
|
end
|
55
48
|
|
56
|
-
|
57
|
-
|
58
|
-
|
49
|
+
def user_plugins_dir
|
50
|
+
File.join(@user_dir, "plugins")
|
51
|
+
end
|
59
52
|
end
|
53
|
+
|
60
54
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# Name:: Automatic::Config::Validator
|
4
|
+
# Author:: aerith <http://aerith.sc/>
|
5
|
+
# Created:: Feb 23, 2012
|
6
|
+
# Updated:: Feb 23, 2012
|
7
|
+
# Copyright:: Copyright (c) 2012
|
8
|
+
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
9
|
+
|
10
|
+
class Automatic
|
11
|
+
module Config
|
12
|
+
class Validator
|
13
|
+
attr_accessor :config, :result
|
14
|
+
|
15
|
+
class InvalidException < Exception; end;
|
16
|
+
|
17
|
+
def initialize(config = nil)
|
18
|
+
@config = config || {}
|
19
|
+
@result = ValidateResult.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def validate(klass, config = nil)
|
23
|
+
return true if config.nil?
|
24
|
+
return true if not config.is_a?(Hash)
|
25
|
+
return true if not klass.respond_to?(:rules)
|
26
|
+
|
27
|
+
rules = klass.rules
|
28
|
+
return true if not rules.is_a?(Hash)
|
29
|
+
|
30
|
+
process(rules, config).result.valid?
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
def process(rules, config)
|
35
|
+
errors = {}
|
36
|
+
|
37
|
+
rules.each do |key, rule|
|
38
|
+
name = key.to_sym
|
39
|
+
|
40
|
+
rule.each do |method, args|
|
41
|
+
unless ValidateRule.send(method, *[config, name, args])
|
42
|
+
errors[name] = {} if errors[name].nil? or errors.size < 1
|
43
|
+
errors[name][method] = true
|
44
|
+
if @config["stop_on_invalid"] and errors[name][method]
|
45
|
+
raise InvalidException
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
@result.errors = errors
|
52
|
+
|
53
|
+
self
|
54
|
+
end
|
55
|
+
|
56
|
+
class ValidateResult
|
57
|
+
attr_accessor :errors
|
58
|
+
|
59
|
+
def error(name)
|
60
|
+
errors.exists?(name)
|
61
|
+
end
|
62
|
+
|
63
|
+
def valid?
|
64
|
+
errors.empty?
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
module ValidateRule
|
69
|
+
def self.required(config, name, *args)
|
70
|
+
return true unless args.size < 1 or args.first
|
71
|
+
return true if not config[name.to_s].nil? and not config[name.to_s].empty?
|
72
|
+
false
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.default(config, name, *args)
|
76
|
+
config[name.to_s] ||= args.first
|
77
|
+
true
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
data/plugins/filter/ignore.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Name:: Automatic::Plugin::Filter::Ignore
|
4
4
|
# Author:: 774 <http://id774.net>
|
5
5
|
# Created:: Feb 22, 2012
|
6
|
-
# Updated:: Mar
|
6
|
+
# Updated:: Mar 8, 2012
|
7
7
|
# Copyright:: 774 Copyright (c) 2012
|
8
8
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
9
9
|
|
@@ -32,6 +32,14 @@ module Automatic::Plugin
|
|
32
32
|
end
|
33
33
|
}
|
34
34
|
end
|
35
|
+
unless @config['exclude'].nil?
|
36
|
+
@config['exclude'].each {|e|
|
37
|
+
if items.link.include?(e.chomp)
|
38
|
+
detection = true
|
39
|
+
Automatic::Log.puts("info", "Excluded by link: #{items.link}")
|
40
|
+
end
|
41
|
+
}
|
42
|
+
end
|
35
43
|
unless @config['description'].nil?
|
36
44
|
@config['description'].each {|e|
|
37
45
|
if items.description.include?(e.chomp)
|
data/plugins/notify/ikachan.rb
CHANGED
@@ -31,20 +31,21 @@ module Automatic::Plugin
|
|
31
31
|
proxy_class = Net::HTTP::Proxy(ENV["PROXY"], 8080)
|
32
32
|
http = proxy_class.new(uri.host, uri.port)
|
33
33
|
http.start do |http|
|
34
|
-
@params['channels'].each do|channel|
|
35
|
-
|
34
|
+
@params['channels'].split(",").each do|channel|
|
35
|
+
# send join command to make sure when if ikachan is not in the channel
|
36
|
+
http.post("/join", "channel=#{channel}")
|
36
37
|
res = http.post(uri.path, %Q(channel=#{channel}&message=#{message}))
|
37
|
-
|
38
|
-
|
39
|
-
puts "#{t} [info] Success: #{message}"
|
38
|
+
if res.code == "200"
|
39
|
+
Automatic::Log.puts(:info, "Success: #{message}")
|
40
40
|
else
|
41
|
-
puts "#{
|
41
|
+
Automatic::Log.puts(:error, "#{res.code} Error: #{message}")
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
private
|
48
|
+
|
48
49
|
def build_message(link, title)
|
49
50
|
message = ""
|
50
51
|
message += "#{title.to_s} - " unless title.blank?
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Name:: Automatic::Plugin::Publish::HatenaBookmark
|
4
4
|
# Author:: 774 <http://id774.net>
|
5
5
|
# Created:: Feb 22, 2012
|
6
|
-
# Updated::
|
6
|
+
# Updated:: Mar 12, 2012
|
7
7
|
# Copyright:: 774 Copyright (c) 2012
|
8
8
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
9
9
|
|
@@ -55,19 +55,16 @@ module Automatic::Plugin
|
|
55
55
|
uri = URI.parse(url)
|
56
56
|
proxy_class = Net::HTTP::Proxy(ENV["PROXY"], 8080)
|
57
57
|
http = proxy_class.new(uri.host)
|
58
|
-
http.start {|http|
|
58
|
+
http.start { |http|
|
59
59
|
# b_url = NKF.nkf('-w', b_url)
|
60
60
|
# b_comment = NKF.nkf('-w', b_comment)
|
61
61
|
res = http.post(uri.path, toXml(b_url, b_comment), header)
|
62
|
-
t = Time.now.strftime("%Y/%m/%d %X")
|
63
62
|
if res.code == "201" then
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
print "#{t} [info] Success: #{b_url}\n"
|
68
|
-
end
|
63
|
+
message = "Success: #{b_url}"
|
64
|
+
message += " Comment: #{b_comment}" unless b_comment.nil?
|
65
|
+
Automatic::Log.puts(:info, message)
|
69
66
|
else
|
70
|
-
|
67
|
+
Automatic::Log.puts(:error, "#{res.code} Error: #{b_url}")
|
71
68
|
end
|
72
69
|
}
|
73
70
|
end
|
data/script/build
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#
|
3
|
+
########################################################################
|
4
|
+
# Integration Build Script
|
5
|
+
#
|
6
|
+
# Maintainer: id774 <idnanashi@gmail.com>
|
7
|
+
#
|
8
|
+
# v1.0 3/16,2012
|
9
|
+
# First.
|
10
|
+
########################################################################
|
11
|
+
|
12
|
+
kickstart() {
|
13
|
+
export RACK_ROOT="."
|
14
|
+
export RACK_ENV="test"
|
15
|
+
export DATABASE_URL="$RACK_ROOT/db"
|
16
|
+
ruby -v
|
17
|
+
test_config log info started.
|
18
|
+
}
|
19
|
+
|
20
|
+
exec_rspec() {
|
21
|
+
$RACK_ROOT/bin/automatic -v
|
22
|
+
$RACK_ROOT/script/bootstrap
|
23
|
+
bundle exec $RACK_ROOT/bin/rake simplecov
|
24
|
+
}
|
25
|
+
|
26
|
+
run_test() {
|
27
|
+
while [ $# -gt 0 ]
|
28
|
+
do
|
29
|
+
$RACK_ROOT/bin/automatic -c $1
|
30
|
+
test_config log info $?
|
31
|
+
shift
|
32
|
+
done
|
33
|
+
}
|
34
|
+
|
35
|
+
load_tests() {
|
36
|
+
for YAML_FILE in "$RACK_ROOT/test/integration/*.yml"
|
37
|
+
do
|
38
|
+
run_test $YAML_FILE
|
39
|
+
done
|
40
|
+
unset YAML_FILE
|
41
|
+
}
|
42
|
+
|
43
|
+
test_config() {
|
44
|
+
$RACK_ROOT/bin/automatic-config $*
|
45
|
+
}
|
46
|
+
|
47
|
+
added_tests() {
|
48
|
+
test_config scaffold
|
49
|
+
test_config autodiscovery http://id774.net/blog/
|
50
|
+
test_config opmlparser "$RACK_ROOT/test/fixtures/sampleOPML.xml"
|
51
|
+
test_config feedparser http://id774.net/blog/feed/ > /dev/null
|
52
|
+
test_config log info finished.
|
53
|
+
}
|
54
|
+
|
55
|
+
main() {
|
56
|
+
kickstart
|
57
|
+
exec_rspec
|
58
|
+
load_tests
|
59
|
+
added_tests
|
60
|
+
}
|
61
|
+
|
62
|
+
set -ex
|
63
|
+
main
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Name:: pipeline_sepc.rb
|
3
|
+
# Author:: ainame
|
4
|
+
# Created:: Mar 10, 2012
|
5
|
+
# Updated:: Mar 10, 2012
|
6
|
+
# Copyright:: ainame Copyright (c) 2012
|
7
|
+
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
8
|
+
|
9
|
+
require File.expand_path(File.join(File.dirname(__FILE__) ,'../../spec_helper'))
|
10
|
+
require 'automatic'
|
11
|
+
require 'automatic/pipeline'
|
12
|
+
|
13
|
+
TEST_MODULES = ["SubscriptionFeed", "FilterIgnore"]
|
14
|
+
|
15
|
+
describe Automatic::Pipeline do
|
16
|
+
describe "in default dir" do
|
17
|
+
before do
|
18
|
+
Automatic.root_dir = APP_ROOT
|
19
|
+
Automatic.user_dir = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#load_plugin" do
|
23
|
+
it "raise no plugin error" do
|
24
|
+
lambda{
|
25
|
+
Automatic::Plugin.load_plugin "FooBar"
|
26
|
+
}.should raise_exception
|
27
|
+
end
|
28
|
+
|
29
|
+
it "correctly load module" do
|
30
|
+
TEST_MODULES.each do |mod|
|
31
|
+
Automatic::Pipeline.load_plugin mod.to_s
|
32
|
+
Automatic::Plugin.const_get(mod).class.should == Class
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "in user dir" do
|
39
|
+
before do
|
40
|
+
Automatic.root_dir = APP_ROOT
|
41
|
+
Automatic.user_dir = File.join(APP_ROOT, "spec/user_dir")
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#load_plugin" do
|
45
|
+
it "correctly load module" do
|
46
|
+
# StoreMock is the mock class that it return pipeline.
|
47
|
+
mock = "StoreMock"
|
48
|
+
Automatic::Pipeline.load_plugin mock
|
49
|
+
klass = Automatic::Plugin.const_get(mock)
|
50
|
+
klass.class.should == Class
|
51
|
+
klass.new(nil, ["mock"]).run.should == "mock"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Name:: Automatic
|
3
|
+
# Author:: kzgs
|
4
|
+
# Created:: Mar 9, 2012
|
5
|
+
# Updated:: Mar 10, 2012
|
6
|
+
# Copyright:: kzgs Copyright (c) 2012
|
7
|
+
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
8
|
+
|
9
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '../spec_helper'))
|
10
|
+
require 'automatic'
|
11
|
+
|
12
|
+
describe Automatic do
|
13
|
+
describe "#run" do
|
14
|
+
describe "with a root dir which has default recipe" do
|
15
|
+
specify {
|
16
|
+
lambda{
|
17
|
+
Automatic.run(:recipe => "",
|
18
|
+
:root_dir => APP_ROOT,
|
19
|
+
:user_dir => APP_ROOT + "/spec/user_dir")
|
20
|
+
}.should_not raise_exception(Errno::ENOENT)
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#(root|config)_dir" do
|
26
|
+
specify {
|
27
|
+
Automatic.root_dir.should == APP_ROOT
|
28
|
+
Automatic.config_dir.should == APP_ROOT+"/config"
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#user_dir= in test env" do
|
33
|
+
before(:all) do
|
34
|
+
Automatic.user_dir = File.join(APP_ROOT, "spec/user_dir")
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#user_dir" do
|
38
|
+
it "return valid value" do
|
39
|
+
Automatic.user_dir.should == File.join(APP_ROOT, "spec/user_dir")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#user_plugins_dir" do
|
44
|
+
it "return valid value" do
|
45
|
+
Automatic.user_plugins_dir.should == File.join(APP_ROOT, "spec/user_dir/plugins")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
after(:all) do
|
50
|
+
Automatic.user_dir = nil
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#set_user_dir in other env" do
|
55
|
+
before(:all) do
|
56
|
+
ENV["AUTOMATIC_RUBY_ENV"] = "other"
|
57
|
+
Automatic.user_dir = nil
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#user_dir" do
|
61
|
+
it "return valid value" do
|
62
|
+
Automatic.user_dir.should == File.expand_path("~/") + "/.automatic"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#user_plugins_dir" do
|
67
|
+
it "return valid value" do
|
68
|
+
Automatic.user_plugins_dir.should == File.expand_path("~/") + "/.automatic/plugins"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
after(:all) do
|
73
|
+
ENV["AUTOMATIC_RUBY_ENV"] = "test"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Name:: pipeline_sepc.rb
|
3
|
+
# Author:: ainame
|
4
|
+
# Created:: Mar 10, 2012
|
5
|
+
# Updated:: Mar 10, 2012
|
6
|
+
# Copyright:: ainame Copyright (c) 2012
|
7
|
+
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
8
|
+
|
9
|
+
require File.expand_path(File.join(File.dirname(__FILE__) ,'../spec_helper'))
|
10
|
+
require 'automatic'
|
11
|
+
require 'automatic/pipeline'
|
12
|
+
|
13
|
+
TEST_MODULES = ["SubscriptionFeed", "FilterIgnore"] if TEST_MODULES.nil?
|
14
|
+
|
15
|
+
describe Automatic::Pipeline do
|
16
|
+
describe "in default dir" do
|
17
|
+
before do
|
18
|
+
Automatic.root_dir = File.expand_path(File.join(File.dirname(__FILE__), "../../"))
|
19
|
+
Automatic.user_dir = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#load_plugin" do
|
23
|
+
it "raise no plugin error" do
|
24
|
+
lambda{
|
25
|
+
Automatic::Pipeline.load_plugin "FooBar"
|
26
|
+
}.should raise_exception(Automatic::NoPluginError,
|
27
|
+
/unknown plugin named FooBar/)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "correctly load module" do
|
31
|
+
TEST_MODULES.each do |mod|
|
32
|
+
Automatic::Pipeline.load_plugin mod.to_s
|
33
|
+
Automatic::Plugin.const_get(mod).class.should == Class
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#run" do
|
39
|
+
it "run a recipe with FilterIgnore module" do
|
40
|
+
plugin = mock("plugin")
|
41
|
+
plugin.should_receive(:module).and_return("FilterIgnore")
|
42
|
+
plugin.should_receive(:config)
|
43
|
+
recipe = mock("recipe")
|
44
|
+
recipe.should_receive(:each_plugin).and_yield(plugin)
|
45
|
+
Automatic::Pipeline.run(recipe).should == []
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "in user dir" do
|
51
|
+
before do
|
52
|
+
Automatic.root_dir = File.expand_path(File.join(File.dirname(__FILE__), "../../"))
|
53
|
+
Automatic.user_dir = File.expand_path(File.join(File.dirname(__FILE__), "../user_dir/"))
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#load_plugin" do
|
57
|
+
it "correctly load module" do
|
58
|
+
# StoreMock is the mock class that it return pipeline.
|
59
|
+
mock = "StoreMock"
|
60
|
+
Automatic::Pipeline.load_plugin mock
|
61
|
+
klass = Automatic::Plugin.const_get(mock)
|
62
|
+
klass.class.should == Class
|
63
|
+
klass.new(nil, ["mock"]).run.should == "mock"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -3,6 +3,22 @@ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
|
|
3
3
|
require 'filter/ignore'
|
4
4
|
|
5
5
|
describe Automatic::Plugin::FilterIgnore do
|
6
|
+
context "with exclusion by description" do
|
7
|
+
subject {
|
8
|
+
Automatic::Plugin::FilterIgnore.new({
|
9
|
+
'exclude' => ["comment"],
|
10
|
+
},
|
11
|
+
AutomaticSpec.generate_pipeline {
|
12
|
+
feed { item "http://github.com" }
|
13
|
+
feed { item "http://google.com" }
|
14
|
+
})
|
15
|
+
}
|
16
|
+
|
17
|
+
describe "#run" do
|
18
|
+
its(:run) { should have(2).feeds }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
6
22
|
context "with exclusion by description" do
|
7
23
|
subject {
|
8
24
|
Automatic::Plugin::FilterIgnore.new({
|
@@ -10,7 +10,7 @@ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
|
|
10
10
|
|
11
11
|
require 'filter/image'
|
12
12
|
|
13
|
-
describe Automatic::Plugin::FilterImage do
|
13
|
+
describe Automatic::Plugin::FilterImage do
|
14
14
|
context "with description with image tag" do
|
15
15
|
subject {
|
16
16
|
Automatic::Plugin::FilterImage.new({},
|
@@ -29,10 +29,10 @@ describe Automatic::Plugin::FilterImage do
|
|
29
29
|
should == "http://27.media.tumblr.com/tumblr_lzrubkfPlt1qb8vzto1_500.png"
|
30
30
|
}
|
31
31
|
end
|
32
|
-
end
|
32
|
+
end
|
33
33
|
end
|
34
34
|
|
35
|
-
describe Automatic::Plugin::FilterImage do
|
35
|
+
describe Automatic::Plugin::FilterImage do
|
36
36
|
context "with description with image tag" do
|
37
37
|
subject {
|
38
38
|
Automatic::Plugin::FilterImage.new({},
|
@@ -51,5 +51,5 @@ describe Automatic::Plugin::FilterImage do
|
|
51
51
|
should == "http://24.media.tumblr.com/tumblr_m07wttnIdy1qzoj1jo1_400.jpg"
|
52
52
|
}
|
53
53
|
end
|
54
|
-
end
|
54
|
+
end
|
55
55
|
end
|