s3lite 0.0.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +68 -0
- data/README.md +35 -0
- data/Rakefile +6 -0
- data/bin/console +9 -0
- data/bin/setup +8 -0
- data/lib/s3lite/base.rb +37 -0
- data/lib/s3lite/parse.rb +10 -0
- data/lib/s3lite/s3.rb +30 -0
- data/lib/s3lite/version.rb +3 -0
- data/lib/s3lite.rb +7 -0
- data/s3lite.gemspec +35 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2bf1286511e5661990746ae9aed7bc451eebfee26db29dd379dfdebda542681e
|
4
|
+
data.tar.gz: b11c193adf9c2eb039e3abf797c4f1ab90bc7ce0fb4a95567773f6f325588832
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2fd6dd1ecbfb090c6296ea4e105aec354ecedc548c9c0979f2649d6ccb5984dc349ad381f77960034f1214149cdfb7ab63f0d72a2a408992fa5cae56864fb49a
|
7
|
+
data.tar.gz: cb14fc6a1e911e2d89002f3147cc166a1962ff88c6675577cb2d7948270f4d6c60428221b39b0913663fdacc098d1bab45659a3f5c334e6a53ec2fa5af565565
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
s3lite (0.0.0.pre.1)
|
5
|
+
aws-sdk-s3 (~> 1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.5.2)
|
11
|
+
public_suffix (>= 2.0.2, < 4.0)
|
12
|
+
aws-partitions (1.73.0)
|
13
|
+
aws-sdk-core (3.17.1)
|
14
|
+
aws-partitions (~> 1.0)
|
15
|
+
aws-sigv4 (~> 1.0)
|
16
|
+
jmespath (~> 1.0)
|
17
|
+
aws-sdk-kms (1.5.0)
|
18
|
+
aws-sdk-core (~> 3)
|
19
|
+
aws-sigv4 (~> 1.0)
|
20
|
+
aws-sdk-s3 (1.8.2)
|
21
|
+
aws-sdk-core (~> 3)
|
22
|
+
aws-sdk-kms (~> 1)
|
23
|
+
aws-sigv4 (~> 1.0)
|
24
|
+
aws-sigv4 (1.0.2)
|
25
|
+
coderay (1.1.2)
|
26
|
+
crack (0.4.3)
|
27
|
+
safe_yaml (~> 1.0.0)
|
28
|
+
diff-lcs (1.3)
|
29
|
+
hashdiff (0.3.7)
|
30
|
+
jmespath (1.3.1)
|
31
|
+
method_source (0.9.0)
|
32
|
+
pry (0.11.3)
|
33
|
+
coderay (~> 1.1.0)
|
34
|
+
method_source (~> 0.9.0)
|
35
|
+
public_suffix (3.0.2)
|
36
|
+
rake (10.5.0)
|
37
|
+
rspec (3.7.0)
|
38
|
+
rspec-core (~> 3.7.0)
|
39
|
+
rspec-expectations (~> 3.7.0)
|
40
|
+
rspec-mocks (~> 3.7.0)
|
41
|
+
rspec-core (3.7.1)
|
42
|
+
rspec-support (~> 3.7.0)
|
43
|
+
rspec-expectations (3.7.0)
|
44
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
+
rspec-support (~> 3.7.0)
|
46
|
+
rspec-mocks (3.7.0)
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
+
rspec-support (~> 3.7.0)
|
49
|
+
rspec-support (3.7.1)
|
50
|
+
safe_yaml (1.0.4)
|
51
|
+
webmock (3.3.0)
|
52
|
+
addressable (>= 2.3.6)
|
53
|
+
crack (>= 0.3.2)
|
54
|
+
hashdiff
|
55
|
+
|
56
|
+
PLATFORMS
|
57
|
+
ruby
|
58
|
+
|
59
|
+
DEPENDENCIES
|
60
|
+
bundler (~> 1.16)
|
61
|
+
pry (~> 0.11)
|
62
|
+
rake (~> 10.0)
|
63
|
+
rspec (~> 3.0)
|
64
|
+
s3lite!
|
65
|
+
webmock
|
66
|
+
|
67
|
+
BUNDLED WITH
|
68
|
+
1.16.1
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# S3lite
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/s3lite`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 's3lite'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install s3lite
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/s3lite.
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
data/lib/s3lite/base.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module S3lite::Base
|
2
|
+
attr_accessor :last_backup_at
|
3
|
+
include S3lite::S3
|
4
|
+
|
5
|
+
def backup(raise_error: false)
|
6
|
+
s3_put(path: s3_path, body: to_json)
|
7
|
+
rescue => e
|
8
|
+
raise e if raise_error
|
9
|
+
false
|
10
|
+
end
|
11
|
+
|
12
|
+
def backup!
|
13
|
+
backup(raise_error: true)
|
14
|
+
end
|
15
|
+
|
16
|
+
def latest
|
17
|
+
obj = s3_get(s3_path)
|
18
|
+
body = obj.body.read
|
19
|
+
json = S3lite::Parse.json(body)
|
20
|
+
json[:last_backup_at] = obj.last_modified
|
21
|
+
self.class.new(json)
|
22
|
+
rescue Aws::S3::Errors::AccessDenied, Aws::S3::Errors::NotFound
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
|
26
|
+
def backedup?
|
27
|
+
to_json == latest.to_json
|
28
|
+
end
|
29
|
+
|
30
|
+
def s3_path
|
31
|
+
if defined?(Rails)
|
32
|
+
"#{Rails.env}/#{self.class.to_s.parameterize}/#{id}"
|
33
|
+
else
|
34
|
+
"#{self.class}/#{id}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/s3lite/parse.rb
ADDED
data/lib/s3lite/s3.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
module S3lite::S3
|
2
|
+
def s3_get(path)
|
3
|
+
s3_resource_object(path).get
|
4
|
+
end
|
5
|
+
|
6
|
+
def s3_list(bucket)
|
7
|
+
s3_resource.bucket(bucket)
|
8
|
+
end
|
9
|
+
|
10
|
+
def s3_put(path:, body:)
|
11
|
+
s3_resource_object(path).put(body: body)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def s3_resource_object(path)
|
17
|
+
raise 'No AWS S3 Bucket Set' if S3lite.s3_bucket.nil?
|
18
|
+
s3_resource.bucket(S3lite.s3_bucket).object(path)
|
19
|
+
end
|
20
|
+
|
21
|
+
def s3_resource
|
22
|
+
raise 'No AWS Access Key Set' if S3lite.aws_key.nil?
|
23
|
+
raise 'No AWS Secret Access Key Set' if S3lite.aws_secret_key.nil?
|
24
|
+
Aws::S3::Resource.new(
|
25
|
+
region: S3lite.region || 'us-east-1',
|
26
|
+
access_key_id: S3lite.aws_key,
|
27
|
+
secret_access_key: S3lite.aws_secret_key
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
data/lib/s3lite.rb
ADDED
data/s3lite.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'aws-sdk-s3'
|
5
|
+
|
6
|
+
require 's3lite'
|
7
|
+
require 's3lite/parse'
|
8
|
+
require 's3lite/s3'
|
9
|
+
require 's3lite/base'
|
10
|
+
|
11
|
+
Gem::Specification.new do |spec|
|
12
|
+
spec.name = 's3lite'
|
13
|
+
spec.version = S3lite::VERSION
|
14
|
+
spec.authors = ['David Richey']
|
15
|
+
spec.email = ['daveyrichey@gmail.com']
|
16
|
+
|
17
|
+
spec.summary = 'S3 Framework to backup SQLite database to S3'
|
18
|
+
spec.description = 'S3 Framework to backup SQLite database to S3'
|
19
|
+
spec.homepage = 'http://www.google.com'
|
20
|
+
spec.license = 'MIT'
|
21
|
+
|
22
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
23
|
+
f.match(%r{^(test|spec|features)/})
|
24
|
+
end
|
25
|
+
spec.bindir = 'exe'
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ['lib']
|
28
|
+
|
29
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
30
|
+
spec.add_development_dependency 'pry', '~> 0.11'
|
31
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
32
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
|
+
|
34
|
+
spec.add_dependency 'aws-sdk-s3', '~> 1'
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: s3lite
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0.pre.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Richey
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-28 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.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.11'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.11'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: aws-sdk-s3
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1'
|
83
|
+
description: S3 Framework to backup SQLite database to S3
|
84
|
+
email:
|
85
|
+
- daveyrichey@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- bin/console
|
98
|
+
- bin/setup
|
99
|
+
- lib/s3lite.rb
|
100
|
+
- lib/s3lite/base.rb
|
101
|
+
- lib/s3lite/parse.rb
|
102
|
+
- lib/s3lite/s3.rb
|
103
|
+
- lib/s3lite/version.rb
|
104
|
+
- s3lite.gemspec
|
105
|
+
homepage: http://www.google.com
|
106
|
+
licenses:
|
107
|
+
- MIT
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 1.3.1
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.7.6
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: S3 Framework to backup SQLite database to S3
|
129
|
+
test_files: []
|