sassc-rails 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae97d3f35dca444f3fc0b4ad70778d255877d25d
4
- data.tar.gz: 2dfda9e9b31a9934cad0793cd781573180485fb0
3
+ metadata.gz: 91ada003823fa3206c9bf2087447f97e56d9a17f
4
+ data.tar.gz: ac6573985e2bc5a8edc719d025836cabecbef7da
5
5
  SHA512:
6
- metadata.gz: bc12198915c971167266c0a17dc451698b3a96e1de117c69f924fed2735a8f81ca45366f1e36875c0c30736a5f8eb12a2b60c1dc17d6063a3bfe33e7e3e138f0
7
- data.tar.gz: 5a9895f07a9c5adc4b5662525a8b5fbe226248db004e0b6b8fc14fc9353659eae7939b344012c5a60c41cda1e0d852b581269ec352d9d17e8bdb28cd8408cfa6
6
+ metadata.gz: 088e2bf35e5a1092bbc0e5a443fe11ae6cbf99356922908f82e6b770bff8b398ab306cf8b175e5820e65d5bc3bc4952147b9a9b5db7bb1b054d2ca7b40b3e593
7
+ data.tar.gz: b09954d3ce74ca2d4f4eabad08621b4c8fb506844ac4c6315c53405092a57263faea6be88d802257d0ad9ac6b2600027e951a8f2399495f67659fea8feb2f34e
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  We all love working with Sass, but compilation can take quite a long time for larger
4
4
  codebases. This gem integrates the C implementation of Sass,
5
- [libsass](https://github.com/sass/libsass), into the asset pipeline.
5
+ [LibSass](https://github.com/sass/libsass), into the asset pipeline.
6
6
 
7
7
  In one larger project, this made compilation 4x faster:
8
8
 
@@ -24,10 +24,23 @@ This should essentially be a drop in alternative to [sass-rails](https://github.
24
24
 
25
25
  __Note: This is a new project, please report any issues you come across!__
26
26
 
27
+ ## Inline Source Maps
27
28
 
28
- ## Libsass Compatibility With Ruby Sass
29
+ With SassC-Rails, it's also extremely easy to turn on inline source maps. Simply
30
+ add the following configuration to your development.rb file:
29
31
 
30
- For a look at the compatibility between Ruby Sass and Libsass, check this
32
+ ```ruby
33
+ # config/environments/development.rb
34
+ config.sass.inline_source_maps = true
35
+ ```
36
+
37
+ Note, as indicated, these source maps are *inline*. They will not generate additional
38
+ files or anything like that. Instead, they will be appended to the compiled
39
+ application.css file.
40
+
41
+ ## LibSass Compatibility With Ruby Sass
42
+
43
+ For a look at the compatibility between Ruby Sass and LibSass, check this
31
44
  [compatibility chart](http://sass-compatibility.github.io/) out.
32
45
 
33
46
 
@@ -43,23 +56,30 @@ And then execute:
43
56
 
44
57
  $ bundle
45
58
 
59
+ ## Common Issues
46
60
 
47
- ## Deployment to Heroku
61
+ ### Deployment to Heroku
48
62
 
49
- Due to Libsass compilation requirements, you upgrade to the
63
+ Due to LibSass compilation requirements, you must upgrade to the
50
64
  [Heroku Cedar-14 Stack](https://devcenter.heroku.com/articles/cedar-14-migration)
51
65
  in order to successfully install this gem.
52
66
 
53
67
  Upgrading to Cedar-14 is usually a painless process.
54
68
 
55
69
 
56
- ## Installing alongside a gem that depends on Sass-Rails
70
+ ### Installing alongside a gem that depends on Sass-Rails
57
71
 
58
72
  Libraries explicitly depending on Sass-Rails, such as ActiveAdmin, can cause
59
73
  conflicts with installation of SassC-Rails. While we have no built-in solution
60
74
  for this, please check out [this issue](https://github.com/bolandrm/sassc-rails/issues/6)
61
75
  for a workaround.
62
76
 
77
+ ## Changelog
78
+
79
+ - **1.0.0**
80
+ - Initial Release
81
+ - Add support for inline source maps
82
+ - Support compression in the way that Sass-Rails handles it
63
83
 
64
84
  ## Contributing
65
85
 
@@ -74,4 +94,4 @@ for a workaround.
74
94
  ## Credits
75
95
 
76
96
  This gem is based on [sass-rails](https://github.com/rails/sass-rails), and
77
- is maintained by [Ryan Boland](https://ryanboland.com).
97
+ is maintained by [Ryan Boland](https://ryanboland.com) and [awesome contributors](https://github.com/bolandrm/sassc-rails/graphs/contributors).
data/Rakefile CHANGED
@@ -16,19 +16,17 @@ namespace :tests do
16
16
  ]
17
17
 
18
18
  gemfiles.each do |gemfile|
19
- desc "Run Tests against #{gemfile}"
19
+ desc "Run tests against #{gemfile}"
20
20
  task gemfile do
21
- sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle --quiet"
21
+ sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle install"
22
22
  sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rake test"
23
23
  end
24
24
  end
25
25
 
26
- desc "Run Tests against all ORMs"
26
+ desc "Run tests against all common asset pipeline setups"
27
27
  task :all do
28
28
  gemfiles.each do |gemfile|
29
- puts "Running Tests against #{gemfile}"
30
- sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle --quiet"
31
- sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rake test"
29
+ Rake::Task["tests:#{gemfile}"].invoke
32
30
  end
33
31
  end
34
32
  end
data/lib/sassc/rails.rb CHANGED
@@ -4,4 +4,5 @@ require "sassc"
4
4
  require_relative "rails/functions"
5
5
  require_relative "rails/importer"
6
6
  require_relative "rails/template"
7
+ require_relative "rails/compressor"
7
8
  require_relative "rails/railtie"
@@ -0,0 +1,21 @@
1
+ require 'sprockets/sass_compressor'
2
+
3
+ class Sprockets::SassCompressor
4
+ def call(*args)
5
+ input = if defined?(data)
6
+ data # sprockets 2.x
7
+ else
8
+ args[0][:data] #sprockets 3.x
9
+ end
10
+
11
+ SassC::Engine.new(
12
+ input,
13
+ {
14
+ style: :compressed
15
+ }
16
+ ).render
17
+ end
18
+
19
+ # sprockets 2.x
20
+ alias :evaluate :call
21
+ end
@@ -56,7 +56,7 @@ module SassC::Rails
56
56
  app.config.assets.css_compressor = nil
57
57
 
58
58
  if !Rails.env.development?
59
- app.config.sass.style = :compressed
59
+ app.config.assets.css_compressor ||= :sass
60
60
  else
61
61
  # Use expanded output instead of the sass default of :nested unless specified
62
62
  app.config.sass.style ||= :expanded
@@ -13,13 +13,12 @@ module SassC::Rails
13
13
  syntax: self.class.syntax,
14
14
  load_paths: input[:environment].paths,
15
15
  importer: SassC::Rails::Importer,
16
- style: sass_style,
17
16
  sprockets: {
18
17
  context: context,
19
18
  environment: input[:environment],
20
19
  dependencies: context.metadata[:dependency_paths]
21
20
  }
22
- }
21
+ }.merge(config_options)
23
22
 
24
23
  engine = ::SassC::Engine.new(input[:data], options)
25
24
 
@@ -44,12 +43,11 @@ module SassC::Rails
44
43
  syntax: syntax,
45
44
  load_paths: context.environment.paths,
46
45
  importer: SassC::Rails::Importer,
47
- style: sass_style,
48
46
  sprockets: {
49
47
  context: context,
50
48
  environment: context.environment
51
49
  }
52
- }
50
+ }.merge(config_options)
53
51
 
54
52
  ::SassC::Engine.new(data, options).render
55
53
  end
@@ -61,9 +59,23 @@ module SassC::Rails
61
59
  include Sprockets2
62
60
  end
63
61
 
62
+ def config_options
63
+ opts = { style: sass_style }
64
+
65
+
66
+ if Rails.application.config.sass.inline_source_maps
67
+ opts.merge!({
68
+ source_map_file: ".",
69
+ source_map_embed: true,
70
+ source_map_contents: true,
71
+ })
72
+ end
73
+
74
+ opts
75
+ end
76
+
64
77
  def sass_style
65
- style = Rails.application.config.sass.style || :expanded
66
- "sass_style_#{style}".to_sym
78
+ (Rails.application.config.sass.style || :expanded).to_sym
67
79
  end
68
80
  end
69
81
 
@@ -1,5 +1,5 @@
1
1
  module SassC
2
2
  module Rails
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
data/sassc-rails.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  # unfortunately we require sass for now, so that we can
27
27
  # reuse portions of the sprockets template
28
28
  spec.add_dependency 'sass'
29
- spec.add_dependency "sassc", "~> 1.2.0"
29
+ spec.add_dependency "sassc", "~> 1.5"
30
30
 
31
31
  spec.add_dependency "tilt"
32
32
 
@@ -155,17 +155,12 @@ class SassRailsTest < MiniTest::Unit::TestCase
155
155
  assert_equal :expanded, Rails.application.config.sass.style
156
156
  end
157
157
 
158
- def test_style_config_item_is_honored_in_development_mode
158
+ def test_style_config_item_is_honored
159
159
  @app.config.sass.style = :nested
160
- initialize_dev!
160
+ initialize!
161
161
  assert_equal :nested, Rails.application.config.sass.style
162
162
  end
163
163
 
164
- def test_style_config_item_is_not_honored_if_environment_is_not_development
165
- initialize_prod!
166
- assert_equal :compressed, Rails.application.config.sass.style
167
- end
168
-
169
164
  def test_context_is_being_passed_to_erb_render
170
165
  initialize!
171
166
 
@@ -178,6 +173,37 @@ class SassRailsTest < MiniTest::Unit::TestCase
178
173
  css_output = render_asset("special_characters.scss")
179
174
  end
180
175
 
176
+ def css_compressor_config_item_is_not_honored_in_development_mode
177
+ @app.config.assets.css_compressor = :test
178
+ initialize_dev!
179
+ assert_equal nil, Rails.application.config.assets.css_compressor
180
+ end
181
+
182
+ def css_compressor_config_item_is_honored_if_not_development_mode
183
+ @app.config.assets.css_compressor = :test
184
+ initialize_prod!
185
+ assert_equal :test, Rails.application.config.assets.css_compressor
186
+ end
187
+
188
+ def css_compressor_is_defined_in_test_mode
189
+ initialize_test!
190
+ assert_equal :sass, Rails.application.config.assets.css_compressor
191
+ end
192
+
193
+ def css_compressor_is_defined_in_prod_mode
194
+ initialize_prod!
195
+ assert_equal :sass, Rails.application.config.assets.css_compressor
196
+ end
197
+
198
+ def test_compression_works
199
+ initialize_prod!
200
+
201
+ asset = render_asset("application.scss")
202
+ assert_equal <<-CSS, asset
203
+ .hello{color:#FFF}
204
+ CSS
205
+ end
206
+
181
207
  def test_compression_works
182
208
  initialize_prod!
183
209
 
@@ -187,6 +213,24 @@ class SassRailsTest < MiniTest::Unit::TestCase
187
213
  CSS
188
214
  end
189
215
 
216
+ def test_sassc_compression_is_used
217
+ initialize_prod!
218
+
219
+ engine = stub(render: "")
220
+ SassC::Engine.expects(:new).returns(engine)
221
+ SassC::Engine.expects(:new).with("", {style: :compressed}).returns(engine)
222
+ render_asset("application.scss")
223
+ end
224
+
225
+ def test_allows_for_inclusion_of_inline_source_maps
226
+ @app.config.sass.inline_source_maps = true
227
+ initialize_dev!
228
+
229
+ asset = render_asset("application.scss")
230
+ assert_match /.hello/, asset
231
+ assert_match /sourceMappingURL/, asset
232
+ end
233
+
190
234
  #test 'sprockets require works correctly' do
191
235
  # skip
192
236
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sassc-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Boland
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-18 00:00:00.000000000 Z
11
+ date: 2015-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.2.0
89
+ version: '1.5'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.2.0
96
+ version: '1.5'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: tilt
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -157,6 +157,7 @@ files:
157
157
  - gemfiles/with_sass_rails.gemfile
158
158
  - lib/sassc-rails.rb
159
159
  - lib/sassc/rails.rb
160
+ - lib/sassc/rails/compressor.rb
160
161
  - lib/sassc/rails/functions.rb
161
162
  - lib/sassc/rails/importer.rb
162
163
  - lib/sassc/rails/railtie.rb