nanoc-dart-sass 1.0.0 → 1.0.1

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: e5859b27799d61ea7f72bba2904aaa0978ad43797f90fd6ab6255dba9279ef3a
4
- data.tar.gz: c8e681f15c0617a42fabbf1d571ad2cd82aa4458087070704c36598bf9909a9c
3
+ metadata.gz: abb3353a67957a72db05a7eaec7a3dcd669b600a188b081bc41d9a8dd8b99a54
4
+ data.tar.gz: ce51516fc85577f8c265669f9a3e71be00417eedda5f419b9e3d0f11d48ffbe4
5
5
  SHA512:
6
- metadata.gz: 906336b07db8e08f332f424d447f0d7a1954da7a5fbfef9d4d8a808936e5c8be92afee9786d1b22a812901d378c3a7454328a06bbb45ee0166b3bd02f8453023
7
- data.tar.gz: c528b493cd63d3dc670a1307c2b78f41d30ca44e45420e5ef05e1f3ba6f42778e898b2f455db060c409bd2cea91c838f6667728a7e79608e397701cd07d839de
6
+ metadata.gz: 7c7a5043abd21b916203fc476a4305b7da06ce44b21e856714a48b88c125be5508bef0a60e41f48db09dbcf92365effa9f158b87628a2c56ba4cb0b2851d5e70
7
+ data.tar.gz: a4e1f92ac5ec75283a1ef62d9b9801a773b05d7aaff4ca75b266d0130047d1343d95f85326c91528f9799273270cc5b3b46cb556b1455be436691303ed9ec060
data/NEWS.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # nanoc-dart-sass news
2
2
 
3
+ ## 1.0.1 (2023-06-15)
4
+
5
+ - Added support for importing relative paths (#1646, #1653)
6
+
3
7
  ## 1.0.0 (2022-12-17)
4
8
 
5
9
  Initial release.
@@ -18,35 +18,68 @@ module Nanoc
18
18
 
19
19
  result = Sass.compile_string(
20
20
  content,
21
- importer: NanocImporter.new(@items),
21
+ importer: NanocImporter.new(@items, item),
22
22
  **params,
23
23
  syntax: syntax,
24
24
  )
25
25
  result.css
26
- rescue StandardError => e
26
+ rescue StandardError => e # rubocop:disable Lint/UselessRescue
27
27
  # TODO: use full_message for syntax errors
28
28
  raise e
29
29
  end
30
30
 
31
31
  class NanocImporter
32
- def initialize(items)
32
+ def initialize(items, source_item)
33
33
  @items = items
34
+ @source_item = source_item
34
35
  end
35
36
 
36
37
  def canonicalize(url, **)
37
- "nanoc:#{@items[url.sub(/\Ananoc:/, '')].identifier}"
38
+ # Construct proper URL with `nanoc:` prefix if needed
39
+ if url.start_with?('nanoc:')
40
+ url
41
+ else
42
+ "nanoc:#{url}"
43
+ end
38
44
  end
39
45
 
40
46
  def load(url)
41
- item = @items[url.sub(/\Ananoc:/, '')]
47
+ item = find_item_for_url(url)
48
+
42
49
  {
43
50
  contents: item.raw_content,
44
51
  syntax: Util.syntax_from_ext(item.identifier.ext),
45
52
  }
46
53
  end
47
- end
48
54
 
49
- private_constant :NanocImporter
55
+ private
56
+
57
+ def find_item_for_url(url)
58
+ pat = url.sub(/\Ananoc:/, '')
59
+
60
+ # If URL has no extension, add `.*` at the end
61
+ if pat.match?(%r{(/|^)[^.]+$})
62
+ pat += '.*'
63
+ end
64
+
65
+ # Convert to absolute pattern
66
+ pat =
67
+ if pat.start_with?('/')
68
+ pat
69
+ else
70
+ dirname = File.dirname(@source_item.identifier.to_s)
71
+ File.expand_path(pat, dirname)
72
+ end
73
+
74
+ item = @items[pat]
75
+
76
+ unless item
77
+ raise "Could not find an item matching pattern `#{pat}`"
78
+ end
79
+
80
+ item
81
+ end
82
+ end
50
83
 
51
84
  module Util
52
85
  module_function
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nanoc
4
4
  module DartSass
5
- VERSION = '1.0.0'
5
+ VERSION = '1.0.1'
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.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-17 00:00:00.000000000 Z
11
+ date: 2023-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nanoc-core
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  - !ruby/object:Gem::Version
72
72
  version: '0'
73
73
  requirements: []
74
- rubygems_version: 3.3.26
74
+ rubygems_version: 3.4.14
75
75
  signing_key:
76
76
  specification_version: 4
77
77
  summary: Dart Sass filter for Nanoc