fake_s3 0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d994993efd15d616784cb985f37d921acd2c65bd814e69484db256250b4ca4b9
4
+ data.tar.gz: 6fb65389b196b8b06a58e28eb7fe326aa07507386002fb007426b77067b45a35
5
+ SHA512:
6
+ metadata.gz: 54bfc011cc636df685d63ece661677f8e0f05e1afab46bf314ecf2f2fb6e531ab2d8c5ced302469e2f7eb75a734b6f2544cf53f70a1342cc0125cfab451a4583
7
+ data.tar.gz: ef079e7e352459563c443baf1ad4ce3c4d0b2ed656393a757c4f1690cfcd4f9070f1128cdc92763e1d480f7ed86cff4ffe5ef7b632df8ad41271133d0097ca35
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in i18n-migrations.gemspec
4
+ gemspec
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fake_s3 (0.9)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.5.0)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 1.9)
16
+ fake_s3!
17
+ rake (~> 10.0)
18
+
19
+ BUNDLED WITH
20
+ 1.17.2
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Transparent Classroom
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ # fake_s3
2
+ This is a fake s3 ruby object that mirrors the s3 part of the aws_sdk gem. You can use it in tests.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ require_relative 'lib/fake_s3'
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "fake_s3"
6
+ spec.version = FakeS3::VERSION
7
+ spec.authors = ["Jeremy Lightsmith"]
8
+ spec.email = ["jeremy.lightsmith@gmail.com"]
9
+
10
+ spec.summary = %q{A fake library that mirrors the S3 part of aws-sdk for ruby}
11
+ spec.description = %q{Use this library for unit testing S3 on ruby}
12
+ spec.homepage = "https://github.com/transparentclassroom/fake_s3"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|features)/}) }
16
+ spec.bindir = "bin"
17
+ # spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.required_ruby_version = '~> 2.4'
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.9"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+
25
+ # spec.add_dependency 'colorize'
26
+ end
@@ -0,0 +1,3 @@
1
+ require_relative 'fake_s3/bucket'
2
+ require_relative 'fake_s3/object'
3
+ require_relative 'fake_s3/version'
@@ -0,0 +1,32 @@
1
+ module FakeS3
2
+ class Bucket
3
+ attr_reader :name
4
+
5
+ def initialize(name)
6
+ @name = name
7
+ clear
8
+ end
9
+
10
+ def clear
11
+ @objects = {}
12
+ end
13
+
14
+ def objects(_ = {})
15
+ @objects.keep_if(&:exists?)
16
+ end
17
+
18
+ def object(key)
19
+ @objects[key] ||= FakeS3::Object.new(self, key, nil)
20
+ end
21
+
22
+ def keys_to_contents
23
+ @objects.map_to_hash do |key, obj|
24
+ [key, obj.get.body.read]
25
+ end
26
+ end
27
+
28
+ def move_to(src, dest)
29
+ @objects[dest.key] = @objects.delete(src.key)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,60 @@
1
+ module FakeS3
2
+ class Object
3
+ attr_reader :key
4
+ attr_reader :bucket
5
+ attr_accessor :last_modified
6
+
7
+ def initialize(bucket, key, body)
8
+ @bucket, @key, @body = bucket, key, body
9
+ @last_modified = Time.now
10
+ @content_length = 1
11
+ end
12
+
13
+ def exists?
14
+ !!@body
15
+ end
16
+
17
+ def content_length
18
+ @body.length # this should be in bytes, but this is roughly the same, good enough for tests
19
+ end
20
+
21
+ def put(options = {})
22
+ if options[:body]
23
+ @body = options[:body]
24
+ end
25
+ self
26
+ end
27
+
28
+ def get
29
+ FakeObjectOutput.new(@body)
30
+ end
31
+
32
+ def download_file(path)
33
+ File.open(path, 'wb') do |f|
34
+ f << @body
35
+ end
36
+ end
37
+
38
+ def upload_file(source, options = {})
39
+ @body = source.respond_to?(:read) ? source.read : File.read(source)
40
+ end
41
+
42
+ def move_to(location)
43
+ location.bucket.move_to(self, location)
44
+ end
45
+
46
+ def public_url
47
+ "https://test.tc.com.s3.amazonaws.com/#{@key}"
48
+ end
49
+
50
+ class FakeObjectOutput
51
+ def initialize(body)
52
+ @body = body
53
+ end
54
+
55
+ def body
56
+ StringIO.new(@body)
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,3 @@
1
+ module FakeS3
2
+ VERSION = "0.9"
3
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fake_s3
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.9'
5
+ platform: ruby
6
+ authors:
7
+ - Jeremy Lightsmith
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-09-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Use this library for unit testing S3 on ruby
42
+ email:
43
+ - jeremy.lightsmith@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - LICENSE
52
+ - README.md
53
+ - Rakefile
54
+ - fake_s3.gemspec
55
+ - lib/fake_s3.rb
56
+ - lib/fake_s3/bucket.rb
57
+ - lib/fake_s3/object.rb
58
+ - lib/fake_s3/version.rb
59
+ homepage: https://github.com/transparentclassroom/fake_s3
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '2.4'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubygems_version: 3.0.3
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: A fake library that mirrors the S3 part of aws-sdk for ruby
82
+ test_files: []