fragile 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.md +54 -0
- data/lib/fragile/application.rb +19 -7
- data/lib/fragile/plugin_manager.rb +7 -1
- data/lib/fragile/version.rb +2 -2
- data/test/test_helper.rb +4 -0
- metadata +3 -2
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
#Fragile
|
2
|
+
|
3
|
+
**Ruby Pipeline Framework**
|
4
|
+
|
5
|
+
##Description
|
6
|
+
|
7
|
+
This is a pipeline framework which can extend the functionality by plug-ins.
|
8
|
+
|
9
|
+
##Get Started
|
10
|
+
|
11
|
+
Installation.
|
12
|
+
|
13
|
+
```html
|
14
|
+
gem install fragile
|
15
|
+
```
|
16
|
+
|
17
|
+
Specify any recipe which -f option.
|
18
|
+
|
19
|
+
```html
|
20
|
+
fragile -f <recipe>
|
21
|
+
```
|
22
|
+
|
23
|
+
Example.
|
24
|
+
|
25
|
+
```html
|
26
|
+
$ fragile -f recipe/example.rb
|
27
|
+
```
|
28
|
+
|
29
|
+
##What is Recipe?
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
pipeline "foobar" do
|
33
|
+
use "feed_input", :url => "http://d.hatena.ne.jp/griefworker/rss"
|
34
|
+
use "unduplicate_filter"
|
35
|
+
use "mail_output", :to => "foobar@example.com"
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
##Environment
|
40
|
+
|
41
|
+
After ruby 1.8.
|
42
|
+
|
43
|
+
##Author
|
44
|
+
|
45
|
+
**tnakamura**
|
46
|
+
|
47
|
+
+ http://d.hatena.ne.jp/griefworker
|
48
|
+
+ https://github.com/tnakamura
|
49
|
+
|
50
|
+
##License
|
51
|
+
|
52
|
+
Licensed under the MIT LICENSE
|
53
|
+
|
54
|
+
|
data/lib/fragile/application.rb
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
# Copyright:: tnakamura Copyright (c) 2012
|
7
7
|
# License:: Licensed under the MIT LICENSE.
|
8
8
|
require "optparse"
|
9
|
+
require "logger"
|
9
10
|
require "fragile/version"
|
10
11
|
require "fragile/pipeline_manager"
|
11
12
|
require "fragile/plugin_manager"
|
@@ -15,19 +16,23 @@ module Fragile
|
|
15
16
|
include Fragile::PipelineManager
|
16
17
|
include Fragile::PluginManager
|
17
18
|
|
19
|
+
attr_reader :logger
|
20
|
+
|
18
21
|
def initialize
|
19
|
-
@
|
22
|
+
@recipe_file = File.join(Dir.pwd, "Spcfile")
|
23
|
+
@logger = Logger.new(STDOUT)
|
24
|
+
@logger.level = Logger::WARN
|
20
25
|
end
|
21
26
|
|
22
27
|
def run
|
23
28
|
handle_options
|
24
29
|
load_plugins
|
25
|
-
|
30
|
+
load_recipe_file
|
26
31
|
run_pipeline(ARGV)
|
27
32
|
end
|
28
33
|
|
29
|
-
def
|
30
|
-
load @
|
34
|
+
def load_recipe_file
|
35
|
+
load @recipe_file
|
31
36
|
end
|
32
37
|
|
33
38
|
def handle_options
|
@@ -41,10 +46,13 @@ module Fragile
|
|
41
46
|
exit
|
42
47
|
end
|
43
48
|
opts.on("-f", "--recipefile=RECIPE_FILE", "Recipe file path") { |v|
|
44
|
-
@
|
45
|
-
@plugin_dir ||= File.join(File.dirname(@
|
49
|
+
@recipe_file = v
|
50
|
+
@plugin_dir ||= File.join(File::expand_path(File.dirname(@recipe_file)), "plugins")
|
51
|
+
}
|
52
|
+
opts.on("-p", "--plugindir=plugin_dir", "Plugin directory") { |v|
|
53
|
+
@plugin_dir = File::expand_path(v)
|
46
54
|
}
|
47
|
-
opts.on("-
|
55
|
+
opts.on("-V", "--verbose", "Show detail log") { |v| @logger.level = Logger::DEBUG }
|
48
56
|
opts.parse!(ARGV)
|
49
57
|
|
50
58
|
unless 0 < ARGV.count
|
@@ -57,5 +65,9 @@ module Fragile
|
|
57
65
|
def self.application
|
58
66
|
@application ||= Application.new
|
59
67
|
end
|
68
|
+
|
69
|
+
def self.logger
|
70
|
+
Fragile.application.logger
|
71
|
+
end
|
60
72
|
end
|
61
73
|
|
@@ -16,11 +16,17 @@ module Fragile
|
|
16
16
|
attr_accessor :plugin_dir
|
17
17
|
|
18
18
|
def load_plugins
|
19
|
-
|
19
|
+
Fragile.logger.info "plugin_dir is '#{@plugin_dir}'."
|
20
|
+
unless Dir.exist?(@plugin_dir)
|
21
|
+
Fragile.logger.warn "'#{@plugin_dir}' is not exist."
|
22
|
+
return
|
23
|
+
end
|
20
24
|
|
21
25
|
pattern = File.join(@plugin_dir, "*.rb")
|
26
|
+
Fragile.logger.info "pattern is '#{pattern}'."
|
22
27
|
Dir.glob(pattern) do |path|
|
23
28
|
load path
|
29
|
+
Fragile.logger.info "'#{path}' is loaded."
|
24
30
|
end
|
25
31
|
end
|
26
32
|
|
data/lib/fragile/version.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
# Name:: Fragile
|
3
3
|
# Author:: tnakamura <http://d.hatena.ne.jp/griefworker>
|
4
4
|
# Created:: Jun 15, 2012
|
5
|
-
# Updated:: Jun
|
5
|
+
# Updated:: Jun 17, 2012
|
6
6
|
# Copyright:: tnakamura Copyright (c) 2012
|
7
7
|
# License:: Licensed under the MIT LICENSE.
|
8
8
|
|
9
9
|
module Fragile
|
10
|
-
VERSION = "0.0.
|
10
|
+
VERSION = "0.0.2"
|
11
11
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fragile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-17 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Ruby Pipeline Framework
|
15
15
|
email:
|
@@ -22,6 +22,7 @@ files:
|
|
22
22
|
- .gitignore
|
23
23
|
- Gemfile
|
24
24
|
- MIT-LICENSE
|
25
|
+
- README.md
|
25
26
|
- Rakefile
|
26
27
|
- bin/fragile
|
27
28
|
- examples/example.rb
|