s3file 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/s3file.rb +17 -2
  3. data/test/test_s3file.rb +1 -0
  4. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/lib/s3file.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  class S3File
2
2
  require 'open4'
3
- require 'ruby-debug'
4
3
  # Require all the files in the lib/s3file
5
4
  $:.unshift File.join(File.dirname(__FILE__),'..','lib')
6
5
  require 's3file/cp'
@@ -29,7 +28,7 @@ class S3File
29
28
  class << self
30
29
  # Deletes the config file that was created.
31
30
  def delete_config_file!
32
- FileUtils.rm_f(@@config_file) if S3File.config_file_exists?
31
+ File.delete(@@config_file) if S3File.config_file_exists?
33
32
  end
34
33
 
35
34
  # Gets the md5 hash of the s3 file. This will be used to confirm if the copy occurred
@@ -39,6 +38,22 @@ class S3File
39
38
  run_command("s3cmd --list-md5 ls #{location} -c #{@@config_file}").split(" ")[3]
40
39
  end
41
40
 
41
+ # Checks if the file is the same on the source and destination
42
+ # The check is done via md5_hash to determine if both the files are the same.
43
+ def equal(location1, location2)
44
+ if s3?(location1)
45
+ s3_location = location1
46
+ local_file = location2
47
+ elsif local?(location1)
48
+ s3_location = location2
49
+ local_file = location1
50
+ else
51
+ raise(S3PathError, "S3 location not specified")
52
+ end
53
+ raise(PathError, "Local file not found") unless File.exists?(local_file)
54
+ md5_hash(s3_location) == Digest::MD5.hexdigest(File.read(location2))
55
+ end
56
+
42
57
  end
43
58
 
44
59
  private
data/test/test_s3file.rb CHANGED
@@ -24,4 +24,5 @@ class TestS3file < Test::Unit::TestCase
24
24
  S3File.new(:access_key => "blah", :secret_access_key => "blah")
25
25
  assert_equal true, S3File.config_file_exists?
26
26
  end
27
+
27
28
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3file
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - glen
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-20 00:00:00 +05:30
18
+ date: 2010-08-18 00:00:00 +05:30
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency