indexmap 0.6.0 → 0.7.1

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.
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+ require "rake"
5
+
6
+ unless respond_to?(:release_version, true)
7
+ load File.expand_path("../Rakefile", __dir__)
8
+ end
9
+
10
+ class ReleaseTaskTest < Minitest::Test
11
+ def test_release_version_increments_patch_from_current_version
12
+ major, minor, patch = Indexmap::VERSION.split(".").map(&:to_i)
13
+
14
+ assert_equal "#{major}.#{minor}.#{patch + 1}", release_version("patch")
15
+ end
16
+
17
+ def test_release_version_accepts_explicit_semantic_version
18
+ assert_equal "0.3.0", release_version("0.3.0")
19
+ end
20
+
21
+ def test_validate_release_version_rejects_current_version
22
+ error = assert_raises(ArgumentError) do
23
+ validate_release_version!("0.2.7", "0.2.7")
24
+ end
25
+
26
+ assert_equal(
27
+ "Release version 0.2.7 must be newer than current version 0.2.7.",
28
+ error.message
29
+ )
30
+ end
31
+
32
+ def test_validate_release_version_rejects_existing_local_tag
33
+ @local_release_tag_exists = true
34
+ @remote_release_tag_exists = false
35
+
36
+ error = assert_raises(ArgumentError) do
37
+ validate_release_version!("0.2.8", "0.2.7")
38
+ end
39
+
40
+ assert_equal "Release tag v0.2.8 already exists locally.", error.message
41
+ end
42
+
43
+ def test_validate_release_version_rejects_existing_remote_tag
44
+ @local_release_tag_exists = false
45
+ @remote_release_tag_exists = true
46
+
47
+ error = assert_raises(ArgumentError) do
48
+ validate_release_version!("0.2.8", "0.2.7")
49
+ end
50
+
51
+ assert_equal "Release tag v0.2.8 already exists on origin.", error.message
52
+ end
53
+
54
+ def test_remote_release_tag_command_asks_git_to_fail_when_no_tag_matches
55
+ assert_equal(
56
+ "git ls-remote --exit-code --tags origin refs/tags/v0.2.8",
57
+ remote_release_tag_command("v0.2.8")
58
+ )
59
+ end
60
+
61
+ def test_changelog_command_prepends_the_next_release
62
+ assert_equal(
63
+ [
64
+ "git-cliff",
65
+ "-c",
66
+ "cliff.toml",
67
+ "--unreleased",
68
+ "--tag",
69
+ "v0.2.8",
70
+ "--prepend",
71
+ "CHANGELOG.md"
72
+ ],
73
+ changelog_command("0.2.8")
74
+ )
75
+ end
76
+
77
+ private
78
+
79
+ def local_release_tag_exists?(_tag)
80
+ @local_release_tag_exists || false
81
+ end
82
+
83
+ def remote_release_tag_exists?(_tag)
84
+ @remote_release_tag_exists || false
85
+ end
86
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: indexmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paulo Fidalgo
@@ -183,12 +183,15 @@ files:
183
183
  - lib/indexmap/index_now_configuration.rb
184
184
  - lib/indexmap/output.rb
185
185
  - lib/indexmap/parser.rb
186
- - lib/indexmap/path.rb
187
186
  - lib/indexmap/pinger/base.rb
188
187
  - lib/indexmap/pinger/google.rb
189
188
  - lib/indexmap/pinger/index_now.rb
190
189
  - lib/indexmap/railtie.rb
191
190
  - lib/indexmap/section.rb
191
+ - lib/indexmap/storage/active_storage.rb
192
+ - lib/indexmap/storage/file.rb
193
+ - lib/indexmap/storage/filesystem.rb
194
+ - lib/indexmap/storage/memory.rb
192
195
  - lib/indexmap/task_runner.rb
193
196
  - lib/indexmap/validator.rb
194
197
  - lib/indexmap/version.rb
@@ -196,12 +199,13 @@ files:
196
199
  - lib/tasks/indexmap_tasks.rake
197
200
  - test/indexmap/configuration_test.rb
198
201
  - test/indexmap/parser_test.rb
199
- - test/indexmap/path_test.rb
200
202
  - test/indexmap/pinger/google_test.rb
201
203
  - test/indexmap/pinger/index_now_test.rb
204
+ - test/indexmap/storage_test.rb
202
205
  - test/indexmap/task_runner_test.rb
203
206
  - test/indexmap/validator_test.rb
204
207
  - test/indexmap/writer_test.rb
208
+ - test/release_task_test.rb
205
209
  - test/test_helper.rb
206
210
  homepage: https://www.ethos-link.com/opensource/indexmap
207
211
  licenses:
@@ -230,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
234
  - !ruby/object:Gem::Version
231
235
  version: '0'
232
236
  requirements: []
233
- rubygems_version: 4.0.6
237
+ rubygems_version: 4.0.10
234
238
  specification_version: 4
235
239
  summary: Generate sitemap indexes and child sitemaps with plain Ruby
236
240
  test_files: []
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
@@ -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