dassets-sass 0.4.0 → 0.5.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
- ---
2
- SHA512:
3
- metadata.gz: eed07b819b6b06f2cb946c8e41fe006d4d09d85c67974d35b11780846b8a8aaca037d9be39626a7e69979979d7677b963b868329c92ab2a6c8d39a1546837417
4
- data.tar.gz: 7bca7355569611069937a91a793a37afb6e520f12df66456da7bb5fb6876e5bad0ad2477e768dc14a3ff4a7d6b0461a3e53dc66cb2001070af375faf16ba80e5
5
- SHA1:
6
- metadata.gz: 1a1f2f5905e4dc17308a01d4669c0bcde43d319c
7
- data.tar.gz: 6dd04ce3f788d66c2b77f09af0a05d2eafb157b5
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 87e5179a5ba5324b0d396486a71a18ef2549c07193fb5ccb7e0dd47e07d52e20
4
+ data.tar.gz: 8ff71e0add60a6286491548cf865727c2e05d69e47bc7d9942bb49f92e504296
5
+ SHA512:
6
+ metadata.gz: 3e0824979a50693cb2b867d140beac07af99a7b92871a913ebdeb9a7e18f2861d76aba7f403b073930591f2f3cc412734fee9d87fce71bc13e472bef4df26ff2
7
+ data.tar.gz: ceb6041fb7261c8033ce4f198137dd4bee3fbb76e80101303784c5156281e232e5d3e6b6144c8f1c0efd3562254202d3c8d341ec94839ceec9fa68baa2f060ef
data/Gemfile CHANGED
@@ -1,9 +1,7 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gemspec
3
+ ruby "~> 2.5"
4
4
 
5
- gem 'pry', "~> 0.9.0"
5
+ gemspec
6
6
 
7
- # lock in sass to 3.4.21 as 3.5+ will no longer support ruby 1.8.7
8
- # also 3.4.22 adds a huge deprecation warning that we don't care about
9
- gem 'sass', "= 3.4.21"
7
+ gem "pry", "~> 0.12.2"
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Dassets::Sass
2
2
 
3
- Dassets [engine](https://github.com/redding/dassets#compiling) for compiling [Sass](http://sass-lang.com/) css sources.
3
+ Dassets [engine](https://github.com/redding/dassets#compiling) to compile dynamic asset filtes written with [SASS/SCSS](http://sass-lang.com/) using [libsass](https://github.com/sass/sassc-ruby).
4
4
 
5
5
  ## Usage
6
6
 
@@ -8,43 +8,41 @@ Register the engine:
8
8
 
9
9
  ```ruby
10
10
  # in config/assets.rb
11
- require 'dassets'
12
- require 'dassets-sass'
11
+ require "dassets"
12
+ require "dassets-sass"
13
13
 
14
14
  Dassets.configure do |c|
15
-
16
15
  c.source "/path/to/assets") do |s|
17
16
  # register for `scss` syntax
18
- s.engine 'scss', Dassets::Sass::Engine, :syntax => 'scss'
17
+ s.engine "scss", Dassets::Sass::Engine, syntax: Dassets::Sass::SCSS
19
18
 
20
19
  # register for `sass` syntax
21
- s.engine 'sass', Dassets::Sass::Engine, :syntax => 'sass'
20
+ s.engine "sass", Dassets::Sass::Engine, syntax: Dassets::Sass::SASS
22
21
 
23
- # by default `:nested` output style is used, but you can
22
+ # by default Dassets::Sass::NESTED output style is used, but you can
24
23
  # specify a custom style (http://sass-lang.com/documentation/file.SASS_REFERENCE.html#output_style)
25
- s.engine 'scss', Dassets::Sass::Engine, {
24
+ s.engine "scss", Dassets::Sass::Engine, {
26
25
  ...
27
- :output_style => :compressed
26
+ output_style: Dassets::Sass::COMPRESSED
28
27
  }
29
28
 
30
- # by default `/path/to/assets` is in the load paths, but
29
+ # by default `/path/to/assets` is in the load path, but
31
30
  # you can specify additional custom load paths to use with `@import`s
32
- s.engine 'scss', Dassets::Sass::Engine, {
31
+ s.engine "scss", Dassets::Sass::Engine, {
33
32
  ...
34
- :load_paths => ['/custom/load/path']
33
+ load_paths: ["/custom/load/path"]
35
34
  }
36
35
  end
37
-
38
36
  end
39
37
  ```
40
38
 
41
- Put your `.scss` and `.sass` source files in your source path. Dassets will compile their content using Sass, switch their extension to `.css`, and write the output to the output path.
39
+ Put your `.scss` and `.sass` source files in your source path. Dassets will compile their content using Sass, switch their extension to `.css`, and write the output to the output path.
42
40
 
43
41
  ## Installation
44
42
 
45
43
  Add this line to your application's Gemfile:
46
44
 
47
- gem 'dassets-sass'
45
+ gem "dassets-sass"
48
46
 
49
47
  And then execute:
50
48
 
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require "dassets-sass/version"
5
5
 
@@ -11,19 +11,15 @@ Gem::Specification.new do |gem|
11
11
  gem.summary = %q{Dassets engine for compiling Sass}
12
12
  gem.description = %q{Dassets engine for compiling Sass}
13
13
  gem.homepage = "http://github.com/redding/dassets-sass"
14
- gem.license = 'MIT'
14
+ gem.license = "MIT"
15
15
 
16
16
  gem.files = `git ls-files`.split($/)
17
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.add_development_dependency("assert", ["~> 2.16.1"])
22
-
23
- # lock in to Sass 3.1 and up b/c this is earliest version implementing
24
- # the expected `Sass.compile` api:
25
- # https://github.com/nex3/sass/commit/332dd6945a8acd660719e0ea4eb48ae3a3ef9b38
26
- gem.add_dependency("sass", ["~> 3.1"])
27
- gem.add_dependency("dassets", ["~> 0.14.0"])
21
+ gem.add_development_dependency("assert", ["~> 2.19.0"])
28
22
 
23
+ gem.add_dependency("dassets", ["~> 0.15.0"])
24
+ gem.add_dependency("sassc", ["~> 2.0"])
29
25
  end
@@ -1,36 +1,72 @@
1
- require 'sass'
2
- require 'dassets/engine'
1
+ # frozen_string_literal: true
2
+
3
+ require "sassc"
4
+ require "dassets/engine"
3
5
  require "dassets-sass/version"
4
6
 
5
7
  module Dassets::Sass
8
+ def self.SASS
9
+ "sass"
10
+ end
11
+
12
+ def self.SCSS
13
+ "scss"
14
+ end
6
15
 
7
- class Engine < Dassets::Engine
16
+ def self.NESTED
17
+ "nested"
18
+ end
19
+
20
+ def self.EXPANDED
21
+ "expanded"
22
+ end
8
23
 
9
- def syntax
10
- (self.opts[:syntax] || self.opts['syntax'] || 'scss').to_s
11
- end
24
+ def self.COMPACT
25
+ "compact"
26
+ end
12
27
 
13
- def output_style
14
- (self.opts[:output_style] || self.opts['output_style'] || 'nested').to_s
15
- end
28
+ def self.COMPRESSED
29
+ "compressed"
30
+ end
31
+ end
16
32
 
17
- def load_paths
18
- @load_paths ||= ([self.opts['source_path']] +
19
- [*(self.opts[:load_paths] || self.opts['load_paths'] || [])])
20
- end
33
+ class Dassets::Sass::Engine < Dassets::Engine
34
+ def syntax
35
+ (
36
+ self.opts[:syntax] ||
37
+ self.opts["syntax"] ||
38
+ Dassets::Sass.SCSS
39
+ ).to_s
40
+ end
21
41
 
22
- def ext(input_ext)
23
- 'css'
24
- end
42
+ def output_style
43
+ (
44
+ self.opts[:output_style] ||
45
+ self.opts["output_style"] ||
46
+ Dassets::Sass.NESTED
47
+ ).to_s
48
+ end
25
49
 
26
- def compile(input_content)
27
- ::Sass.compile(input_content, {
28
- :syntax => self.syntax.to_sym,
29
- :style => self.output_style.to_sym,
30
- :load_paths => self.load_paths
31
- })
32
- end
50
+ def load_paths
51
+ @load_paths ||=
52
+ (
53
+ [self.opts["source_path"]] +
54
+ [*(self.opts[:load_paths] || self.opts["load_paths"] || [])]
55
+ )
56
+ end
33
57
 
58
+ def ext(input_ext)
59
+ "css"
34
60
  end
35
61
 
62
+ def compile(input_content)
63
+ SassC::Engine
64
+ .new(
65
+ input_content,
66
+ syntax: self.syntax.to_sym,
67
+ style: self.output_style.to_sym,
68
+ load_paths: self.load_paths,
69
+ )
70
+ .render
71
+ end
36
72
  end
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dassets; end
2
4
  module Dassets::Sass
3
- VERSION = "0.4.0"
5
+ VERSION = "0.5.0"
4
6
  end
@@ -5,21 +5,12 @@
5
5
  $LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
6
6
 
7
7
  # require pry for debugging (`binding.pry`)
8
- require 'pry'
8
+ require "pry"
9
9
 
10
- require 'test/support/factory'
10
+ require "test/support/factory"
11
11
 
12
12
  class Assert::Context
13
13
  setup{ @factory = Factory }
14
14
  end
15
15
 
16
- # 1.8.7 backfills
17
-
18
- # Array#sample
19
- if !(a = Array.new).respond_to?(:sample) && a.respond_to?(:choice)
20
- class Array
21
- alias_method :sample, :choice
22
- end
23
- end
24
-
25
- ENV['DASSETS_TEST_MODE'] = 'yes'
16
+ ENV["DASSETS_TEST_MODE"] = "yes"
@@ -1,4 +1,4 @@
1
- require 'assert/factory'
1
+ require "assert/factory"
2
2
 
3
3
  module Factory
4
4
  extend Assert::Factory
File without changes
@@ -0,0 +1,118 @@
1
+ require "assert"
2
+ require "dassets-sass"
3
+
4
+ require "dassets/engine"
5
+ require "sassc"
6
+
7
+ module Dassets::Sass
8
+ class UnitTests < Assert::Context
9
+ desc "Dassets::Sass"
10
+ subject { unit_class }
11
+
12
+ let(:unit_class) { Dassets::Sass }
13
+
14
+ should "know its CONSTANTS" do
15
+ assert_that(unit_class.SASS).equals("sass")
16
+ assert_that(unit_class.SCSS).equals("scss")
17
+ assert_that(unit_class.NESTED).equals("nested")
18
+ assert_that(unit_class.EXPANDED).equals("expanded")
19
+ assert_that(unit_class.COMPACT).equals("compact")
20
+ assert_that(unit_class.COMPRESSED).equals("compressed")
21
+ end
22
+ end
23
+
24
+ class EngineTests < UnitTests
25
+ desc "Engine"
26
+ subject { engine_class }
27
+
28
+ let(:engine_class) { unit_class::Engine }
29
+ end
30
+
31
+ class EngineInitTests < EngineTests
32
+ desc "when init"
33
+ subject { engine_class.new }
34
+
35
+ setup do
36
+ @lp1 = "/a-load-path-1"
37
+ @lp2 = "/a-load-path-2"
38
+ end
39
+
40
+ should have_imeths :syntax, :output_style, :load_paths
41
+
42
+ should "be a Dassets engine" do
43
+ assert_that(subject).is_kind_of(Dassets::Engine)
44
+ assert_that(subject).responds_to("ext")
45
+ assert_that(subject).responds_to("compile")
46
+ end
47
+
48
+ should "default its settings" do
49
+ assert_that(subject.syntax).equals(Dassets::Sass.SCSS)
50
+ assert_that(subject.output_style).equals(Dassets::Sass.NESTED)
51
+ assert_that(subject.load_paths).equals([subject.opts["source_path"]])
52
+ end
53
+
54
+ should "allow specifying a custom settings" do
55
+ engine =
56
+ engine_class.new(
57
+ syntax: Dassets::Sass.SASS,
58
+ output_style: Dassets::Sass.COMPRESSED,
59
+ )
60
+ assert_that(engine.syntax).equals(Dassets::Sass.SASS)
61
+ assert_that(engine.output_style).equals(Dassets::Sass.COMPRESSED)
62
+ end
63
+
64
+ should "allow specifying custom load paths, always including the source path" do
65
+ engine = engine_class.new(load_paths: @lp1)
66
+ assert_that(engine.load_paths).includes(@lp1)
67
+ assert_that(engine.load_paths).includes(subject.opts["source_path"])
68
+
69
+ engine = engine_class.new("load_paths" => [@lp1])
70
+ assert_that(engine.load_paths).includes(@lp1)
71
+ assert_that(engine.load_paths).includes(subject.opts["source_path"])
72
+
73
+ engine = engine_class.new("load_paths" => [@lp1, @lp2])
74
+ assert_that(engine.load_paths).includes(@lp1)
75
+ assert_that(engine.load_paths).includes(@lp2)
76
+ assert_that(engine.load_paths).includes(subject.opts["source_path"])
77
+ end
78
+
79
+ should "transform any input extension to `css`" do
80
+ assert_that(subject.ext("scss")).equals("css")
81
+ assert_that(subject.ext("sass")).equals("css")
82
+ assert_that(subject.ext("sassycss")).equals("css")
83
+ assert_that(subject.ext("whatever")).equals("css")
84
+ end
85
+
86
+ should "use its syntax, output style and load paths when compiling" do
87
+ load_paths = [@lp1]
88
+ sass_engine =
89
+ engine_class.new(
90
+ syntax: Dassets::Sass.SASS,
91
+ output_style: Dassets::Sass.COMPRESSED,
92
+ load_paths: load_paths,
93
+ )
94
+
95
+ render_spy =
96
+ Assert.stub_spy(::SassC::Engine, :new, render: "rendered output")
97
+
98
+ input = @factory.sass
99
+ output = sass_engine.compile(input)
100
+
101
+ assert_that(output).equals("rendered output")
102
+ assert_that(render_spy.new_called_with.pargs).equals([input])
103
+ assert_that(render_spy.new_called_with.kargs)
104
+ .equals(
105
+ syntax: Dassets::Sass.SASS.to_sym,
106
+ style: Dassets::Sass.COMPRESSED.to_sym,
107
+ load_paths: ([sass_engine.opts["source_path"]] + load_paths),
108
+ )
109
+ end
110
+
111
+ should "compile any input content as Sass CSS" do
112
+ assert_equal @factory.scss_compiled, subject.compile(@factory.scss)
113
+
114
+ sass_engine = engine_class.new(syntax: Dassets::Sass.SASS)
115
+ assert_equal @factory.sass_compiled, sass_engine.compile(@factory.sass)
116
+ end
117
+ end
118
+ end
metadata CHANGED
@@ -1,59 +1,67 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: dassets-sass
3
- version: !ruby/object:Gem::Version
4
- version: 0.4.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Kelly Redding
8
8
  - Collin Redding
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2016-06-14 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2020-12-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: assert
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
19
- requirements:
20
- - - ~>
21
- - !ruby/object:Gem::Version
22
- version: 2.16.1
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 2.19.0
23
21
  type: :development
24
- version_requirements: *id001
25
- - !ruby/object:Gem::Dependency
26
- name: sass
27
22
  prerelease: false
28
- requirement: &id002 !ruby/object:Gem::Requirement
29
- requirements:
30
- - - ~>
31
- - !ruby/object:Gem::Version
32
- version: "3.1"
33
- type: :runtime
34
- version_requirements: *id002
35
- - !ruby/object:Gem::Dependency
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 2.19.0
28
+ - !ruby/object:Gem::Dependency
36
29
  name: dassets
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 0.15.0
35
+ type: :runtime
37
36
  prerelease: false
38
- requirement: &id003 !ruby/object:Gem::Requirement
39
- requirements:
40
- - - ~>
41
- - !ruby/object:Gem::Version
42
- version: 0.14.0
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 0.15.0
42
+ - !ruby/object:Gem::Dependency
43
+ name: sassc
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '2.0'
43
49
  type: :runtime
44
- version_requirements: *id003
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '2.0'
45
56
  description: Dassets engine for compiling Sass
46
- email:
57
+ email:
47
58
  - kelly@kellyredding.com
48
59
  - collin.redding@me.com
49
60
  executables: []
50
-
51
61
  extensions: []
52
-
53
62
  extra_rdoc_files: []
54
-
55
- files:
56
- - .gitignore
63
+ files:
64
+ - ".gitignore"
57
65
  - Gemfile
58
66
  - LICENSE
59
67
  - README.md
@@ -63,35 +71,34 @@ files:
63
71
  - log/.gitkeep
64
72
  - test/helper.rb
65
73
  - test/support/factory.rb
66
- - test/unit/engine_tests.rb
74
+ - test/system/.keep
75
+ - test/unit/dassets-sass_tests.rb
67
76
  - tmp/.gitkeep
68
77
  homepage: http://github.com/redding/dassets-sass
69
- licenses:
78
+ licenses:
70
79
  - MIT
71
80
  metadata: {}
72
-
73
81
  post_install_message:
74
82
  rdoc_options: []
75
-
76
- require_paths:
83
+ require_paths:
77
84
  - lib
78
- required_ruby_version: !ruby/object:Gem::Requirement
79
- requirements:
80
- - &id004
81
- - ">="
82
- - !ruby/object:Gem::Version
83
- version: "0"
84
- required_rubygems_version: !ruby/object:Gem::Requirement
85
- requirements:
86
- - *id004
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
87
95
  requirements: []
88
-
89
- rubyforge_project:
90
- rubygems_version: 2.6.4
96
+ rubygems_version: 3.1.2
91
97
  signing_key:
92
98
  specification_version: 4
93
99
  summary: Dassets engine for compiling Sass
94
- test_files:
100
+ test_files:
95
101
  - test/helper.rb
96
102
  - test/support/factory.rb
97
- - test/unit/engine_tests.rb
103
+ - test/system/.keep
104
+ - test/unit/dassets-sass_tests.rb
@@ -1,100 +0,0 @@
1
- require 'assert'
2
- require 'dassets-sass'
3
-
4
- require 'dassets/engine'
5
-
6
- class Dassets::Sass::Engine
7
-
8
- class UnitTests < Assert::Context
9
- desc "Dassets::Sass::Engine"
10
- setup do
11
- @lp1 = '/a-load-path-1'
12
- @lp2 = '/a-load-path-2'
13
- @engine = Dassets::Sass::Engine.new
14
- end
15
- subject{ @engine }
16
-
17
- should have_imeths :syntax, :output_style, :load_paths
18
-
19
- should "be a Dassets engine" do
20
- assert_kind_of Dassets::Engine, subject
21
- assert_respond_to 'ext', subject
22
- assert_respond_to 'compile', subject
23
- end
24
-
25
- should "default the syntax to `scss`" do
26
- assert_equal 'scss', subject.syntax
27
- end
28
-
29
- should "allow specifying a custom syntax value" do
30
- engine = Dassets::Sass::Engine.new(:syntax => 'sass')
31
- assert_equal 'sass', engine.syntax
32
- end
33
-
34
- should "default the output style to `nested`" do
35
- assert_equal 'nested', subject.output_style
36
- end
37
-
38
- should "allow specifying a custom output style value" do
39
- engine = Dassets::Sass::Engine.new(:output_style => 'compressed')
40
- assert_equal 'compressed', engine.output_style
41
- end
42
-
43
- should "default the load paths to be just the source path" do
44
- assert_equal [subject.opts['source_path']], subject.load_paths
45
- end
46
-
47
- should "allow specifying custom load paths, always including the source path" do
48
- engine = Dassets::Sass::Engine.new(:load_paths => @lp1)
49
- assert_includes @lp1, engine.load_paths
50
- assert_includes subject.opts['source_path'], engine.load_paths
51
-
52
- engine = Dassets::Sass::Engine.new('load_paths' => [@lp1])
53
- assert_includes @lp1, engine.load_paths
54
- assert_includes subject.opts['source_path'], engine.load_paths
55
-
56
- engine = Dassets::Sass::Engine.new('load_paths' => [@lp1, @lp2])
57
- assert_includes @lp1, engine.load_paths
58
- assert_includes @lp2, engine.load_paths
59
- assert_includes subject.opts['source_path'], engine.load_paths
60
- end
61
-
62
- should "transform any input extension to `css`" do
63
- assert_equal 'css', subject.ext('scss')
64
- assert_equal 'css', subject.ext('sass')
65
- assert_equal 'css', subject.ext('sassycss')
66
- assert_equal 'css', subject.ext('whatever')
67
- end
68
-
69
- should "use its syntax, output style and load paths when compiling" do
70
- compiled_with_options = false
71
- input = @factory.sass
72
- syntax = :sass
73
- output_style = :compressed
74
- sass_engine = Dassets::Sass::Engine.new({
75
- :syntax => syntax,
76
- :output_style => output_style,
77
- :load_paths => [@lp1]
78
- })
79
- load_paths = sass_engine.load_paths
80
-
81
- Assert.stub(::Sass, :compile).with(input, {
82
- :syntax => syntax,
83
- :style => output_style,
84
- :load_paths => load_paths
85
- }){ compiled_with_options = true }
86
-
87
- sass_engine.compile(input)
88
- assert_true compiled_with_options
89
- end
90
-
91
- should "compile any input content as Sass css" do
92
- assert_equal @factory.scss_compiled, subject.compile(@factory.scss)
93
-
94
- sass_engine = Dassets::Sass::Engine.new :syntax => 'sass'
95
- assert_equal @factory.sass_compiled, sass_engine.compile(@factory.sass)
96
- end
97
-
98
- end
99
-
100
- end