sass 3.1.0.alpha.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. data/.yardopts +11 -0
  2. data/CONTRIBUTING +3 -0
  3. data/EDGE_GEM_VERSION +1 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +201 -0
  6. data/REVISION +1 -0
  7. data/Rakefile +353 -0
  8. data/VERSION +1 -0
  9. data/VERSION_NAME +1 -0
  10. data/bin/css2sass +13 -0
  11. data/bin/sass +8 -0
  12. data/bin/sass-convert +7 -0
  13. data/extra/update_watch.rb +13 -0
  14. data/init.rb +18 -0
  15. data/lib/sass.rb +71 -0
  16. data/lib/sass/cache_store.rb +208 -0
  17. data/lib/sass/callbacks.rb +66 -0
  18. data/lib/sass/css.rb +294 -0
  19. data/lib/sass/engine.rb +792 -0
  20. data/lib/sass/environment.rb +143 -0
  21. data/lib/sass/error.rb +201 -0
  22. data/lib/sass/exec.rb +619 -0
  23. data/lib/sass/importers.rb +22 -0
  24. data/lib/sass/importers/base.rb +138 -0
  25. data/lib/sass/importers/filesystem.rb +121 -0
  26. data/lib/sass/less.rb +363 -0
  27. data/lib/sass/plugin.rb +126 -0
  28. data/lib/sass/plugin/compiler.rb +346 -0
  29. data/lib/sass/plugin/configuration.rb +123 -0
  30. data/lib/sass/plugin/generic.rb +15 -0
  31. data/lib/sass/plugin/merb.rb +48 -0
  32. data/lib/sass/plugin/rack.rb +47 -0
  33. data/lib/sass/plugin/rails.rb +41 -0
  34. data/lib/sass/plugin/staleness_checker.rb +145 -0
  35. data/lib/sass/railtie.rb +8 -0
  36. data/lib/sass/repl.rb +58 -0
  37. data/lib/sass/root.rb +7 -0
  38. data/lib/sass/script.rb +63 -0
  39. data/lib/sass/script/bool.rb +18 -0
  40. data/lib/sass/script/color.rb +490 -0
  41. data/lib/sass/script/css_lexer.rb +29 -0
  42. data/lib/sass/script/css_parser.rb +31 -0
  43. data/lib/sass/script/funcall.rb +78 -0
  44. data/lib/sass/script/functions.rb +852 -0
  45. data/lib/sass/script/interpolation.rb +70 -0
  46. data/lib/sass/script/lexer.rb +337 -0
  47. data/lib/sass/script/literal.rb +236 -0
  48. data/lib/sass/script/node.rb +101 -0
  49. data/lib/sass/script/number.rb +420 -0
  50. data/lib/sass/script/operation.rb +92 -0
  51. data/lib/sass/script/parser.rb +392 -0
  52. data/lib/sass/script/string.rb +67 -0
  53. data/lib/sass/script/string_interpolation.rb +93 -0
  54. data/lib/sass/script/unary_operation.rb +57 -0
  55. data/lib/sass/script/variable.rb +48 -0
  56. data/lib/sass/scss.rb +17 -0
  57. data/lib/sass/scss/css_parser.rb +51 -0
  58. data/lib/sass/scss/parser.rb +838 -0
  59. data/lib/sass/scss/rx.rb +126 -0
  60. data/lib/sass/scss/sass_parser.rb +11 -0
  61. data/lib/sass/scss/script_lexer.rb +15 -0
  62. data/lib/sass/scss/script_parser.rb +25 -0
  63. data/lib/sass/scss/static_parser.rb +40 -0
  64. data/lib/sass/selector.rb +361 -0
  65. data/lib/sass/selector/abstract_sequence.rb +62 -0
  66. data/lib/sass/selector/comma_sequence.rb +82 -0
  67. data/lib/sass/selector/sequence.rb +236 -0
  68. data/lib/sass/selector/simple.rb +113 -0
  69. data/lib/sass/selector/simple_sequence.rb +135 -0
  70. data/lib/sass/shared.rb +78 -0
  71. data/lib/sass/tree/comment_node.rb +128 -0
  72. data/lib/sass/tree/debug_node.rb +36 -0
  73. data/lib/sass/tree/directive_node.rb +75 -0
  74. data/lib/sass/tree/extend_node.rb +65 -0
  75. data/lib/sass/tree/for_node.rb +67 -0
  76. data/lib/sass/tree/if_node.rb +81 -0
  77. data/lib/sass/tree/import_node.rb +124 -0
  78. data/lib/sass/tree/mixin_def_node.rb +60 -0
  79. data/lib/sass/tree/mixin_node.rb +123 -0
  80. data/lib/sass/tree/node.rb +490 -0
  81. data/lib/sass/tree/prop_node.rb +220 -0
  82. data/lib/sass/tree/root_node.rb +125 -0
  83. data/lib/sass/tree/rule_node.rb +273 -0
  84. data/lib/sass/tree/variable_node.rb +39 -0
  85. data/lib/sass/tree/warn_node.rb +42 -0
  86. data/lib/sass/tree/while_node.rb +48 -0
  87. data/lib/sass/util.rb +687 -0
  88. data/lib/sass/util/subset_map.rb +101 -0
  89. data/lib/sass/version.rb +109 -0
  90. data/rails/init.rb +1 -0
  91. data/test/sass/cache_test.rb +74 -0
  92. data/test/sass/callbacks_test.rb +61 -0
  93. data/test/sass/conversion_test.rb +1210 -0
  94. data/test/sass/css2sass_test.rb +364 -0
  95. data/test/sass/data/hsl-rgb.txt +319 -0
  96. data/test/sass/engine_test.rb +2273 -0
  97. data/test/sass/extend_test.rb +1348 -0
  98. data/test/sass/functions_test.rb +565 -0
  99. data/test/sass/importer_test.rb +104 -0
  100. data/test/sass/less_conversion_test.rb +632 -0
  101. data/test/sass/mock_importer.rb +49 -0
  102. data/test/sass/more_results/more1.css +9 -0
  103. data/test/sass/more_results/more1_with_line_comments.css +26 -0
  104. data/test/sass/more_results/more_import.css +29 -0
  105. data/test/sass/more_templates/_more_partial.sass +2 -0
  106. data/test/sass/more_templates/more1.sass +23 -0
  107. data/test/sass/more_templates/more_import.sass +11 -0
  108. data/test/sass/plugin_test.rb +430 -0
  109. data/test/sass/results/alt.css +4 -0
  110. data/test/sass/results/basic.css +9 -0
  111. data/test/sass/results/compact.css +5 -0
  112. data/test/sass/results/complex.css +86 -0
  113. data/test/sass/results/compressed.css +1 -0
  114. data/test/sass/results/expanded.css +19 -0
  115. data/test/sass/results/import.css +31 -0
  116. data/test/sass/results/line_numbers.css +49 -0
  117. data/test/sass/results/mixins.css +95 -0
  118. data/test/sass/results/multiline.css +24 -0
  119. data/test/sass/results/nested.css +22 -0
  120. data/test/sass/results/options.css +1 -0
  121. data/test/sass/results/parent_ref.css +13 -0
  122. data/test/sass/results/script.css +16 -0
  123. data/test/sass/results/scss_import.css +31 -0
  124. data/test/sass/results/scss_importee.css +2 -0
  125. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
  126. data/test/sass/results/subdir/subdir.css +3 -0
  127. data/test/sass/results/units.css +11 -0
  128. data/test/sass/results/warn.css +0 -0
  129. data/test/sass/results/warn_imported.css +0 -0
  130. data/test/sass/script_conversion_test.rb +254 -0
  131. data/test/sass/script_test.rb +459 -0
  132. data/test/sass/scss/css_test.rb +897 -0
  133. data/test/sass/scss/rx_test.rb +156 -0
  134. data/test/sass/scss/scss_test.rb +1088 -0
  135. data/test/sass/scss/test_helper.rb +37 -0
  136. data/test/sass/templates/_partial.sass +2 -0
  137. data/test/sass/templates/alt.sass +16 -0
  138. data/test/sass/templates/basic.sass +23 -0
  139. data/test/sass/templates/bork1.sass +2 -0
  140. data/test/sass/templates/bork2.sass +2 -0
  141. data/test/sass/templates/bork3.sass +2 -0
  142. data/test/sass/templates/bork4.sass +2 -0
  143. data/test/sass/templates/compact.sass +17 -0
  144. data/test/sass/templates/complex.sass +305 -0
  145. data/test/sass/templates/compressed.sass +15 -0
  146. data/test/sass/templates/expanded.sass +17 -0
  147. data/test/sass/templates/import.sass +12 -0
  148. data/test/sass/templates/importee.less +2 -0
  149. data/test/sass/templates/importee.sass +19 -0
  150. data/test/sass/templates/line_numbers.sass +13 -0
  151. data/test/sass/templates/mixin_bork.sass +5 -0
  152. data/test/sass/templates/mixins.sass +76 -0
  153. data/test/sass/templates/multiline.sass +20 -0
  154. data/test/sass/templates/nested.sass +25 -0
  155. data/test/sass/templates/nested_bork1.sass +2 -0
  156. data/test/sass/templates/nested_bork2.sass +2 -0
  157. data/test/sass/templates/nested_bork3.sass +2 -0
  158. data/test/sass/templates/nested_bork4.sass +2 -0
  159. data/test/sass/templates/nested_mixin_bork.sass +6 -0
  160. data/test/sass/templates/options.sass +2 -0
  161. data/test/sass/templates/parent_ref.sass +25 -0
  162. data/test/sass/templates/script.sass +101 -0
  163. data/test/sass/templates/scss_import.scss +11 -0
  164. data/test/sass/templates/scss_importee.scss +1 -0
  165. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
  166. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
  167. data/test/sass/templates/subdir/subdir.sass +6 -0
  168. data/test/sass/templates/units.sass +11 -0
  169. data/test/sass/templates/warn.sass +3 -0
  170. data/test/sass/templates/warn_imported.sass +4 -0
  171. data/test/sass/test_helper.rb +8 -0
  172. data/test/sass/util/subset_map_test.rb +91 -0
  173. data/test/sass/util_test.rb +275 -0
  174. data/test/test_helper.rb +64 -0
  175. data/vendor/fssm/LICENSE +20 -0
  176. data/vendor/fssm/README.markdown +55 -0
  177. data/vendor/fssm/Rakefile +59 -0
  178. data/vendor/fssm/VERSION.yml +5 -0
  179. data/vendor/fssm/example.rb +9 -0
  180. data/vendor/fssm/fssm.gemspec +77 -0
  181. data/vendor/fssm/lib/fssm.rb +33 -0
  182. data/vendor/fssm/lib/fssm/backends/fsevents.rb +36 -0
  183. data/vendor/fssm/lib/fssm/backends/inotify.rb +26 -0
  184. data/vendor/fssm/lib/fssm/backends/polling.rb +25 -0
  185. data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +131 -0
  186. data/vendor/fssm/lib/fssm/monitor.rb +26 -0
  187. data/vendor/fssm/lib/fssm/path.rb +91 -0
  188. data/vendor/fssm/lib/fssm/pathname.rb +502 -0
  189. data/vendor/fssm/lib/fssm/state/directory.rb +57 -0
  190. data/vendor/fssm/lib/fssm/state/file.rb +24 -0
  191. data/vendor/fssm/lib/fssm/support.rb +63 -0
  192. data/vendor/fssm/lib/fssm/tree.rb +176 -0
  193. data/vendor/fssm/profile/prof-cache.rb +40 -0
  194. data/vendor/fssm/profile/prof-fssm-pathname.html +1231 -0
  195. data/vendor/fssm/profile/prof-pathname.rb +68 -0
  196. data/vendor/fssm/profile/prof-plain-pathname.html +988 -0
  197. data/vendor/fssm/profile/prof.html +2379 -0
  198. data/vendor/fssm/spec/path_spec.rb +75 -0
  199. data/vendor/fssm/spec/root/duck/quack.txt +0 -0
  200. data/vendor/fssm/spec/root/file.css +0 -0
  201. data/vendor/fssm/spec/root/file.rb +0 -0
  202. data/vendor/fssm/spec/root/file.yml +0 -0
  203. data/vendor/fssm/spec/root/moo/cow.txt +0 -0
  204. data/vendor/fssm/spec/spec_helper.rb +14 -0
  205. metadata +297 -0
@@ -0,0 +1,11 @@
1
+ --readme README.md
2
+ --markup markdown
3
+ --markup-provider maruku
4
+ --default-return ""
5
+ --title "Sass Documentation"
6
+ --query 'object.type != :classvariable'
7
+ --query 'object.type != :constant || @api && @api.text == "public"'
8
+ --hide-void-return
9
+ --protected
10
+ --no-private
11
+ --no-highlight
@@ -0,0 +1,3 @@
1
+ Contributions are welcomed. Please see the following sites for guidelines:
2
+
3
+ http://sass-lang.com/development.html#contributing
@@ -0,0 +1 @@
1
+ 3.1.0.alpha.2
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2006-2009 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,201 @@
1
+ # Sass
2
+
3
+ **Sass makes CSS fun again**. Sass is an extension of CSS3,
4
+ adding nested rules, variables, mixins, selector inheritance, and more.
5
+ It's translated to well-formatted, standard CSS
6
+ using the command line tool or a web-framework plugin.
7
+
8
+ Sass has two syntaxes. The new main syntax (as of Sass 3)
9
+ is known as "SCSS" (for "Sassy CSS"),
10
+ and is a superset of CSS3's syntax.
11
+ This means that every valid CSS3 stylesheet is valid SCSS as well.
12
+ SCSS files use the extension `.scss`.
13
+
14
+ The second, older syntax is known as the indented syntax (or just "Sass").
15
+ Inspired by Haml's terseness, it's intended for people
16
+ who prefer conciseness over similarity to CSS.
17
+ Instead of brackets and semicolons,
18
+ it uses the indentation of lines to specify blocks.
19
+ Although no longer the primary syntax,
20
+ the indented syntax will continue to be supported.
21
+ Files in the indented syntax use the extension `.sass`.
22
+
23
+ ## Using
24
+
25
+ Sass can be used from the command line
26
+ or as part of a web framework.
27
+ The first step is to install the gem:
28
+
29
+ gem install sass
30
+
31
+ After you convert some CSS to Sass, you can run
32
+
33
+ sass style.scss
34
+
35
+ to compile it back to CSS.
36
+ For more information on these commands, check out
37
+
38
+ sass --help
39
+
40
+ To install Sass in Rails 2,
41
+ just add `config.gem "sass"` to `config/environment.rb`.
42
+ In Rails 3, add `gem "sass"` to your Gemfile instead.
43
+ `.sass` or `.scss` files should be placed in `public/stylesheets/sass`,
44
+ where they'll be automatically compiled
45
+ to corresponding CSS files in `public/stylesheets` when needed
46
+ (the Sass template directory is customizable...
47
+ see [the Sass reference](http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#template_location-option) for details).
48
+
49
+ Sass can also be used with any Rack-enabled web framework.
50
+ To do so, just add
51
+
52
+ require 'sass/plugin/rack'
53
+ use Sass::Plugin::Rack
54
+
55
+ to `config.ru`.
56
+ Then any Sass files in `public/stylesheets/sass`
57
+ will be compiled CSS files in `public/stylesheets` on every request.
58
+
59
+ To use Sass programatically,
60
+ check out the [YARD documentation](http://sass-lang.com/docs/yardoc/).
61
+
62
+ ## Formatting
63
+
64
+ Sass is an extension of CSS
65
+ that adds power and elegance to the basic language.
66
+ It allows you to use [variables][vars], [nested rules][nested],
67
+ [mixins][mixins], [inline imports][imports],
68
+ and more, all with a fully CSS-compatible syntax.
69
+ Sass helps keep large stylesheets well-organized,
70
+ and get small stylesheets up and running quickly,
71
+ particularly with the help of
72
+ [the Compass style library](http://compass-style.org).
73
+
74
+ [vars]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#variables_
75
+ [nested]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#nested_rules_
76
+ [mixins]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#mixins
77
+ [imports]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#import
78
+
79
+ Sass has two syntaxes.
80
+ The one presented here, known as "SCSS" (for "Sassy CSS"),
81
+ is fully CSS-compatible.
82
+ The other (older) syntax, known as the indented syntax or just "Sass",
83
+ is whitespace-sensitive and indentation-based.
84
+ For more information, see the [reference documentation][syntax].
85
+
86
+ [syntax]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#syntax
87
+
88
+ To run the following examples and see the CSS they produce,
89
+ put them in a file called `test.scss` and run `sass test.scss`.
90
+
91
+ ### Nesting
92
+
93
+ Sass avoids repetition by nesting selectors within one another.
94
+ The same thing works for properties.
95
+
96
+ table.hl {
97
+ margin: 2em 0;
98
+ td.ln { text-align: right; }
99
+ }
100
+
101
+ li {
102
+ font: {
103
+ family: serif;
104
+ weight: bold;
105
+ size: 1.2em;
106
+ }
107
+ }
108
+
109
+ ### Variables
110
+
111
+ Use the same color all over the place?
112
+ Need to do some math with height and width and text size?
113
+ Sass supports variables, math operations, and many useful functions.
114
+
115
+ $blue: #3bbfce;
116
+ $margin: 16px;
117
+
118
+ .content_navigation {
119
+ border-color: $blue;
120
+ color: darken($blue, 10%);
121
+ }
122
+
123
+ .border {
124
+ padding: $margin / 2;
125
+ margin: $margin / 2;
126
+ border-color: $blue;
127
+ }
128
+
129
+ ### Mixins
130
+
131
+ Even more powerful than variables,
132
+ mixins allow you to re-use whole chunks of CSS,
133
+ properties or selectors.
134
+ You can even give them arguments.
135
+
136
+ @mixin table-scaffolding {
137
+ th {
138
+ text-align: center;
139
+ font-weight: bold;
140
+ }
141
+ td, th { padding: 2px; }
142
+ }
143
+
144
+ @mixin left($dist) {
145
+ float: left;
146
+ margin-left: $dist;
147
+ }
148
+
149
+ #data {
150
+ @include left(10px);
151
+ @include table-scaffolding;
152
+ }
153
+
154
+ A comprehensive list of features is available
155
+ in the [Sass reference](http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html).
156
+
157
+ ## Executables
158
+
159
+ The Sass gem includes several executables that are useful
160
+ for dealing with Sass from the command line.
161
+
162
+ ### `sass`
163
+
164
+ The `sass` executable transforms a source Sass file into CSS.
165
+ See `sass --help` for further information and options.
166
+
167
+ ### `sass-convert`
168
+
169
+ The `sass-convert` executable converts between CSS, Sass, and SCSS.
170
+ When converting from CSS to Sass or SCSS,
171
+ nesting is applied where appropriate.
172
+ See `sass-convert --help` for further information and options.
173
+
174
+ ## Authors
175
+
176
+ Sass was envisioned by [Hampton Catlin](http://hamptoncatlin.com) (hcatlin).
177
+ However, Hampton doesn't even know his way around the code anymore and now
178
+ occasionally consults on the language issues. Hampton lives in Jacksonville,
179
+ Florida and is the lead mobile developer for Wikimedia.
180
+
181
+ [Nathan Weizenbaum](http://nex-3.com) is the primary developer and architect of
182
+ Sass. His hard work has kept the project alive by endlessly answering forum
183
+ posts, fixing bugs, refactoring, finding speed improvements, writing
184
+ documentation, implementing new features, and getting Hampton coffee (a fitting
185
+ task for a boy-genius). Nathan lives in Seattle, Washington and while not being
186
+ a student at the University of Washington or working at an internship, he
187
+ consults for Unspace Interactive.
188
+
189
+ [Chris Eppstein](http://acts-as-architect.blogspot.com) is a core contributor to
190
+ Sass and the creator of Compass, the first Sass-based framework. Chris focuses
191
+ on making Sass more powerful, easy to use, and on ways to speed its adoption
192
+ through the web development community. Chris lives in San Jose, California with
193
+ his wife and daughter. He is the Software Architect for
194
+ [Caring.com](http://caring.com), a website devoted to the 34 Million caregivers
195
+ whose parents are sick or elderly, that uses Haml and Sass.
196
+
197
+ If you use this software, you must pay Hampton a compliment. And
198
+ buy Nathan some jelly beans. Maybe pet a kitten. Yeah. Pet that kitty.
199
+
200
+ Beyond that, the implementation is licensed under the MIT License.
201
+ Okay, fine, I guess that means compliments aren't __required__.
@@ -0,0 +1 @@
1
+ (release)
@@ -0,0 +1,353 @@
1
+ # ----- Utility Functions -----
2
+
3
+ def scope(path)
4
+ File.join(File.dirname(__FILE__), path)
5
+ end
6
+
7
+ # ----- Default: Testing ------
8
+
9
+ task :default => :test
10
+
11
+ require 'rake/testtask'
12
+
13
+ Rake::TestTask.new do |t|
14
+ t.libs << 'lib'
15
+ test_files = FileList[scope('test/**/*_test.rb')]
16
+ test_files.exclude(scope('test/rails/*'))
17
+ test_files.exclude(scope('test/plugins/*'))
18
+ t.test_files = test_files
19
+ t.verbose = true
20
+ end
21
+
22
+ # ----- Packaging -----
23
+
24
+ # Don't use Rake::GemPackageTast because we want prerequisites to run
25
+ # before we load the gemspec.
26
+ desc "Build all the packages."
27
+ task :package => [:revision_file, :submodules] do
28
+ load scope('sass.gemspec')
29
+ Gem::Builder.new(SASS_GEMSPEC).build
30
+ pkg = "#{SASS_GEMSPEC.name}-#{SASS_GEMSPEC.version}"
31
+ mkdir_p "pkg"
32
+ verbose(true) {mv "#{pkg}.gem", "pkg/#{pkg}.gem"}
33
+
34
+ sh %{rm -f pkg/#{pkg}.tar.gz}
35
+ verbose(false) {SASS_GEMSPEC.files.each {|f| sh %{tar rf pkg/#{pkg}.tar #{f}}}}
36
+ sh %{gzip pkg/#{pkg}.tar}
37
+ end
38
+
39
+ task :revision_file do
40
+ require 'lib/sass'
41
+
42
+ release = Rake.application.top_level_tasks.include?('release') || File.exist?(scope('EDGE_GEM_VERSION'))
43
+ if Sass.version[:rev] && !release
44
+ File.open(scope('REVISION'), 'w') { |f| f.puts Sass.version[:rev] }
45
+ elsif release
46
+ File.open(scope('REVISION'), 'w') { |f| f.puts "(release)" }
47
+ else
48
+ File.open(scope('REVISION'), 'w') { |f| f.puts "(unknown)" }
49
+ end
50
+ end
51
+
52
+ # We also need to get rid of this file after packaging.
53
+ at_exit { File.delete(scope('REVISION')) rescue nil }
54
+
55
+ desc "Install Sass as a gem. Use SUDO=1 to install with sudo."
56
+ task :install => [:package] do
57
+ gem = RUBY_PLATFORM =~ /java/ ? 'jgem' : 'gem'
58
+ sh %{#{'sudo ' if ENV["SUDO"]}#{gem} install --no-ri pkg/sass-#{File.read(scope('VERSION')).strip}}
59
+ end
60
+
61
+ desc "Release a new Sass package to Rubyforge."
62
+ task :release => [:check_release, :package] do
63
+ name = File.read(scope("VERSION_NAME")).strip
64
+ version = File.read(scope("VERSION")).strip
65
+ #sh %{rubyforge add_release sass sass "#{name} (v#{version})" pkg/sass-#{version}.gem}
66
+ #sh %{rubyforge add_file sass sass "#{name} (v#{version})" pkg/sass-#{version}.tar.gz}
67
+ sh %{gem push pkg/sass-#{version}.gem}
68
+ end
69
+
70
+ # Ensures that the VERSION file has been updated for a new release.
71
+ task :check_release do
72
+ version = File.read(scope("VERSION")).strip
73
+ raise "There have been changes since current version (#{version})" if changed_since?(version)
74
+ raise "VERSION_NAME must not be 'Bleeding Edge'" if File.read(scope("VERSION_NAME")) == "Bleeding Edge"
75
+ end
76
+
77
+ # Reads a password from the command line.
78
+ #
79
+ # @param name [String] The prompt to use to read the password
80
+ def read_password(prompt)
81
+ require 'readline'
82
+ system "stty -echo"
83
+ Readline.readline("#{prompt}: ").strip
84
+ ensure
85
+ system "stty echo"
86
+ puts
87
+ end
88
+
89
+ # Returns whether or not the repository, or specific files,
90
+ # has/have changed since a given revision.
91
+ #
92
+ # @param rev [String] The revision to check against
93
+ # @param files [Array<String>] The files to check.
94
+ # If this is empty, checks the entire repository
95
+ def changed_since?(rev, *files)
96
+ IO.popen("git diff --exit-code #{rev} #{files.join(' ')}") {}
97
+ return !$?.success?
98
+ end
99
+
100
+ task :submodules do
101
+ if File.exist?(File.dirname(__FILE__) + "/.git")
102
+ sh %{git submodule sync}
103
+ sh %{git submodule update --init}
104
+ elsif !File.exist?(File.dirname(__FILE__) + "/vendor/fssm/lib")
105
+ warn <<WARN
106
+ WARNING: vendor/fssm doesn't exist, and this isn't a git repository so
107
+ I can't get it automatically!
108
+ WARN
109
+ end
110
+ end
111
+
112
+ task :release_edge do
113
+ ensure_git_cleanup do
114
+ puts "#{'=' * 50} Running rake release_edge"
115
+
116
+ sh %{git checkout edge-gem}
117
+ sh %{git reset --hard origin/edge-gem}
118
+ sh %{git merge origin/master}
119
+
120
+ unless edge_version = bump_edge_version
121
+ puts "master is already a prerelease version, no use building an edge gem"
122
+ next
123
+ end
124
+
125
+ File.open(scope('EDGE_GEM_VERSION'), 'w') {|f| f.puts(edge_version)}
126
+ sh %{git commit -m "Bump edge gem version to #{edge_version}." EDGE_GEM_VERSION}
127
+ sh %{git push origin edge-gem}
128
+
129
+ # Package the edge gem with the proper version
130
+ File.open(scope('VERSION'), 'w') {|f| f.puts(edge_version)}
131
+ sh %{rake package}
132
+ sh %{git checkout VERSION}
133
+
134
+ #sh %{rubyforge add_release sass sass "Bleeding Edge (v#{edge_version})" pkg/sass-#{edge_version}.gem}
135
+ sh %{gem push pkg/sass-#{edge_version}.gem}
136
+ end
137
+ end
138
+
139
+ # Reads the master version and the edge gem version,
140
+ # bump the latter, and return it.
141
+ #
142
+ # Returns nil if the current master version is already a non-alpha prerelease.
143
+ def bump_edge_version
144
+ # Get the current master branch version
145
+ version = File.read(scope('VERSION')).strip.split('.')
146
+ version.map! {|n| n =~ /^[0-9]+$/ ? n.to_i : n}
147
+ unless version.size == 5 # prerelease
148
+ raise "master version #{version.join('.')} is not a prerelease version"
149
+ end
150
+
151
+ # Bump the edge gem version
152
+ edge_version = File.read(scope('EDGE_GEM_VERSION')).strip.split('.')
153
+ edge_version.map! {|n| n =~ /^[0-9]+$/ ? n.to_i : n}
154
+
155
+ if version[3] != "alpha"
156
+ return
157
+ elsif edge_version[0..2] != version[0..2]
158
+ # A new master branch version was released, reset the edge gem version
159
+ edge_version[0..2] = version[0..2]
160
+ edge_version[4] = 1
161
+ else
162
+ # Just bump the teeny version
163
+ edge_version[4] += 1
164
+ end
165
+
166
+ edge_version.join('.')
167
+ end
168
+
169
+ task :watch_for_update do
170
+ sh %{ruby extra/update_watch.rb}
171
+ end
172
+
173
+ # ----- Documentation -----
174
+
175
+ task :rdoc do
176
+ puts '=' * 100, <<END, '=' * 100
177
+ Sass uses the YARD documentation system (http://github.com/lsegal/yard).
178
+ Install the yard gem and then run "rake doc".
179
+ END
180
+ end
181
+
182
+ begin
183
+ require 'yard'
184
+
185
+ namespace :doc do
186
+ task :sass do
187
+ require scope('lib/sass')
188
+ Dir[scope("yard/default/**/*.sass")].each do |sass|
189
+ File.open(sass.gsub(/sass$/, 'css'), 'w') do |f|
190
+ f.write(Sass::Engine.new(File.read(sass)).render)
191
+ end
192
+ end
193
+ end
194
+
195
+ desc "List all undocumented methods and classes."
196
+ task :undocumented do
197
+ opts = ENV["YARD_OPTS"] || ""
198
+ ENV["YARD_OPTS"] = opts.dup + <<OPTS
199
+ --list --query "
200
+ object.docstring.blank? &&
201
+ !(object.type == :method && object.is_alias?)"
202
+ OPTS
203
+ Rake::Task['yard'].execute
204
+ end
205
+ end
206
+
207
+ YARD::Rake::YardocTask.new do |t|
208
+ t.files = FileList.new(scope('lib/**/*.rb')) do |list|
209
+ list.exclude('lib/sass/plugin/merb.rb')
210
+ list.exclude('lib/sass/plugin/rails.rb')
211
+ list.exclude('lib/sass/less.rb')
212
+ end.to_a
213
+ t.options << '--incremental' if Rake.application.top_level_tasks.include?('redoc')
214
+ t.options += FileList.new(scope('yard/*.rb')).to_a.map {|f| ['-e', f]}.flatten
215
+ files = FileList.new(scope('doc-src/*')).to_a.sort_by {|s| s.size} + %w[MIT-LICENSE VERSION]
216
+ t.options << '--files' << files.join(',')
217
+ t.options << '--template-path' << scope('yard')
218
+ t.options << '--title' << ENV["YARD_TITLE"] if ENV["YARD_TITLE"]
219
+
220
+ t.before = lambda do
221
+ if ENV["YARD_OPTS"]
222
+ require 'shellwords'
223
+ t.options.concat(Shellwords.shellwords(ENV["YARD_OPTS"]))
224
+ end
225
+ end
226
+ end
227
+ Rake::Task['yard'].prerequisites.insert(0, 'doc:sass')
228
+ Rake::Task['yard'].instance_variable_set('@comment', nil)
229
+
230
+ desc "Generate Documentation"
231
+ task :doc => :yard
232
+ task :redoc => :yard
233
+ rescue LoadError
234
+ desc "Generate Documentation"
235
+ task :doc => :rdoc
236
+ task :yard => :rdoc
237
+ end
238
+
239
+ task :pages do
240
+ ensure_git_cleanup do
241
+ puts "#{'=' * 50} Running rake pages"
242
+ sh %{git checkout sass-pages}
243
+ sh %{git reset --hard origin/sass-pages}
244
+
245
+ Dir.chdir("/var/www/sass-pages") do
246
+ sh %{git fetch origin}
247
+
248
+ sh %{git checkout stable}
249
+ sh %{git reset --hard origin/stable}
250
+
251
+ sh %{git checkout sass-pages}
252
+ sh %{git reset --hard origin/sass-pages}
253
+ sh %{rake build --trace}
254
+ sh %{mkdir -p tmp}
255
+ sh %{touch tmp/restart.txt}
256
+ end
257
+ end
258
+ end
259
+
260
+ # ----- Coverage -----
261
+
262
+ begin
263
+ require 'rcov/rcovtask'
264
+
265
+ Rcov::RcovTask.new do |t|
266
+ t.test_files = FileList[scope('test/**/*_test.rb')]
267
+ t.rcov_opts << '-x' << '"^\/"'
268
+ if ENV['NON_NATIVE']
269
+ t.rcov_opts << "--no-rcovrt"
270
+ end
271
+ t.verbose = true
272
+ end
273
+ rescue LoadError; end
274
+
275
+ # ----- Profiling -----
276
+
277
+ begin
278
+ require 'ruby-prof'
279
+
280
+ desc <<END
281
+ Run a profile of sass.
282
+ TIMES=n sets the number of runs. Defaults to 1000.
283
+ FILE=str sets the file to profile. Defaults to 'complex'.
284
+ OUTPUT=str sets the ruby-prof output format.
285
+ Can be Flat, CallInfo, or Graph. Defaults to Flat. Defaults to Flat.
286
+ END
287
+ task :profile do
288
+ times = (ENV['TIMES'] || '1000').to_i
289
+ file = ENV['FILE']
290
+
291
+ require 'lib/sass'
292
+
293
+ file = File.read(scope("test/sass/templates/#{file || 'complex'}.sass"))
294
+ result = RubyProf.profile { times.times { Sass::Engine.new(file).render } }
295
+
296
+ RubyProf.const_get("#{(ENV['OUTPUT'] || 'Flat').capitalize}Printer").new(result).print
297
+ end
298
+ rescue LoadError; end
299
+
300
+ # ----- Handling Updates -----
301
+
302
+ def email_on_error
303
+ yield
304
+ rescue Exception => e
305
+ IO.popen("sendmail nex342@gmail.com", "w") do |sm|
306
+ sm << "From: nex3@nex-3.com\n" <<
307
+ "To: nex342@gmail.com\n" <<
308
+ "Subject: Exception when running rake #{Rake.application.top_level_tasks.join(', ')}\n" <<
309
+ e.message << "\n\n" <<
310
+ e.backtrace.join("\n")
311
+ end
312
+ ensure
313
+ raise e if e
314
+ end
315
+
316
+ def ensure_git_cleanup
317
+ email_on_error {yield}
318
+ ensure
319
+ sh %{git reset --hard HEAD}
320
+ sh %{git clean -xdf}
321
+ sh %{git checkout master}
322
+ end
323
+
324
+ task :handle_update do
325
+ email_on_error do
326
+ unless ENV["REF"] =~ %r{^refs/heads/(master|stable|sass-pages)$}
327
+ puts "#{'=' * 20} Ignoring rake handle_update REF=#{ENV["REF"].inspect}"
328
+ next
329
+ end
330
+ branch = $1
331
+
332
+ puts
333
+ puts
334
+ puts '=' * 150
335
+ puts "Running rake handle_update REF=#{ENV["REF"].inspect}"
336
+
337
+ sh %{git fetch origin}
338
+ sh %{git checkout stable}
339
+ sh %{git reset --hard origin/stable}
340
+ sh %{git checkout master}
341
+ sh %{git reset --hard origin/master}
342
+
343
+ case branch
344
+ when "master"
345
+ sh %{rake release_edge --trace}
346
+ when "stable", "sass-pages"
347
+ sh %{rake pages --trace}
348
+ end
349
+
350
+ puts 'Done running handle_update'
351
+ puts '=' * 150
352
+ end
353
+ end