sitemap_generator 6.0.2 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 526fb81217b6a251f0855ca41062a46c4e891c7ef0b0f205e66150c71971d88e
4
- data.tar.gz: 60deb9fca4870f1726a366a8179ce4845e0221a8eb59d59dd44d990f603b1665
3
+ metadata.gz: 3d08b16f794edd543800c56dd8b2827c6b4ea4fb85721b18e3b675c4a5599a9d
4
+ data.tar.gz: ce55fb33969d09c5e2d9ca4b841f511b6ecb9a365a64ec20964394266bcee305
5
5
  SHA512:
6
- metadata.gz: 66d23227adef4509f58d8187f8b41008a1357b558db9c669bb83bba3a28372f23be1958cc22a14bab2be891b4984bfda9360afdb807665ebd137fe45a2e19833
7
- data.tar.gz: cedd0f41927cd430a8f3089e71230dcd11f92804b62bb1dad8626925068823e27bce55cb144fc49d2c78010239f4ff350ed877f948291b28b8ff7fd894311d14
6
+ metadata.gz: 0fe5e90c200a165349a424cfbe919bb11613419acad18d068c8406c8998b22c965b80bb7a16caf20e4c59da44595abeae91f4d7555992f6f249cd4665d036cd4
7
+ data.tar.gz: 7f9493d43d626dde991e35f3b552541be9154d22c5a94c55820b50f023b647207167a3dccafeff2a5402c57fa2bd0c4cd6bac2f644ecf6b823fdc1d6716b714e
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 6.1.0
2
+
3
+ * Support uploading files to Google Cloud Storage [#326](https://github.com/kjvarga/sitemap_generator/pull/326) and [#340](https://github.com/kjvarga/sitemap_generator/pull/340)
4
+
1
5
  ### 6.0.2
2
6
 
3
7
  * Resolve `BigDecimal.new is deprecated` warnings in Ruby 2.5 [#305](https://github.com/kjvarga/sitemap_generator/pull/305).
data/README.md CHANGED
@@ -80,6 +80,12 @@ Successful ping of Bing
80
80
  + [Sitemaps with no Index File](#sitemaps-with-no-index-file)
81
81
  + [Upload Sitemaps to a Remote Host using Adapters](#upload-sitemaps-to-a-remote-host-using-adapters)
82
82
  - [Supported Adapters](#supported-adapters)
83
+ * [`SitemapGenerator::FileAdapter`](#sitemapgeneratorfileadapter)
84
+ * [`SitemapGenerator::FogAdapter`](#sitemapgeneratorfogadapter)
85
+ * [`SitemapGenerator::S3Adapter`](#sitemapgenerators3adapter)
86
+ * [`SitemapGenerator::AwsSdkAdapter`](#sitemapgeneratorawssdkadapter)
87
+ * [`SitemapGenerator::WaveAdapter`](#sitemapgeneratorwaveadapter)
88
+ * [`SitemapGenerator::GoogleStorageAdapter`](#sitemapgeneratorgooglestorageadapter)
83
89
  - [An Example of Using an Adapter](#an-example-of-using-an-adapter)
84
90
  + [Generating Multiple Sitemaps](#generating-multiple-sitemaps)
85
91
  * [Sitemap Configuration](#sitemap-configuration)
@@ -329,24 +335,24 @@ directory.
329
335
 
330
336
  #### Supported Adapters
331
337
 
332
- * `SitemapGenerator::FileAdapter`
338
+ ##### `SitemapGenerator::FileAdapter`
333
339
 
334
340
  Standard adapter, writes out to a file.
335
341
 
336
- * `SitemapGenerator::FogAdapter`
342
+ ##### `SitemapGenerator::FogAdapter`
337
343
 
338
344
  Uses `Fog::Storage` to upload to any service supported by Fog.
339
345
 
340
346
  You must `require 'fog'` in your sitemap config before using this adapter,
341
347
  or `require` another library that defines `Fog::Storage`.
342
348
 
343
- * `SitemapGenerator::S3Adapter`
349
+ ##### `SitemapGenerator::S3Adapter`
344
350
 
345
351
  Uses `Fog::Storage` to upload to Amazon S3 storage.
346
352
 
347
353
  You must `require 'fog-aws'` in your sitemap config before using this adapter.
348
354
 
349
- * `SitemapGenerator::AwsSdkAdapter`
355
+ ##### `SitemapGenerator::AwsSdkAdapter`
350
356
 
351
357
  Uses `Aws::S3::Resource` to upload to Amazon S3 storage. Includes automatic detection of your AWS
352
358
  credentials using `Aws::Credentials`.
@@ -364,7 +370,7 @@ directory.
364
370
  )
365
371
  ```
366
372
 
367
- * `SitemapGenerator::WaveAdapter`
373
+ ##### `SitemapGenerator::WaveAdapter`
368
374
 
369
375
  Uses `CarrierWave::Uploader::Base` to upload to any service supported by CarrierWave, for example,
370
376
  Amazon S3, Rackspace Cloud Files, and MongoDB's GridF.
@@ -374,6 +380,31 @@ directory.
374
380
 
375
381
  Some documentation exists [on the wiki page][remote_hosts].
376
382
 
383
+ ##### `SitemapGenerator::GoogleStorageAdapter`
384
+
385
+ Uses [`Google::Cloud::Storage`][google_cloud_storage_gem] to upload to Google Cloud storage.
386
+
387
+ You must `require 'google/cloud/storage'` in your sitemap config before using this adapter.
388
+
389
+ An example of using this adapter in your sitemap configuration with options:
390
+
391
+ ```ruby
392
+ SitemapGenerator::Sitemap.adapter = SitemapGenerator::GoogleStorageAdapter.new(
393
+ credentials: 'path/to/keyfile.json',
394
+ project_id: 'google_account_project_id',
395
+ bucket: 'name_of_bucket'
396
+ )
397
+ ```
398
+ Also, inline with Google Authentication options, it can also pick credentials from environment variables. All [supported environment variables][google_cloud_storage_authentication] can be used, for example: `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_CREDENTIALS`. An example of using this adapter with the environment variables is:
399
+
400
+ ```ruby
401
+ SitemapGenerator::Sitemap.adapter = SitemapGenerator::GoogleStorageAdapter.new(
402
+ bucket: 'name_of_bucket'
403
+ )
404
+ ```
405
+
406
+ All options other than the `:bucket` option are passed to the `Google::Cloud::Storage.new` initializer giving you maximum configurability. See the [Google Cloud Storage initializer][google_cloud_storage_initializer] for supported options.
407
+
377
408
  #### An Example of Using an Adapter
378
409
 
379
410
  1. Please see [this wiki page][remote_hosts] for more information about setting up SitemapGenerator to upload to a
@@ -1120,3 +1151,6 @@ Copyright (c) Karl Varga released under the MIT license
1120
1151
  [iso_4217]:http://en.wikipedia.org/wiki/ISO_4217
1121
1152
  [media]:https://developers.google.com/webmasters/smartphone-sites/details
1122
1153
  [expires]:https://support.google.com/customsearch/answer/2631051?hl=en
1154
+ [google_cloud_storage_gem]:https://rubygems.org/gems/google-cloud-storage
1155
+ [google_cloud_storage_authentication]:https://googleapis.dev/ruby/google-cloud-storage/latest/file.AUTHENTICATION.html
1156
+ [google_cloud_storage_initializer]:https://github.com/googleapis/google-cloud-ruby/blob/master/google-cloud-storage/lib/google/cloud/storage.rb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 6.0.2
1
+ 6.1.0
@@ -7,14 +7,15 @@ require 'sitemap_generator/application'
7
7
  require 'sitemap_generator/sitemap_location'
8
8
 
9
9
  module SitemapGenerator
10
- autoload(:Interpreter, 'sitemap_generator/interpreter')
11
- autoload(:FileAdapter, 'sitemap_generator/adapters/file_adapter')
12
- autoload(:S3Adapter, 'sitemap_generator/adapters/s3_adapter')
13
- autoload(:AwsSdkAdapter, 'sitemap_generator/adapters/aws_sdk_adapter')
14
- autoload(:WaveAdapter, 'sitemap_generator/adapters/wave_adapter')
15
- autoload(:FogAdapter, 'sitemap_generator/adapters/fog_adapter')
16
- autoload(:BigDecimal, 'sitemap_generator/core_ext/big_decimal')
17
- autoload(:Numeric, 'sitemap_generator/core_ext/numeric')
10
+ autoload(:Interpreter, 'sitemap_generator/interpreter')
11
+ autoload(:FileAdapter, 'sitemap_generator/adapters/file_adapter')
12
+ autoload(:S3Adapter, 'sitemap_generator/adapters/s3_adapter')
13
+ autoload(:AwsSdkAdapter, 'sitemap_generator/adapters/aws_sdk_adapter')
14
+ autoload(:WaveAdapter, 'sitemap_generator/adapters/wave_adapter')
15
+ autoload(:FogAdapter, 'sitemap_generator/adapters/fog_adapter')
16
+ autoload(:GoogleStorageAdapter, 'sitemap_generator/adapters/google_storage_adapter')
17
+ autoload(:BigDecimal, 'sitemap_generator/core_ext/big_decimal')
18
+ autoload(:Numeric, 'sitemap_generator/core_ext/numeric')
18
19
 
19
20
  SitemapError = Class.new(StandardError)
20
21
  SitemapFullError = Class.new(SitemapError)
@@ -0,0 +1,37 @@
1
+ if !defined?(Google::Cloud::Storage)
2
+ raise "Error: `Google::Cloud::Storage` is not defined.\n\n"\
3
+ "Please `require 'google/cloud/storage'` - or another library that defines this class."
4
+ end
5
+
6
+ module SitemapGenerator
7
+ # Class for uploading sitemaps to a Google Storage using `google-cloud-storage` gem.
8
+ class GoogleStorageAdapter
9
+ # Requires Google::Cloud::Storage to be defined.
10
+ #
11
+ # @param [Hash] opts Google::Cloud::Storage configuration options.
12
+ # @option :bucket [String] Required. Name of Google Storage Bucket where the file is to be uploaded.
13
+ #
14
+ # All options other than the `:bucket` option are passed to the `Google::Cloud::Storage.new`
15
+ # initializer. See https://googleapis.dev/ruby/google-cloud-storage/latest/file.AUTHENTICATION.html
16
+ # for all the supported environment variables and https://github.com/googleapis/google-cloud-ruby/blob/master/google-cloud-storage/lib/google/cloud/storage.rb
17
+ # for supported options.
18
+ #
19
+ # Suggested Options:
20
+ # @option :credentials [String] Path to Google service account JSON file, or JSON contents.
21
+ # @option :project_id [String] Google Accounts project id where the storage bucket resides.
22
+ def initialize(opts = {})
23
+ opts = opts.clone
24
+ @bucket = opts.delete(:bucket)
25
+ @storage_options = opts
26
+ end
27
+
28
+ # Call with a SitemapLocation and string data
29
+ def write(location, raw_data)
30
+ SitemapGenerator::FileAdapter.new.write(location, raw_data)
31
+
32
+ storage = Google::Cloud::Storage.new(@storage_options)
33
+ bucket = storage.bucket(@bucket)
34
+ bucket.create_file(location.path, location.path_in_public, acl: 'public')
35
+ end
36
+ end
37
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sitemap_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.2
4
+ version: 6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Varga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-10 00:00:00.000000000 Z
11
+ date: 2019-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: google-cloud-storage
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  description: SitemapGenerator is a framework-agnostic XML Sitemap generator written
126
140
  in Ruby with automatic Rails integration. It supports Video, News, Image, Mobile,
127
141
  PageMap and Alternate Links sitemap extensions and includes Rake tasks for managing
@@ -141,6 +155,7 @@ files:
141
155
  - lib/sitemap_generator/adapters/aws_sdk_adapter.rb
142
156
  - lib/sitemap_generator/adapters/file_adapter.rb
143
157
  - lib/sitemap_generator/adapters/fog_adapter.rb
158
+ - lib/sitemap_generator/adapters/google_storage_adapter.rb
144
159
  - lib/sitemap_generator/adapters/s3_adapter.rb
145
160
  - lib/sitemap_generator/adapters/wave_adapter.rb
146
161
  - lib/sitemap_generator/application.rb