nanoc-dart-sass 0.0.1 → 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: 40b93740b864b61bac9b890e3076e2f52ed675d85ec815296d22a29e3d3bb1cf
4
- data.tar.gz: ccfc074b2ac62ed6172ead70e9f3c77311633885efaec81cf1b371bf45d68b51
3
+ metadata.gz: abb3353a67957a72db05a7eaec7a3dcd669b600a188b081bc41d9a8dd8b99a54
4
+ data.tar.gz: ce51516fc85577f8c265669f9a3e71be00417eedda5f419b9e3d0f11d48ffbe4
5
5
  SHA512:
6
- metadata.gz: 665aabe49726e3ec886549f46331d343df41341568fadbc6cd1a4273601e32e41ae1b7d03a48a973ab08745a4ae2b8929b328ef2f4196827580ab92a04a9aecc
7
- data.tar.gz: c0d0dcf3bf0ea5978886b544982e57bed7ff06649dd64e14367299f616d4915bdbd164b8a8f1b4f72bafffe5c5caebee9175656758fdfa4246998f8529a2bc69
6
+ metadata.gz: 7c7a5043abd21b916203fc476a4305b7da06ce44b21e856714a48b88c125be5508bef0a60e41f48db09dbcf92365effa9f158b87628a2c56ba4cb0b2851d5e70
7
+ data.tar.gz: a4e1f92ac5ec75283a1ef62d9b9801a773b05d7aaff4ca75b266d0130047d1343d95f85326c91528f9799273270cc5b3b46cb556b1455be436691303ed9ec060
data/NEWS.md CHANGED
@@ -1,5 +1,17 @@
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
+
7
+ ## 1.0.0 (2022-12-17)
8
+
9
+ Initial release.
10
+
11
+ Fixes:
12
+
13
+ - Apply Sass syntax detection logic to dependencies (#1630) [ntkme]
14
+
3
15
  ## 0.0.1 (2022-11-20)
4
16
 
5
17
  Initial pre-release.
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  This provides a filter that allows [Nanoc](https://nanoc.app) to process content via [Dart Sass](https://sass-lang.com/dart-sass).
4
4
 
5
+ This filter offers similar functionality to Nanoc’s built-in `:sass` filter. The built-in `:sass` filter, however, uses the [Ruby Sass](https://sass-lang.com/ruby-sass) implementation, which has reached end of life.
6
+
5
7
  ## Installation
6
8
 
7
9
  Add `nanoc-dart-sass` to the `nanoc` group of your Gemfile:
@@ -14,47 +14,91 @@ module Nanoc
14
14
  def run(content, params = {})
15
15
  # Read syntax
16
16
  syntax = params[:syntax]
17
- syntax ||=
18
- case item.identifier.ext
19
- when 'sass'
20
- :indented
21
- when 'scss'
22
- :scss
23
- when 'css'
24
- :css
25
- else
26
- nil
27
- end
17
+ syntax ||= Util.syntax_from_ext(item.identifier.ext)
28
18
 
29
19
  result = Sass.compile_string(
30
20
  content,
31
- importer: make_dart_sass_importer(@items),
21
+ importer: NanocImporter.new(@items, item),
32
22
  **params,
33
23
  syntax: syntax,
34
24
  )
35
25
  result.css
36
- rescue StandardError => e
26
+ rescue StandardError => e # rubocop:disable Lint/UselessRescue
37
27
  # TODO: use full_message for syntax errors
38
28
  raise e
39
29
  end
40
30
 
41
- private
42
-
43
- def make_dart_sass_importer(items)
44
- {
45
- canonicalize: lambda do |param, **|
46
- "nanoc:#{items[param.sub(/\Ananoc:/, '')].identifier}"
47
- end,
48
- load: lambda { |url|
49
- param = url.sub(/\Ananoc:/, '')
50
- item = items[param]
51
- return {
52
- contents: item.raw_content,
53
- syntax: item.identifier.ext,
54
- }
55
- },
56
- }
31
+ class NanocImporter
32
+ def initialize(items, source_item)
33
+ @items = items
34
+ @source_item = source_item
35
+ end
36
+
37
+ def canonicalize(url, **)
38
+ # Construct proper URL with `nanoc:` prefix if needed
39
+ if url.start_with?('nanoc:')
40
+ url
41
+ else
42
+ "nanoc:#{url}"
43
+ end
44
+ end
45
+
46
+ def load(url)
47
+ item = find_item_for_url(url)
48
+
49
+ {
50
+ contents: item.raw_content,
51
+ syntax: Util.syntax_from_ext(item.identifier.ext),
52
+ }
53
+ end
54
+
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
83
+
84
+ module Util
85
+ module_function
86
+
87
+ def syntax_from_ext(ext)
88
+ case ext
89
+ when 'sass'
90
+ :indented
91
+ when 'scss'
92
+ :scss
93
+ when 'css'
94
+ :css
95
+ else
96
+ nil
97
+ end
98
+ end
57
99
  end
100
+
101
+ private_constant :Util
58
102
  end
59
103
  end
60
104
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nanoc
4
4
  module DartSass
5
- VERSION = '0.0.1'
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: 0.0.1
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-11-20 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