Skip to content

2.0.0: Remove dependency on Ruby Sass #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ bundler_args: "--binstubs --standalone --without documentation --path ../bundle"
script: "bundle exec rake test"
rvm:
- 2.3.3
- 2.3.7
- 2.4.4
- 2.5.1
notifications:
Expand Down
4 changes: 1 addition & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in sassc.gemspec
source "https://rubygems.org"
gemspec
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015 Ryan Boland
Copyright (c) Ryan Boland & Contributors

MIT License

Expand Down
21 changes: 20 additions & 1 deletion lib/sassc.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
# frozen_string_literal: true

module SassC
end

require_relative "sassc/version"
require_relative "sassc/native"
require_relative "sassc/import_handler"
require_relative "sassc/importer"
require_relative "sassc/util"
require_relative "sassc/util/normalized_map"
require_relative "sassc/script"
require_relative "sassc/script/value"
require_relative "sassc/script/value/bool"
require_relative "sassc/script/value/number"
require_relative "sassc/script/value/color"
require_relative "sassc/script/value/string"
require_relative "sassc/script/value/list"
require_relative "sassc/script/value/map"
require_relative "sassc/script/functions"
require_relative "sassc/script/value_conversion"
require_relative "sassc/script/value_conversion/base"
require_relative "sassc/script/value_conversion/string"
require_relative "sassc/script/value_conversion/number"
require_relative "sassc/script/value_conversion/color"
require_relative "sassc/script/value_conversion/map"
require_relative "sassc/script/value_conversion/list"
require_relative "sassc/script/value_conversion/bool"
require_relative "sassc/functions_handler"
require_relative "sassc/cache_stores"
require_relative "sassc/dependency"
require_relative "sassc/error"
require_relative "sassc/engine"
Expand Down
6 changes: 0 additions & 6 deletions lib/sassc/cache_stores.rb

This file was deleted.

8 changes: 0 additions & 8 deletions lib/sassc/cache_stores/base.rb

This file was deleted.

2 changes: 2 additions & 0 deletions lib/sassc/dependency.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SassC
class Dependency
attr_reader :filename
Expand Down
2 changes: 2 additions & 0 deletions lib/sassc/engine.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative "error"

module SassC
Expand Down
12 changes: 9 additions & 3 deletions lib/sassc/error.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
require 'pathname'
require 'sass/error'
# frozen_string_literal: true

require "pathname"

module SassC

class BaseError < StandardError; end
class NotRenderedError < BaseError; end
class InvalidStyleError < BaseError; end
class UnsupportedValue < BaseError; end

# When dealing with SyntaxErrors,
# it's important to provide filename and line number information.
# This will be used in various error reports to users, including backtraces;
# This will be used in various error reports to users, including backtraces.

class SyntaxError < BaseError

def initialize(message, filename: nil, line: nil)
@filename = filename
@line = line
Expand All @@ -27,5 +31,7 @@ def sass_backtrace
return [] unless @filename && @line
["#{@filename}:#{@line}"]
end

end

end
5 changes: 3 additions & 2 deletions lib/sassc/functions_handler.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SassC
class FunctionsHandler
def initialize(options)
Expand Down Expand Up @@ -54,8 +56,7 @@ def arguments_from_native_list(native_argument_list)
def to_native_value(sass_value)
# if the custom function returns nil, we provide a "default" return
# value of an empty string
sass_value ||= Script::String.new("")

sass_value ||= SassC::Script::Value::String.new("")
sass_value.options = @options
Script::ValueConversion.to_native(sass_value)
end
Expand Down
2 changes: 2 additions & 0 deletions lib/sassc/import_handler.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SassC
class ImportHandler
def initialize(options)
Expand Down
2 changes: 2 additions & 0 deletions lib/sassc/importer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SassC
class Importer
attr_reader :options
Expand Down
5 changes: 3 additions & 2 deletions lib/sassc/native.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "ffi"

module SassC
Expand Down Expand Up @@ -48,8 +50,7 @@ def self.return_string_array(ptr)
end

def self.native_string(string)
string = string.to_s
string << "\0"
string = "#{string}\0"
data = Native::LibC.malloc(string.bytesize)
data.write_string(string)
data
Expand Down
2 changes: 2 additions & 0 deletions lib/sassc/native/lib_c.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SassC
module Native
module LibC
Expand Down
2 changes: 2 additions & 0 deletions lib/sassc/native/native_context_api.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SassC
module Native
attach_function :version, :libsass_version, [], :string
Expand Down
2 changes: 2 additions & 0 deletions lib/sassc/native/native_functions_api.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SassC
module Native
# Creators for sass function list and function descriptors
Expand Down
2 changes: 2 additions & 0 deletions lib/sassc/native/sass2scss_api.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SassC
module Native
# ADDAPI char* ADDCALL sass2scss (const char* sass, const int options);
Expand Down
2 changes: 2 additions & 0 deletions lib/sassc/native/sass_input_style.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SassC
module Native
SassInputStyle = enum(
Expand Down
2 changes: 2 additions & 0 deletions lib/sassc/native/sass_output_style.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SassC
module Native
SassOutputStyle = enum(
Expand Down
2 changes: 2 additions & 0 deletions lib/sassc/native/sass_value.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SassC
module Native
class SassValue < FFI::Union; end
Expand Down
2 changes: 2 additions & 0 deletions lib/sassc/native/string_list.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SassC
module Native
class StringList < FFI::Struct
Expand Down
2 changes: 2 additions & 0 deletions lib/sassc/sass_2_scss.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SassC
class Sass2Scss
def self.convert(sass)
Expand Down
40 changes: 5 additions & 35 deletions lib/sassc/script.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true

module SassC
module Script

def self.custom_functions
Functions.instance_methods.select do |function|
Functions.public_method_defined?(function)
Expand All @@ -8,42 +11,9 @@ def self.custom_functions

def self.formatted_function_name(function_name)
params = Functions.instance_method(function_name).parameters
params = params.map { |param_type, name| "$#{name}#{': null' if param_type == :opt}" }
.join(", ")

"#{function_name}(#{params})"
end

module Value
params = params.map { |param_type, name| "$#{name}#{': null' if param_type == :opt}" }.join(", ")
return "#{function_name}(#{params})"
end
end
end

require_relative "script/functions"
require_relative "script/value_conversion"

module Sass
module Script
end
end

require 'sass/util'

begin
require 'sass/deprecation'
rescue LoadError
end

require 'sass/script/value/base'
require 'sass/script/value/string'
require 'sass/script/value/color'
require 'sass/script/value/bool'

SassC::Script::String = Sass::Script::Value::String
SassC::Script::Value::String = Sass::Script::Value::String

SassC::Script::Color = Sass::Script::Value::Color
SassC::Script::Value::Color = Sass::Script::Value::Color

SassC::Script::Bool = Sass::Script::Value::Bool
SassC::Script::Value::Bool = Sass::Script::Value::Bool
2 changes: 2 additions & 0 deletions lib/sassc/script/functions.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SassC
module Script
module Functions
Expand Down
Loading