nd_transmission 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/README.md +3 -0
- data/lib/nd_transmission/base.rb +26 -0
- data/nd_transmission.gemspec +15 -0
- data/spec/lib/nd_transmission_spec.rb +35 -0
- data/spec/spec_helper.rb +7 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddeca61e81fb7b800e3303e9a1c45dc66dfbb68f
|
4
|
+
data.tar.gz: b2220fb1bbf8a26049ce8a84380346447a70c748
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2617aa985f4baeeb62ba55211a2fb33f557f1834a67769ccd6db037fabd3603a36f2f1b75fdd92965c66a574e4b745cdff4aabf1d3b5c788a1b105e4097da8e7
|
7
|
+
data.tar.gz: c051aa80418c85b71a0dc663076953a52c7ee13cf60a57f438ceac8795ddc80e78abe97c9b45792a92d1d67bf8bbb1548811571129492571440ead92a16c1d52
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module NdTransmission
|
2
|
+
class Base
|
3
|
+
attr_accessor :origin, :dest, :chunk_size
|
4
|
+
|
5
|
+
def initialize config
|
6
|
+
self.chunk_size = config.delete(:chunk_size) || 1
|
7
|
+
self.origin, self.dest = config.keys.first, config.values.first
|
8
|
+
end
|
9
|
+
|
10
|
+
def transmit
|
11
|
+
in_chunks do |chunk|
|
12
|
+
dest.receive chunk
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def in_chunks
|
17
|
+
return to_enum(__callee__) unless block_given?
|
18
|
+
|
19
|
+
yield origins.shift(chunk_size) while origins.any?
|
20
|
+
end
|
21
|
+
|
22
|
+
def origins
|
23
|
+
@origins ||= origin.to_transmit
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'nd_transmission'
|
3
|
+
s.version = '0.0.2'
|
4
|
+
s.date = '2014-09-12'
|
5
|
+
s.summary = "Remote objects synchronization."
|
6
|
+
s.description = ""
|
7
|
+
s.authors = ["Diego Aguir Selzlein"]
|
8
|
+
s.email = 'diegoselzlein@gmail.com'
|
9
|
+
|
10
|
+
s.files = `git ls-files`.split("\n")
|
11
|
+
s.require_paths = ["lib"]
|
12
|
+
|
13
|
+
s.homepage = 'https://github.com/nerde/nd_transmission'
|
14
|
+
s.license = 'MIT'
|
15
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Origin
|
4
|
+
def self.to_transmit
|
5
|
+
[1, 2, 3]
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class Dest
|
10
|
+
def self.received
|
11
|
+
@received ||= []
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.receive data
|
15
|
+
received << data
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe NdTransmission::Base do
|
20
|
+
before do
|
21
|
+
Dest.received.clear
|
22
|
+
end
|
23
|
+
|
24
|
+
it "moves objects" do
|
25
|
+
NdTransmission::Base.new(Origin => Dest).transmit
|
26
|
+
expect(Dest.received).to eq [[1], [2], [3]]
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'a chunk size is given' do
|
30
|
+
it "moves objects in chunks" do
|
31
|
+
NdTransmission::Base.new(Origin => Dest, chunk_size: 2).transmit
|
32
|
+
expect(Dest.received).to eq [[1, 2], [3]]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nd_transmission
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Diego Aguir Selzlein
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ''
|
14
14
|
email: diegoselzlein@gmail.com
|
@@ -16,7 +16,13 @@ executables: []
|
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
|
+
- ".rspec"
|
20
|
+
- README.md
|
19
21
|
- lib/nd_transmission.rb
|
22
|
+
- lib/nd_transmission/base.rb
|
23
|
+
- nd_transmission.gemspec
|
24
|
+
- spec/lib/nd_transmission_spec.rb
|
25
|
+
- spec/spec_helper.rb
|
20
26
|
homepage: https://github.com/nerde/nd_transmission
|
21
27
|
licenses:
|
22
28
|
- MIT
|
@@ -42,3 +48,4 @@ signing_key:
|
|
42
48
|
specification_version: 4
|
43
49
|
summary: Remote objects synchronization.
|
44
50
|
test_files: []
|
51
|
+
has_rdoc:
|