yapra 0.1.0

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.
Files changed (104) hide show
  1. data/History.txt +4 -0
  2. data/LICENCE +22 -0
  3. data/License.txt +22 -0
  4. data/Manifest.txt +103 -0
  5. data/PostInstall.txt +7 -0
  6. data/README.txt +66 -0
  7. data/Rakefile +13 -0
  8. data/bin/yapra +52 -0
  9. data/config/hoe.rb +75 -0
  10. data/config/requirements.rb +15 -0
  11. data/legacy_plugins/Download/nicovideo.rb +45 -0
  12. data/legacy_plugins/Feed/custom_feed.rb +87 -0
  13. data/legacy_plugins/Feed/google_calendar.rb +51 -0
  14. data/legacy_plugins/Feed/google_search_history.rb +45 -0
  15. data/legacy_plugins/Feed/hatena_graph.rb +37 -0
  16. data/legacy_plugins/Feed/lirs.rb +36 -0
  17. data/legacy_plugins/Filter/Translations/yahoo.rb +40 -0
  18. data/legacy_plugins/Filter/apply_text_html.rb +26 -0
  19. data/legacy_plugins/Filter/average.rb +6 -0
  20. data/legacy_plugins/Filter/deduped.rb +51 -0
  21. data/legacy_plugins/Filter/find_num.rb +8 -0
  22. data/legacy_plugins/Filter/find_regex.rb +9 -0
  23. data/legacy_plugins/Filter/fresh.rb +9 -0
  24. data/legacy_plugins/Filter/get_html.rb +11 -0
  25. data/legacy_plugins/Filter/grep.rb +16 -0
  26. data/legacy_plugins/Filter/invert.rb +14 -0
  27. data/legacy_plugins/Filter/sort.rb +10 -0
  28. data/legacy_plugins/Filter/subs.rb +6 -0
  29. data/legacy_plugins/Filter/to_integer.rb +4 -0
  30. data/legacy_plugins/Publish/delicious.rb +91 -0
  31. data/legacy_plugins/Publish/google_calendar.rb +58 -0
  32. data/legacy_plugins/Publish/hatena_bookmark.rb +47 -0
  33. data/legacy_plugins/Publish/hatena_diary_writer.rb +53 -0
  34. data/legacy_plugins/Publish/hatena_graph.rb +39 -0
  35. data/legacy_plugins/Publish/lingr.rb +110 -0
  36. data/legacy_plugins/Publish/mixi_diary_writer.rb +104 -0
  37. data/legacy_plugins/Publish/scuttle.rb +92 -0
  38. data/legacy_plugins/Publish/twitter.rb +35 -0
  39. data/legacy_plugins/RSS/load.rb +38 -0
  40. data/legacy_plugins/RSS/save.rb +41 -0
  41. data/legacy_plugins/Yaml/load.rb +5 -0
  42. data/legacy_plugins/Yaml/save.rb +9 -0
  43. data/legacy_plugins/argv.rb +5 -0
  44. data/legacy_plugins/concat.rb +18 -0
  45. data/legacy_plugins/const_list.rb +15 -0
  46. data/legacy_plugins/first.rb +11 -0
  47. data/legacy_plugins/head.rb +14 -0
  48. data/legacy_plugins/load_path.rb +21 -0
  49. data/legacy_plugins/plagger.rb +94 -0
  50. data/legacy_plugins/plugin_from_uri.rb +31 -0
  51. data/legacy_plugins/pluginbase.rb +4 -0
  52. data/legacy_plugins/print.rb +15 -0
  53. data/legacy_plugins/reverse.rb +10 -0
  54. data/legacy_plugins/send_msg.rb +18 -0
  55. data/legacy_plugins/stdin.rb +6 -0
  56. data/legacy_plugins/stdout.rb +6 -0
  57. data/lib/yapra/config.rb +103 -0
  58. data/lib/yapra/inflector.rb +55 -0
  59. data/lib/yapra/legacy_plugin/advance_mode_registry.rb +38 -0
  60. data/lib/yapra/legacy_plugin/base.rb +26 -0
  61. data/lib/yapra/legacy_plugin/compatible_mode_registry.rb +34 -0
  62. data/lib/yapra/legacy_plugin/registry_factory.rb +21 -0
  63. data/lib/yapra/legacy_plugin.rb +5 -0
  64. data/lib/yapra/pipeline.rb +74 -0
  65. data/lib/yapra/plugin/base.rb +14 -0
  66. data/lib/yapra/plugin/context_aware.rb +14 -0
  67. data/lib/yapra/plugin/erb_applier.rb +15 -0
  68. data/lib/yapra/plugin/feed_item_operator.rb +21 -0
  69. data/lib/yapra/plugin/mechanize_base.rb +26 -0
  70. data/lib/yapra/plugin.rb +5 -0
  71. data/lib/yapra/runtime.rb +36 -0
  72. data/lib/yapra/version.rb +9 -0
  73. data/lib/yapra.rb +44 -0
  74. data/lib-plugins/yapra/plugin/config/agent.rb +34 -0
  75. data/lib-plugins/yapra/plugin/config/basic_auth.rb +19 -0
  76. data/lib-plugins/yapra/plugin/config/web_post.rb +21 -0
  77. data/lib-plugins/yapra/plugin/feed/custom.rb +41 -0
  78. data/lib-plugins/yapra/plugin/feed/load.rb +29 -0
  79. data/lib-plugins/yapra/plugin/filter/entry_full_text.rb +59 -0
  80. data/lib-plugins/yapra/plugin/publish/file_download.rb +109 -0
  81. data/lib-plugins/yapra/plugin/publish/gmail.rb +27 -0
  82. data/lib-plugins/yapra/plugin/publish/imap.rb +82 -0
  83. data/lib-plugins/yapra/plugin/test/append_entry.rb +25 -0
  84. data/plugins/Filter/deduped.rb +57 -0
  85. data/plugins/Filter/sort.rb +28 -0
  86. data/plugins/Filter/subs.rb +16 -0
  87. data/script/console +10 -0
  88. data/script/destroy +14 -0
  89. data/script/generate +14 -0
  90. data/script/txt2html +82 -0
  91. data/setup.rb +1585 -0
  92. data/spec/spec.opts +1 -0
  93. data/spec/spec_helper.rb +11 -0
  94. data/spec/yapra_spec.rb +11 -0
  95. data/tasks/deployment.rake +34 -0
  96. data/tasks/environment.rake +7 -0
  97. data/tasks/rspec.rake +21 -0
  98. data/tasks/website.rake +17 -0
  99. data/website/index.html +115 -0
  100. data/website/index.txt +57 -0
  101. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  102. data/website/stylesheets/screen.css +138 -0
  103. data/website/template.html.erb +48 -0
  104. metadata +170 -0
@@ -0,0 +1,104 @@
1
+ ## author "emergent"
2
+ ## descr "post feed(s) to mixi diary"
3
+ ##
4
+ ## example <<EOE
5
+ ## when posting one diary per one feed
6
+ ## - module: publish::mixi_diary_writer
7
+ ## config:
8
+ ## username: test@test.com
9
+ ## password: ********
10
+ ##
11
+ ## when posting merged feeds to one diary
12
+ ## - module: publish::mixi_diary_writer
13
+ ## config:
14
+ ## username: test@test.com
15
+ ## password: ********
16
+ ## title: "フィード一覧"
17
+ ## merge_feeds: 1
18
+ ## EOE
19
+ ## config({ :username => Field.new("username to login", String, true),
20
+ ## :password => Field.new("password to login", String, true),
21
+ ## :merge_feeds => Field.new("aggregate feeds to one diary", String),
22
+ ## :title => Field.new("title when merge_feeds is on", String) })
23
+
24
+ require 'rubygems'
25
+ require 'mechanize'
26
+ require 'kconv'
27
+
28
+ class MixiDiaryWriter
29
+
30
+ def initialize username=nil, password=nil
31
+ @id = nil
32
+ @username = username
33
+ @password = password
34
+ @agent = WWW::Mechanize.new
35
+ end
36
+
37
+ def login username=@username, password=@password
38
+ if username == nil || password == nil
39
+ return
40
+ else
41
+ @username = username
42
+ @password = password
43
+ end
44
+ @agent.post('http://mixi.jp/login.pl',
45
+ { 'email' => @username,
46
+ 'password' => @password,
47
+ 'next_url' => '/home.pl' })
48
+ @home_page = @agent.get('http://mixi.jp/home.pl')
49
+ end
50
+
51
+ def edit title, content
52
+ if /add_diary\.pl\?id=(\d+)/ =~ @home_page.body
53
+ @id = $1
54
+ end
55
+
56
+ @edit_page = @agent.get('http://mixi.jp/add_diary.pl?id='+@id)
57
+
58
+ begin
59
+ edit_form = @edit_page.forms.name("diary").first
60
+ edit_form['diary_title'] = title.toeuc
61
+ edit_form['diary_body'] = content.toeuc
62
+ confirm_page = @agent.submit(edit_form)
63
+
64
+ conf_form = confirm_page.forms[0] # select 'hai'
65
+ @agent.submit(conf_form)
66
+ rescue => e
67
+ puts "Exception when posting diary"
68
+ puts e.message
69
+ puts e.backtrace.join("\n")
70
+ end
71
+ end
72
+
73
+ OK_TAGS = 'a|p|strong|em|u|del|blockquote'
74
+ def striptags str
75
+ str.gsub!(/<br.*?>/, "\n")
76
+ str.gsub!(/<[\/]{0,1}(?!(?:(?:#{OK_TAGS})(?:\s|>)))\w+[\s]{0,1}.*?>/, '')
77
+ str
78
+ end
79
+ end
80
+
81
+ def mixi_diary_writer(config, data)
82
+ title = config['title'] || data[0].title
83
+ content = []
84
+
85
+ if config['merge_feeds'] #.to_i == 1
86
+ data.each {|item|
87
+ content << {:title => title, :body => ('- <a href="'+item.link+'">'+item.title+"</a>\n"+item.description+"...\n\n" rescue item.to_s)}
88
+ }
89
+ else
90
+ data.each {|d|
91
+ # delete line feed and space at the top of content
92
+ content << {:title => d.title, :body => d.content_encoded.to_s.sub(/^(?:\s+)/, '')}
93
+ }
94
+ end
95
+
96
+ mdw = MixiDiaryWriter.new(config['username'], config['password'])
97
+
98
+ content.each {|entry|
99
+ mdw.login
100
+ mdw.edit entry[:title], mdw.striptags(entry[:body])
101
+ }
102
+
103
+ return data
104
+ end
@@ -0,0 +1,92 @@
1
+ ## Publish::scuttle - to post feed items to scuttle -- emergent
2
+ ##
3
+ ## - module: Publish::scuttle
4
+ ## config:
5
+ ## url: http://your.example.com/scuttle/
6
+ ## username: your_username
7
+ ## password: your_password
8
+ ## opt_tag: pragger
9
+ ## no_comment: 1
10
+ ##
11
+ require 'rubygems'
12
+ require 'mechanize'
13
+ require 'uri'
14
+ require 'kconv'
15
+
16
+ class Scuttle
17
+
18
+ def initialize url, username, password, proxy=nil
19
+ @post_url = url + 'api/posts/add?'
20
+ @username = username
21
+ @password = password
22
+ @agent = WWW::Mechanize.new
23
+ @agent.basic_auth(@username, @password)
24
+ if proxy && proxy.is_a?(Hash) && proxy['proxy_addr'] && proxy['proxy_port']
25
+ @agent.set_proxy(proxy['proxy_addr'], proxy['proxy_port'],
26
+ proxy['proxy_user'], proxy['proxy_pass'])
27
+ end
28
+ end
29
+
30
+ def post url, desc, option=nil
31
+ params = {}
32
+
33
+ params[:url] = url
34
+ params[:description] = desc
35
+
36
+ if option
37
+ params[:extended] = option["summary"] if option["summary"]
38
+ params[:dt] = option["datetime"] if option["datetime"]
39
+ params[:tags] = option["tags"] if option["tags"]
40
+ params[:replace] = 'no' if option["no_replace"]
41
+ params[:shared] = 'no' if option["private"]
42
+ end
43
+
44
+ req_param = []
45
+ params.each do |k,v|
46
+ req_param << k.to_s.toutf8 + '=' + v.toutf8 if (v.length > 0)
47
+ end
48
+ result = @agent.get(URI.encode(@post_url + req_param.join('&')))
49
+ if result.body =~ /code="done"/
50
+ return true
51
+ end
52
+ false
53
+ end
54
+ end
55
+
56
+ def get_tags entry
57
+ entry.dc_subjects.map do |s| s.content end.join(' ') rescue ''
58
+ end
59
+
60
+ def scuttle config, data
61
+ sleeptime = 3
62
+
63
+ if config['sleep']
64
+ sleeptime = config['sleep'].to_i
65
+ end
66
+
67
+ data.each {|entry|
68
+ print 'posting ' + entry.title + ': '
69
+
70
+ tags = get_tags entry
71
+ if config['opt_tag']
72
+ tags = [tags, config['opt_tag']].select{|t| t.length > 0}.join(' ')
73
+ end
74
+
75
+ summary = config['no_comment'] ? entry.description : ''
76
+
77
+ begin
78
+ agent = Scuttle.new(config['url'], config['username'], config['password'])
79
+ res = agent.post(entry.link, entry.title,
80
+ 'tags' => tags, 'summary' => summary)
81
+
82
+ if res then puts 'done' else puts 'failed' end
83
+ rescue
84
+ puts 'exception'
85
+ #raise
86
+ end
87
+
88
+ sleep sleeptime
89
+ }
90
+ return data
91
+ end
92
+
@@ -0,0 +1,35 @@
1
+ ##Publish::twitter -- itoshi
2
+ ##
3
+ ## from: http://itoshi.tv/d/?date=20071123#p01
4
+ ##
5
+ ##- module: Publish::twitter
6
+ ## config:
7
+ ## login: xxxxxx
8
+ ## password: xxx
9
+ ## check: 30##
10
+ ##
11
+
12
+ begin
13
+ require 'rubygems'
14
+ rescue LoadError
15
+ end
16
+ require 'twitter'
17
+ require 'kconv'
18
+
19
+ def twitter(config, data)
20
+ c = Twitter::Client.new(:login=>config["login"], :password=>config["password"])
21
+
22
+ posts = c.timeline_for(:me,:count=>config["check"])
23
+ posted_entries = posts.map do |post| post.text.gsub!(/ http.+$/, '') end
24
+
25
+ data.reverse.each {|item|
26
+ link = item.link
27
+ title = item.title.toutf8
28
+
29
+ next if posted_entries.include? title
30
+
31
+ comment = [title, link].join(' ')
32
+ s = c.status(:post, comment)
33
+ p comment
34
+ }
35
+ end
@@ -0,0 +1,38 @@
1
+ ## Load RSS from given URLs -- IKeJI
2
+ ##
3
+ ## Load RSS from given URLs.
4
+ ## If URL is an Array, all URLs in the array will be loaded.
5
+ ##
6
+ ## - module: RSS::load
7
+ ## config:
8
+ ## uri: http://www.example.com/hoge.rdf
9
+
10
+ require 'open-uri'
11
+ require 'rss/1.0'
12
+ require 'rss/2.0'
13
+ require 'rss/maker'
14
+
15
+ def load(config, data)
16
+ begin
17
+ rss_source =
18
+ if config['url'].is_a?(Array)
19
+ config['url'].map {|url| open(url) {|io| io.read } }
20
+ else
21
+ [ open(config['url']) {|r| r.read } ]
22
+ end
23
+ rescue
24
+ puts "LoadError File = #{config["url"]}"
25
+ return []
26
+ end
27
+
28
+ feeds = rss_source.collect {|cont|
29
+ begin
30
+ RSS::Parser.parse(cont)
31
+ rescue RSS::InvalidRSSError
32
+ RSS::Parser.parse(cont, false)
33
+ end
34
+ }
35
+
36
+ feeds.select {|f| f}.inject([]) {|acc,f| acc + f.items }
37
+ end
38
+
@@ -0,0 +1,41 @@
1
+ ## Save RSS as a file -- IKeJI
2
+ ##
3
+ ## Save RSS as a file.
4
+ ## Title, Link, and Description of the RSS can be set.
5
+ ## The input is expected to be an Array of RSS::RDF::Item.
6
+ ##
7
+ ## - module: RSS::save
8
+ ## config:
9
+ ## title: An Title
10
+ ## link: http://www.example.com/hoge.rdf
11
+ ## description: sample rdf
12
+
13
+ require "rss/maker"
14
+
15
+ @count = Time.now.to_i
16
+
17
+ def save(config,data)
18
+ rss = RSS::Maker.make("1.0") do |maker|
19
+ maker.channel.about = config['about'] || config['link'] || "http://example.net/"
20
+ maker.channel.title = config['title'] || "Pragger output"
21
+ maker.channel.description = config['description'] || ""
22
+ maker.channel.link = config['link'] || "http://example.net/"
23
+
24
+ data.each do |i|
25
+ if(i.instance_of?(RSS::RDF::Item))
26
+ i.setup_maker(maker)
27
+ else
28
+ item = maker.items.new_item
29
+ item.title = i.title rescue i.to_s
30
+ item.link = i.link rescue (config['link'] || "http://example.net/") + "\##{@count}"
31
+ item.description = i.description rescue i.to_s
32
+ item.date = i.date rescue Time.now
33
+ @count += 1
34
+ end
35
+ end
36
+ end
37
+ open(config["filename"],"w"){|w| w.puts rss }
38
+ return data
39
+ end
40
+
41
+
@@ -0,0 +1,5 @@
1
+ def load(config,data)
2
+ require "yaml"
3
+ return YAML.load_file(config["filename"]) || []
4
+ end
5
+
@@ -0,0 +1,9 @@
1
+ require "yaml"
2
+
3
+ def save(config,data)
4
+ File.open(config["filename"],"w") do |w|
5
+ YAML.dump(data,w)
6
+ end
7
+ return data
8
+ end
9
+
@@ -0,0 +1,5 @@
1
+ ## read data form argv -- takatoh
2
+
3
+ def argv(config,data)
4
+ return ARGV.clone
5
+ end
@@ -0,0 +1,18 @@
1
+ ## concat two data -- IKeJI
2
+ ##
3
+ ## concat two data plugin.
4
+ ## this plugin is concat two data.
5
+ ##
6
+ ## - module: concat
7
+ ## config:
8
+ ## - module: foo
9
+ ## - module: bar
10
+ ## - module: baz
11
+ ##
12
+
13
+
14
+ def concat(config,data)
15
+ data2 = eval_pragger(config,[])
16
+ return data+data2
17
+ end
18
+
@@ -0,0 +1,15 @@
1
+ ## constant list -- IKeJI
2
+ ##
3
+ ## constant list plugin.
4
+ ##
5
+ ## - module: const_list
6
+ ## config:
7
+ ## - a
8
+ ## - b
9
+ ## - c
10
+ ##
11
+
12
+ def const_list(config,data)
13
+ return config
14
+ end
15
+
@@ -0,0 +1,11 @@
1
+ ## first data plugin -- IKeJI
2
+ ##
3
+ ## this plugin returns only first data
4
+ ##
5
+ ## -moduel: first
6
+ ##
7
+
8
+ def first(config,data)
9
+ return [data.first]
10
+ end
11
+
@@ -0,0 +1,14 @@
1
+ ## head plugin -- IKeJI
2
+ ##
3
+ ## it looks like linux head command.
4
+ ## this example is like 'head -n 10'
5
+ ##
6
+ ## -module: head
7
+ ## config:
8
+ ## n: 10
9
+ ##
10
+
11
+ def head(config,data)
12
+ return data[0, config['n'].to_i]
13
+ end
14
+
@@ -0,0 +1,21 @@
1
+ ## Add path to $LOAD_PATH -- gtaka555
2
+ ##
3
+ ## Add path to $LOAD_PATH plugin.
4
+ ##
5
+ ## - module: load_path
6
+ ## config:
7
+ ## path:
8
+ ## - /home/foo/ruby/lib/1
9
+ ## - /home/foo/ruby/lib/2
10
+ ## - /home/foo/ruby/lib/3
11
+ ##
12
+
13
+ def load_path(config, data)
14
+ return data unless config.key?('path')
15
+
16
+ config['path'].each {|path|
17
+ $LOAD_PATH << path
18
+ }
19
+
20
+ data
21
+ end
@@ -0,0 +1,94 @@
1
+ ## Interleave Plagger processing -- Soutaro Matsumoto
2
+ ##
3
+ ## Invokes Plagger and process the input with your Plagger.
4
+ ## The input must be an Array of RSS::RDF::Item.
5
+ ## The output is an Array of RSS::RDF::Item.
6
+ ## If "debug" is a value evaluated to true, tempolary files for/from Plagger won't be deleted.
7
+ ## If "input" is not "feed", the input will be ignored.
8
+ ## If you omit "dir", the default is /var.
9
+ ## Make sure your system have /var directory and pragger/Plagger can write.
10
+ ##
11
+ ## - module: plagger
12
+ ## config:
13
+ ## input: feed
14
+ ## debug: false
15
+ ## dir: /var
16
+ ## plugins:
17
+ ## - module: Publish::CSV
18
+ ## config:
19
+ ## dir: /var
20
+ ## filename: a.csv
21
+
22
+ require 'rbconfig'
23
+ require 'open-uri'
24
+ require 'rss/1.0'
25
+ require 'rss/2.0'
26
+ require 'pathname'
27
+
28
+ raise LoadError unless ENV['PATH'].split(Config::CONFIG['PATH_SEPARATOR']).find {|dir|
29
+ File.executable?(File.join(dir, 'plagger')) || File.executable?(File.join(dir, 'plagger.bat'))
30
+ }
31
+
32
+ def plagger(config, data)
33
+ pla_con = config["plugins"]
34
+
35
+ if input_option(config) == :feed
36
+ pla_con = [{"module" => "Subscription::Feed", "config"=>{ "url" => "file:#{pla_input(config)}" }}] + pla_con
37
+ eval_pragger([{"module" => "save_rss", "config" => { "filename" => pla_input(config).to_s }}], data)
38
+ end
39
+
40
+ pla_con.push({"module" => "Publish::Feed",
41
+ "config" =>
42
+ {"dir" => "/var",
43
+ "format" => "RSS",
44
+ "filename" => pla_output(config).basename.to_s}})
45
+
46
+ pla_config(config).open("w") {|io| io.write to_plagger_yaml(YAML.dump({ "plugins" => pla_con })) }
47
+
48
+ system "plagger -c #{pla_config(config)}"
49
+
50
+ begin
51
+ RSS::Parser.parse(pla_output(config).read).items
52
+ rescue
53
+ []
54
+ ensure
55
+ unless config.has_key?("debug")
56
+ pla_config(config).delete
57
+ pla_input(config).delete
58
+ pla_output(config).delete
59
+ end
60
+ end
61
+ end
62
+
63
+ def pla_dir(config)
64
+ Pathname.new(config.has_key?("dir") ? config["dir"] : "/var")
65
+ end
66
+
67
+ def pla_config(config)
68
+ pla_dir(config) + "pla.yaml"
69
+ end
70
+
71
+ def pla_output(config)
72
+ pla_dir(config) + "pla_output"
73
+ end
74
+
75
+ def pla_input(config)
76
+ pla_dir(config) + "pla_input"
77
+ end
78
+
79
+ def input_option(config)
80
+ opt = config.has_key?("input") ? config["input"] : "nothing"
81
+ case opt
82
+ when "feed": :feed
83
+ when "nothing": :nothing
84
+ else
85
+ :nothing
86
+ end
87
+ end
88
+
89
+ def to_plagger_yaml(yaml)
90
+ a = yaml.split(/\n/)
91
+ ret = a[1]+"\n"
92
+ ret + a[2..(a.size-1)].collect {|x| " "+x }.join("\n")+"\n"
93
+ end
94
+
@@ -0,0 +1,31 @@
1
+ ## Load plugin from uri and evaluate it -- Soutaro Matsumoto
2
+ ##
3
+ ## Load plugiin from uri and evaluate it.
4
+ ## If you omit "name", the last component of the uri will be used as the name of plugin.
5
+ ##
6
+ ## - module: plugin_from_uri
7
+ ## config:
8
+ ## uri: http://some_host/some_path
9
+ ## name: super_plugin
10
+ ## config:
11
+ ## ** configuration for the plugin **
12
+
13
+ require 'open-uri'
14
+ require 'uri'
15
+
16
+ def plugin_from_uri(config, data)
17
+ uri = URI(config["uri"])
18
+ name = config["name"] || uri.path.split("/").last.gsub(/\..*$/,'')
19
+
20
+ body = open(uri.to_s) {|io| io.read}
21
+
22
+ plugin = Class.new(Plugin)
23
+ plugin.class_eval {
24
+ def initialize()
25
+ end
26
+ }
27
+ plugin.class_eval(body, uri.to_s, 1)
28
+
29
+ plugin.new().send(name, config["config"], data)
30
+ end
31
+
@@ -0,0 +1,4 @@
1
+ def pluginbase(config,data)
2
+ return []
3
+ end
4
+
@@ -0,0 +1,15 @@
1
+ ## pritty print plugin -- IKeJI
2
+ ##
3
+ ## it for debug
4
+ ## print data using pritty print
5
+ ##
6
+ ## -module: print
7
+ ##
8
+
9
+ require "pp"
10
+
11
+ def print(config,data)
12
+ pp data
13
+ return data
14
+ end
15
+
@@ -0,0 +1,10 @@
1
+ ## reverse plugin -- IKeJI
2
+ ##
3
+ ## it reverse data array
4
+ ##
5
+ ## -module: reverse
6
+ ##
7
+
8
+ def reverse(config, data)
9
+ data.reverse
10
+ end
@@ -0,0 +1,18 @@
1
+ ## Send Message Plugin -- Soutaro Matsumoto
2
+ ##
3
+ ## it invoke ruby method
4
+ ##
5
+ ## -module: send_msg
6
+ ## config:
7
+ ## method: to_s
8
+ ## params: 16
9
+ ##
10
+
11
+ def send_msg(config, data)
12
+ method = config['method'] || nil
13
+ params = config['params'] || []
14
+
15
+ data.collect {|x|
16
+ method ? x.send(method, *params) : x
17
+ }
18
+ end
@@ -0,0 +1,6 @@
1
+ ## Read data from stdin -- Soutaro Matsumoto
2
+
3
+ def stdin(config, data)
4
+ stdin_data = readlines
5
+ (config || { "input" => "concat" })["input"] == "nothing" ? stdin_data : data + stdin_data
6
+ end
@@ -0,0 +1,6 @@
1
+ ## Write data to stdout -- Soutaro Matsumoto
2
+
3
+ def stdout(config, data)
4
+ data.each {|x| puts x }
5
+ data
6
+ end