nanoc-dart-sass 1.0.2 → 1.0.3

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
2
  SHA256:
3
- metadata.gz: 71ddac060520e3149a4caa4bdb0a605e1f123f281255d0e1691600b0eedfe440
4
- data.tar.gz: 2429ebae5cfead56edd001349c4493cbe696fe9b3662c793aa3003ac49ca50dc
3
+ metadata.gz: 3b3ec8688e0eacf5312456127b9f9137d7ee17fdc3b2788c8eb44d2a18a48d39
4
+ data.tar.gz: dfc61b8856486c27210a20b79fa70da2852a88f4eeb5a5e804b2b3411e8d7653
5
5
  SHA512:
6
- metadata.gz: 4ee86ca61d395df8599e4effbf19b5cec3876a8c07f6cd07f48be1b9e2ca3e229c36d9ed2c3428407eef0f080757c24e0c75383468f6496d958813c17977ca57
7
- data.tar.gz: 8a9688ddf9f4faf94578d52eeedb18bcbb87d2efa3ce23433ace33b07ce37e70f528fc6561f5781f754827331de47882d5e9cfe145dd9491a273ed7ade8f0261
6
+ metadata.gz: 054bdb5a6ba1c907c2c8fc06f56efde60a173df8b0aa328b3654df7b7a8e42017b0cc123bcf09317aa6e93ef1754ef65a83e659122ea1794950f8d63c87ef9f8
7
+ data.tar.gz: ba2afccd8953791279521d4444053df10e94ad69e9b16f787519b621e69fdf9e5f9b71bb72a861cb57165ccb9b8e4bf918724bef1805362fd3be2c1c6c2c32dc
data/NEWS.md CHANGED
@@ -1,5 +1,11 @@
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
+
3
9
  ## 1.0.2 (2023-09-30)
4
10
 
5
11
  - Fix dart-sass compatibility (#1664)
@@ -54,10 +54,7 @@ module Nanoc
54
54
  def find_item_for_url(url)
55
55
  pat = url.sub(/\Ananoc:/, '')
56
56
 
57
- # If URL has no extension, add `.*` at the end
58
- if pat.match?(%r{(/|^)[^.]+$})
59
- pat += '.*'
60
- end
57
+ is_extension_given = !pat.match?(%r{(/|^)[^.]+$})
61
58
 
62
59
  # Convert to absolute pattern
63
60
  pat =
@@ -68,13 +65,48 @@ module Nanoc
68
65
  File.expand_path(pat, dirname)
69
66
  end
70
67
 
71
- item = @items[pat]
68
+ items = collect_items(pat, is_extension_given)
72
69
 
73
- 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
74
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.*')))
75
99
  end
76
100
 
77
- 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
78
110
  end
79
111
  end
80
112
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nanoc
4
4
  module DartSass
5
- VERSION = '1.0.2'
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.2
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-09-30 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.20
75
+ rubygems_version: 3.5.9
75
76
  signing_key:
76
77
  specification_version: 4
77
78
  summary: Dart Sass filter for Nanoc