sitemap_generator-aws_s3_adapter 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +52 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/circle.yml +5 -0
- data/lib/sitemap_generator/aws_s3_adapter.rb +87 -0
- data/lib/sitemap_generator/aws_s3_adapter/version.rb +5 -0
- data/sitemap_generator-aws_s3_adapter.gemspec +26 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3bc3c4eb3425df85949f86d957fc1af4089370da
|
4
|
+
data.tar.gz: 6a41685acc748f5fdf05a8b4d2eb999b45c65134
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d322431870e5b7fd9be31d95335ed441f7e93bcd8204c9772080b75de76bbb934dd7a49bc898896c9df5e0ba147dae6e1b8ac53ec7a7b946220918259f772f55
|
7
|
+
data.tar.gz: 3f86b36cb1376fa962b72cde591afb482ff2b152168cb9b0bfeb1133e00722dc6c54e4f04f4d7802361d267e3b520de42a19db88f1cb292006f9d8915e011156
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at junyaogura@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Junya Ogura and qnyp, inc.
|
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,52 @@
|
|
1
|
+
# SitemapGenerator::AwsS3Adapter
|
2
|
+
|
3
|
+
[![Circle CI](https://circleci.com/gh/qnyp/sitemap_generator-aws_s3_adapter.svg?style=svg)](https://circleci.com/gh/qnyp/sitemap_generator-aws_s3_adapter)
|
4
|
+
|
5
|
+
This is a yet another AWS S3 adapter for [sitemap_generator](https://github.com/kjvarga/sitemap_generator), built with official [aws-sdk](https://rubygems.org/gems/aws-sdk) v2.
|
6
|
+
|
7
|
+
## Motivation
|
8
|
+
|
9
|
+
fog introduces [bunch of runtime dependencies](https://rubygems.org/gems/fog). :weary:
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'sitemap_generator-aws_s3_adapter'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
```console
|
22
|
+
$ bundle
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Add following lines to your app's `config/sitemap.rb`.
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
SitemapGenerator::Sitemap.adapter = SitemapGenerator::AwsS3Adapter.new(
|
31
|
+
access_key_id: '...',
|
32
|
+
secret_access_key: '...',
|
33
|
+
region: '...',
|
34
|
+
bucket_name: '...'
|
35
|
+
)
|
36
|
+
```
|
37
|
+
|
38
|
+
If the specified bucket doesn't exist, it will create in the region automatically.
|
39
|
+
|
40
|
+
## Development
|
41
|
+
|
42
|
+
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. Run `bundle exec sitemap_generator-aws_s3_adapter` to use the gem in this directory, ignoring other installed copies of this gem.
|
43
|
+
|
44
|
+
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).
|
45
|
+
|
46
|
+
## Contributing
|
47
|
+
|
48
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/qnyp/sitemap_generator-aws_s3_adapter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
49
|
+
|
50
|
+
## License
|
51
|
+
|
52
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "sitemap_generator/aws_s3_adapter"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/circle.yml
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'sitemap_generator'
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'aws-sdk'
|
5
|
+
rescue LoadError
|
6
|
+
raise LoadError, "Missing required 'aws-sdk. Please 'gem install aws-sdk'."
|
7
|
+
end
|
8
|
+
|
9
|
+
module SitemapGenerator
|
10
|
+
# Adapter for S3 with aws-sdk gem.
|
11
|
+
class AwsS3Adapter
|
12
|
+
# Public: Initialize an instance.
|
13
|
+
#
|
14
|
+
# access_key_id - An Access Key ID String.
|
15
|
+
# secret_access_key - A Secret Access Key String.
|
16
|
+
# bucket_name - A bucket name String.
|
17
|
+
# region - A region name String.
|
18
|
+
#
|
19
|
+
# Returns nothing.
|
20
|
+
def initialize(opts = {})
|
21
|
+
@access_key_id = opts[:access_key_id]
|
22
|
+
@secret_access_key = opts[:secret_access_key]
|
23
|
+
@bucket_name = opts[:bucket_name]
|
24
|
+
@region = opts[:region]
|
25
|
+
end
|
26
|
+
|
27
|
+
# Public: Writes a sitemap to S3 bucket.
|
28
|
+
#
|
29
|
+
# location - A SitemapGenerator::SitemapLocation object.
|
30
|
+
# raw_data - A raw data String.
|
31
|
+
#
|
32
|
+
# Returns nothing.
|
33
|
+
def write(location, raw_data)
|
34
|
+
SitemapGenerator::FileAdapter.new.write(location, raw_data)
|
35
|
+
|
36
|
+
create_bucket unless bucket_exists?
|
37
|
+
put_sitemap(location)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
# Internal: Retuns S3 client object.
|
43
|
+
#
|
44
|
+
# Returns a Aws::S3::Client.
|
45
|
+
def s3_client
|
46
|
+
@s3_client ||= Aws::S3::Client.new(
|
47
|
+
access_key_id: @access_key_id,
|
48
|
+
secret_access_key: @secret_access_key,
|
49
|
+
region: @region
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Internal: Returns whether the target bucket does exist?
|
54
|
+
#
|
55
|
+
# Returns boolean.
|
56
|
+
def bucket_exists?
|
57
|
+
resp = s3_client.list_buckets
|
58
|
+
bucket = resp.buckets.find { |i| i.name == @bucket_name }
|
59
|
+
bucket != nil
|
60
|
+
end
|
61
|
+
|
62
|
+
# Internal: Creates a new bucket.
|
63
|
+
#
|
64
|
+
# Returns nothing.
|
65
|
+
def create_bucket
|
66
|
+
s3_client.create_bucket(acl: 'private', bucket: @bucket_name)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Internal: Put a sitemap into the bucket.
|
70
|
+
#
|
71
|
+
# location - A SitemapGenerator::SitemapLocation object.
|
72
|
+
#
|
73
|
+
# Returns nothing.
|
74
|
+
def put_sitemap(location)
|
75
|
+
content_type = location[:compress] ? 'application/x-gzip' : 'application/xml'
|
76
|
+
|
77
|
+
s3_client.put_object(
|
78
|
+
acl: 'public-read',
|
79
|
+
body: File.open(location.path),
|
80
|
+
bucket: @bucket_name,
|
81
|
+
cache_control: 'private, max-age=0, no-cache',
|
82
|
+
content_type: content_type,
|
83
|
+
key: location.path_in_public
|
84
|
+
)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sitemap_generator/aws_s3_adapter/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'sitemap_generator-aws_s3_adapter'
|
8
|
+
spec.version = SitemapGenerator::AwsS3Adapter::VERSION
|
9
|
+
spec.authors = ['Junya Ogura', 'qnyp, inc.']
|
10
|
+
spec.email = ['junyaogura@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = %q(Yet another AWS S3 adapter for sitemap_generator gem.)
|
13
|
+
spec.description = %q(Yet another AWS S3 adapter for sitemap_generator gem. This adapter works with official aws-sdk gem instead of fog.)
|
14
|
+
spec.homepage = 'https://github.com/qnyp/sitemap_generator-aws_s3_adapter'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_runtime_dependency 'aws-sdk', '~> 2.2.0'
|
21
|
+
spec.add_runtime_dependency 'sitemap_generator', '~> 5.1.0'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sitemap_generator-aws_s3_adapter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Junya Ogura
|
8
|
+
- qnyp, inc.
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-03-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: aws-sdk
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 2.2.0
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 2.2.0
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: sitemap_generator
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 5.1.0
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 5.1.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: bundler
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.11'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.11'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '10.0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '10.0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '3.0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '3.0'
|
84
|
+
description: Yet another AWS S3 adapter for sitemap_generator gem. This adapter works
|
85
|
+
with official aws-sdk gem instead of fog.
|
86
|
+
email:
|
87
|
+
- junyaogura@gmail.com
|
88
|
+
executables: []
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- ".gitignore"
|
93
|
+
- ".rspec"
|
94
|
+
- CODE_OF_CONDUCT.md
|
95
|
+
- Gemfile
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/console
|
100
|
+
- bin/setup
|
101
|
+
- circle.yml
|
102
|
+
- lib/sitemap_generator/aws_s3_adapter.rb
|
103
|
+
- lib/sitemap_generator/aws_s3_adapter/version.rb
|
104
|
+
- sitemap_generator-aws_s3_adapter.gemspec
|
105
|
+
homepage: https://github.com/qnyp/sitemap_generator-aws_s3_adapter
|
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: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.5.1
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: Yet another AWS S3 adapter for sitemap_generator gem.
|
129
|
+
test_files: []
|