nanoc-dart-sass 1.0.1 → 1.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: abb3353a67957a72db05a7eaec7a3dcd669b600a188b081bc41d9a8dd8b99a54
4
- data.tar.gz: ce51516fc85577f8c265669f9a3e71be00417eedda5f419b9e3d0f11d48ffbe4
3
+ metadata.gz: 3b3ec8688e0eacf5312456127b9f9137d7ee17fdc3b2788c8eb44d2a18a48d39
4
+ data.tar.gz: dfc61b8856486c27210a20b79fa70da2852a88f4eeb5a5e804b2b3411e8d7653
5
5
  SHA512:
6
- metadata.gz: 7c7a5043abd21b916203fc476a4305b7da06ce44b21e856714a48b88c125be5508bef0a60e41f48db09dbcf92365effa9f158b87628a2c56ba4cb0b2851d5e70
7
- data.tar.gz: a4e1f92ac5ec75283a1ef62d9b9801a773b05d7aaff4ca75b266d0130047d1343d95f85326c91528f9799273270cc5b3b46cb556b1455be436691303ed9ec060
6
+ metadata.gz: 054bdb5a6ba1c907c2c8fc06f56efde60a173df8b0aa328b3654df7b7a8e42017b0cc123bcf09317aa6e93ef1754ef65a83e659122ea1794950f8d63c87ef9f8
7
+ data.tar.gz: ba2afccd8953791279521d4444053df10e94ad69e9b16f787519b621e69fdf9e5f9b71bb72a861cb57165ccb9b8e4bf918724bef1805362fd3be2c1c6c2c32dc
data/NEWS.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # nanoc-dart-sass news
2
2
 
3
+ ## 1.0.3 (2024-04-19)
4
+
5
+ Enhancements:
6
+
7
+ - Added support for importing partials and directories (#1690, #1699)
8
+
9
+ ## 1.0.2 (2023-09-30)
10
+
11
+ - Fix dart-sass compatibility (#1664)
12
+
3
13
  ## 1.0.1 (2023-06-15)
4
14
 
5
15
  - Added support for importing relative paths (#1646, #1653)
@@ -23,9 +23,6 @@ module Nanoc
23
23
  syntax: syntax,
24
24
  )
25
25
  result.css
26
- rescue StandardError => e # rubocop:disable Lint/UselessRescue
27
- # TODO: use full_message for syntax errors
28
- raise e
29
26
  end
30
27
 
31
28
  class NanocImporter
@@ -34,7 +31,7 @@ module Nanoc
34
31
  @source_item = source_item
35
32
  end
36
33
 
37
- def canonicalize(url, **)
34
+ def canonicalize(url, *, **)
38
35
  # Construct proper URL with `nanoc:` prefix if needed
39
36
  if url.start_with?('nanoc:')
40
37
  url
@@ -57,10 +54,7 @@ module Nanoc
57
54
  def find_item_for_url(url)
58
55
  pat = url.sub(/\Ananoc:/, '')
59
56
 
60
- # If URL has no extension, add `.*` at the end
61
- if pat.match?(%r{(/|^)[^.]+$})
62
- pat += '.*'
63
- end
57
+ is_extension_given = !pat.match?(%r{(/|^)[^.]+$})
64
58
 
65
59
  # Convert to absolute pattern
66
60
  pat =
@@ -71,13 +65,48 @@ module Nanoc
71
65
  File.expand_path(pat, dirname)
72
66
  end
73
67
 
74
- item = @items[pat]
68
+ items = collect_items(pat, is_extension_given)
75
69
 
76
- unless item
70
+ # Get the single matching item, or error if there isn’t exactly one
71
+ items = items.compact
72
+ case items.size
73
+ when 0
77
74
  raise "Could not find an item matching pattern `#{pat}`"
75
+ when 1
76
+ items.first
77
+ else
78
+ raise "It is not clear which item to import. Multiple items match `#{pat}`: #{items.map { _1.identifier.to_s }.sort.join(', ')}"
79
+ end
80
+ end
81
+
82
+ # Given a pattern, return a collection of items that match this pattern.
83
+ # This goes beyond what Nanoc patterns typically support by e.g.
84
+ # supporting partials and index imports.
85
+ def collect_items(pat, is_extension_given)
86
+ items = []
87
+
88
+ # Try as a regular path
89
+ items.concat(try_pat(pat, is_extension_given))
90
+
91
+ # Try as a partial
92
+ partial_pat = File.join(File.dirname(pat), "_#{File.basename(pat)}")
93
+ items.concat(try_pat(partial_pat, is_extension_given))
94
+
95
+ # Try as index
96
+ unless is_extension_given
97
+ items.concat(@items.find_all(File.join(pat, '/index.*')))
98
+ items.concat(@items.find_all(File.join(pat, '/_index.*')))
78
99
  end
79
100
 
80
- item
101
+ items
102
+ end
103
+
104
+ def try_pat(pat, is_extension_given)
105
+ if is_extension_given
106
+ @items.find_all(pat)
107
+ else
108
+ @items.find_all("#{pat}.*")
109
+ end
81
110
  end
82
111
  end
83
112
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nanoc
4
4
  module DartSass
5
- VERSION = '1.0.1'
5
+ VERSION = '1.0.3'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-dart-sass
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-15 00:00:00.000000000 Z
11
+ date: 2024-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nanoc-core
@@ -51,11 +51,12 @@ files:
51
51
  - lib/nanoc/dart_sass.rb
52
52
  - lib/nanoc/dart_sass/filter.rb
53
53
  - lib/nanoc/dart_sass/version.rb
54
- homepage: https://nanoc.ws/
54
+ homepage: https://nanoc.app/
55
55
  licenses:
56
56
  - MIT
57
57
  metadata:
58
58
  rubygems_mfa_required: 'true'
59
+ source_code_uri: https://github.com/nanoc/nanoc/tree/nanoc-dart-sass-v1.0.3/nanoc-dart-sass
59
60
  post_install_message:
60
61
  rdoc_options: []
61
62
  require_paths:
@@ -71,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
72
  - !ruby/object:Gem::Version
72
73
  version: '0'
73
74
  requirements: []
74
- rubygems_version: 3.4.14
75
+ rubygems_version: 3.5.9
75
76
  signing_key:
76
77
  specification_version: 4
77
78
  summary: Dart Sass filter for Nanoc