simmer 1.0.0.pre.alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +8 -0
- data/.gitignore +7 -0
- data/.rubocop.yml +25 -0
- data/.ruby-version +1 -0
- data/.travis.yml +25 -0
- data/CHANGELOG.md +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -0
- data/Guardfile +16 -0
- data/LICENSE +7 -0
- data/README.md +5 -0
- data/Rakefile +17 -0
- data/bin/console +18 -0
- data/bin/simmer +11 -0
- data/lib/simmer.rb +50 -0
- data/lib/simmer/configuration.rb +90 -0
- data/lib/simmer/core_ext/hash.rb +21 -0
- data/lib/simmer/externals.rb +12 -0
- data/lib/simmer/externals/aws_file_system.rb +81 -0
- data/lib/simmer/externals/mysql_database.rb +114 -0
- data/lib/simmer/externals/mysql_database/sql_fixture.rb +43 -0
- data/lib/simmer/externals/spoon_client.rb +77 -0
- data/lib/simmer/externals/spoon_client/mock.rb +39 -0
- data/lib/simmer/externals/spoon_client/result.rb +48 -0
- data/lib/simmer/judge.rb +38 -0
- data/lib/simmer/judge/result.rb +34 -0
- data/lib/simmer/runner.rb +125 -0
- data/lib/simmer/runner/result.rb +52 -0
- data/lib/simmer/session.rb +79 -0
- data/lib/simmer/session/reporter.rb +100 -0
- data/lib/simmer/session/result.rb +45 -0
- data/lib/simmer/specification.rb +34 -0
- data/lib/simmer/specification/act.rb +48 -0
- data/lib/simmer/specification/act/params.rb +55 -0
- data/lib/simmer/specification/assert.rb +27 -0
- data/lib/simmer/specification/assert/assertions.rb +27 -0
- data/lib/simmer/specification/assert/assertions/bad_output_assertion.rb +34 -0
- data/lib/simmer/specification/assert/assertions/bad_table_assertion.rb +38 -0
- data/lib/simmer/specification/assert/assertions/output.rb +37 -0
- data/lib/simmer/specification/assert/assertions/table.rb +47 -0
- data/lib/simmer/specification/stage.rb +28 -0
- data/lib/simmer/specification/stage/input_file.rb +33 -0
- data/lib/simmer/suite.rb +73 -0
- data/lib/simmer/util.rb +13 -0
- data/lib/simmer/util/evaluator.rb +32 -0
- data/lib/simmer/util/fixture.rb +32 -0
- data/lib/simmer/util/fixture_set.rb +41 -0
- data/lib/simmer/util/record.rb +54 -0
- data/lib/simmer/util/record_set.rb +51 -0
- data/lib/simmer/util/resolver.rb +28 -0
- data/lib/simmer/util/yaml_reader.rb +61 -0
- data/lib/simmer/version.rb +12 -0
- data/simmer.gemspec +38 -0
- data/spec/simmer/core_ext/hash_spec.rb +16 -0
- data/spec/spec_helper.rb +22 -0
- metadata +284 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1166684a6f6ae1ba9ca0e87aab0405fd6a83fa4c8bf5206950827b2d857577ff
|
4
|
+
data.tar.gz: 50214a9c1aa9dfb26bc5663f43a7cb2c36b62fbf31a7a1b52e66067ba84b5bdc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2675ec1ade5ebd6465c43040fa561125492a9abb6d58561ad69be852f8b6daa3056d90193fca079c187607f65dbf78983304e1e755ccb9fda0a3ca6a36279edd
|
7
|
+
data.tar.gz: cf2100c542aaf4157417c2e08bbeb7b362bc0505f3ceb2cbc0e47f3e184e9d36826b20347eadb3f6437ac2474672c1faccdefff8b6691e0dc6437a1ae53b5f41
|
data/.editorconfig
ADDED
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Layout/LineLength:
|
2
|
+
Max: 100
|
3
|
+
Exclude:
|
4
|
+
- simmer.gemspec
|
5
|
+
|
6
|
+
Metrics/BlockLength:
|
7
|
+
ExcludedMethods:
|
8
|
+
- let
|
9
|
+
- it
|
10
|
+
- describe
|
11
|
+
- context
|
12
|
+
- specify
|
13
|
+
- define
|
14
|
+
|
15
|
+
Metrics/MethodLength:
|
16
|
+
Max: 25
|
17
|
+
|
18
|
+
AllCops:
|
19
|
+
TargetRubyVersion: 2.4
|
20
|
+
|
21
|
+
Metrics/AbcSize:
|
22
|
+
Max: 16
|
23
|
+
|
24
|
+
Metrics/ClassLength:
|
25
|
+
Max: 125
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.5
|
data/.travis.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
env:
|
2
|
+
global:
|
3
|
+
- CC_TEST_REPORTER_ID=48c3a48cc3c203ac365190a30b3c0a9aae0d2c10c9a86735e654f23b8660bb02
|
4
|
+
language: ruby
|
5
|
+
rvm:
|
6
|
+
# Build on the latest stable of all supported Rubies (https://www.ruby-lang.org/en/downloads/):
|
7
|
+
- 2.4.6
|
8
|
+
- 2.5.5
|
9
|
+
- 2.6.5
|
10
|
+
- 2.7.0
|
11
|
+
cache: bundler
|
12
|
+
before_script:
|
13
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
14
|
+
- chmod +x ./cc-test-reporter
|
15
|
+
- ./cc-test-reporter before-build
|
16
|
+
script:
|
17
|
+
- bundle exec rubocop
|
18
|
+
- bundle exec rspec spec --format documentation
|
19
|
+
after_script:
|
20
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
21
|
+
addons:
|
22
|
+
# https://docs.travis-ci.com/user/uploading-artifacts/
|
23
|
+
artifacts:
|
24
|
+
paths:
|
25
|
+
- Gemfile.lock
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at oss@bluemarblepayroll.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
guard :rspec, cmd: 'DISABLE_SIMPLECOV=true bundle exec rspec --format=documentation' do
|
4
|
+
require 'guard/rspec/dsl'
|
5
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
6
|
+
|
7
|
+
# RSpec files
|
8
|
+
rspec = dsl.rspec
|
9
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
10
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
11
|
+
watch(rspec.spec_files)
|
12
|
+
|
13
|
+
# Ruby files
|
14
|
+
ruby = dsl.ruby
|
15
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
16
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright 2020 Blue Marble Payroll, LLC
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
+
#
|
6
|
+
# This source code is licensed under the MIT license found in the
|
7
|
+
# LICENSE file in the root directory of this source tree.
|
8
|
+
#
|
9
|
+
|
10
|
+
require 'bundler/gem_tasks'
|
11
|
+
require 'rspec/core/rake_task'
|
12
|
+
require 'rubocop/rake_task'
|
13
|
+
|
14
|
+
RSpec::Core::RakeTask.new(:spec)
|
15
|
+
RuboCop::RakeTask.new
|
16
|
+
|
17
|
+
task default: %i[rubocop spec]
|
data/bin/console
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# Copyright (c) 2018-present, Blue Marble Payroll, LLC
|
6
|
+
#
|
7
|
+
# This source code is licensed under the MIT license found in the
|
8
|
+
# LICENSE file in the root directory of this source tree.
|
9
|
+
#
|
10
|
+
|
11
|
+
require 'bundler/setup'
|
12
|
+
require 'simmer'
|
13
|
+
|
14
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
15
|
+
# with your gem easier. You can also use a different console, if you like.
|
16
|
+
|
17
|
+
require 'pry'
|
18
|
+
Pry.start
|
data/bin/simmer
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Examples:
|
5
|
+
# - ./bin/simmer
|
6
|
+
# - ./bin/simmer ./simmer/specs/transformations/examples
|
7
|
+
# - ./bin/simmer ./simmer/specs/transformations/examples/update_user_name.yaml
|
8
|
+
|
9
|
+
require 'simmer'
|
10
|
+
|
11
|
+
exit 1 unless Simmer.run(ARGV[0]).pass?
|
data/lib/simmer.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
+
#
|
6
|
+
# This source code is licensed under the MIT license found in the
|
7
|
+
# LICENSE file in the root directory of this source tree.
|
8
|
+
#
|
9
|
+
|
10
|
+
# External libraries
|
11
|
+
require 'acts_as_hashable'
|
12
|
+
require 'aws-sdk-s3'
|
13
|
+
require 'benchmark'
|
14
|
+
require 'bigdecimal'
|
15
|
+
require 'fileutils'
|
16
|
+
require 'forwardable'
|
17
|
+
require 'mysql2'
|
18
|
+
require 'objectable'
|
19
|
+
require 'pdi'
|
20
|
+
require 'securerandom'
|
21
|
+
require 'set'
|
22
|
+
require 'stringento'
|
23
|
+
require 'yaml'
|
24
|
+
|
25
|
+
# Monkey-patching core libaries
|
26
|
+
require_relative 'simmer/core_ext/hash'
|
27
|
+
Hash.include Simmer::CoreExt::Hash
|
28
|
+
|
29
|
+
# Load up general use-case utils for entire library
|
30
|
+
require_relative 'simmer/util'
|
31
|
+
|
32
|
+
# Core code
|
33
|
+
require_relative 'simmer/suite'
|
34
|
+
|
35
|
+
# The main entry-point API for the library.
|
36
|
+
module Simmer
|
37
|
+
DEFAULT_CONFIG_PATH = File.join('config', 'simmer.yaml')
|
38
|
+
DEFAULT_RESULTS_DIR = 'results'
|
39
|
+
DEFAULT_SIMMER_DIR = 'simmer'
|
40
|
+
class << self
|
41
|
+
def run(path)
|
42
|
+
Suite.new(
|
43
|
+
out: $stdout,
|
44
|
+
config_path: DEFAULT_CONFIG_PATH,
|
45
|
+
results_dir: DEFAULT_RESULTS_DIR,
|
46
|
+
simmer_dir: DEFAULT_SIMMER_DIR
|
47
|
+
).run(path)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
+
#
|
6
|
+
# This source code is licensed under the MIT license found in the
|
7
|
+
# LICENSE file in the root directory of this source tree.
|
8
|
+
#
|
9
|
+
|
10
|
+
module Simmer
|
11
|
+
# Reads in the Simmer configuration file and options and provides it to the rest of the
|
12
|
+
# Simmer implementation.
|
13
|
+
class Configuration
|
14
|
+
# Configuration Keys
|
15
|
+
AWS_FILE_SYSTEM_KEY = :aws_file_system
|
16
|
+
MYSQL_DATABASE_KEY = :mysql_database
|
17
|
+
SPOON_CLIENT_KEY = :spoon_client
|
18
|
+
|
19
|
+
# Paths
|
20
|
+
FILES = 'files'
|
21
|
+
FIXTURES = 'fixtures'
|
22
|
+
TESTS = 'specs'
|
23
|
+
|
24
|
+
private_constant :AWS_FILE_SYSTEM_KEY,
|
25
|
+
:MYSQL_DATABASE_KEY,
|
26
|
+
:SPOON_CLIENT_KEY,
|
27
|
+
:FILES,
|
28
|
+
:FIXTURES,
|
29
|
+
:TESTS
|
30
|
+
|
31
|
+
attr_reader :config
|
32
|
+
|
33
|
+
def initialize(
|
34
|
+
config_path:,
|
35
|
+
resolver: Objectable.resolver,
|
36
|
+
results_dir:,
|
37
|
+
simmer_dir:,
|
38
|
+
yaml_reader: Util::YamlReader.new
|
39
|
+
)
|
40
|
+
@config = yaml_reader.read(config_path)
|
41
|
+
@resolver = resolver
|
42
|
+
@results_dir = results_dir
|
43
|
+
@simmer_dir = simmer_dir
|
44
|
+
@yaml_reader = yaml_reader
|
45
|
+
|
46
|
+
freeze
|
47
|
+
end
|
48
|
+
|
49
|
+
def database_config
|
50
|
+
get(MYSQL_DATABASE_KEY) || {}
|
51
|
+
end
|
52
|
+
|
53
|
+
def file_system_config
|
54
|
+
get(AWS_FILE_SYSTEM_KEY) || {}
|
55
|
+
end
|
56
|
+
|
57
|
+
def spoon_client_config
|
58
|
+
get(SPOON_CLIENT_KEY) || {}
|
59
|
+
end
|
60
|
+
|
61
|
+
def tests_dir
|
62
|
+
File.join(simmer_dir, TESTS)
|
63
|
+
end
|
64
|
+
|
65
|
+
def fixtures_dir
|
66
|
+
File.join(simmer_dir, FIXTURES)
|
67
|
+
end
|
68
|
+
|
69
|
+
def files_dir
|
70
|
+
File.join(simmer_dir, FILES)
|
71
|
+
end
|
72
|
+
|
73
|
+
def fixture_set
|
74
|
+
config = yaml_reader.smash(fixtures_dir)
|
75
|
+
|
76
|
+
Util::FixtureSet.new(config)
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
attr_reader :resolver,
|
82
|
+
:results_dir,
|
83
|
+
:simmer_dir,
|
84
|
+
:yaml_reader
|
85
|
+
|
86
|
+
def get(key)
|
87
|
+
resolver.get(config, key)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
+
#
|
6
|
+
# This source code is licensed under the MIT license found in the
|
7
|
+
# LICENSE file in the root directory of this source tree.
|
8
|
+
#
|
9
|
+
|
10
|
+
module Simmer
|
11
|
+
module CoreExt
|
12
|
+
# Monkey-patches for the core Hash class. These will be manually mixed in separately.
|
13
|
+
module Hash
|
14
|
+
unless method_defined?(:symbolize_keys)
|
15
|
+
def symbolize_keys
|
16
|
+
map { |k, v| [k.to_sym, v] }.to_h
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
+
#
|
6
|
+
# This source code is licensed under the MIT license found in the
|
7
|
+
# LICENSE file in the root directory of this source tree.
|
8
|
+
#
|
9
|
+
|
10
|
+
require_relative 'externals/aws_file_system'
|
11
|
+
require_relative 'externals/mysql_database'
|
12
|
+
require_relative 'externals/spoon_client'
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
+
#
|
6
|
+
# This source code is licensed under the MIT license found in the
|
7
|
+
# LICENSE file in the root directory of this source tree.
|
8
|
+
#
|
9
|
+
|
10
|
+
module Simmer
|
11
|
+
module Externals
|
12
|
+
# Provides the implementation for using AWS S3 as a destination file store.
|
13
|
+
class AwsFileSystem
|
14
|
+
BUCKET_SUFFIX = 'test'
|
15
|
+
|
16
|
+
private_constant :BUCKET_SUFFIX
|
17
|
+
|
18
|
+
def initialize(config, files_dir)
|
19
|
+
config = (config || {}).symbolize_keys
|
20
|
+
|
21
|
+
client = Aws::S3::Client.new(
|
22
|
+
access_key_id: config[:access_key_id],
|
23
|
+
secret_access_key: config[:secret_access_key],
|
24
|
+
region: config[:region]
|
25
|
+
)
|
26
|
+
|
27
|
+
bucket_name = config[:bucket].to_s
|
28
|
+
assert_bucket_name(bucket_name)
|
29
|
+
|
30
|
+
@bucket = Aws::S3::Bucket.new(name: bucket_name, client: client)
|
31
|
+
@encryption = config[:encryption]
|
32
|
+
@files_dir = files_dir
|
33
|
+
|
34
|
+
freeze
|
35
|
+
end
|
36
|
+
|
37
|
+
def write(specification)
|
38
|
+
files = specification.stage.files
|
39
|
+
|
40
|
+
files.each do |file|
|
41
|
+
src = File.join(files_dir, file.src)
|
42
|
+
|
43
|
+
write_single(file.dest, src)
|
44
|
+
end
|
45
|
+
|
46
|
+
files.length
|
47
|
+
end
|
48
|
+
|
49
|
+
def clean
|
50
|
+
bucket.objects.inject(0) do |memo, object|
|
51
|
+
object.delete
|
52
|
+
|
53
|
+
memo + 1
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
attr_reader :bucket, :encryption, :files_dir
|
60
|
+
|
61
|
+
def write_single(dest, src)
|
62
|
+
src = File.expand_path(src)
|
63
|
+
|
64
|
+
File.open(src, 'rb') do |file|
|
65
|
+
bucket.object(dest).put(
|
66
|
+
body: file,
|
67
|
+
server_side_encryption: encryption
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
nil
|
72
|
+
end
|
73
|
+
|
74
|
+
def assert_bucket_name(name)
|
75
|
+
return if name.end_with?(BUCKET_SUFFIX)
|
76
|
+
|
77
|
+
raise ArgumentError, "bucket (#{name}) must end in #{BUCKET_SUFFIX}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|