sprockets-sass 1.3.1 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.reek +12 -0
  3. data/.rubocop.yml +77 -0
  4. data/.travis.yml +16 -0
  5. data/Appraisals +32 -15
  6. data/Gemfile +5 -0
  7. data/README.md +41 -4
  8. data/Rakefile +15 -3
  9. data/gemfiles/compass_0.11.gemfile +1 -1
  10. data/gemfiles/sass_3.1.gemfile +1 -1
  11. data/gemfiles/sass_3.3.gemfile +8 -0
  12. data/gemfiles/sass_3.4.gemfile +8 -0
  13. data/gemfiles/sprockets_2.10.gemfile +1 -1
  14. data/gemfiles/sprockets_2.11.gemfile +1 -1
  15. data/gemfiles/sprockets_2.2.gemfile +1 -1
  16. data/gemfiles/sprockets_2.3.gemfile +1 -1
  17. data/gemfiles/sprockets_2.4.gemfile +1 -1
  18. data/gemfiles/sprockets_2.5.gemfile +1 -1
  19. data/gemfiles/sprockets_2.6.gemfile +1 -1
  20. data/gemfiles/sprockets_2.7.gemfile +1 -1
  21. data/gemfiles/sprockets_2.8.gemfile +1 -1
  22. data/gemfiles/sprockets_2.9.gemfile +1 -1
  23. data/gemfiles/sprockets_3.7.gemfile +9 -0
  24. data/gemfiles/sprockets_4.0.gemfile +10 -0
  25. data/gemfiles/sprockets_4.0_beta2.gemfile +9 -0
  26. data/lib/sprockets-sass.rb +1 -0
  27. data/lib/sprockets/sass.rb +37 -12
  28. data/lib/sprockets/sass/functions.rb +24 -159
  29. data/lib/sprockets/sass/registration.rb +126 -0
  30. data/lib/sprockets/sass/utils.rb +115 -0
  31. data/lib/sprockets/sass/v2/cache_store.rb +26 -0
  32. data/lib/sprockets/sass/v2/compressor.rb +31 -0
  33. data/lib/sprockets/sass/v2/functions.rb +142 -0
  34. data/lib/sprockets/sass/v2/importer.rb +209 -0
  35. data/lib/sprockets/sass/v2/sass_template.rb +221 -0
  36. data/lib/sprockets/sass/v2/scss_template.rb +14 -0
  37. data/lib/sprockets/sass/v3/cache_store.rb +28 -0
  38. data/lib/sprockets/sass/v3/compressor.rb +97 -0
  39. data/lib/sprockets/sass/v3/functions.rb +12 -0
  40. data/lib/sprockets/sass/v3/importer.rb +212 -0
  41. data/lib/sprockets/sass/v3/sass_template.rb +37 -0
  42. data/lib/sprockets/sass/v3/scss_template.rb +15 -0
  43. data/lib/sprockets/sass/v4/cache_store.rb +11 -0
  44. data/lib/sprockets/sass/v4/compressor.rb +11 -0
  45. data/lib/sprockets/sass/v4/functions.rb +12 -0
  46. data/lib/sprockets/sass/v4/importer.rb +105 -0
  47. data/lib/sprockets/sass/v4/sass_template.rb +27 -0
  48. data/lib/sprockets/sass/v4/scss_template.rb +16 -0
  49. data/lib/sprockets/sass/version.rb +2 -1
  50. data/spec/custom_importer_spec.rb +4 -6
  51. data/spec/spec_helper.rb +30 -3
  52. data/spec/sprockets-sass_spec.rb +101 -61
  53. data/spec/support/be_fresh_matcher.rb +10 -6
  54. data/spec/support/dummy_importer.rb +1 -1
  55. data/spec/support/fail_postprocessor.rb +23 -0
  56. data/spec/support/sass_template.rb +11 -0
  57. data/sprockets-sass.gemspec +27 -8
  58. metadata +92 -95
  59. data/gemfiles/compass_0.12.gemfile +0 -7
  60. data/gemfiles/sass_3.2.gemfile +0 -7
  61. data/gemfiles/sprockets_2.0.gemfile +0 -7
  62. data/gemfiles/sprockets_2.1.gemfile +0 -9
  63. data/lib/sprockets/sass/cache_store.rb +0 -27
  64. data/lib/sprockets/sass/compressor.rb +0 -22
  65. data/lib/sprockets/sass/importer.rb +0 -142
  66. data/lib/sprockets/sass/sass_template.rb +0 -115
  67. data/lib/sprockets/sass/scss_template.rb +0 -12
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9af094799e7e501a8bd0e4d69f7a7fd79e2f3056
4
+ data.tar.gz: d889b5fba8d6296978821c0c12aa8b063f8a4324
5
+ SHA512:
6
+ metadata.gz: 759bf41724fa6f5a2cafe99eb39ce7f0f15a820dce7cf1979589ecf13c93e245597a9c93cbb98602beba937da69463bed6441ef7eec20d0a70dce4e46ed0fd86
7
+ data.tar.gz: 63fa7d50c5350bfd57ce0e0c2fdba2cf902632a767ed950a541e71ee7c82249abee870d7fe7a94a0724bd11608cf7be4ea30f87ac5e38ec875bb9045c186cf64
data/.reek ADDED
@@ -0,0 +1,12 @@
1
+ ---
2
+ Attribute:
3
+ enabled: false
4
+ TooManyInstanceVariables:
5
+ enabled: false
6
+ TooManyMethods:
7
+ enabled: false
8
+ UtilityFunction:
9
+ enabled: false
10
+ exclude_paths:
11
+ - examples
12
+ - spec
@@ -0,0 +1,77 @@
1
+ AllCops:
2
+ Exclude:
3
+ - sprockets-sass.gemspec
4
+ - lib/sprockets/sass.rb
5
+ - bin/**/*
6
+ - Guardfile
7
+ - vendor/**/**
8
+ - spec/**/*
9
+ - Gemfile
10
+ - Rakefile
11
+
12
+ TargetRubyVersion: 2.3
13
+
14
+ ClassLength:
15
+ Max: 500
16
+
17
+ Documentation:
18
+ Enabled: true
19
+
20
+ Encoding:
21
+ Enabled: false
22
+
23
+ LineLength:
24
+ Max: 200
25
+
26
+ AccessModifierIndentation:
27
+ EnforcedStyle: outdent
28
+
29
+ IfUnlessModifier:
30
+ Enabled: false
31
+
32
+ CaseIndentation:
33
+ IndentWhenRelativeTo: case
34
+ IndentOneStep: true
35
+
36
+ MethodLength:
37
+ CountComments: false
38
+ Max: 20
39
+
40
+ SignalException:
41
+ Enabled: false
42
+
43
+ ColonMethodCall:
44
+ Enabled: false
45
+
46
+ AsciiComments:
47
+ Enabled: false
48
+
49
+ RegexpLiteral:
50
+ Enabled: false
51
+
52
+ AssignmentInCondition:
53
+ Enabled: false
54
+
55
+ ParameterLists:
56
+ CountKeywordArgs: false
57
+
58
+ SingleLineBlockParams:
59
+ Methods:
60
+ - reduce:
61
+ - memo
62
+ - item
63
+
64
+ Metrics/AbcSize:
65
+ Enabled: false
66
+
67
+ Style/CollectionMethods:
68
+ Enabled: true
69
+
70
+ Style/SymbolArray:
71
+ Enabled: true
72
+
73
+ Style/ExtraSpacing:
74
+ Enabled: true
75
+
76
+ Style/FileName:
77
+ Enabled: false
@@ -0,0 +1,16 @@
1
+ sudo: false
2
+ cache: bundler
3
+ language: ruby
4
+ before_install:
5
+ - "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
6
+ - gem install bundler
7
+ rvm:
8
+ - 2.0.0
9
+ - 2.1.5
10
+ - 2.2.2
11
+ - 2.2.3
12
+ - 2.3.1
13
+ env:
14
+ - RAILS_ENV=test RACK_ENV=test
15
+ notifications:
16
+ email: false
data/Appraisals CHANGED
@@ -1,18 +1,3 @@
1
- appraise 'sass_3.1' do
2
- gem 'sass', '~> 3.1.0'
3
- gem 'compass', '~> 0.12.0'
4
- end
5
-
6
- appraise 'compass_0.11' do
7
- gem 'sass', '~> 3.2.0'
8
- gem 'compass', '~> 0.11.0'
9
- end
10
-
11
- appraise 'sprockets_2.1' do
12
- gem 'sprockets', '~> 2.1.0'
13
- gem 'sass', '~> 3.2.0'
14
- gem 'compass', '~> 0.12.0'
15
- end
16
1
 
17
2
  appraise 'sprockets_2.2' do
18
3
  gem 'sprockets', '~> 2.2.0'
@@ -73,3 +58,35 @@ appraise 'sprockets_2.11' do
73
58
  gem 'sass', '~> 3.2.0'
74
59
  gem 'compass', '~> 0.12.0'
75
60
  end
61
+
62
+ appraise 'sprockets_3.7' do
63
+ gem 'sprockets', '~> 3.7.0'
64
+ gem 'sass', '~> 3.4.0'
65
+ gem 'compass', '~> 1.0.0'
66
+ end
67
+
68
+ appraise 'sass_3.1' do
69
+ gem 'sass', '~> 3.1.0'
70
+ gem 'compass', '~> 0.12.0'
71
+ end
72
+
73
+ appraise 'sass_3.3' do
74
+ gem 'sass', '~> 3.3.0'
75
+ gem 'compass', '~> 1.0.0'
76
+ end
77
+
78
+ appraise 'sass_3.4' do
79
+ gem 'sass', '~> 3.4.0'
80
+ gem 'compass', '~> 1.0.0'
81
+ end
82
+
83
+ appraise 'compass_0.11' do
84
+ gem 'sass', '~> 3.2.0'
85
+ gem 'compass', '~> 0.11.0'
86
+ end
87
+
88
+ # appraise 'sprockets_4.0_beta2' do
89
+ # gem 'sprockets', '4.0.0.beta2'
90
+ # gem 'sass', '~> 3.4.0'
91
+ # gem 'compass', '~> 1.0.0'
92
+ # end
data/Gemfile CHANGED
@@ -1,2 +1,7 @@
1
1
  source 'https://rubygems.org'
2
+
2
3
  gemspec
4
+
5
+ if RUBY_VERSION < "2.2.0"
6
+ gem 'rack', '>= 1.0', '< 2.0'
7
+ end
data/README.md CHANGED
@@ -1,15 +1,17 @@
1
1
  sprockets-sass
2
2
  ==============
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/sprockets-sass.svg)](https://badge.fury.io/rb/sprockets-sass) [![Build Status](https://travis-ci.org/petebrowne/sprockets-sass.svg?branch=master)](https://travis-ci.org/petebrowne/sprockets-sass)
5
+
4
6
  **Better Sass integration with [Sprockets 2.x](http://github.com/sstephenson/sprockets)**
5
7
 
6
8
  When using Sprockets 2.x with Sass you will eventually run into a pretty big issue. `//= require` directives will not allow Sass mixins, variables, etc. to be shared between files. So you'll try to use `@import`, and that'll also blow up in your face. `sprockets-sass` fixes all of this by creating a Sass::Importer that is Sprockets aware.
7
9
 
8
- _Note: This works in Rails 3.1, thanks to the [sass-rails gem](http://github.com/rails/sass-rails). But if you want to use Sprockets and Sass anywhere else, like Sinatra, use `sprockets-sass`._
10
+ **Note: This works in Rails 3.1, thanks to the [sass-rails gem](http://github.com/rails/sass-rails). But if you want to use Sprockets and Sass anywhere else, like Sinatra, use `sprockets-sass`**
9
11
 
10
12
  ### Features
11
13
 
12
- * Imports Sass _partials_ (filenames prepended with "_").
14
+ * Imports Sass ```_partials_``` (filenames prepended with ```_```).
13
15
  * Import paths work exactly like `require` directives.
14
16
  * Imports either Sass syntax, or just regular CSS files.
15
17
  * Imported files are preprocessed by Sprockets, so `.css.scss.erb` files can be imported.
@@ -48,6 +50,24 @@ map "/" do
48
50
  end
49
51
  ```
50
52
 
53
+ Sprockets Sass provides also a compressor for ```.css``` files
54
+
55
+ You can use it with Sprockets 2.x by doing this:
56
+
57
+ ```ruby
58
+ environment = Sprockets::Environment.new
59
+ environment.css_compressor = Sprockets::Sass::V2::Compressor
60
+ ```
61
+
62
+ Or with Sprockets 3.x by doing this:
63
+
64
+ ```ruby
65
+ environment = Sprockets::Environment.new
66
+ environment.css_compressor = :sprockets_sass
67
+ ```
68
+
69
+ Or with Rails by setting ```css_compressor``` in the ```config/application.rb``` file to one of the values listed above depending on your version of Sprockets
70
+
51
71
  Now `@import` works essentially just like a `require` directive, but with one essential bonus:
52
72
  Sass mixins, variables, etc. work as expected.
53
73
 
@@ -158,13 +178,13 @@ require "sass"
158
178
  map "/assets" do
159
179
  environment = Sprockets::Environment.new
160
180
  environment.append_path "assets/stylesheets"
161
-
181
+
162
182
  Sprockets::Helpers.configure do |config|
163
183
  config.environment = environment
164
184
  config.prefix = "/assets"
165
185
  config.digest = false
166
186
  end
167
-
187
+
168
188
  run environment
169
189
  end
170
190
 
@@ -192,6 +212,23 @@ background: asset-data-uri("image.jpg"); // background: url(data:image/jpeg;base
192
212
  ```
193
213
 
194
214
 
215
+ Development
216
+ -----------
217
+
218
+ Install dependencies using bundler:
219
+
220
+ ``` bash
221
+ bundle install
222
+ ```
223
+
224
+ sprocket-sass is tested against numerous versions of Sass, Compoass, and Sprockets using [appraisal](https://github.com/thoughtbot/appraisal).
225
+ This will install all the gems and run the tests against all versions
226
+ Run tests:
227
+
228
+ ``` bash
229
+ bundle exec rake
230
+ ```
231
+
195
232
  Copyright
196
233
  ---------
197
234
 
data/Rakefile CHANGED
@@ -1,6 +1,18 @@
1
- require 'appraisal'
1
+ require 'bundler/setup'
2
2
  require 'bundler/gem_tasks'
3
+ require 'appraisal'
3
4
  require 'rspec/core/rake_task'
4
5
 
5
- RSpec::Core::RakeTask.new
6
- task :default => :spec
6
+
7
+ RSpec::Core::RakeTask.new(:spec) do |spec|
8
+ spec.rspec_opts = ['--backtrace '] if ENV['DEBUG']
9
+ spec.verbose = true
10
+ end
11
+
12
+ desc 'Default: run the unit tests.'
13
+ task default: [:all]
14
+
15
+ desc 'Test the plugin under all supported versions.'
16
+ task :all do |_t|
17
+ exec('bundle exec appraisal install && bundle exec rake appraisal spec')
18
+ end
@@ -5,4 +5,4 @@ source "https://rubygems.org"
5
5
  gem "sass", "~> 3.2.0"
6
6
  gem "compass", "~> 0.11.0"
7
7
 
8
- gemspec :path=>"../"
8
+ gemspec :path => "../"
@@ -5,4 +5,4 @@ source "https://rubygems.org"
5
5
  gem "sass", "~> 3.1.0"
6
6
  gem "compass", "~> 0.12.0"
7
7
 
8
- gemspec :path=>"../"
8
+ gemspec :path => "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "sass", "~> 3.3.0"
6
+ gem "compass", "~> 1.0.0"
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "sass", "~> 3.4.0"
6
+ gem "compass", "~> 1.0.0"
7
+
8
+ gemspec :path => "../"
@@ -6,4 +6,4 @@ gem "sprockets", "~> 2.9.0"
6
6
  gem "sass", "~> 3.2.0"
7
7
  gem "compass", "~> 0.12.0"
8
8
 
9
- gemspec :path=>"../"
9
+ gemspec :path => "../"
@@ -6,4 +6,4 @@ gem "sprockets", "~> 2.9.0"
6
6
  gem "sass", "~> 3.2.0"
7
7
  gem "compass", "~> 0.12.0"
8
8
 
9
- gemspec :path=>"../"
9
+ gemspec :path => "../"
@@ -6,4 +6,4 @@ gem "sprockets", "~> 2.2.0"
6
6
  gem "sass", "~> 3.2.0"
7
7
  gem "compass", "~> 0.12.0"
8
8
 
9
- gemspec :path=>"../"
9
+ gemspec :path => "../"
@@ -6,4 +6,4 @@ gem "sprockets", "~> 2.3.0"
6
6
  gem "sass", "~> 3.2.0"
7
7
  gem "compass", "~> 0.12.0"
8
8
 
9
- gemspec :path=>"../"
9
+ gemspec :path => "../"
@@ -6,4 +6,4 @@ gem "sprockets", "~> 2.4.0"
6
6
  gem "sass", "~> 3.2.0"
7
7
  gem "compass", "~> 0.12.0"
8
8
 
9
- gemspec :path=>"../"
9
+ gemspec :path => "../"
@@ -6,4 +6,4 @@ gem "sprockets", "~> 2.5.0"
6
6
  gem "sass", "~> 3.2.0"
7
7
  gem "compass", "~> 0.12.0"
8
8
 
9
- gemspec :path=>"../"
9
+ gemspec :path => "../"
@@ -6,4 +6,4 @@ gem "sprockets", "~> 2.6.0"
6
6
  gem "sass", "~> 3.2.0"
7
7
  gem "compass", "~> 0.12.0"
8
8
 
9
- gemspec :path=>"../"
9
+ gemspec :path => "../"
@@ -6,4 +6,4 @@ gem "sprockets", "~> 2.7.0"
6
6
  gem "sass", "~> 3.2.0"
7
7
  gem "compass", "~> 0.12.0"
8
8
 
9
- gemspec :path=>"../"
9
+ gemspec :path => "../"
@@ -6,4 +6,4 @@ gem "sprockets", "~> 2.8.0"
6
6
  gem "sass", "~> 3.2.0"
7
7
  gem "compass", "~> 0.12.0"
8
8
 
9
- gemspec :path=>"../"
9
+ gemspec :path => "../"
@@ -6,4 +6,4 @@ gem "sprockets", "~> 2.9.0"
6
6
  gem "sass", "~> 3.2.0"
7
7
  gem "compass", "~> 0.12.0"
8
8
 
9
- gemspec :path=>"../"
9
+ gemspec :path => "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "sprockets", "~> 3.7.0"
6
+ gem "sass", "~> 3.4.0"
7
+ gem "compass", "~> 1.0.0"
8
+
9
+ gemspec :path => "../"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rack", ">= 1.0", "< 2.0"
6
+ gem "sprockets", "4.0.0.beta2"
7
+ gem "sass", ">= 3.4.0"
8
+ gem "compass", ">= 1.0.0"
9
+
10
+ gemspec :path => "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "sprockets", "4.0.0.beta2"
6
+ gem "sass", "~> 3.4.0"
7
+ gem "compass", "~> 1.0.0"
8
+
9
+ gemspec :path => "../"
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  require 'sprockets/sass'
@@ -1,29 +1,54 @@
1
+ # frozen_string_literal: true
1
2
  require 'sprockets'
2
3
  require 'sprockets/sass/version'
3
- require 'sprockets/sass/sass_template'
4
- require 'sprockets/sass/scss_template'
5
- require 'sprockets/engines'
4
+ require 'sprockets/sass/utils'
5
+ require 'sprockets/sass/registration'
6
+ require 'sass'
7
+ require 'sass/importers/base'
6
8
 
9
+ require 'json'
10
+ require 'pathname'
11
+
12
+
13
+ # the module of Sprockets
7
14
  module Sprockets
15
+ # The internal Sass module used to load and acessing configuration
8
16
  module Sass
9
- autoload :CacheStore, 'sprockets/sass/cache_store'
10
- autoload :Compressor, 'sprockets/sass/compressor'
11
- autoload :Importer, 'sprockets/sass/importer'
12
-
13
17
  class << self
14
18
  # Global configuration for `Sass::Engine` instances.
15
19
  attr_accessor :options
16
-
20
+
17
21
  # When false, the asset path helpers provided by
18
22
  # sprockets-helpers will not be added as Sass functions.
19
23
  # `true` by default.
20
24
  attr_accessor :add_sass_functions
21
25
  end
22
-
26
+
23
27
  @options = {}
24
28
  @add_sass_functions = true
25
29
  end
26
-
27
- register_engine '.sass', Sass::SassTemplate
28
- register_engine '.scss', Sass::ScssTemplate
30
+
31
+ begin
32
+ require 'sprockets/directive_processor'
33
+ require 'sprockets/sass_processor'
34
+ require 'sprockets/sassc_processor'
35
+ require 'sprockets/digest_utils'
36
+ require 'sprockets/engines'
37
+ rescue LoadError; end
38
+
39
+ if Sprockets::Sass::Utils.version_of_sprockets >= 3
40
+ # We need this only for Sprockets > 3 in order to be able to register anything.
41
+ # For Sprockets 2.x , although the file and the module name exist,
42
+ # they can't be used because it will give errors about undefined methods, because this is included only on Sprockets::Base
43
+ # and in order to use them we would have to subclass it and define methods to expire cache and other methods for registration ,
44
+ # which are not needed since Sprockets already knows about that using the environment instead internally
45
+ require 'sprockets/processing'
46
+ extend Sprockets::Processing
47
+ end
48
+
49
+ registration = Sprockets::Sass::Registration.new(self)
50
+ registration.run
29
51
  end
52
+
53
+ # Sprockets 4 needs this , becasue it doesnt use ::Sass in code, which results in a conflict with this gem :(
54
+ Sprockets::Sass::Importers = ::Sass::Importers