s3mpi 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +4 -0
- data/Gemfile +5 -0
- data/LICENSE +7 -0
- data/README.md +7 -0
- data/Rakefile +17 -0
- data/lib/s3mpi/format.rb +14 -0
- data/lib/s3mpi/interface.rb +67 -0
- data/lib/s3mpi/s3.rb +15 -0
- data/lib/s3mpi/version.rb +10 -0
- data/lib/s3mpi.rb +6 -0
- data/s3mpi.gemspec +32 -0
- data/spec/s3mpi/s3_spec.rb +19 -0
- data/spec/spec_helper.rb +9 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 750b7484b10dac34808cb7c1cb1c1f2bdfd7eeb0
|
4
|
+
data.tar.gz: e63652c05a474322356d2587ad62dff51f030d25
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ce652479bba4088e04d61aa1565c8f03db7db7839b4525520a34efc36e199a4dd7d32c475e86a354c065bb46b1fba8818ee38f1441f5f30099afa759a958c1b3
|
7
|
+
data.tar.gz: adf00002f3bb1e21a1ec052603fc8f44044b530e4f9e935f8bac9ece01138b22bf58d78fde509acf652e75a926df3ebb6b67f1f9affd57197d52cffbd6363728
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2010-2014 Andrew Benton.
|
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/README.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
S3MPI
|
2
|
+
=========
|
3
|
+
|
4
|
+
Upload and download files to S3 using a very convenient API.
|
5
|
+
|
6
|
+
[![Build Status](https://travis-ci.org/robertzk/s3mpi.svg?branch=master)](https://travis-ci.org/robertzk/s3mpi)
|
7
|
+
[![Code Climate](https://codeclimate.com/github/robertzk/s3mpi.png)](https://codeclimate.com/github/robertzk/s3mpi)
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
|
3
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
4
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
5
|
+
end
|
6
|
+
|
7
|
+
task default: [:spec]
|
8
|
+
|
9
|
+
desc 'Load gem inside irb console'
|
10
|
+
task :console do
|
11
|
+
require 'irb'
|
12
|
+
require 'irb/completion'
|
13
|
+
require File.join(__FILE__, '../lib/github_api')
|
14
|
+
ARGV.clear
|
15
|
+
IRB.start
|
16
|
+
end
|
17
|
+
|
data/lib/s3mpi/format.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 's3mpi/format'
|
3
|
+
require 's3mpi/s3'
|
4
|
+
|
5
|
+
module S3MPI
|
6
|
+
class Interface
|
7
|
+
include Format
|
8
|
+
include S3
|
9
|
+
|
10
|
+
# Return S3 bucket under use.
|
11
|
+
#
|
12
|
+
# @return [AWS::S3::Bucket]
|
13
|
+
attr_reader :bucket
|
14
|
+
|
15
|
+
# Return S3 path under use.
|
16
|
+
#
|
17
|
+
# @return [String]
|
18
|
+
attr_reader :path
|
19
|
+
|
20
|
+
# Create a new S3MPI object that responds to #read and #store.
|
21
|
+
#
|
22
|
+
# @return [S3MPI::Interface]
|
23
|
+
#
|
24
|
+
# @api public
|
25
|
+
def initialize bucket, path = ''
|
26
|
+
@bucket = parse_bucket bucket
|
27
|
+
@path = path
|
28
|
+
end
|
29
|
+
|
30
|
+
# Store a Ruby object in an S3 bucket.
|
31
|
+
#
|
32
|
+
# @param [Object] obj
|
33
|
+
# Any JSON-serializable Ruby object (usually a hash or array).
|
34
|
+
# @param [String] key
|
35
|
+
# The key under which to save the object in the S3 bucket.
|
36
|
+
# @param [Integer] try
|
37
|
+
# The number of times to attempt to store the object.
|
38
|
+
def store(obj, key = SecureRandom.uuid, try = 1)
|
39
|
+
s3_object(key).write(obj.to_json)
|
40
|
+
rescue
|
41
|
+
(try -= 1) > 0 ? retry : raise
|
42
|
+
end
|
43
|
+
|
44
|
+
# Read a JSON-serialized Ruby object from an S3 bucket.
|
45
|
+
#
|
46
|
+
# @param [String] key
|
47
|
+
# The key under which to save the object in the S3 bucket.
|
48
|
+
def read key = nil
|
49
|
+
parse_json_allowing_quirks_mode s3_object(key).read
|
50
|
+
rescue AWS::S3::Errors::NoSuchKey
|
51
|
+
nil
|
52
|
+
end
|
53
|
+
|
54
|
+
# Check whether a key exists for this MPI interface.
|
55
|
+
#
|
56
|
+
# @param [String] key
|
57
|
+
# The key under which to save the object in the S3 bucket.
|
58
|
+
#
|
59
|
+
# @return [TrueClass,FalseClass]
|
60
|
+
def exists?(key)
|
61
|
+
s3_object(key).exists?
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
data/lib/s3mpi/s3.rb
ADDED
data/lib/s3mpi.rb
ADDED
data/s3mpi.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require './lib/s3mpi/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 's3mpi'
|
6
|
+
s.version = S3MPI::VERSION::STRING.dup
|
7
|
+
s.date = Date.today.to_s
|
8
|
+
s.summary = 'Upload and download files to S3 using a very convenient API.'
|
9
|
+
s.description = %(Passing objects between Ruby consoles can be cumbersome if the
|
10
|
+
user has performed some serialization and deserialization procedure.
|
11
|
+
S3MPI aims to enable simple reading and writing to S3 buckets
|
12
|
+
without the typical overhead of the AWS gem.
|
13
|
+
).strip.gsub(/\s+/, " ")
|
14
|
+
s.authors = ["Robert Krzyzanowski"]
|
15
|
+
s.email = 'rkrzyzanowski@gmail.com'
|
16
|
+
s.homepage = 'http://github.com/robertzk'
|
17
|
+
s.license = 'MIT'
|
18
|
+
s.homepage = 'https://github.com/robertzk/s3mpi-ruby'
|
19
|
+
|
20
|
+
s.platform = Gem::Platform::RUBY
|
21
|
+
s.require_paths = %w[lib]
|
22
|
+
s.files = `git ls-files`.split("\n")
|
23
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
24
|
+
|
25
|
+
s.add_dependency 'aws-sdk', '~> 1.3.4'
|
26
|
+
|
27
|
+
s.add_development_dependency 'rake', '~> 10.1.0'
|
28
|
+
s.add_development_dependency 'rspec', '~> 2.14.1'
|
29
|
+
|
30
|
+
s.extra_rdoc_files = ['README.md', 'LICENSE']
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module S3MPI
|
4
|
+
|
5
|
+
describe Format do
|
6
|
+
let(:format_mixin) {
|
7
|
+
klass = Class.new
|
8
|
+
klass.send :include, Format
|
9
|
+
klass.new
|
10
|
+
}
|
11
|
+
|
12
|
+
it 'expects #parse_json_allowing_quirks_mode to parse JSON' do
|
13
|
+
obj = {"a" => 1, "b" => "test"}
|
14
|
+
expect(format_mixin.parse_json_allowing_quirks_mode(obj.to_json)).to eql(obj)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: s3mpi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robert Krzyzanowski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aws-sdk
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.3.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.3.4
|
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.1.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.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.14.1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.14.1
|
55
|
+
description: Passing objects between Ruby consoles can be cumbersome if the user has
|
56
|
+
performed some serialization and deserialization procedure. S3MPI aims to enable
|
57
|
+
simple reading and writing to S3 buckets without the typical overhead of the AWS
|
58
|
+
gem.
|
59
|
+
email: rkrzyzanowski@gmail.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files:
|
63
|
+
- README.md
|
64
|
+
- LICENSE
|
65
|
+
files:
|
66
|
+
- .gitignore
|
67
|
+
- .travis.yml
|
68
|
+
- Gemfile
|
69
|
+
- LICENSE
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- lib/s3mpi.rb
|
73
|
+
- lib/s3mpi/format.rb
|
74
|
+
- lib/s3mpi/interface.rb
|
75
|
+
- lib/s3mpi/s3.rb
|
76
|
+
- lib/s3mpi/version.rb
|
77
|
+
- s3mpi.gemspec
|
78
|
+
- spec/s3mpi/s3_spec.rb
|
79
|
+
- spec/spec_helper.rb
|
80
|
+
homepage: https://github.com/robertzk/s3mpi-ruby
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.1.11
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: Upload and download files to S3 using a very convenient API.
|
104
|
+
test_files:
|
105
|
+
- spec/s3mpi/s3_spec.rb
|
106
|
+
- spec/spec_helper.rb
|