fragile 0.0.3 → 0.0.4
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/.coveralls.yml +1 -0
- data/.gitignore +54 -6
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +7 -4
- data/LICENSE.txt +22 -0
- data/README.md +61 -60
- data/Rakefile +1 -1
- data/bin/fragile +19 -19
- data/examples/example.rb +47 -33
- data/fragile.gemspec +21 -24
- data/lib/fragile.rb +14 -14
- data/lib/fragile/application.rb +68 -68
- data/lib/fragile/dsl.rb +18 -18
- data/lib/fragile/pipeline.rb +54 -54
- data/lib/fragile/pipeline_manager.rb +36 -36
- data/lib/fragile/plugin/console_output.rb +17 -17
- data/lib/fragile/plugin/im_kayac_output.rb +56 -0
- data/lib/fragile/plugin/mail_output.rb +50 -50
- data/lib/fragile/plugin/map_filter.rb +18 -18
- data/lib/fragile/plugin/rss_input.rb +36 -21
- data/lib/fragile/plugin/select_filter.rb +18 -18
- data/lib/fragile/plugin_manager.rb +38 -38
- data/lib/fragile/version.rb +11 -11
- data/{test/dsl_test.rb → spec/dsl_spec.rb} +17 -18
- data/{test/pipeline_manager_test.rb → spec/pipeline_manager_spec.rb} +94 -94
- data/{test/pipeline_test.rb → spec/pipeline_spec.rb} +108 -106
- data/spec/plugin/im_kayac_output_spec.rb +65 -0
- data/spec/plugin_manager_spec.rb +49 -0
- data/spec/spec_helper.rb +15 -0
- metadata +39 -12
- data/MIT-LICENSE +0 -23
- data/test/plugin_manager_test.rb +0 -57
- data/test/test_helper.rb +0 -14
@@ -0,0 +1,65 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
require "fragile/plugin/im_kayac_output"
|
4
|
+
|
5
|
+
describe Fragile::Plugin::ImKayacOutput do
|
6
|
+
let :output do
|
7
|
+
described_class.new(
|
8
|
+
:handler => 'handler',
|
9
|
+
:username => 'username',
|
10
|
+
:password => 'password',
|
11
|
+
:secret_key => 'secret_key',
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
it '@base_url が正しく設定されているべき' do
|
16
|
+
expect(output.instance_eval { @base_url }).to eq 'http://im.kayac.com/api/post/'
|
17
|
+
end
|
18
|
+
|
19
|
+
it '@handler が正しく設定されているべき' do
|
20
|
+
expect(output.instance_eval { @handler }).to eq 'handler'
|
21
|
+
end
|
22
|
+
|
23
|
+
it '@username が正しく設定されているべき' do
|
24
|
+
expect(output.instance_eval { @username }).to eq 'username'
|
25
|
+
end
|
26
|
+
|
27
|
+
it '@password が正しく設定されているべき' do
|
28
|
+
expect(output.instance_eval { @password }).to eq 'password'
|
29
|
+
end
|
30
|
+
|
31
|
+
it '@secret_key が正しく設定されているべき' do
|
32
|
+
expect(output.instance_eval { @secret_key }).to eq 'secret_key'
|
33
|
+
end
|
34
|
+
|
35
|
+
it '#call を持つべき' do
|
36
|
+
expect(output).to respond_to :call
|
37
|
+
end
|
38
|
+
|
39
|
+
context '#callが引数なしで実行されたとき' do
|
40
|
+
it '#send_im_kayac が実行されないべき' do
|
41
|
+
output.should_not_receive(:send_im_kayac)
|
42
|
+
output.call
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context '#callが引数ありで実行されたとき' do
|
47
|
+
it '#send_im_kayac が実行されるべき' do
|
48
|
+
output.should_receive(:send_im_kayac).exactly(1).times
|
49
|
+
output.call(['a', 'b', 'c'])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context '#callが:link, :title を含むHash型の配列で実行されたとき' do
|
54
|
+
it '#send_im_kayac が配列サイズ数だけ実行されるべき' do
|
55
|
+
output.should_receive(:send_im_kayac).exactly(3).times
|
56
|
+
output.call([
|
57
|
+
{:link => 'http://example.com/a', :title => 'a'},
|
58
|
+
{:link => 'http://example.com/b', :title => 'b'},
|
59
|
+
{:link => 'http://example.com/c', :title => 'c'},
|
60
|
+
])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require_relative "spec_helper"
|
3
|
+
require "fragile/plugin/console_output"
|
4
|
+
|
5
|
+
class TestApp
|
6
|
+
include Fragile::PluginManager
|
7
|
+
end
|
8
|
+
|
9
|
+
module Fragile::Plugin
|
10
|
+
class TestPlugin
|
11
|
+
def initialize(config)
|
12
|
+
@config = config
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(data)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe Fragile::PluginManager do
|
21
|
+
describe "#create_plugin" do
|
22
|
+
before do
|
23
|
+
@manager = TestApp.new
|
24
|
+
end
|
25
|
+
|
26
|
+
context "プラグインクラスを指定したとき" do
|
27
|
+
it "プラグインクラスのインスタンスを生成できる" do
|
28
|
+
@plugin = @manager.create_plugin(Fragile::Plugin::TestPlugin, {})
|
29
|
+
expect(@plugin).to be_an_instance_of(Fragile::Plugin::TestPlugin)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "存在しないプラグインクラスの名前を指定したとき" do
|
34
|
+
it "NameError が発生する" do
|
35
|
+
expect {
|
36
|
+
@manager.create_plugin("foo_bar_hoge_fuga", {})
|
37
|
+
}.to raise_error(NameError)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "存在するプラグインクラスの名前を指定したとき" do
|
42
|
+
it "プラグインクラスのインスタンスを生成できる" do
|
43
|
+
@plugin = @manager.create_plugin(:console_output, {})
|
44
|
+
expect(@plugin).to be_an_instance_of(Fragile::Plugin::ConsoleOutput)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'fragile'
|
5
|
+
|
6
|
+
require 'coveralls'
|
7
|
+
Coveralls.wear!
|
8
|
+
|
9
|
+
# Requires supporting files with custom matchers and macros, etc,
|
10
|
+
# in ./support/ and its subdirectories.
|
11
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
|
15
|
+
end
|
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.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
12
|
+
date: 2013-06-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
14
30
|
description: Ruby Pipeline Framework
|
15
31
|
email:
|
16
32
|
- griefworker@gmail.com
|
@@ -19,9 +35,12 @@ executables:
|
|
19
35
|
extensions: []
|
20
36
|
extra_rdoc_files: []
|
21
37
|
files:
|
38
|
+
- .coveralls.yml
|
22
39
|
- .gitignore
|
40
|
+
- .rspec
|
41
|
+
- .travis.yml
|
23
42
|
- Gemfile
|
24
|
-
-
|
43
|
+
- LICENSE.txt
|
25
44
|
- README.md
|
26
45
|
- Rakefile
|
27
46
|
- bin/fragile
|
@@ -33,17 +52,19 @@ files:
|
|
33
52
|
- lib/fragile/pipeline.rb
|
34
53
|
- lib/fragile/pipeline_manager.rb
|
35
54
|
- lib/fragile/plugin/console_output.rb
|
55
|
+
- lib/fragile/plugin/im_kayac_output.rb
|
36
56
|
- lib/fragile/plugin/mail_output.rb
|
37
57
|
- lib/fragile/plugin/map_filter.rb
|
38
58
|
- lib/fragile/plugin/rss_input.rb
|
39
59
|
- lib/fragile/plugin/select_filter.rb
|
40
60
|
- lib/fragile/plugin_manager.rb
|
41
61
|
- lib/fragile/version.rb
|
42
|
-
-
|
43
|
-
-
|
44
|
-
-
|
45
|
-
-
|
46
|
-
-
|
62
|
+
- spec/dsl_spec.rb
|
63
|
+
- spec/pipeline_manager_spec.rb
|
64
|
+
- spec/pipeline_spec.rb
|
65
|
+
- spec/plugin/im_kayac_output_spec.rb
|
66
|
+
- spec/plugin_manager_spec.rb
|
67
|
+
- spec/spec_helper.rb
|
47
68
|
homepage: https://github.com/tnakamura/fragile
|
48
69
|
licenses: []
|
49
70
|
post_install_message:
|
@@ -63,9 +84,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
84
|
- !ruby/object:Gem::Version
|
64
85
|
version: '0'
|
65
86
|
requirements: []
|
66
|
-
rubyforge_project:
|
67
|
-
rubygems_version: 1.8.
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 1.8.23
|
68
89
|
signing_key:
|
69
90
|
specification_version: 3
|
70
91
|
summary: Ruby Pipeline Framework
|
71
|
-
test_files:
|
92
|
+
test_files:
|
93
|
+
- spec/dsl_spec.rb
|
94
|
+
- spec/pipeline_manager_spec.rb
|
95
|
+
- spec/pipeline_spec.rb
|
96
|
+
- spec/plugin/im_kayac_output_spec.rb
|
97
|
+
- spec/plugin_manager_spec.rb
|
98
|
+
- spec/spec_helper.rb
|
data/MIT-LICENSE
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
Copyright (c) 2012 Takashi Nakamura
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person
|
4
|
-
obtaining a copy of this software and associated documentation
|
5
|
-
files (the "Software"), to deal in the Software without
|
6
|
-
restriction, including without limitation the rights to use,
|
7
|
-
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
copies of the Software, and to permit persons to whom the
|
9
|
-
Software is furnished to do so, subject to the following
|
10
|
-
conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be
|
13
|
-
included in all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
-
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
-
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
-
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
-
OTHER DEALINGS IN THE SOFTWARE.
|
23
|
-
|
data/test/plugin_manager_test.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require_relative "test_helper"
|
3
|
-
|
4
|
-
class TestApp
|
5
|
-
include Fragile::PluginManager
|
6
|
-
end
|
7
|
-
|
8
|
-
module Fragile::Plugin
|
9
|
-
class TestPlugin
|
10
|
-
def initialize(config)
|
11
|
-
@config = config
|
12
|
-
end
|
13
|
-
|
14
|
-
def call(data)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "PluginManager" do
|
20
|
-
describe "#create_plugin" do
|
21
|
-
describe "クラスを指定したとき" do
|
22
|
-
before do
|
23
|
-
@manager = TestApp.new
|
24
|
-
end
|
25
|
-
|
26
|
-
it "プラグインのインスタンスを生成できるべき" do
|
27
|
-
obj = @manager.create_plugin(Fragile::Plugin::TestPlugin, {})
|
28
|
-
assert_equal Fragile::Plugin::TestPlugin, obj.class
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "存在しないプラグイン名を指定したとき" do
|
33
|
-
before do
|
34
|
-
@manager = TestApp.new
|
35
|
-
end
|
36
|
-
|
37
|
-
it "NameError が発生するべき" do
|
38
|
-
assert_raises NameError do
|
39
|
-
@manager.create_plugin("foo_bar_hoge_fuga", {})
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "存在するプラグイン名を指定したとき" do
|
45
|
-
before do
|
46
|
-
@manager = TestApp.new
|
47
|
-
require "fragile/plugin/console_output"
|
48
|
-
end
|
49
|
-
|
50
|
-
it "プラグインのインスタンスを生成できるべき" do
|
51
|
-
obj = @manager.create_plugin(:console_output, {})
|
52
|
-
assert_equal Fragile::Plugin::ConsoleOutput, obj.class
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
data/test/test_helper.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
4
|
-
$LOAD_PATH.unshift APP_ROOT
|
5
|
-
$LOAD_PATH.unshift File.join(APP_ROOT)
|
6
|
-
$LOAD_PATH.unshift File.join(APP_ROOT, 'lib')
|
7
|
-
|
8
|
-
require "logger"
|
9
|
-
require "fragile"
|
10
|
-
Fragile.logger.level = Logger::DEBUG
|
11
|
-
|
12
|
-
require "minitest/spec"
|
13
|
-
require "minitest/autorun"
|
14
|
-
|