daioikachan 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/VERSION +1 -1
- data/daioikachan.gemspec +1 -0
- data/lib/fluent/plugin/in_daioikachan.rb +8 -2
- data/test/plugin/test_in_daioikachan.rb +40 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c78f4bd1547342b095bc02952b999849adea8af0
|
4
|
+
data.tar.gz: f153c9627506286d977d77b436cedc27d5cf1c83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8279164a4f7f8ba7a9ec3fda48b0428ee4cebe01bb53b76d172d4e4f9aba15aae4654c04f833db848f30376b6a5fbb15bbe8e955682e32f495dd0da7f37c2465
|
7
|
+
data.tar.gz: 0d959a59d2bbacffe1f717c578225fcbd70c525897ab76128ae967fa4d22fef9f17948a1296731d615083a2200d617e35ed5d3944b764f9108cb99412533a4ef
|
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/daioikachan.gemspec
CHANGED
@@ -46,6 +46,7 @@ module Fluent
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def on_request(env)
|
49
|
+
log.debug { "in_daioikachan: #{env.to_s}" }
|
49
50
|
@app.run(env)
|
50
51
|
end
|
51
52
|
|
@@ -73,8 +74,13 @@ module Fluent
|
|
73
74
|
# req = Rack::Request.new(env)
|
74
75
|
method = env['REQUEST_METHOD'.freeze] # req.method
|
75
76
|
path = URI.parse(env['REQUEST_URI'.freeze]).path # req.path
|
76
|
-
|
77
|
-
|
77
|
+
# Rack::Request.new should take care of this, but it did not
|
78
|
+
if env['CONTENT_TYPE'.freeze].start_with?('multipart/form-data'.freeze)
|
79
|
+
params = Rack::Multipart.parse_multipart(env)
|
80
|
+
else
|
81
|
+
body = env['rack.input'].read # req.body.read
|
82
|
+
params = Rack::Utils.parse_query(body)
|
83
|
+
end
|
78
84
|
|
79
85
|
begin
|
80
86
|
if method == 'POST'
|
@@ -18,6 +18,28 @@ class DaioikachanInputTest < Test::Unit::TestCase
|
|
18
18
|
http.request(req)
|
19
19
|
end
|
20
20
|
|
21
|
+
def post_multipart(path, params, header = {}, ssl = false)
|
22
|
+
http = Net::HTTP.new("127.0.0.1", PORT)
|
23
|
+
if ssl
|
24
|
+
http.use_ssl = true
|
25
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
26
|
+
end
|
27
|
+
req = Net::HTTP::Post.new(path, header)
|
28
|
+
req.set_content_type("multipart/form-data; boundary=myboundary")
|
29
|
+
|
30
|
+
body = ""
|
31
|
+
params.each do |key, val|
|
32
|
+
body.concat("--myboundary\r\n")
|
33
|
+
body.concat("content-disposition: form-data; name=\"#{key}\";\r\n")
|
34
|
+
body.concat("\r\n")
|
35
|
+
body.concat("#{val}\r\n")
|
36
|
+
end
|
37
|
+
body.concat("--myboundary--\r\n")
|
38
|
+
req.body = body
|
39
|
+
|
40
|
+
http.request(req)
|
41
|
+
end
|
42
|
+
|
21
43
|
def setup
|
22
44
|
Fluent::Test.setup
|
23
45
|
end
|
@@ -102,4 +124,22 @@ class DaioikachanInputTest < Test::Unit::TestCase
|
|
102
124
|
assert_equal "200", res.code
|
103
125
|
end
|
104
126
|
end
|
127
|
+
|
128
|
+
|
129
|
+
def test_multipart
|
130
|
+
d = create_driver
|
131
|
+
|
132
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
133
|
+
Fluent::Engine.now = time
|
134
|
+
|
135
|
+
d.expect_emit "privmsg.channel", time, {"command" => "privmsg", "channel" => "channel", "message" => "message"}
|
136
|
+
|
137
|
+
d.run do
|
138
|
+
d.expected_emits.each {|tag, time, record|
|
139
|
+
res = post_multipart("/privmsg", {command: "privmsg", channel: "channel", message: "message"})
|
140
|
+
puts res.body
|
141
|
+
assert_equal "200", res.code
|
142
|
+
}
|
143
|
+
end
|
144
|
+
end
|
105
145
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daioikachan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: test-unit
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: Ikachan compatible interface with multiple backends (IRC, Slack, etc)
|
98
112
|
email: sonots@gmail.com
|
99
113
|
executables:
|