forked from sproutit/sproutcore-abbot
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for scss (sass v3 css files) and less css files
- Loading branch information
Showing
12 changed files
with
175 additions
and
27 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
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
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,41 @@ | ||
# =========================================================================== | ||
# Project: Abbot - SproutCore Build Tools | ||
# Copyright: ©2009 Apple Inc. | ||
# portions copyright @2006-2009 Sprout Systems, Inc. | ||
# and contributors | ||
# =========================================================================== | ||
|
||
require File.expand_path(File.join(File.dirname(__FILE__), 'stylesheet')) | ||
require 'fileutils' | ||
|
||
module SC | ||
|
||
# This build can compile a Less stylesheet. | ||
class Builder::Less < Builder::Stylesheet | ||
|
||
def build(dst_path) | ||
begin | ||
require 'less' | ||
rescue | ||
raise "Cannot compile #{entry.source_path} because less is not installed. Please try 'sudo gem install less' and try again" | ||
end | ||
|
||
begin | ||
content = readlines(entry.source_path)*'' | ||
css = ::Less::Engine.new(content).to_css | ||
lines = [] | ||
css.each_line { |l| lines << rewrite_inline_code(l) } | ||
writelines dst_path, lines | ||
rescue Exception => e | ||
|
||
# explain sass syntax error a bit more... | ||
if e.is_a? Less::SyntaxError | ||
e.message << " of #{@entry.source_path}" | ||
end | ||
raise e # reraise | ||
end # rescue | ||
end # def | ||
|
||
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
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
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,4 @@ | ||
#main p { | ||
color: lime; | ||
width: 97%; | ||
background: static_url("image"); } |
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,4 @@ | ||
#main p { | ||
color: lime; | ||
width: 97%; | ||
background: static_url("image"); } |
Empty file.
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,51 @@ | ||
require File.join(File.dirname(__FILE__), 'spec_helper') | ||
|
||
# If less is not installed, just skip these. | ||
has_less = true | ||
begin | ||
require 'less' | ||
|
||
rescue Exception => e | ||
puts "WARNING: Skipping SC::Builder::Less tests because less is not installed. Run 'sudo gem install less' first and try again." | ||
has_less = false | ||
end | ||
|
||
if has_less | ||
describe SC::Builder::Less do | ||
|
||
include SC::SpecHelpers | ||
include SC::BuilderSpecHelper | ||
|
||
before do | ||
std_before :less_test | ||
@manifest.add_entry 'icons/image.png' | ||
end | ||
|
||
|
||
after do | ||
std_after | ||
end | ||
|
||
def run_builder(filename) | ||
super do |entry, dst_path| | ||
SC::Builder::Less.build(entry, dst_path) | ||
end | ||
end | ||
|
||
it "should build a less file" do | ||
lines = run_builder('sample.less') | ||
lines = lines.join('').gsub("\n",'') # strip newlines to make compare easy | ||
|
||
# just verify that output looks like the CSS we expect | ||
lines.should =~ /\#main\s+p.+\{.+color.+width.+\}/ | ||
end | ||
|
||
it "converts static_url() and sc_static() => 'url('foo')' " do | ||
lines = run_builder('sample.less') | ||
css = lines.join("\n") | ||
|
||
css.should_not =~ /(static_url|sc_static)/ | ||
css.should =~ /url\('.+'\)/ # important MUST have some url... | ||
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