sass-embedded 1.0.21 → 1.1.2

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: abdeb3585b53d503b0eeb292dcc7fa3f4354458e210804b0022975abf398dfa1
4
- data.tar.gz: cd186b55f440381874f838a293b819dd24d3841859537c5734972175922ff052
3
+ metadata.gz: e9f113d7bb15374cf348bfb8bdfd7d1d349251a122b1e153b48f97bf2b61f438
4
+ data.tar.gz: 9f0898214fe9abef5c49009a2a190385e90c40896235b46ff4a4c023ca6f2798
5
5
  SHA512:
6
- metadata.gz: ba6c8a98aed591bfa886c31f3eaf212f71c6907c97188e5a0edc67fd300142b504360e01d347221953889c204306917b5a88b1af89b23139dc5b86221291bdda
7
- data.tar.gz: a5e8011368137a29c1f590825b1dd549c2b934f45591f646732b40d39c393bc89b06998eab8cfa0f34b4cad16f6da9e6afc04dc1e230a43ae5e66bc77094d6f2
6
+ metadata.gz: 69444e33879b691226abcf732bc27d63276af27c2ecab0aaa394bfd6e80090916259dc6ae7accf1a23e1ca904b11a5257ecca52fad4daabcf3d19cb2b70df916
7
+ data.tar.gz: aa119cd52f0c334cddcbdce5be6cc6b3a17a88472e1de50136c5ee4f17194c661f4965ae272449694cf4db94ba713b26355a3c17f4a993f9dc13eeff5be77f78
data/README.md CHANGED
@@ -35,6 +35,8 @@ result = Sass.compile_string('h1 { font-size: 40px; }')
35
35
  puts result.css
36
36
  ```
37
37
 
38
+ See [rubydoc.info/gems/sass-embedded](https://rubydoc.info/gems/sass-embedded) for full API documentation.
39
+
38
40
  ---
39
41
 
40
42
  Disclaimer: this is not an official Google product.
data/ext/sass/Rakefile CHANGED
@@ -63,45 +63,54 @@ module FileUtils
63
63
  sh 'unzip', '-od', dest, archive
64
64
  end
65
65
  else
66
- raise "Unknown archive format #{archive}"
66
+ raise ArgumentError, "Unknown archive format #{archive}"
67
67
  end
68
68
  end
69
69
 
70
- def fetch(uri_or_path, dest = nil)
71
- require 'open-uri'
70
+ def fetch(source_uri, dest_path = nil)
71
+ require 'rubygems/remote_fetcher'
72
72
 
73
- begin
74
- uri = URI.parse(uri_or_path)
75
- path = URI::DEFAULT_PARSER.unescape(uri.path)
76
- if uri.instance_of?(URI::File) || uri.instance_of?(URI::Generic)
77
- path = path.delete_prefix('/') if Gem.win_platform? && !File.file?(path)
78
- raise unless File.file?(path)
73
+ unless source_uri.is_a?(URI::Generic)
74
+ begin
75
+ source_uri = URI.parse(source_uri)
76
+ rescue StandardError
77
+ source_uri = URI.parse(URI::DEFAULT_PARSER.escape(source_uri.to_s))
79
78
  end
80
- rescue StandardError
81
- raise unless File.file?(uri_or_path)
79
+ end
80
+
81
+ scheme = source_uri.scheme
82
+ source_path = URI::DEFAULT_PARSER.unescape(source_uri.path || source_uri.opaque)
82
83
 
83
- uri = nil
84
- path = uri_or_path
84
+ if Gem.win_platform? && scheme =~ /^[a-z]$/i && !source_path.include?(':')
85
+ source_path = "#{scheme}:#{source_path}"
86
+ scheme = nil
85
87
  end
86
88
 
87
- dest = File.basename(path) if dest.nil?
89
+ dest_path = File.basename(source_path) if dest_path.nil?
88
90
 
89
- if uri.nil? || uri.instance_of?(URI::File) || uri.instance_of?(URI::Generic)
90
- cp path, dest
91
- elsif uri.respond_to?(:open)
92
- Rake.rake_output_message "curl -fsSLo #{dest} -- #{uri}" if Rake::FileUtilsExt.verbose_flag
93
- unless Rake::FileUtilsExt.nowrite_flag
94
- uri.open do |stream|
95
- File.binwrite(dest, stream.read)
96
- end
91
+ case scheme
92
+ when nil, 'file'
93
+ if Gem.win_platform? && source_path[0].chr == '/' && source_path[1].chr =~ /[a-z]/i && source_path[2].chr == ':'
94
+ source_path = source_path[1..]
97
95
  end
96
+ cp source_path, dest_path
98
97
  else
99
- raise
98
+ fetcher = Gem::RemoteFetcher.fetcher
99
+ symbol = "fetch_#{scheme}".to_sym
100
+ raise ArgumentError, "Unsupported URI scheme #{scheme}" unless fetcher.respond_to?(symbol)
101
+
102
+ if Rake::FileUtilsExt.verbose_flag
103
+ redacted_uri = Gem::RemoteFetcher::FetchError.new('', source_uri).uri
104
+ Rake.rake_output_message "fetch #{redacted_uri}"
105
+ end
106
+
107
+ unless Rake::FileUtilsExt.nowrite_flag
108
+ data = fetcher.public_send(symbol, source_uri)
109
+ Gem.write_binary(dest_path, data)
110
+ end
100
111
  end
101
112
 
102
- dest
103
- rescue StandardError
104
- raise IOError, "Failed to fetch #{uri_or_path}"
113
+ dest_path
105
114
  end
106
115
  end
107
116
 
@@ -124,9 +124,10 @@ module Sass
124
124
  )
125
125
  when :number
126
126
  Sass::Value::Number.new(
127
- obj.value,
128
- obj.numerators.to_a,
129
- obj.denominators.to_a
127
+ obj.value, {
128
+ numerator_units: obj.numerators.to_a,
129
+ denominator_units: obj.denominators.to_a
130
+ }
130
131
  )
131
132
  when :rgb_color
132
133
  Sass::Value::Color.new(
@@ -1,5 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'host/function_registry'
4
+ require_relative 'host/importer_registry'
5
+ require_relative 'host/logger_registry'
6
+ require_relative 'host/value_protofier'
7
+
3
8
  module Sass
4
9
  class Embedded
5
10
  # The {Host} class.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sass
4
4
  class Embedded
5
- VERSION = '1.0.21'
5
+ VERSION = '1.1.2'
6
6
  end
7
7
  end
data/lib/sass/embedded.rb CHANGED
@@ -9,30 +9,12 @@ require_relative 'embedded/channel'
9
9
  require_relative 'embedded/compiler'
10
10
  require_relative 'embedded/dispatcher'
11
11
  require_relative 'embedded/host'
12
- require_relative 'embedded/host/function_registry'
13
- require_relative 'embedded/host/importer_registry'
14
- require_relative 'embedded/host/logger_registry'
15
- require_relative 'embedded/host/value_protofier'
16
12
  require_relative 'embedded/protofier'
17
13
  require_relative 'embedded/structifier'
18
14
  require_relative 'embedded/varint'
19
15
  require_relative 'embedded/version'
20
16
  require_relative 'logger'
21
- require_relative 'logger/source_location'
22
- require_relative 'logger/source_span'
23
- require_relative 'script_error'
24
17
  require_relative 'value'
25
- require_relative 'value/list'
26
- require_relative 'value/argument_list'
27
- require_relative 'value/boolean'
28
- require_relative 'value/color'
29
- require_relative 'value/function'
30
- require_relative 'value/fuzzy_math'
31
- require_relative 'value/map'
32
- require_relative 'value/null'
33
- require_relative 'value/number'
34
- require_relative 'value/number/unit'
35
- require_relative 'value/string'
36
18
 
37
19
  module Sass
38
20
  # The {Embedded} host for using dart-sass-embedded. Each instance creates
data/lib/sass/logger.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'logger/source_location'
4
+ require_relative 'logger/source_span'
5
+
3
6
  module Sass
4
7
  # A namespace for built-in Loggers.
5
8
  #
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sass
4
+ # An exception thrown by Sass Script.
4
5
  class ScriptError < StandardError; end
5
6
  end
@@ -8,8 +8,11 @@ module Sass
8
8
  class Function
9
9
  include Value
10
10
 
11
- # @param id_or_signature [Numeric, ::String]
12
- # @param callback [Proc]
11
+ # @overload initialize(id)
12
+ # @param id [Numeric]
13
+ # @overload initialize(signature, callback)
14
+ # @param signature [::String]
15
+ # @param callback [Proc]
13
16
  def initialize(id_or_signature, callback = nil)
14
17
  if id_or_signature.is_a? Numeric
15
18
  @id = id_or_signature
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'number/unit'
4
+
3
5
  module Sass
4
6
  module Value
5
7
  # Sass's number type.
@@ -9,11 +11,26 @@ module Sass
9
11
  include Value
10
12
 
11
13
  # @param value [Numeric]
12
- # @param numerator_units [Array<::String>, ::String]
13
- # @param denominator_units [Array<::String>, ::String]
14
- def initialize(value, numerator_units = [], denominator_units = [])
15
- numerator_units = [numerator_units] if numerator_units.is_a?(::String)
16
- denominator_units = [denominator_units] if denominator_units.is_a?(::String)
14
+ # @param unit [::String, Hash]
15
+ # @option unit [Array<::String>] :numerator_units
16
+ # @option unit [Array<::String>] :denominator_units
17
+ def initialize(value, unit = nil)
18
+ case unit
19
+ when nil
20
+ numerator_units = []
21
+ denominator_units = []
22
+ when ::String
23
+ numerator_units = [unit]
24
+ denominator_units = []
25
+ when ::Hash
26
+ numerator_units = unit.fetch(:numerator_units, [])
27
+ raise error "invalid numerator_units #{numerator_units.inspect}" unless numerator_units.is_a? Array
28
+
29
+ denominator_units = unit.fetch(:denominator_units, [])
30
+ raise error "invalid denominator_units #{denominator_units.inspect}" unless denominator_units.is_a? Array
31
+ else
32
+ raise error "invalid unit #{unit.inspect}"
33
+ end
17
34
 
18
35
  unless denominator_units.empty? && numerator_units.empty?
19
36
  value = value.dup
@@ -159,8 +176,10 @@ module Sass
159
176
  # @param new_denominator_units [Array<::String>]
160
177
  # @return [Number]
161
178
  def convert(new_numerator_units, new_denominator_units, name = nil)
162
- Number.new(convert_value(new_numerator_units, new_denominator_units, name), new_numerator_units,
163
- new_denominator_units)
179
+ Number.new(convert_value(new_numerator_units, new_denominator_units, name), {
180
+ numerator_units: new_numerator_units,
181
+ denominator_units: new_denominator_units
182
+ })
164
183
  end
165
184
 
166
185
  # @param new_numerator_units [Array<::String>]
@@ -175,7 +194,10 @@ module Sass
175
194
  # @param other [Number]
176
195
  # @return [Number]
177
196
  def convert_to_match(other, name = nil, other_name = nil)
178
- Number.new(convert_value_to_match(other, name, other_name), other.numerator_units, other.denominator_units)
197
+ Number.new(convert_value_to_match(other, name, other_name), {
198
+ numerator_units: other.numerator_units,
199
+ denominator_units: other.denominator_units
200
+ })
179
201
  end
180
202
 
181
203
  # @param other [Number]
@@ -192,8 +214,10 @@ module Sass
192
214
  # @param new_denominator_units [Array<::String>]
193
215
  # @return [Number]
194
216
  def coerce(new_numerator_units, new_denominator_units, name = nil)
195
- Number.new(coerce_value(new_numerator_units, new_denominator_units, name), new_numerator_units,
196
- new_denominator_units)
217
+ Number.new(coerce_value(new_numerator_units, new_denominator_units, name), {
218
+ numerator_units: new_numerator_units,
219
+ denominator_units: new_denominator_units
220
+ })
197
221
  end
198
222
 
199
223
  # @param new_numerator_units [Array<::String>]
@@ -214,7 +238,10 @@ module Sass
214
238
  # @param other [Number]
215
239
  # @return [Number]
216
240
  def coerce_to_match(other, name = nil, other_name = nil)
217
- Number.new(coerce_value_to_match(other, name, other_name), other.numerator_units, other.denominator_units)
241
+ Number.new(coerce_value_to_match(other, name, other_name), {
242
+ numerator_units: other.numerator_units,
243
+ denominator_units: other.denominator_units
244
+ })
218
245
  end
219
246
 
220
247
  # @param other [Number]
@@ -9,7 +9,7 @@ module Sass
9
9
  include Value
10
10
 
11
11
  # @param text [::String]
12
- # @param quoted: [::Boolean]
12
+ # @param quoted [::Boolean]
13
13
  def initialize(text = '', quoted: true)
14
14
  @text = text.freeze
15
15
  @quoted = quoted
data/lib/sass/value.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'script_error'
4
+
3
5
  module Sass
4
6
  # The abstract base class of Sass's value types.
5
7
  #
@@ -117,3 +119,14 @@ module Sass
117
119
  end
118
120
  end
119
121
  end
122
+
123
+ require_relative 'value/list'
124
+ require_relative 'value/argument_list'
125
+ require_relative 'value/boolean'
126
+ require_relative 'value/color'
127
+ require_relative 'value/function'
128
+ require_relative 'value/fuzzy_math'
129
+ require_relative 'value/map'
130
+ require_relative 'value/null'
131
+ require_relative 'value/number'
132
+ require_relative 'value/string'
data/lib/sass.rb CHANGED
@@ -13,21 +13,27 @@ require_relative 'sass/embedded'
13
13
  # Sass.compile_string('h1 { font-size: 40px; }')
14
14
  module Sass
15
15
  class << self
16
- # @return [CompileResult]
17
- # @raise [CompileError]
16
+ # Compiles the Sass file at +path+ to CSS.
17
+ # @param (see Embedded#compile)
18
+ # @return (see Embedded#compile)
19
+ # @raise (see Embedded#compile)
18
20
  # @see Embedded#compile
19
21
  def compile(path, **kwargs)
20
22
  instance.compile(path, **kwargs)
21
23
  end
22
24
 
23
- # @return [CompileResult]
24
- # @raise [CompileError]
25
+ # Compiles a stylesheet whose contents is +source+ to CSS.
26
+ # @param (see Embedded#compile_string)
27
+ # @return (see Embedded#compile_string)
28
+ # @raise (see Embedded#compile_string)
25
29
  # @see Embedded#compile_string
26
30
  def compile_string(source, **kwargs)
27
31
  instance.compile_string(source, **kwargs)
28
32
  end
29
33
 
30
- # @return [String]
34
+ # @param (see Embedded#info)
35
+ # @return (see Embedded#info)
36
+ # @raise (see Embedded#info)
31
37
  # @see Embedded#info
32
38
  def info
33
39
  instance.info
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass-embedded
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.21
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-17 00:00:00.000000000 Z
11
+ date: 2022-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -160,8 +160,8 @@ homepage: https://github.com/ntkme/sass-embedded-host-ruby
160
160
  licenses:
161
161
  - MIT
162
162
  metadata:
163
- documentation_uri: https://www.rubydoc.info/gems/sass-embedded/1.0.21
164
- source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.0.21
163
+ documentation_uri: https://rubydoc.info/gems/sass-embedded/1.1.2
164
+ source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.1.2
165
165
  funding_uri: https://github.com/sponsors/ntkme
166
166
  post_install_message:
167
167
  rdoc_options: []