macaroni 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.coveralls.yml +1 -0
- data/.gitignore +17 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +82 -0
- data/Rakefile +2 -0
- data/bin/macaroni +8 -0
- data/example/example.rb +67 -0
- data/lib/macaroni/core/application.rb +23 -0
- data/lib/macaroni/core/pipe.rb +24 -0
- data/lib/macaroni/dsl.rb +16 -0
- data/lib/macaroni/plugin/filter/base.rb +19 -0
- data/lib/macaroni/plugin/filter/deduped.rb +35 -0
- data/lib/macaroni/plugin/filter.rb +22 -0
- data/lib/macaroni/plugin/input/rss.rb +18 -0
- data/lib/macaroni/plugin/output/im_kayac.rb +38 -0
- data/lib/macaroni/plugin/output/stdout.rb +18 -0
- data/lib/macaroni/version.rb +3 -0
- data/lib/macaroni.rb +27 -0
- data/macaroni.gemspec +24 -0
- data/spec/macaroni/core/application_spec.rb +40 -0
- data/spec/macaroni/core/pipe_spec.rb +26 -0
- data/spec/macaroni/dsl_spec.rb +5 -0
- data/spec/macaroni/plugin/filter_spec.rb +18 -0
- data/spec/macaroni/plugin/output/stdout_spec.rb +16 -0
- data/spec/macaroni_spec.rb +17 -0
- data/spec/spec_helper.rb +6 -0
- metadata +145 -0
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 mizoryu
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# Macaroni [![Build Status](https://secure.travis-ci.org/mizoR/macaroni.png)](https://travis-ci.org/mizoR/macaroni) [![Code Climate](https://codeclimate.com/github/mizoR/macaroni.png)](https://codeclimate.com/github/mizoR/macaroni) [![Coverage Status](https://coveralls.io/repos/mizoR/macaroni/badge.png?branch=master)](https://coveralls.io/r/mizoR/macaroni?branch=master)
|
2
|
+
|
3
|
+
|
4
|
+
Macaroni is a ruby DSL for easily feed agregation and pipeline processing.
|
5
|
+
|
6
|
+
```
|
7
|
+
include Macaroni::Plugin
|
8
|
+
|
9
|
+
pipe :news do
|
10
|
+
plug Input::RSS, 'http://news.yahoo.com/rss/'
|
11
|
+
plug Input::RSS, 'https://news.google.com/news/feeds?cf=all&ned=us&hl=en&output=rss'
|
12
|
+
plug Filter::Sort do |a, b|
|
13
|
+
b.date_published <=> a.date_published
|
14
|
+
end
|
15
|
+
plug Filter::Slice, 1, 5
|
16
|
+
plug Filter::Map do |row|
|
17
|
+
{:title => row.title, :url => row.url}
|
18
|
+
end
|
19
|
+
plug Output::Stdout
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
## Installation
|
24
|
+
|
25
|
+
Add this line to your application's Gemfile:
|
26
|
+
|
27
|
+
gem 'macaroni'
|
28
|
+
|
29
|
+
And then execute:
|
30
|
+
|
31
|
+
$ bundle
|
32
|
+
|
33
|
+
Or install it yourself as:
|
34
|
+
|
35
|
+
$ gem install macaroni
|
36
|
+
|
37
|
+
## Usage
|
38
|
+
|
39
|
+
Recipe's sample:
|
40
|
+
|
41
|
+
```
|
42
|
+
# my_recipe.rb
|
43
|
+
|
44
|
+
include Macaroni::Plugin
|
45
|
+
|
46
|
+
pipe :news do
|
47
|
+
plug Input::RSS, 'http://news.yahoo.com/rss/'
|
48
|
+
plug Input::RSS, 'https://news.google.com/news/feeds?cf=all&ned=us&hl=en&output=rss'
|
49
|
+
plug Filter::Sort do |a, b|
|
50
|
+
b.date_published <=> a.date_published
|
51
|
+
end
|
52
|
+
plug Filter::Slice, 1, 5
|
53
|
+
plug Filter::Map do |row|
|
54
|
+
{:title => row.title, :url => row.url}
|
55
|
+
end
|
56
|
+
plug Output::Stdout
|
57
|
+
end
|
58
|
+
```
|
59
|
+
|
60
|
+
Start with:
|
61
|
+
|
62
|
+
```
|
63
|
+
macaroni --recipe my_recipe.rb --target news
|
64
|
+
```
|
65
|
+
|
66
|
+
Output
|
67
|
+
|
68
|
+
```
|
69
|
+
{:title=>"Plaintiffs in Calif. marriage case marry in SF", :url=>"http://news.yahoo.com/plaintiffs-calif-marriage-case-marry-sf-000449812.html"}
|
70
|
+
{:title=>"Obama yet to have African legacy like predecessors - Houston Chronicle", :url=>"http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNGQLT2e30BTh-bVNWOZSPN6hbqFkQ&url=http://www.chron.com/news/politics/article/Obama-yet-to-have-African-legacy-like-predecessors-4630606.php"}
|
71
|
+
{:title=>"Plaintiffs in Calif. gay marriage case wed in SF", :url=>"http://news.yahoo.com/plaintiffs-calif-gay-marriage-case-wed-sf-235831059.html"}
|
72
|
+
{:title=>"End of era as Celtics rebuild without Pierce", :url=>"http://news.yahoo.com/end-era-celtics-rebuild-without-pierce-203533133.html"}
|
73
|
+
{:title=>"'Preposterous' to suggest Cartwright betrayed US, lawyer says - NBCNews.com", :url=>"http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNGt8aynSXvEm0sAYhjJKPVTMMp7Kg&url=http://www.nbcnews.com/video/nightly-news/52345858/"}
|
74
|
+
```
|
75
|
+
|
76
|
+
## Contributing
|
77
|
+
|
78
|
+
1. Fork it
|
79
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
80
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
81
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
82
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/macaroni
ADDED
data/example/example.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# -*- coding: utf-8-*-
|
2
|
+
|
3
|
+
include Macaroni::Plugin
|
4
|
+
|
5
|
+
pipe :news do
|
6
|
+
plug Input::RSS, 'http://news.yahoo.com/rss/'
|
7
|
+
plug Input::RSS, 'https://news.google.com/news/feeds?cf=all&ned=us&hl=en&output=rss'
|
8
|
+
plug Filter::Sort do |a, b|
|
9
|
+
b.date_published <=> a.date_published
|
10
|
+
end
|
11
|
+
plug Filter::Slice, 1, 5
|
12
|
+
plug Filter::Map do |row|
|
13
|
+
{:title => row.title, :url => row.url}
|
14
|
+
end
|
15
|
+
plug Output::Stdout
|
16
|
+
end
|
17
|
+
|
18
|
+
pipe :string_processing_sample, :data => 'Hello World!' do
|
19
|
+
plug Filter::Downcase
|
20
|
+
plug Output::Stdout
|
21
|
+
plug Filter::Reverse
|
22
|
+
plug Output::Stdout
|
23
|
+
plug Filter::Upcase
|
24
|
+
plug Output::Stdout
|
25
|
+
end
|
26
|
+
|
27
|
+
pipe :reverse_sample do
|
28
|
+
plug Input::RSS, 'http://news.yahoo.com/rss/'
|
29
|
+
plug Input::RSS, 'http://rss.dailynews.yahoo.co.jp/fc/rss.xml'
|
30
|
+
plug Filter::Reverse
|
31
|
+
plug Filter::Map do |row|
|
32
|
+
{:title => row.title, :url => row.url}
|
33
|
+
end
|
34
|
+
plug Output::Stdout
|
35
|
+
end
|
36
|
+
|
37
|
+
pipe :deduped_sample do
|
38
|
+
plug Input::RSS, 'http://news.yahoo.com/rss/'
|
39
|
+
plug Input::RSS, 'http://rss.dailynews.yahoo.co.jp/fc/rss.xml'
|
40
|
+
plug Filter::Deduped
|
41
|
+
plug Filter::Map do |row|
|
42
|
+
{:title => row.title, :url => row.url}
|
43
|
+
end
|
44
|
+
plug Output::Stdout
|
45
|
+
end
|
46
|
+
|
47
|
+
pipe :each_with_index_sample do
|
48
|
+
plug Input::RSS, 'http://news.yahoo.com/rss/'
|
49
|
+
plug Input::RSS, 'http://rss.dailynews.yahoo.co.jp/fc/rss.xml'
|
50
|
+
plug Filter::Map do |row|
|
51
|
+
{:title => row.title, :url => row.url}
|
52
|
+
end
|
53
|
+
plug Filter::EachWithIndex do |row, i|
|
54
|
+
row.merge!(id: i)
|
55
|
+
end
|
56
|
+
plug Output::Stdout
|
57
|
+
end
|
58
|
+
|
59
|
+
pipe :im_kayac_sample do
|
60
|
+
plug Input::RSS, 'http://news.yahoo.com/rss/'
|
61
|
+
plug Input::RSS, 'http://rss.dailynews.yahoo.co.jp/fc/rss.xml'
|
62
|
+
plug Filter::Map do |row|
|
63
|
+
{:message => row.title, :handler => row.url}
|
64
|
+
end
|
65
|
+
plug Output::ImKayac, :username => ENV['IM_KAYAC_USERNAME'], :secret_key => ENV['IM_KAYAC_SECRET_KEY']
|
66
|
+
end
|
67
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'singleton'
|
3
|
+
|
4
|
+
module Macaroni
|
5
|
+
module Core
|
6
|
+
class Application
|
7
|
+
include Singleton
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@pipes = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def set_pipe(name, pipe)
|
14
|
+
@pipes[name.to_sym] = pipe
|
15
|
+
end
|
16
|
+
|
17
|
+
def exec_pipe(name)
|
18
|
+
@pipes[name.to_sym].exec
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
module Macaroni
|
4
|
+
module Core
|
5
|
+
class Pipe
|
6
|
+
def initialize(options={})
|
7
|
+
@data = options[:data] || []
|
8
|
+
@plugins = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def exec
|
12
|
+
@plugins.inject(@data) do |data, (klass, args, block)|
|
13
|
+
klass.new(*args, &block).exec(data)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def plug(klass, *args, &block)
|
20
|
+
@plugins << [klass, args, block]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/macaroni/dsl.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
module Macaroni
|
4
|
+
module DSL
|
5
|
+
def pipe(name, options={}, &block)
|
6
|
+
pipe = Macaroni::Core::Pipe.new options
|
7
|
+
pipe.instance_eval(&block)
|
8
|
+
Macaroni::application.set_pipe(name, pipe)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class << self
|
14
|
+
include Macaroni::DSL
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Macaroni
|
5
|
+
module Plugin
|
6
|
+
module Filter
|
7
|
+
class Deduped < Select
|
8
|
+
def initialize(options={})
|
9
|
+
@cache_path = options[:cache_path] || '/tmp/macaroni-cache'
|
10
|
+
@block = lambda { |entry|
|
11
|
+
hash = Digest::MD5.hexdigest(entry.url)
|
12
|
+
hash_path = File.join(@cache_path, hash)
|
13
|
+
deduped = !File.exists?(hash_path)
|
14
|
+
|
15
|
+
File.open(hash_path, 'w') do |file|
|
16
|
+
file.write({
|
17
|
+
:url => entry.url,
|
18
|
+
:title => entry.title,
|
19
|
+
:content => entry.content,
|
20
|
+
}.to_yaml)
|
21
|
+
end if deduped
|
22
|
+
|
23
|
+
deduped
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def exec(data)
|
28
|
+
FileUtils.mkdir_p(@cache_path) if !File.exists?(@cache_path)
|
29
|
+
super
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'macaroni/plugin/filter/base'
|
3
|
+
|
4
|
+
module Macaroni
|
5
|
+
module Plugin
|
6
|
+
module Filter
|
7
|
+
def self.const_missing(name)
|
8
|
+
method_name = name.to_s.
|
9
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
10
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').tr("-", "_").
|
11
|
+
downcase
|
12
|
+
klass = Class.new(Base) do
|
13
|
+
define_method :exec do |data|
|
14
|
+
data.send(method_name, *@args, &@block)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
const_set(name, klass)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'feed-normalizer'
|
3
|
+
|
4
|
+
module Macaroni
|
5
|
+
module Plugin
|
6
|
+
module Input
|
7
|
+
class RSS
|
8
|
+
def initialize(url)
|
9
|
+
@feed = FeedNormalizer::FeedNormalizer.parse open(url)
|
10
|
+
end
|
11
|
+
|
12
|
+
def exec(data)
|
13
|
+
data + @feed.entries
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
module Macaroni
|
4
|
+
module Plugin
|
5
|
+
module Output
|
6
|
+
class ImKayac
|
7
|
+
def initialize(params={})
|
8
|
+
@base_url = "http://im.kayac.com/api/post/"
|
9
|
+
@username = params[:username] or raise ArgumentError
|
10
|
+
@password = params[:password] || nil
|
11
|
+
@secret_key = params[:secret_key] || nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def exec(data)
|
15
|
+
return data if data.empty?
|
16
|
+
|
17
|
+
uri = URI.parse "#{@base_url}#{@username}"
|
18
|
+
Net::HTTP.new(uri.host, uri.port).start do |http|
|
19
|
+
data.each do |row|
|
20
|
+
sig = @secret_key ? \
|
21
|
+
Digest::SHA1.new.update("#{row[:message]}#{@secret_key}").to_s : nil
|
22
|
+
|
23
|
+
request = Net::HTTP::Post.new(uri.path)
|
24
|
+
request.set_form_data(
|
25
|
+
:handler => row[:handler],
|
26
|
+
:password => @password,
|
27
|
+
:sig => sig,
|
28
|
+
:message => row[:message]
|
29
|
+
)
|
30
|
+
http.request(request)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
data/lib/macaroni.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'macaroni/version'
|
2
|
+
require 'macaroni/core/application'
|
3
|
+
require 'macaroni/core/pipe'
|
4
|
+
require 'macaroni/plugin/input/rss'
|
5
|
+
require 'macaroni/plugin/filter'
|
6
|
+
require 'macaroni/plugin/filter/deduped'
|
7
|
+
require 'macaroni/plugin/output/stdout'
|
8
|
+
require 'macaroni/plugin/output/im_kayac'
|
9
|
+
require 'optparse'
|
10
|
+
|
11
|
+
module Macaroni
|
12
|
+
def self.application
|
13
|
+
Core::Application.instance
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.main(argv)
|
17
|
+
options = {:recipe => 'recipe', :target => 'default'}
|
18
|
+
OptionParser.new.tap do |opt|
|
19
|
+
opt.on('--recipe [RECIPE]') {|v| options[:recipe] = v}
|
20
|
+
opt.on('--target [TARGET]') {|v| options[:target] = v}
|
21
|
+
opt.parse!(argv)
|
22
|
+
end
|
23
|
+
|
24
|
+
load File.join(Dir.pwd, options[:recipe])
|
25
|
+
application.exec_pipe(options[:target])
|
26
|
+
end
|
27
|
+
end
|
data/macaroni.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'macaroni/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "macaroni"
|
8
|
+
gem.version = Macaroni::VERSION
|
9
|
+
gem.authors = ["mizoR"]
|
10
|
+
gem.email = ["r.mizokami@gmail.com"]
|
11
|
+
gem.description = %q{Macaroni is a ruby DSL for easily feed agregation and pipeline processing.}
|
12
|
+
gem.summary = %q{Ruby DSL for feed aggregation.}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.add_dependency "feed-normalizer"
|
20
|
+
|
21
|
+
gem.add_development_dependency "pry"
|
22
|
+
gem.add_development_dependency "rspec"
|
23
|
+
gem.add_development_dependency "coveralls"
|
24
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Macaroni::Core::Application do
|
5
|
+
let :application do
|
6
|
+
described_class.instance
|
7
|
+
end
|
8
|
+
|
9
|
+
context '#new' do
|
10
|
+
it do
|
11
|
+
pipes = application.instance_eval {@pipes}
|
12
|
+
expect(pipes).to eq({})
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context '#set_pipe' do
|
17
|
+
before do
|
18
|
+
@pipe = double('pipe')
|
19
|
+
@pipe.stub(:exec).and_return('test')
|
20
|
+
application.set_pipe(:test, @pipe)
|
21
|
+
end
|
22
|
+
|
23
|
+
it do
|
24
|
+
expect(application.instance_eval {@pipes[:test]}).to be @pipe
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context '#exec_pipe' do
|
29
|
+
before do
|
30
|
+
pipe = double('pipe')
|
31
|
+
pipe.stub(:exec).and_return('TEST')
|
32
|
+
application.set_pipe(:test, pipe)
|
33
|
+
end
|
34
|
+
|
35
|
+
it do
|
36
|
+
expect(application.exec_pipe('test')).to eq 'TEST'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
describe Macaroni::Core::Pipe do
|
4
|
+
it '#plug' do
|
5
|
+
plugin_class = double(:plugin_class)
|
6
|
+
|
7
|
+
pipe = described_class.new
|
8
|
+
pipe.send(:plug, plugin_class) {}
|
9
|
+
pipe.send(:plug, plugin_class) {}
|
10
|
+
pipe.send(:plug, plugin_class) {}
|
11
|
+
expect(pipe.instance_eval {@plugins.length}).to be 3
|
12
|
+
end
|
13
|
+
|
14
|
+
it '#exec' do
|
15
|
+
plugin = double(:plugin)
|
16
|
+
plugin.should_receive(:exec).and_return('TEST')
|
17
|
+
|
18
|
+
plugin_class = double(:plugin_class).stub(:new)
|
19
|
+
plugin_class.should_receive(:new).and_return(plugin)
|
20
|
+
|
21
|
+
pipe = described_class.new
|
22
|
+
pipe.send(:plug, plugin_class) {}
|
23
|
+
expect(pipe.exec).to eq 'TEST'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
describe Macaroni::Plugin::Filter do
|
4
|
+
context do
|
5
|
+
it do
|
6
|
+
ancestors = Macaroni::Plugin::Filter::Each.ancestors
|
7
|
+
expect(ancestors).to include(Macaroni::Plugin::Filter::Base)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context do
|
12
|
+
it do
|
13
|
+
to_i_filter = Macaroni::Plugin::Filter::ToI.new
|
14
|
+
expect(to_i_filter.exec('1')).to be 1
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
describe Macaroni::Plugin::Output::Stdout do
|
4
|
+
it do
|
5
|
+
begin
|
6
|
+
stdout = $stdout
|
7
|
+
$stdout = StringIO.new
|
8
|
+
stdout_output = described_class.new
|
9
|
+
stdout_output.exec 'TEST'
|
10
|
+
expect($stdout.string).to eq "TEST\n"
|
11
|
+
ensure
|
12
|
+
$stdout = stdout
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Macaroni do
|
5
|
+
it do
|
6
|
+
expect(Macaroni).to respond_to :main
|
7
|
+
end
|
8
|
+
|
9
|
+
it do
|
10
|
+
expect(Macaroni).to respond_to :application
|
11
|
+
end
|
12
|
+
|
13
|
+
it do
|
14
|
+
expect(Macaroni::application).to be Macaroni::Core::Application.instance
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: macaroni
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- mizoR
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-06-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: feed-normalizer
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: pry
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: coveralls
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: Macaroni is a ruby DSL for easily feed agregation and pipeline processing.
|
79
|
+
email:
|
80
|
+
- r.mizokami@gmail.com
|
81
|
+
executables:
|
82
|
+
- macaroni
|
83
|
+
extensions: []
|
84
|
+
extra_rdoc_files: []
|
85
|
+
files:
|
86
|
+
- .coveralls.yml
|
87
|
+
- .gitignore
|
88
|
+
- .travis.yml
|
89
|
+
- Gemfile
|
90
|
+
- LICENSE.txt
|
91
|
+
- README.md
|
92
|
+
- Rakefile
|
93
|
+
- bin/macaroni
|
94
|
+
- example/example.rb
|
95
|
+
- lib/macaroni.rb
|
96
|
+
- lib/macaroni/core/application.rb
|
97
|
+
- lib/macaroni/core/pipe.rb
|
98
|
+
- lib/macaroni/dsl.rb
|
99
|
+
- lib/macaroni/plugin/filter.rb
|
100
|
+
- lib/macaroni/plugin/filter/base.rb
|
101
|
+
- lib/macaroni/plugin/filter/deduped.rb
|
102
|
+
- lib/macaroni/plugin/input/rss.rb
|
103
|
+
- lib/macaroni/plugin/output/im_kayac.rb
|
104
|
+
- lib/macaroni/plugin/output/stdout.rb
|
105
|
+
- lib/macaroni/version.rb
|
106
|
+
- macaroni.gemspec
|
107
|
+
- spec/macaroni/core/application_spec.rb
|
108
|
+
- spec/macaroni/core/pipe_spec.rb
|
109
|
+
- spec/macaroni/dsl_spec.rb
|
110
|
+
- spec/macaroni/plugin/filter_spec.rb
|
111
|
+
- spec/macaroni/plugin/output/stdout_spec.rb
|
112
|
+
- spec/macaroni_spec.rb
|
113
|
+
- spec/spec_helper.rb
|
114
|
+
homepage: ''
|
115
|
+
licenses: []
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
requirements: []
|
133
|
+
rubyforge_project:
|
134
|
+
rubygems_version: 1.8.23
|
135
|
+
signing_key:
|
136
|
+
specification_version: 3
|
137
|
+
summary: Ruby DSL for feed aggregation.
|
138
|
+
test_files:
|
139
|
+
- spec/macaroni/core/application_spec.rb
|
140
|
+
- spec/macaroni/core/pipe_spec.rb
|
141
|
+
- spec/macaroni/dsl_spec.rb
|
142
|
+
- spec/macaroni/plugin/filter_spec.rb
|
143
|
+
- spec/macaroni/plugin/output/stdout_spec.rb
|
144
|
+
- spec/macaroni_spec.rb
|
145
|
+
- spec/spec_helper.rb
|