sass-rails 4.0.3 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (241) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +19 -16
  3. data/lib/rails/generators/sass/assets/assets_generator.rb +1 -1
  4. data/lib/rails/generators/sass/assets/templates/{stylesheet.css.sass → stylesheet.sass} +0 -0
  5. data/lib/rails/generators/sass_scaffold.rb +1 -2
  6. data/lib/rails/generators/scss/assets/assets_generator.rb +1 -1
  7. data/lib/rails/generators/scss/assets/templates/{stylesheet.css.scss → stylesheet.scss} +0 -0
  8. data/lib/sass/rails/cache_store.rb +31 -0
  9. data/lib/sass/rails/helpers.rb +4 -21
  10. data/lib/sass/rails/importer.rb +124 -81
  11. data/lib/sass/rails/logger.rb +1 -0
  12. data/lib/sass/rails/railtie.rb +34 -11
  13. data/lib/sass/rails/template.rb +67 -23
  14. data/lib/sass/rails/version.rb +1 -1
  15. metadata +63 -474
  16. data/.gitignore +0 -6
  17. data/.travis.yml +0 -22
  18. data/CHANGELOG.md +0 -48
  19. data/Gemfile +0 -8
  20. data/Rakefile +0 -29
  21. data/sass-rails.gemspec +0 -27
  22. data/sass-rails.gemspec.erb +0 -27
  23. data/test/fixtures/alternate_config_project/.gitignore +0 -5
  24. data/test/fixtures/alternate_config_project/Gemfile +0 -7
  25. data/test/fixtures/alternate_config_project/README +0 -261
  26. data/test/fixtures/alternate_config_project/Rakefile +0 -7
  27. data/test/fixtures/alternate_config_project/app/assets/images/1x1.png +0 -0
  28. data/test/fixtures/alternate_config_project/app/assets/images/rails.png +0 -0
  29. data/test/fixtures/alternate_config_project/app/assets/javascripts/application.js +0 -9
  30. data/test/fixtures/alternate_config_project/app/assets/stylesheets/_top_level_partial.css.scss +0 -3
  31. data/test/fixtures/alternate_config_project/app/assets/stylesheets/application.css.scss +0 -32
  32. data/test/fixtures/alternate_config_project/app/assets/stylesheets/css_application.css +0 -7
  33. data/test/fixtures/alternate_config_project/app/assets/stylesheets/globbed/globbed.css.scss +0 -3
  34. data/test/fixtures/alternate_config_project/app/assets/stylesheets/globbed/nested/nested_glob.css.scss +0 -3
  35. data/test/fixtures/alternate_config_project/app/assets/stylesheets/partials/_sass_import.css.sass +0 -5
  36. data/test/fixtures/alternate_config_project/app/assets/stylesheets/partials/_scss_import.css.scss +0 -9
  37. data/test/fixtures/alternate_config_project/app/assets/stylesheets/partials/_without_css_ext.scss +0 -3
  38. data/test/fixtures/alternate_config_project/app/assets/stylesheets/partials/subfolder/_relative_sass.css.sass +0 -2
  39. data/test/fixtures/alternate_config_project/app/assets/stylesheets/partials/subfolder/_relative_scss.css.scss +0 -3
  40. data/test/fixtures/alternate_config_project/app/assets/stylesheets/partials/subfolder/relative_not_a_partial.css.scss +0 -3
  41. data/test/fixtures/alternate_config_project/app/assets/stylesheets/subfolder/another_plain.css +0 -3
  42. data/test/fixtures/alternate_config_project/app/assets/stylesheets/subfolder/plain.css +0 -3
  43. data/test/fixtures/alternate_config_project/app/assets/stylesheets/subfolder/second_level.css.scss +0 -1
  44. data/test/fixtures/alternate_config_project/app/controllers/application_controller.rb +0 -3
  45. data/test/fixtures/alternate_config_project/app/helpers/application_helper.rb +0 -2
  46. data/test/fixtures/alternate_config_project/app/mailers/.gitkeep +0 -0
  47. data/test/fixtures/alternate_config_project/app/models/.gitkeep +0 -0
  48. data/test/fixtures/alternate_config_project/app/views/layouts/application.html.erb +0 -14
  49. data/test/fixtures/alternate_config_project/config.ru +0 -4
  50. data/test/fixtures/alternate_config_project/config/application.rb +0 -49
  51. data/test/fixtures/alternate_config_project/config/boot.rb +0 -6
  52. data/test/fixtures/alternate_config_project/config/database.yml +0 -25
  53. data/test/fixtures/alternate_config_project/config/environment.rb +0 -5
  54. data/test/fixtures/alternate_config_project/config/environments/development.rb +0 -27
  55. data/test/fixtures/alternate_config_project/config/environments/production.rb +0 -56
  56. data/test/fixtures/alternate_config_project/config/environments/test.rb +0 -38
  57. data/test/fixtures/alternate_config_project/config/initializers/backtrace_silencers.rb +0 -7
  58. data/test/fixtures/alternate_config_project/config/initializers/inflections.rb +0 -10
  59. data/test/fixtures/alternate_config_project/config/initializers/mime_types.rb +0 -5
  60. data/test/fixtures/alternate_config_project/config/initializers/secret_token.rb +0 -7
  61. data/test/fixtures/alternate_config_project/config/initializers/session_store.rb +0 -8
  62. data/test/fixtures/alternate_config_project/config/initializers/wrap_parameters.rb +0 -12
  63. data/test/fixtures/alternate_config_project/config/locales/en.yml +0 -5
  64. data/test/fixtures/alternate_config_project/config/routes.rb +0 -58
  65. data/test/fixtures/alternate_config_project/db/seeds.rb +0 -7
  66. data/test/fixtures/alternate_config_project/doc/README_FOR_APP +0 -2
  67. data/test/fixtures/alternate_config_project/lib/tasks/.gitkeep +0 -0
  68. data/test/fixtures/alternate_config_project/log/.gitkeep +0 -0
  69. data/test/fixtures/alternate_config_project/public/404.html +0 -26
  70. data/test/fixtures/alternate_config_project/public/422.html +0 -26
  71. data/test/fixtures/alternate_config_project/public/500.html +0 -26
  72. data/test/fixtures/alternate_config_project/public/favicon.ico +0 -0
  73. data/test/fixtures/alternate_config_project/public/index.html +0 -241
  74. data/test/fixtures/alternate_config_project/public/robots.txt +0 -5
  75. data/test/fixtures/alternate_config_project/script/rails +0 -6
  76. data/test/fixtures/alternate_config_project/vendor/assets/stylesheets/.gitkeep +0 -0
  77. data/test/fixtures/alternate_config_project/vendor/plugins/.gitkeep +0 -0
  78. data/test/fixtures/engine_project/.gitignore +0 -8
  79. data/test/fixtures/engine_project/Gemfile +0 -14
  80. data/test/fixtures/engine_project/MIT-LICENSE +0 -20
  81. data/test/fixtures/engine_project/README.rdoc +0 -3
  82. data/test/fixtures/engine_project/Rakefile +0 -34
  83. data/test/fixtures/engine_project/app/assets/images/engine_project/.keep +0 -0
  84. data/test/fixtures/engine_project/app/assets/javascripts/engine_project/application.js +0 -16
  85. data/test/fixtures/engine_project/app/assets/stylesheets/engine_project/application.css +0 -13
  86. data/test/fixtures/engine_project/app/controllers/engine_project/application_controller.rb +0 -4
  87. data/test/fixtures/engine_project/app/helpers/engine_project/application_helper.rb +0 -4
  88. data/test/fixtures/engine_project/app/views/layouts/engine_project/application.html.erb +0 -14
  89. data/test/fixtures/engine_project/config/routes.rb +0 -2
  90. data/test/fixtures/engine_project/engine_project.gemspec +0 -23
  91. data/test/fixtures/engine_project/lib/engine_project.rb +0 -4
  92. data/test/fixtures/engine_project/lib/engine_project/engine.rb +0 -5
  93. data/test/fixtures/engine_project/lib/engine_project/version.rb +0 -3
  94. data/test/fixtures/engine_project/lib/tasks/engine_project_tasks.rake +0 -4
  95. data/test/fixtures/engine_project/script/rails +0 -8
  96. data/test/fixtures/engine_project/test/dummy/README.rdoc +0 -28
  97. data/test/fixtures/engine_project/test/dummy/Rakefile +0 -6
  98. data/test/fixtures/engine_project/test/dummy/app/assets/javascripts/application.js +0 -16
  99. data/test/fixtures/engine_project/test/dummy/app/assets/stylesheets/application.css +0 -13
  100. data/test/fixtures/engine_project/test/dummy/app/controllers/application_controller.rb +0 -5
  101. data/test/fixtures/engine_project/test/dummy/app/controllers/concerns/.keep +0 -0
  102. data/test/fixtures/engine_project/test/dummy/app/helpers/application_helper.rb +0 -2
  103. data/test/fixtures/engine_project/test/dummy/app/mailers/.keep +0 -0
  104. data/test/fixtures/engine_project/test/dummy/app/models/.keep +0 -0
  105. data/test/fixtures/engine_project/test/dummy/app/models/concerns/.keep +0 -0
  106. data/test/fixtures/engine_project/test/dummy/app/views/layouts/application.html.erb +0 -14
  107. data/test/fixtures/engine_project/test/dummy/bin/bundle +0 -3
  108. data/test/fixtures/engine_project/test/dummy/bin/rails +0 -4
  109. data/test/fixtures/engine_project/test/dummy/bin/rake +0 -4
  110. data/test/fixtures/engine_project/test/dummy/config.ru +0 -4
  111. data/test/fixtures/engine_project/test/dummy/config/application.rb +0 -23
  112. data/test/fixtures/engine_project/test/dummy/config/boot.rb +0 -9
  113. data/test/fixtures/engine_project/test/dummy/config/database.yml +0 -25
  114. data/test/fixtures/engine_project/test/dummy/config/environment.rb +0 -5
  115. data/test/fixtures/engine_project/test/dummy/config/environments/development.rb +0 -27
  116. data/test/fixtures/engine_project/test/dummy/config/environments/production.rb +0 -80
  117. data/test/fixtures/engine_project/test/dummy/config/environments/test.rb +0 -36
  118. data/test/fixtures/engine_project/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  119. data/test/fixtures/engine_project/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  120. data/test/fixtures/engine_project/test/dummy/config/initializers/inflections.rb +0 -16
  121. data/test/fixtures/engine_project/test/dummy/config/initializers/mime_types.rb +0 -5
  122. data/test/fixtures/engine_project/test/dummy/config/initializers/secret_token.rb +0 -12
  123. data/test/fixtures/engine_project/test/dummy/config/initializers/session_store.rb +0 -3
  124. data/test/fixtures/engine_project/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  125. data/test/fixtures/engine_project/test/dummy/config/locales/en.yml +0 -23
  126. data/test/fixtures/engine_project/test/dummy/config/routes.rb +0 -4
  127. data/test/fixtures/engine_project/test/dummy/lib/assets/.keep +0 -0
  128. data/test/fixtures/engine_project/test/dummy/log/.keep +0 -0
  129. data/test/fixtures/engine_project/test/dummy/public/404.html +0 -27
  130. data/test/fixtures/engine_project/test/dummy/public/422.html +0 -26
  131. data/test/fixtures/engine_project/test/dummy/public/500.html +0 -26
  132. data/test/fixtures/engine_project/test/dummy/public/favicon.ico +0 -0
  133. data/test/fixtures/sass_project/.gitignore +0 -5
  134. data/test/fixtures/sass_project/Gemfile +0 -7
  135. data/test/fixtures/sass_project/README +0 -261
  136. data/test/fixtures/sass_project/Rakefile +0 -7
  137. data/test/fixtures/sass_project/app/assets/images/rails.png +0 -0
  138. data/test/fixtures/sass_project/app/assets/javascripts/application.js +0 -9
  139. data/test/fixtures/sass_project/app/assets/stylesheets/application.css +0 -7
  140. data/test/fixtures/sass_project/app/controllers/application_controller.rb +0 -3
  141. data/test/fixtures/sass_project/app/helpers/application_helper.rb +0 -2
  142. data/test/fixtures/sass_project/app/mailers/.gitkeep +0 -0
  143. data/test/fixtures/sass_project/app/models/.gitkeep +0 -0
  144. data/test/fixtures/sass_project/app/views/layouts/application.html.erb +0 -14
  145. data/test/fixtures/sass_project/config.ru +0 -4
  146. data/test/fixtures/sass_project/config/application.rb +0 -52
  147. data/test/fixtures/sass_project/config/boot.rb +0 -6
  148. data/test/fixtures/sass_project/config/database.yml +0 -25
  149. data/test/fixtures/sass_project/config/environment.rb +0 -5
  150. data/test/fixtures/sass_project/config/environments/development.rb +0 -21
  151. data/test/fixtures/sass_project/config/environments/production.rb +0 -51
  152. data/test/fixtures/sass_project/config/environments/test.rb +0 -36
  153. data/test/fixtures/sass_project/config/initializers/backtrace_silencers.rb +0 -7
  154. data/test/fixtures/sass_project/config/initializers/inflections.rb +0 -10
  155. data/test/fixtures/sass_project/config/initializers/mime_types.rb +0 -5
  156. data/test/fixtures/sass_project/config/initializers/secret_token.rb +0 -7
  157. data/test/fixtures/sass_project/config/initializers/session_store.rb +0 -8
  158. data/test/fixtures/sass_project/config/initializers/wrap_parameters.rb +0 -12
  159. data/test/fixtures/sass_project/config/locales/en.yml +0 -5
  160. data/test/fixtures/sass_project/config/routes.rb +0 -58
  161. data/test/fixtures/sass_project/db/seeds.rb +0 -7
  162. data/test/fixtures/sass_project/doc/README_FOR_APP +0 -2
  163. data/test/fixtures/sass_project/lib/tasks/.gitkeep +0 -0
  164. data/test/fixtures/sass_project/log/.gitkeep +0 -0
  165. data/test/fixtures/sass_project/public/404.html +0 -26
  166. data/test/fixtures/sass_project/public/422.html +0 -26
  167. data/test/fixtures/sass_project/public/500.html +0 -26
  168. data/test/fixtures/sass_project/public/favicon.ico +0 -0
  169. data/test/fixtures/sass_project/public/index.html +0 -241
  170. data/test/fixtures/sass_project/public/robots.txt +0 -5
  171. data/test/fixtures/sass_project/script/rails +0 -6
  172. data/test/fixtures/sass_project/vendor/assets/stylesheets/.gitkeep +0 -0
  173. data/test/fixtures/sass_project/vendor/plugins/.gitkeep +0 -0
  174. data/test/fixtures/scss_project/.gitignore +0 -5
  175. data/test/fixtures/scss_project/Gemfile +0 -7
  176. data/test/fixtures/scss_project/README +0 -261
  177. data/test/fixtures/scss_project/Rakefile +0 -7
  178. data/test/fixtures/scss_project/app/assets/images/1x1.png +0 -0
  179. data/test/fixtures/scss_project/app/assets/images/rails.png +0 -0
  180. data/test/fixtures/scss_project/app/assets/javascripts/application.js +0 -9
  181. data/test/fixtures/scss_project/app/assets/stylesheets/_top_level_partial.css.scss +0 -3
  182. data/test/fixtures/scss_project/app/assets/stylesheets/application.css.scss +0 -37
  183. data/test/fixtures/scss_project/app/assets/stylesheets/css_application.css +0 -7
  184. data/test/fixtures/scss_project/app/assets/stylesheets/css_erb_handler.css.erb +0 -3
  185. data/test/fixtures/scss_project/app/assets/stylesheets/css_sass_erb_handler.css.sass.erb +0 -2
  186. data/test/fixtures/scss_project/app/assets/stylesheets/css_scss_erb_handler.css.scss.erb +0 -3
  187. data/test/fixtures/scss_project/app/assets/stylesheets/globbed/globbed.css.scss +0 -3
  188. data/test/fixtures/scss_project/app/assets/stylesheets/globbed/nested/nested_glob.css.scss +0 -3
  189. data/test/fixtures/scss_project/app/assets/stylesheets/partials/_sass_import.css.sass +0 -5
  190. data/test/fixtures/scss_project/app/assets/stylesheets/partials/_scss_import.css.scss +0 -9
  191. data/test/fixtures/scss_project/app/assets/stylesheets/partials/_without_css_ext.scss +0 -3
  192. data/test/fixtures/scss_project/app/assets/stylesheets/partials/subfolder/_relative_sass.css.sass +0 -2
  193. data/test/fixtures/scss_project/app/assets/stylesheets/partials/subfolder/_relative_scss.css.scss +0 -3
  194. data/test/fixtures/scss_project/app/assets/stylesheets/partials/subfolder/relative_not_a_partial.css.scss +0 -3
  195. data/test/fixtures/scss_project/app/assets/stylesheets/sass_erb_handler.sass.erb +0 -2
  196. data/test/fixtures/scss_project/app/assets/stylesheets/scss_erb_handler.scss.erb +0 -3
  197. data/test/fixtures/scss_project/app/assets/stylesheets/subfolder/_defaults.css.scss +0 -3
  198. data/test/fixtures/scss_project/app/assets/stylesheets/subfolder/another_plain.css +0 -3
  199. data/test/fixtures/scss_project/app/assets/stylesheets/subfolder/plain.css +0 -3
  200. data/test/fixtures/scss_project/app/assets/stylesheets/subfolder/second_level.css.scss +0 -2
  201. data/test/fixtures/scss_project/app/controllers/application_controller.rb +0 -3
  202. data/test/fixtures/scss_project/app/helpers/application_helper.rb +0 -2
  203. data/test/fixtures/scss_project/app/mailers/.gitkeep +0 -0
  204. data/test/fixtures/scss_project/app/models/.gitkeep +0 -0
  205. data/test/fixtures/scss_project/app/views/layouts/application.html.erb +0 -14
  206. data/test/fixtures/scss_project/config.ru +0 -4
  207. data/test/fixtures/scss_project/config/application.rb +0 -49
  208. data/test/fixtures/scss_project/config/boot.rb +0 -6
  209. data/test/fixtures/scss_project/config/database.yml +0 -25
  210. data/test/fixtures/scss_project/config/environment.rb +0 -5
  211. data/test/fixtures/scss_project/config/environments/development.rb +0 -23
  212. data/test/fixtures/scss_project/config/environments/production.rb +0 -53
  213. data/test/fixtures/scss_project/config/environments/test.rb +0 -38
  214. data/test/fixtures/scss_project/config/initializers/backtrace_silencers.rb +0 -7
  215. data/test/fixtures/scss_project/config/initializers/inflections.rb +0 -10
  216. data/test/fixtures/scss_project/config/initializers/mime_types.rb +0 -5
  217. data/test/fixtures/scss_project/config/initializers/postprocessor.rb +0 -3
  218. data/test/fixtures/scss_project/config/initializers/secret_token.rb +0 -7
  219. data/test/fixtures/scss_project/config/initializers/session_store.rb +0 -8
  220. data/test/fixtures/scss_project/config/initializers/wrap_parameters.rb +0 -12
  221. data/test/fixtures/scss_project/config/locales/en.yml +0 -5
  222. data/test/fixtures/scss_project/config/routes.rb +0 -58
  223. data/test/fixtures/scss_project/db/seeds.rb +0 -7
  224. data/test/fixtures/scss_project/doc/README_FOR_APP +0 -2
  225. data/test/fixtures/scss_project/lib/tasks/.gitkeep +0 -0
  226. data/test/fixtures/scss_project/log/.gitkeep +0 -0
  227. data/test/fixtures/scss_project/public/404.html +0 -26
  228. data/test/fixtures/scss_project/public/422.html +0 -26
  229. data/test/fixtures/scss_project/public/500.html +0 -26
  230. data/test/fixtures/scss_project/public/favicon.ico +0 -0
  231. data/test/fixtures/scss_project/public/index.html +0 -241
  232. data/test/fixtures/scss_project/public/robots.txt +0 -5
  233. data/test/fixtures/scss_project/script/rails +0 -6
  234. data/test/fixtures/scss_project/vendor/assets/stylesheets/.gitkeep +0 -0
  235. data/test/fixtures/scss_project/vendor/plugins/.gitkeep +0 -0
  236. data/test/gemfiles/Gemfile-master +0 -8
  237. data/test/sass_rails_generators_test.rb +0 -62
  238. data/test/sass_rails_logger_test.rb +0 -24
  239. data/test/sass_rails_test.rb +0 -133
  240. data/test/support/sass_rails_test_case.rb +0 -166
  241. data/test/test_helper.rb +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 54dce7aa277951f8a75d414c3d306bcb31e8f197
4
- data.tar.gz: 24ac93add7c710d1bc971ca6fd128a4d1c983559
2
+ SHA256:
3
+ metadata.gz: 81b377677315439a968f5d8c1fe884680e40681853aa6ce0059fec8f81a7561e
4
+ data.tar.gz: fce2dc70c42fd35b13dd1310c6e7f48825143497bb98fde3d4ded15efa5b72fe
5
5
  SHA512:
6
- metadata.gz: 10f18b7e6991934d836c7bf6beeda155b943a700440b9cd9fe95c31f204744aa5e984a9bd4ee74ede0d6938fff753c83ee29d95ba2ff1e8010e9cc30dd3e25f9
7
- data.tar.gz: e203aa3c350946f547b14eb6d2c2e035d880e7cd656675e3e54ea08e0f374a4d99bd821f1a9835748266c83d870362dbdd81b09618da9e2a1608a1f9f11d552f
6
+ metadata.gz: 561d100c511ed762dec416a081117bb949833e2ffde2ea8fa984cfae44f4f432e3cb52f3f213c8b4c37fe365c50a77b8fbe04e26f48a4a12b7cc5f8fd074ffce
7
+ data.tar.gz: 20b336c399d4907f64c95112a95ab912ce04575f8e3f153476e1b10d5d70dba4038d220baadbf4d408f509fe2c58cdde26c5250383ad52b011394c46afe90f65
data/README.md CHANGED
@@ -16,20 +16,23 @@ properties that will be passed to Sass.
16
16
 
17
17
  ### Options
18
18
 
19
- The [list of supported options](http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#options)
19
+ - `preferred_syntax` - This option determines the default Sass syntax and file extensions that will be used by Rails generators. Can be `:scss` (default CSS-compatible SCSS syntax) or `:sass` (indented Sass syntax).
20
+
21
+ The [list of supported Sass options](http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#options)
20
22
  can be found on the Sass Website with the following caveats:
21
23
 
22
- 1. `:style` - This option is not supported. This is determined by the Rails environment. It's `:expanded` only on development, otherwise it's `:compressed`.
23
- 2. `:never_update` - This option is not supported. Instead set `config.assets.enabled = false`
24
- 3. `:always_update` - This option is not supported. Sprockets uses a controller to access stylesheets in development mode instead of a full scan for changed files.
25
- 4. `:always_check` - This option is not supported. Sprockets always checks in development.
26
- 5. `:syntax` - This is determined by the file's extensions.
27
- 6. `:filename` - This is determined by the file's name.
28
- 7. `:line` - This is provided by the template handler.
24
+ - `:style` - This option is not supported. This is determined by the Rails environment. It's `:expanded` only on development, otherwise it's `:compressed`.
25
+ - `:never_update` - This option is not supported. Instead set `config.assets.enabled = false`
26
+ - `:always_update` - This option is not supported. Sprockets uses a controller to access stylesheets in development mode instead of a full scan for changed files.
27
+ - `:always_check` - This option is not supported. Sprockets always checks in development.
28
+ - `:syntax` - This is determined by the file's extensions.
29
+ - `:filename` - This is determined by the file's name.
30
+ - `:line` - This is provided by the template handler.
29
31
 
30
32
  ### Example
31
33
 
32
34
  MyProject::Application.configure do
35
+ config.sass.preferred_syntax = :sass
33
36
  config.sass.line_comments = false
34
37
  config.sass.cache = false
35
38
  end
@@ -65,24 +68,24 @@ in Sass):
65
68
  #### `asset-path($relative-asset-path)`
66
69
  Returns a string to the asset.
67
70
 
68
- * `asset-path("rails.png")` becomes `"/assets/rails.png"`
71
+ * `asset-path("rails.png")` returns `"/assets/rails.png"`
69
72
 
70
73
  #### `asset-url($relative-asset-path)`
71
74
  Returns a url reference to the asset.
72
75
 
73
- * `asset-url("rails.png")` becomes `url(/assets/rails.png)`
76
+ * `asset-url("rails.png")` returns `url(/assets/rails.png)`
74
77
 
75
78
  As a convenience, for each of the following asset classes there are
76
79
  corresponding `-path` and `-url` helpers:
77
80
  image, font, video, audio, javascript, stylesheet.
78
81
 
79
- * `image-path("rails.png")` becomes `"/assets/rails.png"`
80
- * `image-url("rails.png")` becomes `url(/assets/rails.png)`
82
+ * `image-path("rails.png")` returns `"/assets/rails.png"`
83
+ * `image-url("rails.png")` returns `url(/assets/rails.png)`
81
84
 
82
85
  #### `asset-data-url($relative-asset-path)`
83
86
  Returns a url reference to the Base64-encoded asset at the specified path.
84
87
 
85
- * `asset-data-url("rails.png")` becomes `url(data:image/png;base64,iVBORw0K...)`
88
+ * `asset-data-url("rails.png")` returns `url(data:image/png;base64,iVBORw0K...)`
86
89
 
87
90
  ## Running Tests
88
91
 
@@ -93,6 +96,6 @@ If you need to test against local gems, use Bundler's gem :path option in the Ge
93
96
 
94
97
  ## Code Status
95
98
 
96
- * [![Travis CI](https://api.travis-ci.org/rails/sass-rails.png)](http://travis-ci.org/rails/sass-rails)
97
- * [![Gem Version](https://badge.fury.io/rb/sass-rails.png)](http://badge.fury.io/rb/sass-rails)
98
- * [![Dependencies](https://gemnasium.com/rails/sass-rails.png)](https://gemnasium.com/rails/sass-rails)
99
+ * [![Travis CI](https://api.travis-ci.org/rails/sass-rails.svg)](http://travis-ci.org/rails/sass-rails)
100
+ * [![Gem Version](https://badge.fury.io/rb/sass-rails.svg)](http://badge.fury.io/rb/sass-rails)
101
+ * [![Dependencies](https://gemnasium.com/rails/sass-rails.svg)](https://gemnasium.com/rails/sass-rails)
@@ -6,7 +6,7 @@ module Sass
6
6
  source_root File.expand_path("../templates", __FILE__)
7
7
 
8
8
  def copy_sass
9
- template "stylesheet.css.sass", File.join('app/assets/stylesheets', class_path, "#{file_name}.css.sass")
9
+ template "stylesheet.sass", File.join('app/assets/stylesheets', class_path, "#{file_name}.sass")
10
10
  end
11
11
  end
12
12
  end
@@ -8,9 +8,8 @@ module Sass
8
8
  dir = ::Rails::Generators::ScaffoldGenerator.source_root
9
9
  file = File.join(dir, "scaffold.css")
10
10
  converted_contents = ::Sass::CSS.new(File.read(file)).render(syntax)
11
- create_file "app/assets/stylesheets/scaffolds.css.#{syntax}", converted_contents
11
+ create_file "app/assets/stylesheets/scaffolds.#{syntax}", converted_contents
12
12
  end
13
13
  end
14
14
  end
15
15
  end
16
-
@@ -6,7 +6,7 @@ module Scss
6
6
  source_root File.expand_path("../templates", __FILE__)
7
7
 
8
8
  def copy_scss
9
- template "stylesheet.css.scss", File.join('app/assets/stylesheets', class_path, "#{file_name}.css.scss")
9
+ template "stylesheet.scss", File.join('app/assets/stylesheets', class_path, "#{file_name}.scss")
10
10
  end
11
11
  end
12
12
  end
@@ -0,0 +1,31 @@
1
+ require 'sass'
2
+
3
+ module Sass
4
+ module Rails
5
+ class CacheStore < ::Sass::CacheStores::Base
6
+ attr_reader :environment
7
+
8
+ def initialize(environment)
9
+ @environment = environment
10
+ end
11
+
12
+ def _store(key, version, sha, contents)
13
+ environment.cache_set("sass/#{key}", {:version => version, :sha => sha, :contents => contents})
14
+ end
15
+
16
+ def _retrieve(key, version, sha)
17
+ if obj = environment.cache_get("sass/#{key}")
18
+ return unless obj[:version] == version
19
+ return unless obj[:sha] == sha
20
+ obj[:contents]
21
+ else
22
+ nil
23
+ end
24
+ end
25
+
26
+ def path_to(key)
27
+ key
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,30 +1,13 @@
1
+ require 'sass'
1
2
  require 'sprockets/sass_functions'
2
- require 'active_support/deprecation'
3
3
 
4
4
  module Sprockets
5
5
  module SassFunctions
6
- if instance_methods.map(&:to_sym).include?(:asset_path)
7
- undef_method :asset_path
8
- end
9
-
10
- def asset_path(path, kind = nil)
11
- ActiveSupport::Deprecation.warn "asset_path with two arguments is deprecated. Use asset_path(#{path}) instead." if kind
12
-
13
- Sass::Script::String.new(sprockets_context.asset_path(path.value), :string)
14
- end
15
-
16
- if instance_methods.map(&:to_sym).include?(:asset_url)
17
- undef_method :asset_url
18
- end
19
-
20
- def asset_url(path, kind = nil)
21
- ActiveSupport::Deprecation.warn "asset_url with two arguments is deprecated. Use asset_url(#{path}) instead." if kind
22
-
23
- Sass::Script::String.new("url(" + sprockets_context.asset_path(path.value) + ")")
24
- end
25
-
6
+ remove_method :asset_data_url if method_defined?(:asset_data_url)
26
7
  def asset_data_url(path)
27
8
  Sass::Script::String.new("url(" + sprockets_context.asset_data_uri(path.value) + ")")
28
9
  end
29
10
  end
30
11
  end
12
+
13
+ ::Sass::Script::Functions.send :include, Sprockets::SassFunctions
@@ -1,104 +1,147 @@
1
+ require 'active_support/deprecation/reporting'
2
+ require 'sass'
1
3
  require 'sprockets/sass_importer'
4
+ require 'tilt'
5
+
6
+ module Sass
7
+ module Rails
8
+ class SassImporter < Sass::Importers::Filesystem
9
+ module Globbing
10
+ GLOB = /(\A|\/)(\*|\*\*\/\*)\z/
11
+
12
+ def find_relative(name, base, options)
13
+ if options[:sprockets] && m = name.match(GLOB)
14
+ path = name.sub(m[0], "")
15
+ base = File.expand_path(path, File.dirname(base))
16
+ glob_imports(base, m[2], options)
17
+ else
18
+ super
19
+ end
20
+ end
2
21
 
3
- module Sprockets
4
- class SassImporter < Sass::Importers::Filesystem
5
- GLOB = /\*|\[.+\]/
6
-
7
- attr_reader :context
8
- private :context
9
-
10
- def extensions
11
- {
12
- 'css' => :scss,
13
- 'css.scss' => :scss,
14
- 'css.sass' => :sass,
15
- 'css.erb' => :scss,
16
- 'scss.erb' => :scss,
17
- 'sass.erb' => :sass,
18
- 'css.scss.erb' => :scss,
19
- 'css.sass.erb' => :sass
20
- }.merge!(super)
21
- end
22
+ def find(name, options)
23
+ # globs must be relative
24
+ return if name =~ GLOB
25
+ super
26
+ end
22
27
 
23
- def find_relative(name, base, options)
24
- if name =~ GLOB
25
- glob_imports(name, Pathname.new(base), options)
26
- else
27
- engine_from_path(name, File.dirname(base), options)
28
+ private
29
+ def glob_imports(base, glob, options)
30
+ contents = ""
31
+ context = options[:sprockets][:context]
32
+ each_globbed_file(base, glob, context) do |filename|
33
+ next if filename == options[:filename]
34
+ contents << "@import #{filename.inspect};\n"
35
+ end
36
+ return nil if contents == ""
37
+ Sass::Engine.new(contents, options.merge(
38
+ :filename => base,
39
+ :importer => self,
40
+ :syntax => :scss
41
+ ))
42
+ end
43
+
44
+ def each_globbed_file(base, glob, context)
45
+ raise ArgumentError unless glob == "*" || glob == "**/*"
46
+
47
+ exts = extensions.keys.map { |ext| Regexp.escape(".#{ext}") }.join("|")
48
+ sass_re = Regexp.compile("(#{exts})$")
49
+
50
+ context.depend_on(base)
51
+
52
+ Dir["#{base}/#{glob}"].sort.each do |path|
53
+ if File.directory?(path)
54
+ context.depend_on(path)
55
+ elsif sass_re =~ path
56
+ yield path
57
+ end
58
+ end
59
+ end
28
60
  end
29
- end
30
61
 
31
- def find(name, options)
32
- if name =~ GLOB
33
- nil # globs must be relative
34
- else
35
- engine_from_path(name, root, options)
36
- end
37
- end
62
+ module ERB
63
+ def extensions
64
+ {
65
+ 'css.erb' => :scss_erb,
66
+ 'scss.erb' => :scss_erb,
67
+ 'sass.erb' => :sass_erb
68
+ }.merge(super)
69
+ end
38
70
 
39
- def each_globbed_file(glob, base_pathname, options)
40
- Dir["#{base_pathname}/#{glob}"].sort.each do |filename|
41
- next if filename == options[:filename]
42
- yield filename if File.directory?(filename) || context.asset_requirable?(filename)
43
- end
44
- end
71
+ def erb_extensions
72
+ {
73
+ :scss_erb => :scss,
74
+ :sass_erb => :sass
75
+ }
76
+ end
45
77
 
46
- def glob_imports(glob, base_pathname, options)
47
- contents = ""
48
- each_globbed_file(glob, base_pathname.dirname, options) do |filename|
49
- if File.directory?(filename)
50
- depend_on(filename)
51
- elsif context.asset_requirable?(filename)
52
- depend_on(filename)
53
- contents << "@import #{Pathname.new(filename).relative_path_from(base_pathname.dirname).to_s.inspect};\n"
78
+ def find_relative(*args)
79
+ process_erb_engine(super)
54
80
  end
55
- end
56
- return nil if contents.empty?
57
- Sass::Engine.new(contents, options.merge(
58
- :filename => base_pathname.to_s,
59
- :importer => self,
60
- :syntax => :scss
61
- ))
62
- end
63
81
 
64
- private
82
+ def find(*args)
83
+ process_erb_engine(super)
84
+ end
65
85
 
66
- def depend_on(filename)
67
- context.depend_on(filename)
68
- context.depend_on(globbed_file_parent(filename))
86
+ private
87
+ def process_erb_engine(engine)
88
+ if engine && engine.options[:sprockets] && syntax = erb_extensions[engine.options[:syntax]]
89
+ template = Tilt::ERBTemplate.new(engine.options[:filename])
90
+ contents = template.render(engine.options[:sprockets][:context], {})
91
+
92
+ Sass::Engine.new(contents, engine.options.merge(:syntax => syntax))
93
+ else
94
+ engine
95
+ end
96
+ end
69
97
  end
70
98
 
71
- def globbed_file_parent(filename)
72
- if File.directory?(filename)
73
- File.expand_path('..', filename)
74
- else
75
- File.dirname(filename)
99
+ module Deprecated
100
+ def extensions
101
+ {
102
+ 'css.scss' => :scss,
103
+ 'css.sass' => :sass,
104
+ 'css.scss.erb' => :scss_erb,
105
+ 'css.sass.erb' => :sass_erb
106
+ }.merge(super)
76
107
  end
77
- end
78
-
79
- def engine_from_path(name, dir, options)
80
- full_filename, syntax = Sass::Util.destructure(find_real_file(dir, name, options))
81
- return unless full_filename && File.readable?(full_filename)
82
108
 
83
- engine = Sass::Engine.new(evaluate(full_filename), options.merge(
84
- syntax: syntax,
85
- filename: full_filename,
86
- importer: self
87
- ))
109
+ def find_relative(*args)
110
+ deprecate_extra_css_extension(super)
111
+ end
88
112
 
89
- if engine && (filename = engine.options[:filename])
90
- @context.depend_on(filename)
113
+ def find(*args)
114
+ deprecate_extra_css_extension(super)
91
115
  end
92
116
 
93
- engine
117
+ private
118
+ def deprecate_extra_css_extension(engine)
119
+ if engine && filename = engine.options[:filename]
120
+ if filename.end_with?('.css.scss')
121
+ msg = "Extra .css in SCSS file is unnecessary. Rename #{filename} to #{filename.sub('.css.scss', '.scss')}."
122
+ elsif filename.end_with?('.css.sass')
123
+ msg = "Extra .css in SASS file is unnecessary. Rename #{filename} to #{filename.sub('.css.sass', '.sass')}."
124
+ elsif filename.end_with?('.css.scss.erb')
125
+ msg = "Extra .css in SCSS/ERB file is unnecessary. Rename #{filename} to #{filename.sub('.css.scss.erb', '.scss.erb')}."
126
+ elsif filename.end_with?('.css.sass.erb')
127
+ msg = "Extra .css in SASS/ERB file is unnecessary. Rename #{filename} to #{filename.sub('.css.sass.erb', '.sass.erb')}."
128
+ end
129
+
130
+ ActiveSupport::Deprecation.warn(msg) if msg
131
+ end
132
+
133
+ engine
134
+ end
94
135
  end
95
136
 
96
- def evaluate(filename)
97
- attributes = context.environment.attributes_for(filename)
98
- processors = context.environment.preprocessors(attributes.content_type) +
99
- attributes.engines.reverse - [Sprockets::ScssTemplate, Sprockets::SassTemplate]
137
+ include Deprecated
138
+ include ERB
139
+ include Globbing
100
140
 
101
- context.evaluate(filename, processors: processors)
141
+ # Allow .css files to be @import'd
142
+ def extensions
143
+ { 'css' => :scss }.merge(super)
102
144
  end
145
+ end
103
146
  end
104
147
  end
@@ -1,3 +1,4 @@
1
+ require 'sass'
1
2
  require 'sass/logger'
2
3
 
3
4
  module Sass
@@ -1,11 +1,9 @@
1
+ require 'sass'
2
+ require 'active_support/core_ext/class/attribute'
1
3
  require 'sprockets/railtie'
2
4
 
3
5
  module Sass::Rails
4
6
  class Railtie < ::Rails::Railtie
5
- module SassContext
6
- attr_accessor :sass_config
7
- end
8
-
9
7
  config.sass = ActiveSupport::OrderedOptions.new
10
8
 
11
9
  # Establish static configuration defaults
@@ -23,11 +21,15 @@ module Sass::Rails
23
21
  config.sass.logger = Sass::Rails::Logger.new
24
22
 
25
23
  # Set the default stylesheet engine
26
- # It can be overridedden by passing:
24
+ # It can be overridden by passing:
27
25
  # --stylesheet_engine=sass
28
26
  # to the rails generate command
29
27
  config.app_generators.stylesheet_engine config.sass.preferred_syntax
30
28
 
29
+ if config.respond_to?(:annotations)
30
+ config.annotations.register_extensions("scss", "sass") { |annotation| /\/\/\s*(#{annotation}):?\s*(.*)$/ }
31
+ end
32
+
31
33
  # Remove the sass middleware if it gets inadvertently enabled by applications.
32
34
  config.after_initialize do |app|
33
35
  app.config.middleware.delete(Sass::Plugin::Rack) if defined?(Sass::Plugin::Rack)
@@ -51,20 +53,41 @@ module Sass::Rails
51
53
  config.sass.full_exception = app.config.consider_all_requests_local
52
54
  end
53
55
 
54
- if app.assets
55
- app.assets.context_class.extend(SassContext)
56
- app.assets.context_class.sass_config = app.config.sass
56
+ config.assets.configure do |env|
57
+ if env.respond_to?(:register_engine)
58
+ args = ['.sass', Sass::Rails::SassTemplate]
59
+ args << { silence_deprecation: true } if env.method(:register_engine).arity.abs > 2
60
+ env.register_engine(*args)
61
+
62
+ args = ['.scss', Sass::Rails::ScssTemplate]
63
+ args << { silence_deprecation: true } if env.method(:register_engine).arity.abs > 2
64
+ env.register_engine(*args)
65
+ end
66
+
67
+ if env.respond_to?(:register_transformer)
68
+ env.register_transformer 'text/sass', 'text/css',
69
+ Sprockets::SassProcessor.new(importer: SassImporter, sass_config: app.config.sass)
70
+ env.register_transformer 'text/scss', 'text/css',
71
+ Sprockets::ScssProcessor.new(importer: SassImporter, sass_config: app.config.sass)
72
+ end
73
+
74
+ env.context_class.class_eval do
75
+ class_attribute :sass_config
76
+ self.sass_config = app.config.sass
77
+ end
57
78
  end
58
79
 
59
80
  Sass.logger = app.config.sass.logger
60
81
  end
61
82
 
62
83
  initializer :setup_compression, group: :all do |app|
63
- unless Rails.env.development?
64
- app.config.assets.css_compressor ||= :sass
65
- else
84
+ if Rails.env.development?
66
85
  # Use expanded output instead of the sass default of :nested unless specified
67
86
  app.config.sass.style ||= :expanded
87
+ else
88
+ # config.assets.css_compressor may be set to nil in non-dev environments.
89
+ # otherwise, the default is sass compression.
90
+ app.config.assets.css_compressor = :sass unless app.config.assets.has_key?(:css_compressor)
68
91
  end
69
92
  end
70
93
  end