rflow-components-file 1.0.0a1 → 1.0.0a2
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.
- checksums.yaml +7 -0
- data/.rspec +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/lib/rflow/components/file/directory_watcher.rb +24 -32
- data/lib/rflow/components/file/extensions.rb +0 -4
- data/lib/rflow/components/file/output_raw_to_files.rb +0 -8
- data/lib/rflow/components/file/version.rb +1 -1
- data/lib/rflow/components/file.rb +0 -1
- data/rflow-components-file.gemspec +3 -2
- data/spec/rflow/components/file/extensions/file_extension_spec.rb +48 -0
- data/spec/rflow/components/file/output_raw_to_files_spec.rb +36 -0
- data/spec/schema_spec.rb +6 -10
- data/spec/spec_helper.rb +3 -3
- metadata +40 -33
- data/spec/directory_watcher_spec.rb +0 -4
- data/spec/extensions_spec.rb +0 -49
- data/spec/output_raw_to_files_spec.rb +0 -36
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 49e0feafd2bf3538bb54fc26b5397eb80990d8d5
|
4
|
+
data.tar.gz: c0f1749b1ea6370addc49da2bb445fe35618c231
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 694d39fb20d27a10ea09c5599916fb015f90c636987b8254ec6ca229716247b58823c5599a085ead9e1b37ab58618152e9a7e2658c012d856f3a2812d9aad1a4
|
7
|
+
data.tar.gz: 58287bf900d590961d93f8db64de94eafcec18faa336cc9312922e294fe381ee70b94ffb6bb481ba836fdbacaef4a89cf4750ed5c3c3ef5ff3661b1d10c8d6e1
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color -fd
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rflow-dev
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.1.1
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'rflow/component'
|
2
|
-
|
3
2
|
require 'digest/md5'
|
4
3
|
|
5
4
|
class RFlow
|
@@ -38,7 +37,6 @@ class RFlow
|
|
38
37
|
# TODO: more error checking of input config
|
39
38
|
end
|
40
39
|
|
41
|
-
|
42
40
|
# TODO: optimize sending of messages based on what is connected
|
43
41
|
def run!
|
44
42
|
timer = EventMachine::PeriodicTimer.new(poll_interval) do
|
@@ -47,32 +45,30 @@ class RFlow
|
|
47
45
|
# modified file first
|
48
46
|
file_paths = Dir.glob(::File.join(@directory_path, @file_name_glob)).sort_by {|f| test(?M, f)}
|
49
47
|
|
50
|
-
file_paths.first(@files_per_poll).each do |
|
51
|
-
RFlow.logger.debug "Importing #{
|
52
|
-
::File.open(
|
53
|
-
|
54
|
-
|
55
|
-
RFlow.logger.debug "read #{
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
raw_message.data.raw = file_content
|
70
|
-
raw_port.send_message raw_message
|
48
|
+
file_paths.first(@files_per_poll).each do |path|
|
49
|
+
RFlow.logger.debug "Importing #{path}"
|
50
|
+
::File.open(path, 'r:BINARY') do |file|
|
51
|
+
content = file.read
|
52
|
+
|
53
|
+
RFlow.logger.debug "read #{content.bytesize} bytes of #{file.size} in #{file.path}, md5 #{Digest::MD5.hexdigest(content)}"
|
54
|
+
|
55
|
+
file_port.send_message(RFlow::Message.new('RFlow::Message::Data::File').tap do |m|
|
56
|
+
m.data.path = ::File.expand_path(file.path)
|
57
|
+
m.data.size = file.size
|
58
|
+
m.data.content = content
|
59
|
+
m.data.creation_timestamp = file.ctime
|
60
|
+
m.data.modification_timestamp = file.mtime
|
61
|
+
m.data.access_timestamp = file.atime
|
62
|
+
end)
|
63
|
+
|
64
|
+
raw_port.send_message(RFlow::Message.new('RFlow::Message::Data::Raw').tap do |m|
|
65
|
+
m.data.raw = content
|
66
|
+
end)
|
71
67
|
end
|
72
68
|
|
73
69
|
if @remove_files
|
74
|
-
RFlow.logger.debug "Removing #{::File.join(@directory_path,
|
75
|
-
::File.delete
|
70
|
+
RFlow.logger.debug "Removing #{::File.join(@directory_path, path)}"
|
71
|
+
::File.delete path
|
76
72
|
end
|
77
73
|
end
|
78
74
|
end
|
@@ -80,15 +76,11 @@ class RFlow
|
|
80
76
|
|
81
77
|
def to_boolean(string)
|
82
78
|
case string
|
83
|
-
when /^true$/i, '1', true
|
84
|
-
|
85
|
-
|
86
|
-
false
|
87
|
-
else
|
88
|
-
raise ArgumentError, "'#{string}' cannot be coerced to a boolean value"
|
79
|
+
when /^true$/i, '1', true; true
|
80
|
+
when /^false/i, '0', false; false
|
81
|
+
else raise ArgumentError, "'#{string}' cannot be coerced to a boolean value"
|
89
82
|
end
|
90
83
|
end
|
91
|
-
|
92
84
|
end
|
93
85
|
end
|
94
86
|
end
|
@@ -1,10 +1,7 @@
|
|
1
1
|
class RFlow
|
2
2
|
module Components
|
3
3
|
module File
|
4
|
-
|
5
|
-
# The set of extensions to add capability to File data types
|
6
4
|
module Extensions
|
7
|
-
|
8
5
|
# Need to be careful when extending to not clobber data already in data_object
|
9
6
|
module FileExtension
|
10
7
|
def self.extended(base_data)
|
@@ -50,7 +47,6 @@ class RFlow
|
|
50
47
|
end
|
51
48
|
end
|
52
49
|
end
|
53
|
-
|
54
50
|
end
|
55
51
|
end
|
56
52
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'eventmachine'
|
2
2
|
require 'rflow/component'
|
3
|
-
|
4
3
|
require 'digest/md5'
|
5
4
|
|
6
5
|
class RFlow
|
@@ -34,7 +33,6 @@ class RFlow
|
|
34
33
|
# TODO: more error checking of input config
|
35
34
|
end
|
36
35
|
|
37
|
-
|
38
36
|
def process_message(input_port, input_port_key, connection, message)
|
39
37
|
return unless message.data_type_name == 'RFlow::Message::Data::Raw'
|
40
38
|
|
@@ -62,25 +60,19 @@ class RFlow
|
|
62
60
|
final_output_file_path
|
63
61
|
end
|
64
62
|
|
65
|
-
|
66
63
|
private
|
67
|
-
|
68
|
-
|
69
64
|
def output_file_name
|
70
65
|
"#{file_name_prefix}.#{current_timestamp}.#{output_file_entropy_string}#{file_name_suffix}"
|
71
66
|
end
|
72
67
|
|
73
|
-
|
74
68
|
def output_file_entropy_string
|
75
69
|
sprintf("%04d", @output_file_entropy || 1)
|
76
70
|
end
|
77
71
|
|
78
|
-
|
79
72
|
def current_timestamp
|
80
73
|
time = Time.now
|
81
74
|
time.utc.strftime("%Y%m%d_%H%M%S.") + "%06d" % time.utc.usec
|
82
75
|
end
|
83
|
-
|
84
76
|
end
|
85
77
|
end
|
86
78
|
end
|
@@ -21,8 +21,9 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
22
|
s.require_paths = ["lib"]
|
23
23
|
|
24
|
-
s.add_dependency 'rflow', '~> 1.0.
|
24
|
+
s.add_dependency 'rflow', '~> 1.0.0a2'
|
25
25
|
|
26
|
-
s.add_development_dependency 'rspec', '~> 2.
|
26
|
+
s.add_development_dependency 'rspec', '~> 2.99'
|
27
|
+
s.add_development_dependency 'rspec-collection_matchers', '~> 0.0.4'
|
27
28
|
s.add_development_dependency 'rake', '~> 0.8'
|
28
29
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
class RFlow
|
5
|
+
module Components
|
6
|
+
module File
|
7
|
+
module Extensions
|
8
|
+
describe FileExtension do
|
9
|
+
it "should add the extension to RFlow::Configuration" do
|
10
|
+
Configuration.available_data_extensions['RFlow::Message::Data::File'].should include(described_class)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should set the defaults" do
|
14
|
+
file = Message.new('RFlow::Message::Data::File').data.tap do |d|
|
15
|
+
d.path.should == '/'
|
16
|
+
d.size.should == 0
|
17
|
+
d.content.should == ''
|
18
|
+
d.creation_timestamp.should be_nil
|
19
|
+
d.modification_timestamp.should be_nil
|
20
|
+
d.access_timestamp.should be_nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should correctly use integers or strings for size field" do
|
25
|
+
Message.new('RFlow::Message::Data::File').data.tap do |d|
|
26
|
+
d.size.should == 0
|
27
|
+
d.size = 10
|
28
|
+
d.size.should == 10
|
29
|
+
d.size = '20'
|
30
|
+
d.size == 20
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should correctly use Time or xmlschema strings for timestamp fields" do
|
35
|
+
Message.new('RFlow::Message::Data::File').data.tap do |d|
|
36
|
+
now = Time.now
|
37
|
+
d.creation_timestamp.should == nil
|
38
|
+
d.creation_timestamp = now
|
39
|
+
d.creation_timestamp.should == Time.xmlschema(now.xmlschema(9))
|
40
|
+
d.creation_timestamp = now.xmlschema
|
41
|
+
d.creation_timestamp.should == Time.xmlschema(now.xmlschema)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class RFlow
|
4
|
+
module Components
|
5
|
+
module File
|
6
|
+
describe OutputRawToFiles do
|
7
|
+
let(:component_config) do
|
8
|
+
OpenStruct.new(:name => 'port name',
|
9
|
+
:uuid => 0,
|
10
|
+
:input_ports => [],
|
11
|
+
:output_ports => [],
|
12
|
+
:options => {
|
13
|
+
'file_name_prefix' => 'boom',
|
14
|
+
'file_name_suffix' => '.town',
|
15
|
+
'directory_path' => '/tmp'})
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:component) { described_class.new(component_config).tap {|c| c.configure!(component_config.options) } }
|
19
|
+
|
20
|
+
it "should correctly process file name prefix/suffix" do
|
21
|
+
component.send(:output_file_name).should match(/boom.*0001.town/)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should do stuff" do
|
25
|
+
message = Message.new('RFlow::Message::Data::Raw').tap do |m|
|
26
|
+
m.data.raw = 'boomertown'
|
27
|
+
end
|
28
|
+
|
29
|
+
output_file_path = component.process_message nil, nil, nil, message
|
30
|
+
|
31
|
+
::File.exist?(output_file_path).should be true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/schema_spec.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
|
-
require 'spec_helper
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'RFlow::Message::Data::File Avro Schema' do
|
4
|
-
|
5
|
-
@schema_string = RFlow::Configuration.available_data_types['RFlow::Message::Data::File']['avro']
|
6
|
-
end
|
4
|
+
let(:schema) { RFlow::Configuration.available_data_types['RFlow::Message::Data::File']['avro'] }
|
7
5
|
|
8
6
|
it "should encode and decode an object" do
|
9
7
|
file = {
|
@@ -15,14 +13,12 @@ describe 'RFlow::Message::Data::File Avro Schema' do
|
|
15
13
|
'access_timestamp' => 'ACCESSEDTIMESTRING'
|
16
14
|
}
|
17
15
|
|
18
|
-
expect {encode_avro(
|
19
|
-
|
16
|
+
expect { encode_avro(schema, file) }.to_not raise_error
|
17
|
+
encoded_file = encode_avro(schema, file)
|
20
18
|
|
21
|
-
expect {decode_avro(
|
22
|
-
decoded_file = decode_avro(
|
19
|
+
expect { decode_avro(schema, encoded_file) }.to_not raise_error
|
20
|
+
decoded_file = decode_avro(schema, encoded_file)
|
23
21
|
|
24
22
|
decoded_file.should == file
|
25
|
-
|
26
23
|
end
|
27
24
|
end
|
28
|
-
|
data/spec/spec_helper.rb
CHANGED
@@ -3,11 +3,11 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'rflow-c
|
|
3
3
|
require 'logger'
|
4
4
|
|
5
5
|
RFlow.logger = Logger.new STDOUT
|
6
|
+
RFlow.logger.level = 5
|
6
7
|
|
7
|
-
def decode_avro(schema_string,
|
8
|
+
def decode_avro(schema_string, data)
|
8
9
|
schema = Avro::Schema.parse(schema_string)
|
9
|
-
|
10
|
-
Avro::IO::DatumReader.new(schema, schema).read Avro::IO::BinaryDecoder.new(sio)
|
10
|
+
Avro::IO::DatumReader.new(schema, schema).read Avro::IO::BinaryDecoder.new(StringIO.new(data))
|
11
11
|
end
|
12
12
|
|
13
13
|
def encode_avro(schema_string, object)
|
metadata
CHANGED
@@ -1,62 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rflow-components-file
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease: 5
|
4
|
+
version: 1.0.0a2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Michael L. Artz
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-04
|
11
|
+
date: 2014-06-04 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rflow
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.0.
|
19
|
+
version: 1.0.0a2
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.0.
|
26
|
+
version: 1.0.0a2
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version: '2.
|
33
|
+
version: '2.99'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version: '2.
|
40
|
+
version: '2.99'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-collection_matchers
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.0.4
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.0.4
|
46
55
|
- !ruby/object:Gem::Dependency
|
47
56
|
name: rake
|
48
57
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
58
|
requirements:
|
51
|
-
- - ~>
|
59
|
+
- - "~>"
|
52
60
|
- !ruby/object:Gem::Version
|
53
61
|
version: '0.8'
|
54
62
|
type: :development
|
55
63
|
prerelease: false
|
56
64
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
65
|
requirements:
|
59
|
-
- - ~>
|
66
|
+
- - "~>"
|
60
67
|
- !ruby/object:Gem::Version
|
61
68
|
version: '0.8'
|
62
69
|
description: Components that operate on files for the RFlow FBP framework. Also includes
|
@@ -67,8 +74,11 @@ executables: []
|
|
67
74
|
extensions: []
|
68
75
|
extra_rdoc_files: []
|
69
76
|
files:
|
70
|
-
- .gitignore
|
71
|
-
- .
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".ruby-gemset"
|
80
|
+
- ".ruby-version"
|
81
|
+
- ".travis.yml"
|
72
82
|
- Gemfile
|
73
83
|
- LICENSE
|
74
84
|
- README.md
|
@@ -81,39 +91,36 @@ files:
|
|
81
91
|
- lib/rflow/components/file/version.rb
|
82
92
|
- rflow-components-file.gemspec
|
83
93
|
- schema/file.avsc
|
84
|
-
- spec/
|
85
|
-
- spec/
|
86
|
-
- spec/output_raw_to_files_spec.rb
|
94
|
+
- spec/rflow/components/file/extensions/file_extension_spec.rb
|
95
|
+
- spec/rflow/components/file/output_raw_to_files_spec.rb
|
87
96
|
- spec/schema_spec.rb
|
88
97
|
- spec/spec_helper.rb
|
89
98
|
homepage: https://github.com/redjack/rflow-components-file
|
90
99
|
licenses:
|
91
100
|
- Apache-2.0
|
101
|
+
metadata: {}
|
92
102
|
post_install_message:
|
93
103
|
rdoc_options: []
|
94
104
|
require_paths:
|
95
105
|
- lib
|
96
106
|
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
107
|
requirements:
|
99
|
-
- -
|
108
|
+
- - ">="
|
100
109
|
- !ruby/object:Gem::Version
|
101
110
|
version: '1.9'
|
102
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
-
none: false
|
104
112
|
requirements:
|
105
|
-
- -
|
113
|
+
- - ">"
|
106
114
|
- !ruby/object:Gem::Version
|
107
115
|
version: 1.3.1
|
108
116
|
requirements: []
|
109
117
|
rubyforge_project: rflow-components-file
|
110
|
-
rubygems_version:
|
118
|
+
rubygems_version: 2.2.2
|
111
119
|
signing_key:
|
112
|
-
specification_version:
|
120
|
+
specification_version: 4
|
113
121
|
summary: Components that operate on files for the RFlow FBP framework
|
114
122
|
test_files:
|
115
|
-
- spec/
|
116
|
-
- spec/
|
117
|
-
- spec/output_raw_to_files_spec.rb
|
123
|
+
- spec/rflow/components/file/extensions/file_extension_spec.rb
|
124
|
+
- spec/rflow/components/file/output_raw_to_files_spec.rb
|
118
125
|
- spec/schema_spec.rb
|
119
126
|
- spec/spec_helper.rb
|
data/spec/extensions_spec.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'spec_helper.rb'
|
2
|
-
|
3
|
-
require 'time'
|
4
|
-
|
5
|
-
describe RFlow::Components::File::Extensions::FileExtension do
|
6
|
-
before(:each) do
|
7
|
-
@schema_string = RFlow::Configuration.available_data_types['RFlow::Message::Data::File']['avro']
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should add the extension to RFlow::Configuration" do
|
11
|
-
RFlow::Configuration.available_data_extensions['RFlow::Message::Data::File'].should include(described_class)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should set the defaults" do
|
15
|
-
file = RFlow::Message.new('RFlow::Message::Data::File')
|
16
|
-
|
17
|
-
file.data.path.should == '/'
|
18
|
-
file.data.size.should == 0
|
19
|
-
file.data.content.should == ''
|
20
|
-
file.data.creation_timestamp.should == nil
|
21
|
-
file.data.modification_timestamp.should == nil
|
22
|
-
file.data.access_timestamp.should == nil
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should correctly use integers or strings for size field" do
|
26
|
-
file = RFlow::Message.new('RFlow::Message::Data::File')
|
27
|
-
|
28
|
-
file.data.size.should == 0
|
29
|
-
file.data.size = 10
|
30
|
-
file.data.size.should == 10
|
31
|
-
file.data.size = '20'
|
32
|
-
file.data.size == 20
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should correctly use Time or xmlschema strings for timestamp fields" do
|
36
|
-
file = RFlow::Message.new('RFlow::Message::Data::File')
|
37
|
-
|
38
|
-
file.data.creation_timestamp.should == nil
|
39
|
-
now = Time.now
|
40
|
-
|
41
|
-
file.data.creation_timestamp = now
|
42
|
-
file.data.creation_timestamp.should == Time.xmlschema(now.xmlschema(9))
|
43
|
-
|
44
|
-
file.data.creation_timestamp = now.xmlschema
|
45
|
-
file.data.creation_timestamp.should == Time.xmlschema(now.xmlschema)
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'spec_helper.rb'
|
2
|
-
|
3
|
-
describe RFlow::Components::File::OutputRawToFiles do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
end
|
7
|
-
|
8
|
-
let :component_config do
|
9
|
-
OpenStruct.new(:name => 'port name',
|
10
|
-
:uuid => 0,
|
11
|
-
:input_ports => [],
|
12
|
-
:output_ports => [],
|
13
|
-
:options => {
|
14
|
-
'file_name_prefix' => 'boom',
|
15
|
-
'file_name_suffix' => '.town',
|
16
|
-
'directory_path' => '/tmp'})
|
17
|
-
end
|
18
|
-
|
19
|
-
let :component do
|
20
|
-
described_class.new(component_config)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should correctly process file name prefix/suffix" do
|
24
|
-
component.send(:output_file_name).should match(/boom.*0001.town/)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should do stuff" do
|
28
|
-
message = RFlow::Message.new('RFlow::Message::Data::Raw')
|
29
|
-
message.data.raw = 'boomertown'
|
30
|
-
|
31
|
-
output_file_path = component.process_message nil, nil, nil, message
|
32
|
-
|
33
|
-
File.exist?(output_file_path).should be_true
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|