beachio-hammer 0.1.0.pre2 → 0.1.0.pre3
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/PUBLISH.md +8 -2
- data/lib/hammer/tag_parser.rb +69 -32
- data/lib/hammer/version.rb +1 -1
- data/spec/path_resolution_spec.rb +26 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9ff203a27e8f29525a3120a073279ab2e8578f9d60a49a7f1c62c7ebf1a59253
|
|
4
|
+
data.tar.gz: e706eaee172b73d6abf8c14f7d936adb48144b2c4b2fc8ebdbf44fcfb9952f81
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 47a316f9de1c74ec4c16881c2663ab8aa172256264fe6e7aa66aa84d95f7d26a8082bdf521bc998bcb26f5e8bc621b8b05c6301034ead326e2dbb8271e292185
|
|
7
|
+
data.tar.gz: 3c5cbc689cb680d0e3adf630adfc2add3f13285aebdd2f6dae258ea83deff4a7364dfe609ac816e638dab2b732ab2cf63404b9effe1d5424afb8ac182e7e35d0
|
data/PUBLISH.md
CHANGED
|
@@ -38,7 +38,13 @@ gem build beachio-hammer.gemspec
|
|
|
38
38
|
gem push beachio-hammer-*.gem
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
Prerelease pin for executor team: **`beachio-hammer` `0.1.0.
|
|
41
|
+
Prerelease pin for executor team: **`beachio-hammer` `0.1.0.pre3`**
|
|
42
|
+
|
|
43
|
+
### 0.1.0.pre3 changes (nested @path resolution)
|
|
44
|
+
|
|
45
|
+
- Resolve `@path` using full path segments (not basename only)
|
|
46
|
+
- Resolve directory paths via `index.html` lookup
|
|
47
|
+
- Always emit context-aware relative URLs (Swift parity)
|
|
42
48
|
|
|
43
49
|
### 0.1.0.pre2 changes (Beachio / Linux fixes)
|
|
44
50
|
|
|
@@ -52,7 +58,7 @@ Prerelease pin for executor team: **`beachio-hammer` `0.1.0.pre2`**
|
|
|
52
58
|
Pin the published gem version in the executor Dockerfile:
|
|
53
59
|
|
|
54
60
|
```dockerfile
|
|
55
|
-
RUN gem install beachio-hammer -v 0.1.0.
|
|
61
|
+
RUN gem install beachio-hammer -v 0.1.0.pre3
|
|
56
62
|
```
|
|
57
63
|
|
|
58
64
|
Build step in the agent:
|
data/lib/hammer/tag_parser.rb
CHANGED
|
@@ -349,34 +349,58 @@ module Hammer
|
|
|
349
349
|
ref = get_variable(ref[1..]) || ref
|
|
350
350
|
end
|
|
351
351
|
|
|
352
|
-
|
|
353
|
-
generate_context_aware_path(".")
|
|
354
|
-
else
|
|
355
|
-
preserve_slash = ref.end_with?("/")
|
|
356
|
-
filename = preserve_slash ? ref.chomp("/") : ref
|
|
357
|
-
paths, error = find_file(File.basename(filename))
|
|
358
|
-
raise TagError, error if error
|
|
359
|
-
|
|
360
|
-
if paths.empty?
|
|
361
|
-
@delegate&.warning(@current_file_path, "File not found: #{ref}")
|
|
362
|
-
ref
|
|
363
|
-
else
|
|
364
|
-
path = paths.first
|
|
365
|
-
path = "#{path}/" if preserve_slash
|
|
366
|
-
generate_context_aware_path(path).gsub("%20", " ").gsub(" ", "%20")
|
|
367
|
-
end
|
|
368
|
-
end
|
|
352
|
+
resolve_path_reference(ref)
|
|
369
353
|
end
|
|
370
354
|
end
|
|
371
355
|
|
|
356
|
+
def resolve_path_reference(ref)
|
|
357
|
+
if ref == "/"
|
|
358
|
+
return root_relative_path
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
preserve_slash = ref.end_with?("/")
|
|
362
|
+
search_path = preserve_slash ? ref.chomp("/") : ref
|
|
363
|
+
paths, error = find_file(search_path)
|
|
364
|
+
raise TagError, error if error
|
|
365
|
+
|
|
366
|
+
if preserve_slash && paths.empty?
|
|
367
|
+
index_path = "#{search_path}/index.html"
|
|
368
|
+
index_paths, index_error = find_file(index_path)
|
|
369
|
+
raise TagError, index_error if index_error
|
|
370
|
+
|
|
371
|
+
paths = [search_path] unless index_paths.empty?
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
relative_path = (paths.first || search_path).tr(" ", "%20")
|
|
375
|
+
relative_path = "#{relative_path}/" if preserve_slash && !relative_path.end_with?("/")
|
|
376
|
+
|
|
377
|
+
@delegate&.warning(@current_file_path, "File not found: #{ref}") if paths.empty?
|
|
378
|
+
|
|
379
|
+
generate_context_aware_path(relative_path, preserve_trailing_slash: preserve_slash)
|
|
380
|
+
.tr("%20", " ")
|
|
381
|
+
.gsub(" ", "%20")
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
def root_relative_path
|
|
385
|
+
return "./" unless @current_file_path
|
|
386
|
+
|
|
387
|
+
current_dir = current_directory_components
|
|
388
|
+
return "./" if current_dir.empty?
|
|
389
|
+
|
|
390
|
+
"#{"../" * current_dir.length}"
|
|
391
|
+
end
|
|
392
|
+
|
|
372
393
|
def find_file(filename)
|
|
373
394
|
found = []
|
|
395
|
+
direct_path = File.join(@source_directory, filename)
|
|
396
|
+
found << filename if File.file?(direct_path)
|
|
397
|
+
|
|
374
398
|
dirs = %w[assets/img assets/images assets/media images img media]
|
|
375
399
|
dirs.each do |dir|
|
|
376
400
|
path = "#{dir}/#{filename}"
|
|
377
401
|
found << path if File.file?(File.join(@source_directory, path))
|
|
378
402
|
end
|
|
379
|
-
found
|
|
403
|
+
found.uniq!
|
|
380
404
|
|
|
381
405
|
if found.empty? || found.length > 1
|
|
382
406
|
Dir.glob(File.join(@source_directory, "**", "*")).each do |f|
|
|
@@ -384,7 +408,9 @@ module Hammer
|
|
|
384
408
|
rel = f.delete_prefix("#{@source_directory}/")
|
|
385
409
|
next if skip_scan_path?(rel)
|
|
386
410
|
|
|
387
|
-
|
|
411
|
+
if rel == filename || File.basename(f) == filename
|
|
412
|
+
found << rel unless found.include?(rel)
|
|
413
|
+
end
|
|
388
414
|
end
|
|
389
415
|
end
|
|
390
416
|
|
|
@@ -394,26 +420,37 @@ module Hammer
|
|
|
394
420
|
[found, nil]
|
|
395
421
|
end
|
|
396
422
|
|
|
397
|
-
def
|
|
423
|
+
def current_directory_components
|
|
424
|
+
@current_file_path.split("/")[0...-1].reject { |part| part == "." || part.empty? }
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
def generate_context_aware_path(file_path, preserve_trailing_slash: file_path.end_with?("/"))
|
|
398
428
|
return "./#{file_path}" unless @current_file_path
|
|
399
429
|
|
|
400
|
-
path_for_processing =
|
|
401
|
-
current_dir =
|
|
430
|
+
path_for_processing = preserve_trailing_slash ? file_path.chomp("/") : file_path
|
|
431
|
+
current_dir = current_directory_components
|
|
402
432
|
target_parts = path_for_processing.split("/")
|
|
403
433
|
common = 0
|
|
404
434
|
common += 1 while common < current_dir.length && common < target_parts.length && current_dir[common] == target_parts[common]
|
|
405
435
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
parts = ([".."] * levels_up) + remaining
|
|
409
|
-
|
|
410
|
-
if parts.empty?
|
|
411
|
-
"./#{target_parts.last}"
|
|
412
|
-
elsif levels_up.zero? && remaining.length == 1
|
|
413
|
-
"./#{remaining[0]}"
|
|
436
|
+
if current_dir == target_parts
|
|
437
|
+
result = "./"
|
|
414
438
|
else
|
|
415
|
-
|
|
416
|
-
|
|
439
|
+
levels_up = current_dir.length - common
|
|
440
|
+
remaining = target_parts[common..]
|
|
441
|
+
parts = ([".."] * levels_up) + remaining
|
|
442
|
+
|
|
443
|
+
result = if parts.empty?
|
|
444
|
+
"./#{target_parts.last}"
|
|
445
|
+
elsif levels_up.zero? && remaining.length == 1
|
|
446
|
+
"./#{remaining[0]}"
|
|
447
|
+
else
|
|
448
|
+
parts.join("/")
|
|
449
|
+
end
|
|
450
|
+
end
|
|
451
|
+
|
|
452
|
+
result << "/" if preserve_trailing_slash && !result.end_with?("/")
|
|
453
|
+
result
|
|
417
454
|
end
|
|
418
455
|
|
|
419
456
|
def process_navigation_helpers(content)
|
data/lib/hammer/version.rb
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe Hammer::TagParser do
|
|
6
|
+
let(:source_directory) { File.expand_path("../../Test Projects/classic-fixture", __dir__) }
|
|
7
|
+
let(:parser) { described_class.new(source_directory: source_directory) }
|
|
8
|
+
|
|
9
|
+
it "resolves nested @path references relative to the output page" do
|
|
10
|
+
parser.current_file_path = "work/mixfit/index.html"
|
|
11
|
+
content = '<a href="<!-- @path products/gleo/ -->">'
|
|
12
|
+
|
|
13
|
+
result = parser.send(:parse, content)
|
|
14
|
+
|
|
15
|
+
expect(result).to include('href="../../products/gleo/"')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "resolves root @path references from nested pages" do
|
|
19
|
+
parser.current_file_path = "work/mixfit/index.html"
|
|
20
|
+
content = '<a href="<!-- @path / -->">'
|
|
21
|
+
|
|
22
|
+
result = parser.send(:parse, content)
|
|
23
|
+
|
|
24
|
+
expect(result).to include('href="../../"')
|
|
25
|
+
end
|
|
26
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: beachio-hammer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.0.
|
|
4
|
+
version: 0.1.0.pre3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Beach.io
|
|
@@ -80,6 +80,7 @@ files:
|
|
|
80
80
|
- spec/encoding_spec.rb
|
|
81
81
|
- spec/parity/classic_spec.rb
|
|
82
82
|
- spec/parity/content_spec.rb
|
|
83
|
+
- spec/path_resolution_spec.rb
|
|
83
84
|
- spec/spec_helper.rb
|
|
84
85
|
homepage: https://github.com/beachio/hammer-swift
|
|
85
86
|
licenses:
|