indexmap 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -5
- data/README.md +92 -22
- data/lib/indexmap/configuration.rb +3 -6
- data/lib/indexmap/creator.rb +22 -35
- data/lib/indexmap/index_now_configuration.rb +12 -5
- data/lib/indexmap/output.rb +3 -5
- data/lib/indexmap/parser.rb +26 -14
- data/lib/indexmap/pinger/base.rb +5 -1
- data/lib/indexmap/pinger/google.rb +2 -2
- data/lib/indexmap/pinger/index_now.rb +21 -24
- data/lib/indexmap/storage/active_storage.rb +105 -0
- data/lib/indexmap/storage/file.rb +11 -0
- data/lib/indexmap/storage/filesystem.rb +77 -0
- data/lib/indexmap/storage/memory.rb +61 -0
- data/lib/indexmap/task_runner.rb +8 -8
- data/lib/indexmap/validator.rb +42 -30
- data/lib/indexmap/version.rb +1 -1
- data/lib/indexmap/writer.rb +2 -9
- data/lib/indexmap.rb +4 -1
- data/lib/tasks/indexmap_tasks.rake +5 -5
- data/test/indexmap/configuration_test.rb +98 -129
- data/test/indexmap/parser_test.rb +44 -3
- data/test/indexmap/pinger/google_test.rb +101 -123
- data/test/indexmap/pinger/index_now_test.rb +148 -179
- data/test/indexmap/storage_test.rb +123 -0
- data/test/indexmap/task_runner_test.rb +92 -63
- data/test/indexmap/validator_test.rb +96 -92
- data/test/indexmap/writer_test.rb +63 -74
- metadata +6 -3
- data/lib/indexmap/path.rb +0 -42
- data/test/indexmap/path_test.rb +0 -28
data/lib/indexmap/path.rb
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "uri"
|
|
4
|
-
|
|
5
|
-
module Indexmap
|
|
6
|
-
module Path
|
|
7
|
-
INDEX_FILENAME = "sitemap.xml"
|
|
8
|
-
LEGACY_FILENAME = "sitemap_index.xml"
|
|
9
|
-
|
|
10
|
-
module_function
|
|
11
|
-
|
|
12
|
-
def canonical_public_path(public_path: default_public_path_root, index_filename: default_index_filename)
|
|
13
|
-
Pathname(public_path).join(index_filename)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def existing_public_path(public_path: default_public_path_root, index_filename: default_index_filename, legacy_filename: LEGACY_FILENAME)
|
|
17
|
-
index_path = canonical_public_path(public_path: public_path, index_filename: index_filename)
|
|
18
|
-
return index_path if index_path.exist?
|
|
19
|
-
|
|
20
|
-
Pathname(public_path).join(legacy_filename)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def canonical_url(base_url, index_filename: default_index_filename)
|
|
24
|
-
URI.join(base_url, "/#{index_filename}").to_s
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def default_index_filename
|
|
28
|
-
configured = Indexmap.configuration.index_filename
|
|
29
|
-
configured.to_s.strip.empty? ? INDEX_FILENAME : configured
|
|
30
|
-
rescue
|
|
31
|
-
INDEX_FILENAME
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def default_public_path_root
|
|
35
|
-
if defined?(Rails)
|
|
36
|
-
Rails.public_path
|
|
37
|
-
else
|
|
38
|
-
Pathname("public")
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
data/test/indexmap/path_test.rb
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "test_helper"
|
|
4
|
-
|
|
5
|
-
class IndexmapPathTest < Minitest::Test
|
|
6
|
-
def test_existing_public_path_prefers_sitemap_index_when_present
|
|
7
|
-
Dir.mktmpdir do |dir|
|
|
8
|
-
public_path = Pathname(dir)
|
|
9
|
-
public_path.join("sitemap_index.xml").write("<urlset/>")
|
|
10
|
-
public_path.join("sitemap.xml").write("<sitemapindex/>")
|
|
11
|
-
|
|
12
|
-
assert_equal public_path.join("sitemap.xml"), Indexmap::Path.existing_public_path(public_path: public_path)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def test_existing_public_path_falls_back_to_legacy_sitemap_path
|
|
17
|
-
Dir.mktmpdir do |dir|
|
|
18
|
-
public_path = Pathname(dir)
|
|
19
|
-
public_path.join("sitemap_index.xml").write("<sitemapindex/>")
|
|
20
|
-
|
|
21
|
-
assert_equal public_path.join("sitemap_index.xml"), Indexmap::Path.existing_public_path(public_path: public_path)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def test_canonical_url_targets_sitemap_index
|
|
26
|
-
assert_equal "https://www.example.com/sitemap.xml", Indexmap::Path.canonical_url("https://www.example.com")
|
|
27
|
-
end
|
|
28
|
-
end
|