dassets-sass 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.
- data/Gemfile +0 -1
- data/README.md +15 -7
- data/dassets-sass.gemspec +2 -1
- data/lib/dassets-sass.rb +9 -1
- data/lib/dassets-sass/version.rb +1 -1
- data/test/helper.rb +0 -3
- data/test/unit/engine_tests.rb +45 -4
- metadata +18 -29
- data/test/support/app/assets/from_sass.sass +0 -2
- data/test/support/app/assets/from_scss.scss +0 -7
- data/test/support/config/assets.rb +0 -11
- data/test/support/public/from_sass-7173fff1fe11e06f1339beceaf4a9857.css +0 -2
- data/test/support/public/from_scss-ffcdabded94a78022e9c92e06e311f69.css +0 -4
- data/test/system/digest_tests.rb +0 -52
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Dassets::Sass
|
|
2
2
|
|
|
3
3
|
Dassets [engine](https://github.com/redding/dassets#compiling) for compiling [Sass](http://sass-lang.com/) css sources.
|
|
4
4
|
|
|
@@ -12,18 +12,26 @@ require 'dassets'
|
|
|
12
12
|
require 'dassets-sass'
|
|
13
13
|
|
|
14
14
|
Dassets.configure do |c|
|
|
15
|
-
c.root_path '/some/root/path'
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
c.source "/path/to/assets") do |s|
|
|
17
|
+
# register for `scss` syntax
|
|
18
|
+
s.engine 'scss', Dassets::Sass::Engine, :syntax => 'scss'
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
# register for `sass` syntax
|
|
21
|
+
s.engine 'sass', Dassets::Sass::Engine, :syntax => 'sass'
|
|
22
|
+
|
|
23
|
+
# by default `/path/to/assets` is in the load paths, but
|
|
24
|
+
# you can specify additional custom load paths to use with `@import`s
|
|
25
|
+
s.engine 'scss', Dassets::Sass::Engine, {
|
|
26
|
+
:syntax => 'scss',
|
|
27
|
+
:load_paths => ['/custom/load/path']
|
|
28
|
+
}
|
|
29
|
+
end
|
|
22
30
|
|
|
23
31
|
end
|
|
24
32
|
```
|
|
25
33
|
|
|
26
|
-
Put your `.scss` and `.sass` source files in your source path
|
|
34
|
+
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.
|
|
27
35
|
|
|
28
36
|
## Installation
|
|
29
37
|
|
data/dassets-sass.gemspec
CHANGED
|
@@ -11,13 +11,14 @@ Gem::Specification.new do |gem|
|
|
|
11
11
|
gem.description = %q{Dassets engine for compiling Sass}
|
|
12
12
|
gem.summary = %q{Dassets engine for compiling Sass}
|
|
13
13
|
gem.homepage = "http://github.com/redding/dassets-sass"
|
|
14
|
+
gem.license = 'MIT'
|
|
14
15
|
|
|
15
16
|
gem.files = `git ls-files`.split($/)
|
|
16
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
17
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
18
19
|
gem.require_paths = ["lib"]
|
|
19
20
|
|
|
20
|
-
gem.add_development_dependency("assert")
|
|
21
|
+
gem.add_development_dependency("assert", ["~> 2.12"])
|
|
21
22
|
|
|
22
23
|
# lock in to Sass 3.1 and up b/c this is earliest version implementing
|
|
23
24
|
# the expected `Sass.compile` api:
|
data/lib/dassets-sass.rb
CHANGED
|
@@ -10,12 +10,20 @@ module Dassets::Sass
|
|
|
10
10
|
(self.opts[:syntax] || self.opts['syntax'] || 'scss').to_s
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
+
def load_paths
|
|
14
|
+
@load_paths ||= ([self.opts['source_path']] +
|
|
15
|
+
[*(self.opts[:load_paths] || self.opts['load_paths'] || [])])
|
|
16
|
+
end
|
|
17
|
+
|
|
13
18
|
def ext(input_ext)
|
|
14
19
|
'css'
|
|
15
20
|
end
|
|
16
21
|
|
|
17
22
|
def compile(input_content)
|
|
18
|
-
::Sass.compile(input_content,
|
|
23
|
+
::Sass.compile(input_content, {
|
|
24
|
+
:syntax => self.syntax.to_sym,
|
|
25
|
+
:load_paths => self.load_paths
|
|
26
|
+
})
|
|
19
27
|
end
|
|
20
28
|
|
|
21
29
|
end
|
data/lib/dassets-sass/version.rb
CHANGED
data/test/helper.rb
CHANGED
|
@@ -8,9 +8,6 @@ $LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
|
|
|
8
8
|
require 'pry'
|
|
9
9
|
|
|
10
10
|
ENV['DASSETS_TEST_MODE'] = 'yes'
|
|
11
|
-
ENV['DASSETS_ASSETS_FILE'] = 'test/support/config/assets'
|
|
12
|
-
require 'dassets'
|
|
13
|
-
Dassets.init
|
|
14
11
|
|
|
15
12
|
require 'test/support/factory'
|
|
16
13
|
class Assert::Context
|
data/test/unit/engine_tests.rb
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
require 'assert'
|
|
2
|
-
require 'dassets/engine'
|
|
3
2
|
require 'dassets-sass'
|
|
4
3
|
|
|
4
|
+
require 'dassets/engine'
|
|
5
|
+
|
|
5
6
|
class Dassets::Sass::Engine
|
|
6
7
|
|
|
7
|
-
class
|
|
8
|
-
desc "
|
|
8
|
+
class UnitTests < Assert::Context
|
|
9
|
+
desc "Dassets::Sass::Engine"
|
|
9
10
|
setup do
|
|
11
|
+
@lp1 = '/a-load-path-1'
|
|
12
|
+
@lp2 = '/a-load-path-2'
|
|
10
13
|
@engine = Dassets::Sass::Engine.new
|
|
11
14
|
end
|
|
12
15
|
subject{ @engine }
|
|
13
16
|
|
|
14
|
-
should
|
|
17
|
+
should have_imeths :syntax, :load_paths
|
|
15
18
|
|
|
16
19
|
should "be a Dassets engine" do
|
|
17
20
|
assert_kind_of Dassets::Engine, subject
|
|
@@ -27,6 +30,25 @@ class Dassets::Sass::Engine
|
|
|
27
30
|
assert_equal 'sass', Dassets::Sass::Engine.new(:syntax => 'sass').syntax
|
|
28
31
|
end
|
|
29
32
|
|
|
33
|
+
should "default the load paths to be just the source path" do
|
|
34
|
+
assert_equal [subject.opts['source_path']], subject.load_paths
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
should "allow specifying custom load paths, always including the source path" do
|
|
38
|
+
engine = Dassets::Sass::Engine.new(:load_paths => @lp1)
|
|
39
|
+
assert_includes @lp1, engine.load_paths
|
|
40
|
+
assert_includes subject.opts['source_path'], engine.load_paths
|
|
41
|
+
|
|
42
|
+
engine = Dassets::Sass::Engine.new('load_paths' => [@lp1])
|
|
43
|
+
assert_includes @lp1, engine.load_paths
|
|
44
|
+
assert_includes subject.opts['source_path'], engine.load_paths
|
|
45
|
+
|
|
46
|
+
engine = Dassets::Sass::Engine.new('load_paths' => [@lp1, @lp2])
|
|
47
|
+
assert_includes @lp1, engine.load_paths
|
|
48
|
+
assert_includes @lp2, engine.load_paths
|
|
49
|
+
assert_includes subject.opts['source_path'], engine.load_paths
|
|
50
|
+
end
|
|
51
|
+
|
|
30
52
|
should "transform any input extension to `css`" do
|
|
31
53
|
assert_equal 'css', subject.ext('scss')
|
|
32
54
|
assert_equal 'css', subject.ext('sass')
|
|
@@ -34,6 +56,25 @@ class Dassets::Sass::Engine
|
|
|
34
56
|
assert_equal 'css', subject.ext('whatever')
|
|
35
57
|
end
|
|
36
58
|
|
|
59
|
+
should "use its syntax and load paths when compiling" do
|
|
60
|
+
compiled_with_options = false
|
|
61
|
+
input = @factory.sass
|
|
62
|
+
syntax = :sass
|
|
63
|
+
sass_engine = Dassets::Sass::Engine.new({
|
|
64
|
+
:syntax => syntax,
|
|
65
|
+
:load_paths => [@lp1]
|
|
66
|
+
})
|
|
67
|
+
load_paths = sass_engine.load_paths
|
|
68
|
+
|
|
69
|
+
Assert.stub(::Sass, :compile).with(input, {
|
|
70
|
+
:syntax => syntax,
|
|
71
|
+
:load_paths => load_paths
|
|
72
|
+
}){ compiled_with_options = true }
|
|
73
|
+
|
|
74
|
+
sass_engine.compile(input)
|
|
75
|
+
assert_true compiled_with_options
|
|
76
|
+
end
|
|
77
|
+
|
|
37
78
|
should "compile any input content as Sass css" do
|
|
38
79
|
assert_equal @factory.scss_compiled, subject.compile(@factory.scss)
|
|
39
80
|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dassets-sass
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 23
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
|
-
-
|
|
8
|
+
- 2
|
|
9
9
|
- 0
|
|
10
|
-
version: 0.
|
|
10
|
+
version: 0.2.0
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Kelly Redding
|
|
@@ -16,25 +16,24 @@ autorequire:
|
|
|
16
16
|
bindir: bin
|
|
17
17
|
cert_chain: []
|
|
18
18
|
|
|
19
|
-
date:
|
|
19
|
+
date: 2014-08-03 00:00:00 Z
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|
|
22
|
-
name: assert
|
|
23
|
-
prerelease: false
|
|
24
22
|
requirement: &id001 !ruby/object:Gem::Requirement
|
|
25
23
|
none: false
|
|
26
24
|
requirements:
|
|
27
|
-
- -
|
|
25
|
+
- - ~>
|
|
28
26
|
- !ruby/object:Gem::Version
|
|
29
|
-
hash:
|
|
27
|
+
hash: 27
|
|
30
28
|
segments:
|
|
31
|
-
-
|
|
32
|
-
|
|
29
|
+
- 2
|
|
30
|
+
- 12
|
|
31
|
+
version: "2.12"
|
|
33
32
|
type: :development
|
|
33
|
+
name: assert
|
|
34
34
|
version_requirements: *id001
|
|
35
|
-
- !ruby/object:Gem::Dependency
|
|
36
|
-
name: sass
|
|
37
35
|
prerelease: false
|
|
36
|
+
- !ruby/object:Gem::Dependency
|
|
38
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
|
39
38
|
none: false
|
|
40
39
|
requirements:
|
|
@@ -46,10 +45,10 @@ dependencies:
|
|
|
46
45
|
- 1
|
|
47
46
|
version: "3.1"
|
|
48
47
|
type: :runtime
|
|
48
|
+
name: sass
|
|
49
49
|
version_requirements: *id002
|
|
50
|
-
- !ruby/object:Gem::Dependency
|
|
51
|
-
name: dassets
|
|
52
50
|
prerelease: false
|
|
51
|
+
- !ruby/object:Gem::Dependency
|
|
53
52
|
requirement: &id003 !ruby/object:Gem::Requirement
|
|
54
53
|
none: false
|
|
55
54
|
requirements:
|
|
@@ -60,7 +59,9 @@ dependencies:
|
|
|
60
59
|
- 0
|
|
61
60
|
version: "0"
|
|
62
61
|
type: :runtime
|
|
62
|
+
name: dassets
|
|
63
63
|
version_requirements: *id003
|
|
64
|
+
prerelease: false
|
|
64
65
|
description: Dassets engine for compiling Sass
|
|
65
66
|
email:
|
|
66
67
|
- kelly@kellyredding.com
|
|
@@ -82,18 +83,12 @@ files:
|
|
|
82
83
|
- lib/dassets-sass/version.rb
|
|
83
84
|
- log/.gitkeep
|
|
84
85
|
- test/helper.rb
|
|
85
|
-
- test/support/app/assets/from_sass.sass
|
|
86
|
-
- test/support/app/assets/from_scss.scss
|
|
87
|
-
- test/support/config/assets.rb
|
|
88
86
|
- test/support/factory.rb
|
|
89
|
-
- test/support/public/from_sass-7173fff1fe11e06f1339beceaf4a9857.css
|
|
90
|
-
- test/support/public/from_scss-ffcdabded94a78022e9c92e06e311f69.css
|
|
91
|
-
- test/system/digest_tests.rb
|
|
92
87
|
- test/unit/engine_tests.rb
|
|
93
88
|
- tmp/.gitkeep
|
|
94
89
|
homepage: http://github.com/redding/dassets-sass
|
|
95
|
-
licenses:
|
|
96
|
-
|
|
90
|
+
licenses:
|
|
91
|
+
- MIT
|
|
97
92
|
post_install_message:
|
|
98
93
|
rdoc_options: []
|
|
99
94
|
|
|
@@ -120,17 +115,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
120
115
|
requirements: []
|
|
121
116
|
|
|
122
117
|
rubyforge_project:
|
|
123
|
-
rubygems_version: 1.8.
|
|
118
|
+
rubygems_version: 1.8.25
|
|
124
119
|
signing_key:
|
|
125
120
|
specification_version: 3
|
|
126
121
|
summary: Dassets engine for compiling Sass
|
|
127
122
|
test_files:
|
|
128
123
|
- test/helper.rb
|
|
129
|
-
- test/support/app/assets/from_sass.sass
|
|
130
|
-
- test/support/app/assets/from_scss.scss
|
|
131
|
-
- test/support/config/assets.rb
|
|
132
124
|
- test/support/factory.rb
|
|
133
|
-
- test/support/public/from_sass-7173fff1fe11e06f1339beceaf4a9857.css
|
|
134
|
-
- test/support/public/from_scss-ffcdabded94a78022e9c92e06e311f69.css
|
|
135
|
-
- test/system/digest_tests.rb
|
|
136
125
|
- test/unit/engine_tests.rb
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
require 'dassets'
|
|
2
|
-
require 'dassets-sass'
|
|
3
|
-
|
|
4
|
-
Dassets.configure do |c|
|
|
5
|
-
c.root_path File.expand_path("../..", __FILE__)
|
|
6
|
-
c.engine 'scss', Dassets::Sass::Engine, :syntax => 'scss'
|
|
7
|
-
c.engine 'sass', Dassets::Sass::Engine, :syntax => 'sass'
|
|
8
|
-
c.cache = nil
|
|
9
|
-
c.file_store 'public'
|
|
10
|
-
|
|
11
|
-
end
|
data/test/system/digest_tests.rb
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
require 'assert'
|
|
2
|
-
require 'fileutils'
|
|
3
|
-
require 'dassets'
|
|
4
|
-
require 'dassets-sass'
|
|
5
|
-
|
|
6
|
-
module Dassets::Sass
|
|
7
|
-
|
|
8
|
-
class DigestScssTests < Assert::Context
|
|
9
|
-
desc "digesting a scss source file with the sass engine registered"
|
|
10
|
-
setup do
|
|
11
|
-
@source_file = File.join(Dassets.config.source_path, "from_scss.scss")
|
|
12
|
-
File.open(@source_file, 'w'){ |f| f.write(@factory.scss) }
|
|
13
|
-
@compiled_file = File.join(Dassets.config.root_path, "public/from_scss-ffcdabded94a78022e9c92e06e311f69.css")
|
|
14
|
-
@exp_compiled_content = @factory.scss_compiled
|
|
15
|
-
|
|
16
|
-
FileUtils.rm_f @compiled_file
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
should "produce a css file with the source scss compiled to css" do
|
|
20
|
-
assert_file_exists @source_file
|
|
21
|
-
assert_not_file_exists @compiled_file
|
|
22
|
-
Dassets.digest_source_files
|
|
23
|
-
|
|
24
|
-
assert_file_exists @compiled_file
|
|
25
|
-
assert_equal @exp_compiled_content, File.read(@compiled_file)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
class DigestSassTests < Assert::Context
|
|
31
|
-
desc "digesting a sass source file with the sass engine registered"
|
|
32
|
-
setup do
|
|
33
|
-
@source_file = File.join(Dassets.config.source_path, "from_sass.sass")
|
|
34
|
-
File.open(@source_file, 'w'){ |f| f.write(@factory.sass) }
|
|
35
|
-
@compiled_file = File.join(Dassets.config.root_path, "public/from_sass-7173fff1fe11e06f1339beceaf4a9857.css")
|
|
36
|
-
@exp_compiled_content = @factory.sass_compiled
|
|
37
|
-
|
|
38
|
-
FileUtils.rm_f @compiled_file
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
should "produce a css file with the source sass compiled to css" do
|
|
42
|
-
assert_file_exists @source_file
|
|
43
|
-
assert_not_file_exists @compiled_file
|
|
44
|
-
Dassets.digest_source_files
|
|
45
|
-
|
|
46
|
-
assert_file_exists @compiled_file
|
|
47
|
-
assert_equal @exp_compiled_content, File.read(@compiled_file)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
end
|