This repository has been archived by the owner on Jun 26, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
719 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
ruby '1.9.3' | ||
#ruby '1.9.3' | ||
|
||
source 'https://rubygems.org' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule libsass
updated
from d0e37b to 97e534
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ module SassC | |
VERSION = "0.0.1" | ||
end | ||
|
||
require_relative 'sassc/engine' | ||
require 'sassc/engine' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'ostruct' | ||
|
||
module SassC | ||
class Engine::Color < OpenStruct | ||
def initialize(r=0, g=0, b=0, a=255) | ||
super() | ||
self.r = r | ||
self.g = g | ||
self.b = b | ||
self.a = a | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module SassC | ||
class Engine::List < Array | ||
SEPARATORS = [" ", ","] | ||
DEFAULT_SEPARATOR = :" " | ||
|
||
def initialize(arr, sep=nil) | ||
super(arr) | ||
self.separator = sep if sep | ||
end | ||
|
||
def separator | ||
@separator || DEFAULT_SEPARATOR | ||
end | ||
|
||
def separator=(sep) | ||
unless SEPARATORS.include? sep.to_s | ||
raise "delimiter must be one of ` `, `,`" | ||
end | ||
|
||
@separator = sep.to_sym | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'delegate' | ||
|
||
module SassC | ||
class Engine::Number < SimpleDelegator | ||
attr_accessor :unit | ||
|
||
def initialize(num, unit="") | ||
super(num) | ||
@unit = unit | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,25 @@ | ||
require 'ffi' | ||
|
||
require_relative 'lib/context' | ||
|
||
module SassC | ||
# Represents the exact wrapper around libsass | ||
module Lib | ||
extend FFI::Library | ||
ffi_lib File.join(File.dirname(__FILE__), '../libsass.bundle') | ||
ffi_lib "sass" | ||
|
||
attach_function :sass_new_context, [], :pointer | ||
attach_function :sass_new_file_context, [], :pointer | ||
attach_function :sass_new_folder_context, [], :pointer | ||
|
||
attach_function :sass_free_context, [:pointer], :void | ||
attach_function :sass_free_file_context, [:pointer], :void | ||
attach_function :sass_free_folder_context, [:pointer], :void | ||
|
||
attach_function :sass_compile, [:pointer], :int32 | ||
attach_function :sass_compile_file, [:pointer], :int32 | ||
attach_function :sass_compile_folder, [:pointer], :int32 | ||
|
||
def self.to_char(string) | ||
# get the number of bytes in the key | ||
bytecount = string.unpack("C*").size | ||
|
||
# create a pointer to memory and write the file to it | ||
ptr = FFI::MemoryPointer.new(:char, bytecount) | ||
ptr.put_bytes(0, string.dup, 0, bytecount) | ||
end | ||
end | ||
end | ||
end | ||
|
||
require 'sassc/lib/context' | ||
require 'sassc/lib/sass_value' | ||
require 'sassc/lib/sass_c_function_descriptor' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module SassC::Lib | ||
class SassCFunctionDescriptor < FFI::Struct | ||
# struct Sass_C_Function_Descriptor { | ||
# const char* signature; | ||
# Sass_C_Function function; | ||
# }; | ||
layout :signature, :pointer, | ||
:function, :pointer | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module SassC::Lib | ||
class SassOptions < FFI::Struct | ||
STYLES = %w(nested expanded compact compressed) | ||
SOURCE_COMMENTS = %w(none default map) | ||
|
||
# struct sass_options { | ||
# int output_style; | ||
# int source_comments; // really want a bool, but C doesn't have them | ||
# char* include_paths; | ||
# char* image_path; | ||
# }; | ||
layout :output_style, :int, | ||
:source_comments, :int, | ||
:include_paths, :pointer, | ||
:image_path, :pointer | ||
|
||
def self.create(options = {}) | ||
options = { | ||
:output_style => "nested", | ||
:source_comments => "none", | ||
:image_path => "images", | ||
:include_paths => "" | ||
}.merge(options) | ||
|
||
struct = SassOptions.new | ||
struct[:output_style] = STYLES.index(options[:output_style]) | ||
struct[:source_comments] = SOURCE_COMMENTS.index(options[:source_comments]) | ||
struct[:image_path] = FFI::MemoryPointer.from_string(options[:image_path]) | ||
struct[:include_paths] = FFI::MemoryPointer.from_string(options[:include_paths]) | ||
struct | ||
end | ||
end | ||
end |
Oops, something went wrong.