dartsass-ruby 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,117 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SassC::Script::ValueConversion
4
+
5
+ def self.from_native(value, options)
6
+ case value
7
+ when ::Sass::Value::Null::NULL
8
+ nil
9
+ when ::Sass::Value::Boolean
10
+ ::SassC::Script::Value::Bool.new(value.to_bool)
11
+ when ::Sass::Value::Color
12
+ if value.instance_eval { defined? @hue }
13
+ ::SassC::Script::Value::Color.new(
14
+ hue: value.hue,
15
+ saturation: value.saturation,
16
+ lightness: value.lightness,
17
+ alpha: value.alpha
18
+ )
19
+ else
20
+ ::SassC::Script::Value::Color.new(
21
+ red: value.red,
22
+ green: value.green,
23
+ blue: value.blue,
24
+ alpha: value.alpha
25
+ )
26
+ end
27
+ when ::Sass::Value::List
28
+ ::SassC::Script::Value::List.new(
29
+ value.to_a.map { |element| from_native(element, options) },
30
+ separator: case value.separator
31
+ when ','
32
+ :comma
33
+ when ' '
34
+ :space
35
+ else
36
+ raise UnsupportedValue, "Sass list separator #{value.separator} unsupported"
37
+ end,
38
+ bracketed: value.bracketed?
39
+ )
40
+ when ::Sass::Value::Map
41
+ ::SassC::Script::Value::Map.new(
42
+ value.contents.to_a.to_h { |k, v| [from_native(k, options), from_native(v, options)] }
43
+ )
44
+ when ::Sass::Value::Number
45
+ ::SassC::Script::Value::Number.new(
46
+ value.value,
47
+ value.numerator_units,
48
+ value.denominator_units
49
+ )
50
+ when ::Sass::Value::String
51
+ ::SassC::Script::Value::String.new(
52
+ value.text,
53
+ value.quoted? ? :string : :identifier
54
+ )
55
+ else
56
+ raise UnsupportedValue, "Sass argument of type #{value.class.name.split('::').last} unsupported"
57
+ end
58
+ end
59
+
60
+ def self.to_native(value)
61
+ case value
62
+ when nil
63
+ ::Sass::Value::Null::NULL
64
+ when ::SassC::Script::Value::Bool
65
+ ::Sass::Value::Boolean.new(value.to_bool)
66
+ when ::SassC::Script::Value::Color
67
+ if value.rgba?
68
+ ::Sass::Value::Color.new(
69
+ red: value.red,
70
+ green: value.green,
71
+ blue: value.blue,
72
+ alpha: value.alpha
73
+ )
74
+ elsif value.hlsa?
75
+ ::Sass::Value::Color.new(
76
+ hue: value.hue,
77
+ saturation: value.saturation,
78
+ lightness: value.lightness,
79
+ alpha: value.alpha
80
+ )
81
+ else
82
+ raise UnsupportedValue, "Sass color mode #{value.instance_eval { @mode }} unsupported"
83
+ end
84
+ when ::SassC::Script::Value::List
85
+ ::Sass::Value::List.new(
86
+ value.to_a.map { |element| to_native(element) },
87
+ separator: case value.separator
88
+ when :comma
89
+ ','
90
+ when :space
91
+ ' '
92
+ else
93
+ raise UnsupportedValue, "Sass list separator #{value.separator} unsupported"
94
+ end,
95
+ bracketed: value.bracketed
96
+ )
97
+ when ::SassC::Script::Value::Map
98
+ ::Sass::Value::Map.new(
99
+ value.value.to_a.to_h { |k, v| [to_native(k), to_native(v)] }
100
+ )
101
+ when ::SassC::Script::Value::Number
102
+ ::Sass::Value::Number.new(
103
+ value.value, {
104
+ numerator_units: value.numerator_units,
105
+ denominator_units: value.denominator_units
106
+ }
107
+ )
108
+ when ::SassC::Script::Value::String
109
+ ::Sass::Value::String.new(
110
+ value.value,
111
+ quoted: value.type != :identifier
112
+ )
113
+ else
114
+ raise UnsupportedValue, "Sass return type #{value.class.name.split('::').last} unsupported"
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SassC
4
+ module Script
5
+
6
+ def self.custom_functions(functions: Functions)
7
+ functions.public_instance_methods
8
+ end
9
+
10
+ def self.formatted_function_name(function_name, functions: Functions)
11
+ params = functions.instance_method(function_name).parameters
12
+ params = params.map { |param_type, name| "$#{name}#{': null' if param_type == :opt}" }.join(", ")
13
+ return "#{function_name}(#{params})"
14
+ end
15
+ end
16
+ end
data/lib/sassc/url.rb ADDED
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SassC
4
+ module URL
5
+ PARSER = URI::Parser.new({ RESERVED: ';/?:@&=+$,' })
6
+
7
+ private_constant :PARSER
8
+
9
+ module_function
10
+
11
+ def parse(str)
12
+ PARSER.parse(str)
13
+ end
14
+
15
+ def escape(str)
16
+ PARSER.escape(str)
17
+ end
18
+
19
+ def unescape(str)
20
+ PARSER.unescape(str)
21
+ end
22
+
23
+ def file_url_to_path(url)
24
+ return if url.nil?
25
+
26
+ path = unescape(parse(url).path)
27
+ path = path[1..] if Gem.win_platform? && path[0].chr == '/' && path[1].chr =~ /[a-z]/i && path[2].chr == ':'
28
+ path
29
+ end
30
+
31
+ def path_to_file_url(path)
32
+ return if path.nil?
33
+
34
+ path = "/#{path}" unless path.start_with?('/')
35
+ URI::File.build([nil, escape(path)]).to_s
36
+ end
37
+ end
38
+
39
+ private_constant :URL
40
+ end
data/lib/sassc/util.rb ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ # # A module containing various useful functions.
4
+ module SassC::Util
5
+
6
+ extend self
7
+
8
+ # Whether or not this is running on Windows.
9
+ #
10
+ # @return [Boolean]
11
+ def windows?
12
+ return @windows if defined?(@windows)
13
+ @windows = RbConfig::CONFIG['host_os'].match?(/mswin|windows|mingw/i)
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SassC
4
+ VERSION = '3.0.0'
5
+ end
data/lib/sassc.rb ADDED
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SassC
4
+ # The global load paths for Sass files. This is meant for plugins and
5
+ # libraries to register the paths to their Sass stylesheets to that they may
6
+ # be `@imported`. This load path is used by every instance of {Sass::Engine}.
7
+ # They are lower-precedence than any load paths passed in via the
8
+ # {file:SASS_REFERENCE.md#load_paths-option `:load_paths` option}.
9
+ #
10
+ # If the `SASS_PATH` environment variable is set,
11
+ # the initial value of `load_paths` will be initialized based on that.
12
+ # The variable should be a colon-separated list of path names
13
+ # (semicolon-separated on Windows).
14
+ #
15
+ # Note that files on the global load path are never compiled to CSS
16
+ # themselves, even if they aren't partials. They exist only to be imported.
17
+ #
18
+ # @example
19
+ # SassC.load_paths << File.dirname(__FILE__ + '/sass')
20
+ # @return [Array<String, Pathname, Sass::Importers::Base>]
21
+ def self.load_paths
22
+ @load_paths ||= if ENV['SASS_PATH']
23
+ ENV['SASS_PATH'].split(SassC::Util.windows? ? ';' : ':')
24
+ else
25
+ []
26
+ end
27
+ end
28
+ end
29
+
30
+ require 'sass-embedded'
31
+ require 'base64'
32
+ require 'json'
33
+ require 'uri'
34
+ require 'set'
35
+
36
+ require_relative "sassc/version"
37
+ require_relative "sassc/import_handler"
38
+ require_relative "sassc/importer"
39
+ require_relative "sassc/util"
40
+ require_relative "sassc/script"
41
+ require_relative "sassc/script/value"
42
+ require_relative "sassc/script/value/bool"
43
+ require_relative "sassc/script/value/number"
44
+ require_relative "sassc/script/value/color"
45
+ require_relative "sassc/script/value/string"
46
+ require_relative "sassc/script/value/list"
47
+ require_relative "sassc/script/value/map"
48
+ require_relative "sassc/script/functions"
49
+ require_relative "sassc/script/value_conversion"
50
+ require_relative "sassc/functions_handler"
51
+ require_relative "sassc/dependency"
52
+ require_relative "sassc/error"
53
+ require_relative "sassc/sass_2_scss"
54
+ require_relative "sassc/url"
55
+ require_relative "sassc/protocol"
56
+ require_relative "sassc/engine"
metadata ADDED
@@ -0,0 +1,185 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dartsass-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Boland
8
+ - なつき
9
+ - Johnny Shields
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2023-02-03 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: sass-embedded
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.54'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '1.54'
29
+ - !ruby/object:Gem::Dependency
30
+ name: minitest
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: 5.16.0
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: 5.16.0
43
+ - !ruby/object:Gem::Dependency
44
+ name: minitest-around
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: 0.5.0
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: 0.5.0
57
+ - !ruby/object:Gem::Dependency
58
+ name: rake
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 10.0.0
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 10.0.0
71
+ - !ruby/object:Gem::Dependency
72
+ name: rubocop
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: 1.37.0
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: 1.37.0
85
+ - !ruby/object:Gem::Dependency
86
+ name: rubocop-minitest
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: 0.22.0
92
+ type: :development
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - "~>"
97
+ - !ruby/object:Gem::Version
98
+ version: 0.22.0
99
+ - !ruby/object:Gem::Dependency
100
+ name: rubocop-performance
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - "~>"
104
+ - !ruby/object:Gem::Version
105
+ version: 1.15.0
106
+ type: :development
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - "~>"
111
+ - !ruby/object:Gem::Version
112
+ version: 1.15.0
113
+ - !ruby/object:Gem::Dependency
114
+ name: rubocop-rake
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: 0.6.0
120
+ type: :development
121
+ prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - "~>"
125
+ - !ruby/object:Gem::Version
126
+ version: 0.6.0
127
+ description: Use Dart Sass with Ruby and Sprockets
128
+ email:
129
+ - ryan@tanookilabs.com
130
+ - i@ntk.me
131
+ executables: []
132
+ extensions: []
133
+ extra_rdoc_files: []
134
+ files:
135
+ - LICENSE.txt
136
+ - README.md
137
+ - lib/dartsass-ruby.rb
138
+ - lib/sassc.rb
139
+ - lib/sassc/dependency.rb
140
+ - lib/sassc/engine.rb
141
+ - lib/sassc/error.rb
142
+ - lib/sassc/functions_handler.rb
143
+ - lib/sassc/import_handler.rb
144
+ - lib/sassc/importer.rb
145
+ - lib/sassc/protocol.rb
146
+ - lib/sassc/sass_2_scss.rb
147
+ - lib/sassc/script.rb
148
+ - lib/sassc/script/functions.rb
149
+ - lib/sassc/script/value.rb
150
+ - lib/sassc/script/value/bool.rb
151
+ - lib/sassc/script/value/color.rb
152
+ - lib/sassc/script/value/list.rb
153
+ - lib/sassc/script/value/map.rb
154
+ - lib/sassc/script/value/number.rb
155
+ - lib/sassc/script/value/string.rb
156
+ - lib/sassc/script/value_conversion.rb
157
+ - lib/sassc/url.rb
158
+ - lib/sassc/util.rb
159
+ - lib/sassc/version.rb
160
+ homepage: https://github.com/tablecheck/dartsass-ruby
161
+ licenses:
162
+ - MIT
163
+ metadata:
164
+ documentation_uri: https://rubydoc.info/gems/dartsass-ruby/3.0.0
165
+ source_code_uri: https://github.com/tablecheck/dartsass-ruby/tree/v3.0.0
166
+ post_install_message:
167
+ rdoc_options: []
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: 2.6.0
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ requirements: []
181
+ rubygems_version: 3.4.4
182
+ signing_key:
183
+ specification_version: 4
184
+ summary: Use Dart Sass with Ruby and Sprockets
185
+ test_files: []