rodimus 1.0.0 → 1.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.
- checksums.yaml +4 -4
- data/README.md +2 -5
- data/examples/rails_log/file_output.rb +1 -1
- data/examples/rails_log/run.rb +4 -0
- data/lib/rodimus/benchmark.rb +21 -6
- data/lib/rodimus/version.rb +1 -1
- data/test/rodimus/observable_test.rb +23 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b41faf166609c0301fa56b7b675f3be73b4a986d
|
4
|
+
data.tar.gz: dd8f0d1d9a73cb73c38dfea42e448cf36ab926ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdf745cb5fb1645602df330d5f32dc1121932c288ea1ddc8e4b8e40095ad7a1a6928b69272688a61089a6a356a2e439846c35e8abbac90700d159664a137213a
|
7
|
+
data.tar.gz: f7830584a6e02a39a3b82ebcd680762ff415ae7a971e832f5a5c805cf560a4b6a3f66179a50c4c2a27bc4a8d3374290dc2f1413993e5406bcda5ed7c44d00d59
|
data/README.md
CHANGED
@@ -12,9 +12,6 @@ __Why the name?__ Rodimus Prime is one of the leaders of the Autobots, and he
|
|
12
12
|
has a cool name. Naming a data transformation library after a Transformer
|
13
13
|
increases the coolness factor. It's science.
|
14
14
|
|
15
|
-
__NOTE:__ This library is still in the earliest phases of development. Things
|
16
|
-
are prone to change suddenly and rapidly. Use at your own risk.
|
17
|
-
|
18
15
|
## Installation
|
19
16
|
|
20
17
|
Add this line to your application's Gemfile:
|
@@ -40,14 +37,14 @@ destination.
|
|
40
37
|
|
41
38
|
In Rodimus, you create a transformation object, and then you add
|
42
39
|
one or more steps to its array of steps. You typically create steps by writing
|
43
|
-
your own classes that
|
40
|
+
your own classes that inherit from Rodimus::Step. When the transformation is
|
44
41
|
subsequently run, a new process is forked for each step. All processes are
|
45
42
|
connected together using pipes except for the first and last steps (those being the
|
46
43
|
source and destination steps). Each step then consumes rows of data from its
|
47
44
|
incoming pipe and performs some operation on it before writing it to the
|
48
45
|
outgoing pipe.
|
49
46
|
|
50
|
-
There are several methods on the Rodimus::Step
|
47
|
+
There are several methods on the Rodimus::Step class that are able to be
|
51
48
|
overridden for custom processing behavior before, during, or after the each
|
52
49
|
row is handled. If those aren't enough, you're also free to manipulate the
|
53
50
|
input/output objects (i.e. to redirect to standard out).
|
data/examples/rails_log/run.rb
CHANGED
@@ -3,6 +3,10 @@ require_relative 'log_input'
|
|
3
3
|
require_relative 'parse_connection'
|
4
4
|
require_relative 'file_output'
|
5
5
|
|
6
|
+
Rodimus.configure do |config|
|
7
|
+
config.benchmarking = true
|
8
|
+
end
|
9
|
+
|
6
10
|
log = File.expand_path('../rails_example.log', __FILE__)
|
7
11
|
t = Rodimus::Transformation.new
|
8
12
|
step1 = LogInput.new(log)
|
data/lib/rodimus/benchmark.rb
CHANGED
@@ -21,27 +21,42 @@ module Rodimus
|
|
21
21
|
private
|
22
22
|
|
23
23
|
def after_row
|
24
|
-
row_run_time = (Time.now.to_f - @
|
25
|
-
stats[:
|
24
|
+
row_run_time = (Time.now.to_f - @row_start_time).round(4)
|
25
|
+
stats[:processing] = (stats[:processing] + row_run_time).round(4)
|
26
26
|
stats[:min] = row_run_time if stats[:min] > row_run_time
|
27
27
|
stats[:max] = row_run_time if stats[:max] < row_run_time
|
28
28
|
end
|
29
29
|
|
30
30
|
def before_row
|
31
31
|
stats[:count] += 1
|
32
|
-
@
|
32
|
+
@row_start_time = Time.now.to_f
|
33
33
|
end
|
34
34
|
|
35
35
|
def finalize_stats(subject)
|
36
|
+
stats[:total] = (Time.now.to_f - @start_time).round(4)
|
36
37
|
if stats[:count] > 0
|
37
|
-
stats[:average] = (stats[:
|
38
|
+
stats[:average] = (stats[:processing] / stats[:count]).round(4)
|
38
39
|
end
|
39
40
|
|
40
|
-
Rodimus.logger.info
|
41
|
+
Rodimus.logger.info(subject) { summary }
|
41
42
|
end
|
42
43
|
|
43
44
|
def initialize_stats
|
44
|
-
@stats = {count: 0,
|
45
|
+
@stats = {count: 0, processing: 0, min: 1, max: 0, average: 0}
|
46
|
+
@start_time = Time.now.to_f
|
47
|
+
end
|
48
|
+
|
49
|
+
def summary
|
50
|
+
<<-EOS
|
51
|
+
\n\t\tTotal time: #{stats[:total]} seconds
|
52
|
+
\tTotal time spent processing: #{stats[:processing]} seconds
|
53
|
+
\tTotal time spent waiting: #{(stats[:total] - stats[:processing]).round(4)} seconds
|
54
|
+
\tTime ratio spent processing: #{(stats[:processing] / stats[:total]).round(4)}
|
55
|
+
\tTotal rows processed: #{stats[:count]}
|
56
|
+
\tFastest row: #{stats[:min]} seconds
|
57
|
+
\tSlowest row: #{stats[:max]} seconds
|
58
|
+
\tAverage row: #{stats[:average]} seconds
|
59
|
+
EOS
|
45
60
|
end
|
46
61
|
end
|
47
62
|
|
data/lib/rodimus/version.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'rodimus'
|
3
|
+
|
4
|
+
class TestObservable < MiniTest::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@fake_observer = Class.new do
|
7
|
+
attr_reader :subject, :event_type
|
8
|
+
|
9
|
+
def on_notify(subject, event_type)
|
10
|
+
@subject = subject
|
11
|
+
@event_type = event_type
|
12
|
+
end
|
13
|
+
end.new
|
14
|
+
@subject = Object.new.extend(Rodimus::Observable)
|
15
|
+
@subject.observers << @fake_observer
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_observer_notification
|
19
|
+
@subject.notify(@subject, :test_event)
|
20
|
+
assert_equal @fake_observer.subject, @subject
|
21
|
+
assert_equal @fake_observer.event_type, :test_event
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rodimus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Rice
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- lib/rodimus/transformation.rb
|
72
72
|
- lib/rodimus/version.rb
|
73
73
|
- rodimus.gemspec
|
74
|
+
- test/rodimus/observable_test.rb
|
74
75
|
- test/rodimus/observing_test.rb
|
75
76
|
- test/rodimus/step_test.rb
|
76
77
|
- test/rodimus/transformation_test.rb
|
@@ -100,6 +101,7 @@ specification_version: 4
|
|
100
101
|
summary: An ETL (Extract-Transform-Load) library that uses a forking process model
|
101
102
|
for concurrency.
|
102
103
|
test_files:
|
104
|
+
- test/rodimus/observable_test.rb
|
103
105
|
- test/rodimus/observing_test.rb
|
104
106
|
- test/rodimus/step_test.rb
|
105
107
|
- test/rodimus/transformation_test.rb
|