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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad1139d5395c7b6a2a9f193bfc13d2446030b696
4
- data.tar.gz: e9f1835edb94046e96e08be3ebcd027c0f7c3492
3
+ metadata.gz: ddeca61e81fb7b800e3303e9a1c45dc66dfbb68f
4
+ data.tar.gz: b2220fb1bbf8a26049ce8a84380346447a70c748
5
5
  SHA512:
6
- metadata.gz: 8fde9ba18ecae845ecd194b33d4a3f9d8417c6c5f3a11d1b55a95b055f3418dcd7203fe5c33a5131d58f812242e02109c7ba2ed912223ea07a7f04ab9f54df92
7
- data.tar.gz: 9006124a9343e7eaeaa985ba23393c9477958e19a80752d61ee08c5bdb09ed9db56bc1f53ec1c83fb40a627a8e918ad1caf99de6c093b8169dab6bdd4478b967
6
+ metadata.gz: 2617aa985f4baeeb62ba55211a2fb33f557f1834a67769ccd6db037fabd3603a36f2f1b75fdd92965c66a574e4b745cdff4aabf1d3b5c788a1b105e4097da8e7
7
+ data.tar.gz: c051aa80418c85b71a0dc663076953a52c7ee13cf60a57f438ceac8795ddc80e78abe97c9b45792a92d1d67bf8bbb1548811571129492571440ead92a16c1d52
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,3 @@
1
+ # Transmission
2
+
3
+ Moving objects around using chunks
@@ -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
@@ -0,0 +1,7 @@
1
+ require File.expand_path('../../lib/nd_transmission', __FILE__)
2
+
3
+ RSpec.configure do |config|
4
+ config.order = "random"
5
+ config.before(:each) { GC.disable }
6
+ config.after(:each) { GC.enable }
7
+ end
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.1
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-08-21 00:00:00.000000000 Z
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: