Created
October 2, 2012 20:37
-
-
Save djalmaaraujo/3823131 to your computer and use it in GitHub Desktop.
sass-parse-alloy-components
This file contains hidden or 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
<?xml version="1.0"?> | |
<project name="AlloySass" default="local" xmlns:antelope="antlib:ise.antelope.tasks"> | |
<basename property="ant.file.basename" file="${ant.file}" suffix=".xml" /> | |
<target name="build-ruby-gems"> | |
<if> | |
<not> | |
<available file="${project.dir}/lib/ruby-gems.jar" /> | |
</not> | |
<then> | |
<tstamp> | |
<format property="tstamp.value" pattern="yyyyMMddkkmmssSSS" /> | |
</tstamp> | |
<get | |
dest="${project.dir}/lib/jruby.jar" | |
src="http://jruby.org.s3.amazonaws.com/downloads/1.6.7.2/jruby-complete-1.6.7.2.jar" | |
/> | |
<mkdir dir="${tstamp.value}/compass" /> | |
<get | |
dest="${tstamp.value}/compass/compass-0.12.2.gem" | |
src="http://rubygems.org/downloads/compass-0.12.2.gem" | |
/> | |
<java | |
fork="true" | |
jar="${project.dir}/lib/jruby.jar" | |
> | |
<arg line="-S gem install -i ./${tstamp.value}/output ${tstamp.value}/compass/compass-0.12.2.gem --no-rdoc --no-ri" /> | |
</java> | |
<jar | |
basedir="${tstamp.value}/output" | |
jarfile="${project.dir}/lib/ruby-gems.jar" | |
/> | |
<delete dir="${tstamp.value}" /> | |
</then> | |
</if> | |
</target> | |
<target name="sass-parse"> | |
<if> | |
<equals arg1="${ant.file.basename}" arg2="build" /> | |
<then> | |
<if> | |
<available file="${component.assets.base}" type="dir" /> | |
<then> | |
<echo message="Parsing SASS" /> | |
<copy todir="${component.basedir}/_assets" overwrite="true"> | |
<fileset dir="${component.assets.base}" /> | |
</copy> | |
<property name="file.path.pattern" value="${component.assets.base}/**.css" /> | |
<path id="JRuby"> | |
<fileset file="${project.dir}/lib/jruby.jar"/> | |
</path> | |
<script language="ruby" classpathref="JRuby"> | |
<![CDATA[ | |
require 'rubygems' | |
require 'compass' | |
filePath = $project.getProperty('file.path.pattern') | |
files = Dir.glob(filePath) | |
files.each do | file | | |
fileContent = File.read(file) | |
engine = Sass::Engine.new( | |
fileContent, | |
{ | |
:syntax => :scss, | |
:style => :expanded, | |
:ugly => true | |
} | |
) | |
File.open(file, 'w') { |f| f.write(engine.render) } | |
end | |
]]> | |
</script> | |
</then> | |
</if> | |
</then> | |
</if> | |
</target> | |
<target name="sass-rename-assets"> | |
<if> | |
<equals arg1="${ant.file.basename}" arg2="build" /> | |
<then> | |
<if> | |
<available file="${component.assets.base}" type="dir"/> | |
<then> | |
<delete dir="${component.assets.base}" /> | |
<copy todir="${component.assets.base}" overwrite="true"> | |
<fileset dir="${component.basedir}/_assets" /> | |
</copy> | |
<delete dir="${component.basedir}/_assets" /> | |
</then> | |
</if> | |
</then> | |
</if> | |
</target> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment