Permalink
Browse files

Merge branch 'release/v0.1.6' into develop

  • Loading branch information...
2 parents ce6e26c + 27115f5 commit 5cd229c87dfc503350f66568a6a1fda78e871732 @vwall vwall committed Sep 18, 2011
Showing with 74 additions and 1 deletion.
  1. +4 −0 CHANGELOG.md
  2. +1 −1 lib/compass_twitter_bootstrap/version.rb
  3. +69 −0 lib/convert.rb
View
@@ -1,5 +1,9 @@
# Overview
+## 0.1.6
+* Start of a less to scss converter
+* Added change log
+
## 0.1.5
* Upgraded to twitter bootstrap version 1.3
* Asset Pipeline (thanks to ascrazy)
@@ -1,3 +1,3 @@
module CompassTwitterBootstrap
- VERSION = "0.1.5"
+ VERSION = "0.1.6"
end
View
@@ -0,0 +1,69 @@
+class Convert
+ def process
+ less_files.each do |name, file|
+ file = open_git_file(file)
+ file = convert(file)
+ save_file(name, file)
+ end
+ end
+
+private
+
+ def less_files
+ {
+ '_reset' => 'https://raw.github.com/twitter/bootstrap/master/lib/reset.less',
+ '_variables' => 'https://raw.github.com/twitter/bootstrap/master/lib/variables.less',
+ '_scaffolding' => 'https://raw.github.com/twitter/bootstrap/master/lib/scaffolding.less',
+ '_type' => 'https://raw.github.com/twitter/bootstrap/1.3-wip/lib/type.less',
+ '_forms' => 'https://raw.github.com/twitter/bootstrap/master/lib/forms.less',
+ '_tables' => 'https://raw.github.com/twitter/bootstrap/master/lib/tables.less',
+ '_patterns' => 'https://raw.github.com/twitter/bootstrap/1.3-wip/lib/patterns.less'
+ }
+ end
+
+ def convert(file)
+ file = replace_vars(file)
+ file = replace_fonts(file)
+ file = replace_grads(file)
+ file = replace_mixins(file)
+ file = replace_includes(file)
+ file = replace_spin(file)
+
+ file
+ end
+
+ def open_git_file(file)
+ URI.parse(file).read
+ end
+
+ def save_file(name, content)
+ f = File.new("#{name}.scss", "w")
+ f.write(content)
+ f.close
+ end
+
+ def replace_vars(less)
+ less.gsub(/@/, '$')
+ end
+
+ def replace_fonts(less)
+ less.gsub(/#font \> \.([\w-]+)/, '@include \1')
+ end
+
+ def replace_grads(less)
+ less.gsub(/#gradient \> \.([\w-]+)/, '@include gradient-\1')
+ end
+
+ def replace_mixins(less)
+ less.gsub(/^\.([\w-]*)(\(.*\))([\s\{]+)$/, '@mixin \1\2\3')
+ end
+
+ def replace_includes(less)
+ less.gsub(/\.([\w-]*)(\(.*\));?/, '@include \1\2;')
+ end
+
+ def replace_spin(less)
+ less.gsub(/spin/, 'adjust-hue')
+ end
+
+end

0 comments on commit 5cd229c

Please sign in to comment.