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 +4 -4
- data/changelog.md +5 -0
- data/filey-diff.gemspec +1 -1
- data/lib/filey-diff/data-sources/aws_sdk_s3.rb +5 -2
- data/lib/filey-diff/data-sources/file_system.rb +5 -2
- data/spec/data_sources_spec.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6d3e121abf7a303c0bc60475118c3c65a267deb
|
4
|
+
data.tar.gz: 909bb3f3afff66db6dddb33fafd4699780f400f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5362f0d3e12e7a6541cd80546c4107d13f2709401b7f23a42d9f31c0f892917e1f50554604c7e74667560ce0327fc05a330c9f181faccd7b8098b2c0be237c8c
|
7
|
+
data.tar.gz: a0ef3e543c3b27901cc520f25189dcd9cc1ac0b40a8655e703d4c8c8a8c0d08f9339771a204d558e17df8e26d386ee57046cf217db70508f2fac8954eb2c362d
|
data/changelog.md
CHANGED
data/filey-diff.gemspec
CHANGED
@@ -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
|
data/spec/data_sources_spec.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2013-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|