sitemap_generator 6.0.0 → 6.1.2

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
- SHA1:
3
- metadata.gz: bd5273cdd05ca2424e838c1505a796cb7bb55647
4
- data.tar.gz: 05cbb2f7268b6631738b8a6be118ae3319f053da
2
+ SHA256:
3
+ metadata.gz: 07d190381c5aae66acc3b6eaa43d61444f3280e1ff76fd0dadf49d6c730d9b7a
4
+ data.tar.gz: dc61f7ff02926247d30ead18d71b16068e14a01ed36bb0694f0615febef6000a
5
5
  SHA512:
6
- metadata.gz: 7c777c3ea4cbecfdaebbd51ae1d0a8179360d88550cb2b37dfe649cc5f3644edf84494f29caa1b1ccddadd5d84281e6fa15906f825c2824c00145c076e06aeb0
7
- data.tar.gz: d96685b4029e704e8320936dc74d63db60527f6846bc7aa4682612c254b1c4e89060c85c45b592c4f89d21c12580f815ef2fcedc067a4283ade468888515e388
6
+ metadata.gz: ee8f86311c174e2b9b01514d48325f6d824bcabfaf8e5a711ff7e83442bc9f5adf4bbbe1ddc990d292c8ffc73138e7244b840a38aaeccef6f26bb55adee8cae6
7
+ data.tar.gz: 1049e27acaa1dafee38153d4faa1b51de61e67162a792a525269090e51f85e1c5c919c9755cc301543e6cd97dd8f18f5d914685cc7e3a23c49a494d3abdb21d9
data/CHANGES.md CHANGED
@@ -1,3 +1,25 @@
1
+ ### 6.1.2
2
+
3
+ * Resolve NoMethodError using URI#open for Ruby less than 2.5.0 [#353](https://github.com/kjvarga/sitemap_generator/pull/353)
4
+
5
+ ### 6.1.1
6
+
7
+ * Resolve deprecation warning on using Kernel#open in Ruby 2.7 (use URI.open instead) [#342](https://github.com/kjvarga/sitemap_generator/pull/342)
8
+ * Support S3 Endpoints for S3 Compliant Providers like DigitalOcean Spaces [#325](https://github.com/kjvarga/sitemap_generator/pull/325)
9
+
10
+ ### 6.1.0
11
+
12
+ * 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)
13
+
14
+ ### 6.0.2
15
+
16
+ * Resolve `BigDecimal.new is deprecated` warnings in Ruby 2.5 [#305](https://github.com/kjvarga/sitemap_generator/pull/305).
17
+ * Resolve `instance variable not initialized`, `File.exists? is deprecated` and `'*' interpreted as argument prefix` warnings [#304](https://github.com/kjvarga/sitemap_generator/pull/304).
18
+
19
+ ### 6.0.1
20
+
21
+ * Use `yaml_tag` instead of `yaml_as`, which was deprecated in Ruby 2.4, and removed in 2.5 [#298](https://github.com/kjvarga/sitemap_generator/pull/298).
22
+
1
23
  ### 6.0.0
2
24
 
3
25
  *Backwards incompatible changes*
data/README.md CHANGED
@@ -20,7 +20,7 @@ Sitemaps adhere to the [Sitemap 0.9 protocol][sitemap_protocol] specification.
20
20
 
21
21
  ### Show Me
22
22
 
23
- This is a simple standalone example. For Rails installation see the [Rails instructions](#rails) in the [Install](#install) section.
23
+ This is a simple standalone example. For Rails installation see the [Rails instructions](#rails) in the [Install](#installation) section.
24
24
 
25
25
  Install:
26
26
 
@@ -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)
@@ -158,12 +164,14 @@ Add the gem to your `Gemfile`:
158
164
  gem 'sitemap_generator'
159
165
  ```
160
166
 
161
- Alternatively, if you are not using a `Gemfile` add the gem to your `config/environment.rb` file config block:
167
+ Alternatively, if you are not using a `Gemfile` add the gem to your `config/application.rb` file config block:
162
168
 
163
169
  ```ruby
164
170
  config.gem 'sitemap_generator'
165
171
  ```
166
172
 
173
+ Note: SitemapGenerator automatically loads its Rake tasks when used with Rails. You **do not need** to require the `sitemap_generator/tasks` file.
174
+
167
175
  ## Getting Started
168
176
 
169
177
  ### Preventing Output
@@ -327,29 +335,29 @@ directory.
327
335
 
328
336
  #### Supported Adapters
329
337
 
330
- * `SitemapGenerator::FileAdapter`
338
+ ##### `SitemapGenerator::FileAdapter`
331
339
 
332
340
  Standard adapter, writes out to a file.
333
341
 
334
- * `SitemapGenerator::FogAdapter`
342
+ ##### `SitemapGenerator::FogAdapter`
335
343
 
336
344
  Uses `Fog::Storage` to upload to any service supported by Fog.
337
345
 
338
346
  You must `require 'fog'` in your sitemap config before using this adapter,
339
347
  or `require` another library that defines `Fog::Storage`.
340
348
 
341
- * `SitemapGenerator::S3Adapter`
349
+ ##### `SitemapGenerator::S3Adapter`
342
350
 
343
351
  Uses `Fog::Storage` to upload to Amazon S3 storage.
344
352
 
345
353
  You must `require 'fog-aws'` in your sitemap config before using this adapter.
346
354
 
347
- * `SitemapGenerator::AwsSdkAdapter`
355
+ ##### `SitemapGenerator::AwsSdkAdapter`
348
356
 
349
357
  Uses `Aws::S3::Resource` to upload to Amazon S3 storage. Includes automatic detection of your AWS
350
358
  credentials using `Aws::Credentials`.
351
359
 
352
- You must `require 'aws-sdk'` in your sitemap config before using this adapter,
360
+ You must `require 'aws-sdk-s3'` in your sitemap config before using this adapter,
353
361
  or `require` another library that defines `Aws::S3::Resource` and `Aws::Credentials`.
354
362
 
355
363
  An example of using this adapter in your sitemap configuration:
@@ -362,7 +370,26 @@ directory.
362
370
  )
363
371
  ```
364
372
 
365
- * `SitemapGenerator::WaveAdapter`
373
+ ##### `SitemapGenerator::AwsSdkAdapter (DigitalOcean Spaces)`
374
+
375
+ Uses `Aws::S3::Resource` to upload to Amazon S3 storage. Includes automatic detection of your AWS
376
+ credentials using `Aws::Credentials`.
377
+
378
+ You must `require 'aws-sdk-s3'` in your sitemap config before using this adapter,
379
+ or `require` another library that defines `Aws::S3::Resource` and `Aws::Credentials`.
380
+
381
+ An example of using this adapter in your sitemap configuration:
382
+
383
+ ```ruby
384
+ SitemapGenerator::Sitemap.adapter = SitemapGenerator::AwsSdkAdapter.new('s3_bucket',
385
+ aws_access_key_id: 'AKIAI3SW5CRAZBL4WSTA',
386
+ aws_secret_access_key: 'asdfadsfdsafsadf',
387
+ aws_region: 'sfo2',
388
+ aws_endpoint: 'https://sfo2.digitaloceanspaces.com'
389
+ )
390
+ ```
391
+
392
+ ##### `SitemapGenerator::WaveAdapter`
366
393
 
367
394
  Uses `CarrierWave::Uploader::Base` to upload to any service supported by CarrierWave, for example,
368
395
  Amazon S3, Rackspace Cloud Files, and MongoDB's GridF.
@@ -372,6 +399,31 @@ directory.
372
399
 
373
400
  Some documentation exists [on the wiki page][remote_hosts].
374
401
 
402
+ ##### `SitemapGenerator::GoogleStorageAdapter`
403
+
404
+ Uses [`Google::Cloud::Storage`][google_cloud_storage_gem] to upload to Google Cloud storage.
405
+
406
+ You must `require 'google/cloud/storage'` in your sitemap config before using this adapter.
407
+
408
+ An example of using this adapter in your sitemap configuration with options:
409
+
410
+ ```ruby
411
+ SitemapGenerator::Sitemap.adapter = SitemapGenerator::GoogleStorageAdapter.new(
412
+ credentials: 'path/to/keyfile.json',
413
+ project_id: 'google_account_project_id',
414
+ bucket: 'name_of_bucket'
415
+ )
416
+ ```
417
+ 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:
418
+
419
+ ```ruby
420
+ SitemapGenerator::Sitemap.adapter = SitemapGenerator::GoogleStorageAdapter.new(
421
+ bucket: 'name_of_bucket'
422
+ )
423
+ ```
424
+
425
+ 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.
426
+
375
427
  #### An Example of Using an Adapter
376
428
 
377
429
  1. Please see [this wiki page][remote_hosts] for more information about setting up SitemapGenerator to upload to a
@@ -1118,3 +1170,6 @@ Copyright (c) Karl Varga released under the MIT license
1118
1170
  [iso_4217]:http://en.wikipedia.org/wiki/ISO_4217
1119
1171
  [media]:https://developers.google.com/webmasters/smartphone-sites/details
1120
1172
  [expires]:https://support.google.com/customsearch/answer/2631051?hl=en
1173
+ [google_cloud_storage_gem]:https://rubygems.org/gems/google-cloud-storage
1174
+ [google_cloud_storage_authentication]:https://googleapis.dev/ruby/google-cloud-storage/latest/file.AUTHENTICATION.html
1175
+ [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.0
1
+ 6.1.2
@@ -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)
@@ -56,6 +57,7 @@ module SitemapGenerator
56
57
  attr_accessor :root, :app, :templates
57
58
  attr_writer :yield_sitemap, :verbose
58
59
  end
60
+ @yield_sitemap = nil
59
61
 
60
62
  # Global default for the verbose setting.
61
63
  def self.verbose
@@ -24,6 +24,7 @@ module SitemapGenerator
24
24
  @aws_access_key_id = options[:aws_access_key_id]
25
25
  @aws_secret_access_key = options[:aws_secret_access_key]
26
26
  @aws_region = options[:aws_region]
27
+ @aws_endpoint = options[:aws_endpoint]
27
28
  end
28
29
 
29
30
  # Call with a SitemapLocation and string data
@@ -46,6 +47,7 @@ module SitemapGenerator
46
47
  def s3_resource_options
47
48
  options = {}
48
49
  options[:region] = @aws_region if !@aws_region.nil?
50
+ options[:endpoint] = @aws_endpoint if !@aws_endpoint.nil?
49
51
  if !@aws_access_key_id.nil? && !@aws_secret_access_key.nil?
50
52
  options[:credentials] = Aws::Credentials.new(
51
53
  @aws_access_key_id,
@@ -11,7 +11,7 @@ module SitemapGenerator
11
11
  def write(location, raw_data)
12
12
  # Ensure that the directory exists
13
13
  dir = location.directory
14
- if !File.exists?(dir)
14
+ if !File.exist?(dir)
15
15
  FileUtils.mkdir_p(dir)
16
16
  elsif !File.directory?(dir)
17
17
  raise SitemapError.new("#{dir} should be a directory!")
@@ -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
@@ -30,6 +30,7 @@ module SitemapGenerator
30
30
  # Store the URL of the first sitemap added because if create_index is
31
31
  # false this is the "index" URL
32
32
  @first_sitemap_url = nil
33
+ @create_index = nil
33
34
  end
34
35
 
35
36
  # Finalize sitemaps as they are added to the index.
@@ -8,11 +8,23 @@ end
8
8
  require 'yaml'
9
9
 
10
10
  # Define our own class rather than modify the global class
11
- class SitemapGenerator::BigDecimal < BigDecimal
11
+ class SitemapGenerator::BigDecimal
12
12
  YAML_TAG = 'tag:yaml.org,2002:float'
13
13
  YAML_MAPPING = { 'Infinity' => '.Inf', '-Infinity' => '-.Inf', 'NaN' => '.NaN' }
14
14
 
15
- yaml_as YAML_TAG
15
+ yaml_tag YAML_TAG
16
+
17
+ def initialize(num)
18
+ @value = BigDecimal(num)
19
+ end
20
+
21
+ def *(other)
22
+ other * @value
23
+ end
24
+
25
+ def /(other)
26
+ SitemapGenerator::BigDecimal === other ? @value / other.instance_variable_get(:@value) : @value / other
27
+ end
16
28
 
17
29
  # This emits the number without any scientific notation.
18
30
  # This is better than self.to_f.to_s since it doesn't lose precision.
@@ -37,9 +49,7 @@ class SitemapGenerator::BigDecimal < BigDecimal
37
49
  end
38
50
 
39
51
  DEFAULT_STRING_FORMAT = 'F'
40
- def to_formatted_s(format = DEFAULT_STRING_FORMAT)
41
- _original_to_s(format)
52
+ def to_s(format = DEFAULT_STRING_FORMAT)
53
+ @value.to_s(format)
42
54
  end
43
- alias_method :_original_to_s, :to_s
44
- alias_method :to_s, :to_formatted_s
45
55
  end
@@ -118,6 +118,8 @@ module SitemapGenerator
118
118
  # Note: When adding a new option be sure to include it in `options_for_group()` if
119
119
  # the option should be inherited by groups.
120
120
  def initialize(options={})
121
+ @default_host, @sitemaps_host, @yield_sitemap, @sitemaps_path, @adapter, @verbose, @protect_index, @sitemap_index, @added_default_links, @created_group, @sitemap = nil
122
+
121
123
  options = SitemapGenerator::Utilities.reverse_merge(options,
122
124
  :include_root => true,
123
125
  :include_index => false,
@@ -293,7 +295,11 @@ module SitemapGenerator
293
295
  name = Utilities.titleize(engine.to_s)
294
296
  begin
295
297
  Timeout::timeout(10) {
296
- open(link)
298
+ if URI.respond_to?(:open) # Available since Ruby 2.5
299
+ URI.open(link)
300
+ else
301
+ open(link) # using Kernel#open became deprecated since Ruby 2.7. See https://bugs.ruby-lang.org/issues/15893
302
+ end
297
303
  }
298
304
  output(" Successful ping of #{name}")
299
305
  rescue Timeout::Error, StandardError => e
@@ -11,7 +11,7 @@ module SitemapGenerator
11
11
  }
12
12
 
13
13
  # Dynamically define accessors for each key defined in <tt>FILES</tt>
14
- attr_accessor *FILES.keys
14
+ attr_accessor(*FILES.keys)
15
15
  FILES.keys.each do |name|
16
16
  eval <<-END
17
17
  define_method(:#{name}) do
@@ -38,4 +38,4 @@ module SitemapGenerator
38
38
  File.read(template_path(template))
39
39
  end
40
40
  end
41
- end
41
+ 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.0
4
+ version: 6.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Varga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-11 00:00:00.000000000 Z
11
+ date: 2020-06-03 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
@@ -184,8 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
199
  - !ruby/object:Gem::Version
185
200
  version: '0'
186
201
  requirements: []
187
- rubyforge_project:
188
- rubygems_version: 2.6.14
202
+ rubygems_version: 3.1.2
189
203
  signing_key:
190
204
  specification_version: 4
191
205
  summary: Easily generate XML Sitemaps