filey-diff 1.3.1 → 1.4.0

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: 818c93ae3c9c0f5651463f55fb43d5e5975910ad
4
- data.tar.gz: 22d99051e52a8f1be0cc5b3ed502f50fdc53719e
3
+ metadata.gz: a6d3e121abf7a303c0bc60475118c3c65a267deb
4
+ data.tar.gz: 909bb3f3afff66db6dddb33fafd4699780f400f6
5
5
  SHA512:
6
- metadata.gz: eb67194febafe3ae1c38d548479536379b3fd9914b63cae7b8069b498f6d5f6344d67769566dd4ff26b492002f70e73d1f4292dd83503a02ca84a0621893a3c4
7
- data.tar.gz: 6b3b5252735f003ad5065dc0062eec8331c91e5b6f856e06ea5e3ff62f364d420c60fc034aebd949f4788d56b365437ebf5bfd30bc81c3f80c59f7a95a024bf8
6
+ metadata.gz: 5362f0d3e12e7a6541cd80546c4107d13f2709401b7f23a42d9f31c0f892917e1f50554604c7e74667560ce0327fc05a330c9f181faccd7b8098b2c0be237c8c
7
+ data.tar.gz: a0ef3e543c3b27901cc520f25189dcd9cc1ac0b40a8655e703d4c8c8a8c0d08f9339771a204d558e17df8e26d386ee57046cf217db70508f2fac8954eb2c362d
@@ -2,6 +2,11 @@
2
2
 
3
3
  This project is [Semantically Versioned](http://semver.org).
4
4
 
5
+ ## 1.4.0
6
+
7
+ * If `DataSource.new` receives a block, call the block upon every new `Filey`
8
+ that the data source generates
9
+
5
10
  ## 1.3.1
6
11
 
7
12
  * Remove a non-printable char
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'filey-diff'
3
- s.version = '1.3.1'
3
+ s.version = '1.4.0'
4
4
 
5
5
  s.summary = "Compare two data sources that contain file-like objects"
6
6
  s.description =
@@ -1,9 +1,10 @@
1
1
  module Filey
2
2
  module DataSources
3
3
  class AwsSdkS3 < DataSource
4
- def initialize(s3_bucket, config = { :concurrency_level => DEFAULT_CONCURRENCY_LEVEL })
4
+ def initialize(s3_bucket, config = { :concurrency_level => DEFAULT_CONCURRENCY_LEVEL }, &block)
5
5
  @s3_bucket = s3_bucket
6
6
  @config = config
7
+ @when_filey_loaded = lambda { |filey| block.call filey } if block
7
8
  end
8
9
 
9
10
  private
@@ -62,12 +63,14 @@ module Filey
62
63
  end
63
64
 
64
65
  normalised_path = "./#{path}"
65
- Filey.new(
66
+ filey = Filey.new(
66
67
  normalised_path,
67
68
  name,
68
69
  last_modified,
69
70
  md5
70
71
  )
72
+ @when_filey_loaded.call(filey) if @when_filey_loaded
73
+ filey
71
74
  end
72
75
 
73
76
  def last_modified_and_md5(s3_object)
@@ -3,8 +3,9 @@ require 'digest/md5'
3
3
  module Filey
4
4
  module DataSources
5
5
  class FileSystem < DataSource
6
- def initialize(root_directory)
6
+ def initialize(root_directory, &block)
7
7
  @root_directory = root_directory
8
+ @when_filey_loaded = lambda { |filey| block.call filey } if block
8
9
  end
9
10
 
10
11
  private
@@ -17,7 +18,9 @@ module Filey
17
18
  name = file.scan(/.*\/(.*)/).first.first
18
19
  normalised_path = ".#{path}"
19
20
  md5 = Digest::MD5.hexdigest(File.read(file))
20
- Filey.new(normalised_path, name, File.mtime(file), md5)
21
+ filey = Filey.new(normalised_path, name, File.mtime(file), md5)
22
+ @when_filey_loaded.call(filey) if @when_filey_loaded
23
+ filey
21
24
  }
22
25
  end
23
26
  end
@@ -39,6 +39,18 @@ shared_examples "a data source" do |source|
39
39
  file_object.should be_an_instance_of(Filey::Filey)
40
40
  }
41
41
  end
42
+
43
+ context '#initialize' do
44
+ it 'takes a block and dispatches every new filey to the block' do
45
+ called_upon_fileys = []
46
+ data_source = described_class.new(source) { |filey|
47
+ called_upon_fileys << filey
48
+ }
49
+ resulting_fileys = data_source.get_fileys
50
+ called_upon_fileys.empty?.should be(false)
51
+ resulting_fileys.should eq(called_upon_fileys)
52
+ end
53
+ end
42
54
  end
43
55
 
44
56
  objects = [
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filey-diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lauri Lehmijoki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-20 00:00:00.000000000 Z
11
+ date: 2013-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake