rflow-components-file 1.1.1 → 1.2.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3fb18f29b55805334491346a6b5367fd9d2b0aa
|
4
|
+
data.tar.gz: 9d34329433db0a8bfe12ed2571407bcdcc60e087
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ca31d49b46b5cf32922db20d8cc3d2c9dfe11891c3805ddbebea19df4b0d08cb104918d1c2c3f468b2e0a6b8f03a5bb64022519078e46e9b3ae580d448962d3
|
7
|
+
data.tar.gz: 211b962929e93b7dd6f3147bad0336370e7ad653842dede1584d8005f7f2c0d3ab2fb13baf4447b4d443653a1d6ce9e77a3de89568230f374894d293decc02b6
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.1
|
1
|
+
ruby-2.3.1
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'uuidtools'
|
2
|
+
|
1
3
|
class RFlow
|
2
4
|
module Components
|
3
5
|
module File
|
@@ -30,7 +32,6 @@ class RFlow
|
|
30
32
|
# if passed properties, will look for data_uuid property and use as suffix preamble
|
31
33
|
def write_to_file(properties)
|
32
34
|
properties ||= {}
|
33
|
-
@output_file_entropy = 1
|
34
35
|
begin
|
35
36
|
final_output_file_name = output_file_name(properties)
|
36
37
|
|
@@ -48,11 +49,7 @@ class RFlow
|
|
48
49
|
end
|
49
50
|
::File.rename(temp_output_file_path, final_output_file_path)
|
50
51
|
final_output_file_path
|
51
|
-
rescue Errno::EEXIST => e
|
52
|
-
RFlow.logger.debug { "#{self.class}: File #{temp_output_file_path} exists, increasing entropy" }
|
53
|
-
@output_file_entropy += 1
|
54
|
-
retry
|
55
|
-
rescue StandardError => e
|
52
|
+
rescue StandardError, Errno::EEXIST => e
|
56
53
|
RFlow.logger.error { "#{self.class} encountered #{e.message} when creating #{temp_output_file_path}" }
|
57
54
|
begin
|
58
55
|
::File.delete(temp_output_file_path)
|
@@ -65,12 +62,9 @@ class RFlow
|
|
65
62
|
|
66
63
|
private
|
67
64
|
def output_file_name(properties)
|
68
|
-
uuid = properties['data_uuid']
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
def output_file_entropy_string
|
73
|
-
sprintf("%04d", @output_file_entropy || 1)
|
65
|
+
uuid = properties['data_uuid'] || UUIDTools::UUID.random_create.to_s
|
66
|
+
priority = properties['priority'] || 0
|
67
|
+
"#{file_name_prefix}.#{'%03d' % priority}.#{current_timestamp}.#{uuid}#{file_name_suffix}"
|
74
68
|
end
|
75
69
|
|
76
70
|
def current_timestamp
|
@@ -13,12 +13,22 @@ class RFlow
|
|
13
13
|
let(:component) { described_class.new.tap {|c| c.configure!(config) } }
|
14
14
|
|
15
15
|
it 'should correctly process file name prefix/suffix when given message properties with no uuid' do
|
16
|
-
expect(component.send(:output_file_name, {})).to match(/boom
|
16
|
+
expect(component.send(:output_file_name, {})).to match(/boom\.000\..+\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.town/)
|
17
17
|
end
|
18
18
|
|
19
|
-
it 'should correctly process file name prefix/suffix when given message properties' do
|
19
|
+
it 'should correctly process file name prefix/suffix when given message properties with priority' do
|
20
|
+
props = { 'priority' => 5 }
|
21
|
+
expect(component.send(:output_file_name, props)).to match(/boom\.005\..+\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.town/)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should correctly process file name prefix/suffix when given message properties with uuid' do
|
20
25
|
props = { 'data_uuid' => 'uuid' }
|
21
|
-
expect(component.send(:output_file_name, props)).to match(/boom
|
26
|
+
expect(component.send(:output_file_name, props)).to match(/boom\.000\..+\.uuid\.town/)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should correctly process file name prefix/suffix when given message properties with uuid and priority' do
|
30
|
+
props = { 'data_uuid' => 'uuid', 'priority' => 5 }
|
31
|
+
expect(component.send(:output_file_name, props)).to match(/boom\.005\..+\.uuid\.town/)
|
22
32
|
end
|
23
33
|
|
24
34
|
it "should do stuff" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rflow-components-file
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael L. Artz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rflow
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
118
|
rubyforge_project: rflow-components-file
|
119
|
-
rubygems_version: 2.
|
119
|
+
rubygems_version: 2.5.1
|
120
120
|
signing_key:
|
121
121
|
specification_version: 4
|
122
122
|
summary: Components that operate on files for the RFlow FBP framework
|