serverkit-s3 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c7f8091aeee8d7a951dfd6523922d14d644ddb7e
4
+ data.tar.gz: 98543ce801cffebc7bc1232c0e61cc5cfbf90a90
5
+ SHA512:
6
+ metadata.gz: 12700a6eca53ceff7c8559c7efb187bce1fc0c6bf54697f93b6edf2a2fbc89aa65c2f1f9d152ae5b2166796935fd45b88d48aef291cb068824bd38a44204cca9
7
+ data.tar.gz: 1fcbc7af61d52ee533b0260be4ce693b7de0682343f444062079f35ecf6f117776c79fefa8a02f89ef5cfd533d7d3f716264bfad544e327d98b3470f734cbe05
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ ## 0.0.1
2
+ - 1st Release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in serverkit-s3.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Ryo Nakamura
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # serverkit-s3
2
+ [Serverkit](https://github.com/serverkit/serverkit) plug-in for Amazon S3.
3
+
4
+ ## Install
5
+ ```rb
6
+ # Gemfile
7
+ gem "serverkit-s3"
8
+ ```
9
+
10
+ ## Resource
11
+ ### s3_bucket
12
+ Create a S3 bucket.
13
+
14
+ #### Attributes
15
+ - name - S3 bucket name (required) (e.g. `"my-bucket"`)
16
+ - aws_access_key_id - AWS access key ID
17
+ - aws_region - AWS region
18
+ - aws_secret_access_key - AWS secret access key
19
+
20
+ Note: serverkit-s3 searches the following locations for credentials and a region:
21
+
22
+ - `ENV["AWS_ACCESS_KEY_ID"]`
23
+ - `ENV["AWS_REGION"]`
24
+ - `ENV["AWS_SECRET_ACCESS_KEY"]`
25
+ - The shared credentials ini file at `~/.aws/credentials`
26
+ - From an instance profile when running on EC2
27
+
28
+ #### Example
29
+ ```yml
30
+ resources:
31
+ - type: s3_bucket
32
+ name: my-bucket
33
+ aws_region: ap-northeast-1
34
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,42 @@
1
+ require "aws-sdk"
2
+ require "serverkit/resources/base"
3
+
4
+ module Serverkit
5
+ module Resources
6
+ class S3Bucket < Base
7
+ attribute :aws_access_key_id, type: String
8
+ attribute :aws_region, type: String
9
+ attribute :aws_secret_access_key, type: String
10
+ attribute :name, required: true, type: String
11
+
12
+ # @note Override
13
+ def apply
14
+ client.create_bucket(bucket: name)
15
+ end
16
+
17
+ # @note Override
18
+ def check
19
+ client.head_bucket(bucket: name)
20
+ true
21
+ rescue ::Aws::S3::Errors::NotFound
22
+ false
23
+ end
24
+
25
+ private
26
+
27
+ # @return [Aws::S3::Client]
28
+ def client
29
+ @client ||= ::Aws::S3::Client.new(client_options)
30
+ end
31
+
32
+ # @return [Hash]
33
+ def client_options
34
+ options = { region: aws_region }
35
+ if aws_access_key_id || aws_secret_access_key
36
+ options[:credentials] = ::Aws::Credentials.new(aws_access_key_id, aws_secret_access_key)
37
+ end
38
+ options
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,2 @@
1
+ require "serverkit/s3/version"
2
+ require "serverkit/resources/s3_bucket"
@@ -0,0 +1,5 @@
1
+ module Serverkit
2
+ module S3
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "serverkit/s3/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "serverkit-s3"
7
+ spec.version = Serverkit::S3::VERSION
8
+ spec.authors = ["Ryo Nakamura"]
9
+ spec.email = ["r7kamura@gmail.com"]
10
+ spec.summary = "Serverkit plug-in for Amazon S3"
11
+ spec.homepage = "https://github.com/serverkit/serverkit-s3"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
15
+ spec.require_paths = ["lib"]
16
+
17
+ spec.add_runtime_dependency "aws-sdk", "~> 2"
18
+ spec.add_runtime_dependency "serverkit", ">= 0.6.7"
19
+ spec.add_development_dependency "bundler", "~> 1.9"
20
+ spec.add_development_dependency "rake", "~> 10.0"
21
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: serverkit-s3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ryo Nakamura
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-15 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: '2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: serverkit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.6.7
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.6.7
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.9'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description:
70
+ email:
71
+ - r7kamura@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - CHANGELOG.md
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - lib/serverkit/resources/s3_bucket.rb
83
+ - lib/serverkit/s3.rb
84
+ - lib/serverkit/s3/version.rb
85
+ - serverkit-s3.gemspec
86
+ homepage: https://github.com/serverkit/serverkit-s3
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.4.5
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Serverkit plug-in for Amazon S3
110
+ test_files: []
111
+ has_rdoc: