dassets-sass 0.1.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/.gitignore +19 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +48 -0
- data/Rakefile +1 -0
- data/dassets-sass.gemspec +28 -0
- data/lib/dassets-sass.rb +23 -0
- data/lib/dassets-sass/version.rb +4 -0
- data/log/.gitkeep +0 -0
- data/test/helper.rb +18 -0
- data/test/support/app/assets/from_sass.sass +2 -0
- data/test/support/app/assets/from_scss.scss +7 -0
- data/test/support/config/assets.rb +11 -0
- data/test/support/factory.rb +37 -0
- data/test/support/public/from_sass-7173fff1fe11e06f1339beceaf4a9857.css +2 -0
- data/test/support/public/from_scss-ffcdabded94a78022e9c92e06e311f69.css +4 -0
- data/test/system/digest_tests.rb +52 -0
- data/test/unit/engine_tests.rb +46 -0
- metadata +136 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013-Present Kelly Redding and Collin Redding
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# DassetsSass
|
2
|
+
|
3
|
+
Dassets [engine](https://github.com/redding/dassets#compiling) for compiling [Sass](http://sass-lang.com/) css sources.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Register the engine:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
# in config/assets.rb
|
11
|
+
require 'dassets'
|
12
|
+
require 'dassets-sass'
|
13
|
+
|
14
|
+
Dassets.configure do |c|
|
15
|
+
c.root_path '/some/root/path'
|
16
|
+
|
17
|
+
# register for `scss` syntax
|
18
|
+
c.engine 'scss', Dassets::Sass::Engine, :syntax => 'scss'
|
19
|
+
|
20
|
+
# register for `sass` syntax
|
21
|
+
c.engine 'sass', Dassets::Sass::Engine, :syntax => 'sass'
|
22
|
+
|
23
|
+
end
|
24
|
+
```
|
25
|
+
|
26
|
+
Put your `.scss` and `.sass` source files in your source path and digest them. Dassets will compile their content using Sass, switch their extension to `.css`, and write the output to the output path.
|
27
|
+
|
28
|
+
## Installation
|
29
|
+
|
30
|
+
Add this line to your application's Gemfile:
|
31
|
+
|
32
|
+
gem 'dassets-sass'
|
33
|
+
|
34
|
+
And then execute:
|
35
|
+
|
36
|
+
$ bundle
|
37
|
+
|
38
|
+
Or install it yourself as:
|
39
|
+
|
40
|
+
$ gem install dassets-sass
|
41
|
+
|
42
|
+
## Contributing
|
43
|
+
|
44
|
+
1. Fork it
|
45
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
46
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
47
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
48
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "dassets-sass/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "dassets-sass"
|
8
|
+
gem.version = Dassets::Sass::VERSION
|
9
|
+
gem.authors = ["Kelly Redding", "Collin Redding"]
|
10
|
+
gem.email = ["kelly@kellyredding.com", "collin.redding@me.com"]
|
11
|
+
gem.description = %q{Dassets engine for compiling Sass}
|
12
|
+
gem.summary = %q{Dassets engine for compiling Sass}
|
13
|
+
gem.homepage = "http://github.com/redding/dassets-sass"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_development_dependency("assert")
|
21
|
+
|
22
|
+
# lock in to Sass 3.1 and up b/c this is earliest version implementing
|
23
|
+
# the expected `Sass.compile` api:
|
24
|
+
# https://github.com/nex3/sass/commit/332dd6945a8acd660719e0ea4eb48ae3a3ef9b38
|
25
|
+
gem.add_dependency("sass", ["~> 3.1"])
|
26
|
+
gem.add_dependency("dassets")
|
27
|
+
|
28
|
+
end
|
data/lib/dassets-sass.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'sass'
|
2
|
+
require 'dassets/engine'
|
3
|
+
require "dassets-sass/version"
|
4
|
+
|
5
|
+
module Dassets::Sass
|
6
|
+
|
7
|
+
class Engine < Dassets::Engine
|
8
|
+
|
9
|
+
def syntax
|
10
|
+
(self.opts[:syntax] || self.opts['syntax'] || 'scss').to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
def ext(input_ext)
|
14
|
+
'css'
|
15
|
+
end
|
16
|
+
|
17
|
+
def compile(input_content)
|
18
|
+
::Sass.compile(input_content, :syntax => self.syntax.to_sym)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/log/.gitkeep
ADDED
File without changes
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# this file is automatically required when you run `assert`
|
2
|
+
# put any test helpers here
|
3
|
+
|
4
|
+
# add the root dir to the load path
|
5
|
+
$LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
|
6
|
+
|
7
|
+
# require pry for debugging (`binding.pry`)
|
8
|
+
require 'pry'
|
9
|
+
|
10
|
+
ENV['DASSETS_TEST_MODE'] = 'yes'
|
11
|
+
ENV['DASSETS_ASSETS_FILE'] = 'test/support/config/assets'
|
12
|
+
require 'dassets'
|
13
|
+
Dassets.init
|
14
|
+
|
15
|
+
require 'test/support/factory'
|
16
|
+
class Assert::Context
|
17
|
+
setup{ @factory = Dassets::Sass::Factory }
|
18
|
+
end
|
@@ -0,0 +1,11 @@
|
|
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
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Dassets::Sass
|
2
|
+
|
3
|
+
module Factory
|
4
|
+
module_function
|
5
|
+
|
6
|
+
def scss
|
7
|
+
"$blue: #3bbfce;\n"\
|
8
|
+
"$margin: 16px;\n"\
|
9
|
+
".border {\n"\
|
10
|
+
" padding: $margin / 2;\n"\
|
11
|
+
" margin: $margin / 2;\n"\
|
12
|
+
" border-color: $blue;\n"\
|
13
|
+
"}\n"
|
14
|
+
end
|
15
|
+
|
16
|
+
def scss_compiled
|
17
|
+
".border {\n"\
|
18
|
+
" padding: 8px;\n"\
|
19
|
+
" margin: 8px;\n"\
|
20
|
+
" border-color: #3bbfce; "\
|
21
|
+
"}\n"
|
22
|
+
end
|
23
|
+
|
24
|
+
def sass
|
25
|
+
"table.hl\n"\
|
26
|
+
" margin: 2em 0\n"\
|
27
|
+
end
|
28
|
+
|
29
|
+
def sass_compiled
|
30
|
+
"table.hl {\n"\
|
31
|
+
" margin: 2em 0; "\
|
32
|
+
"}\n"\
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,52 @@
|
|
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
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'assert'
|
2
|
+
require 'dassets/engine'
|
3
|
+
require 'dassets-sass'
|
4
|
+
|
5
|
+
class Dassets::Sass::Engine
|
6
|
+
|
7
|
+
class BaseTests < Assert::Context
|
8
|
+
desc "the Dassets::Sass engine"
|
9
|
+
setup do
|
10
|
+
@engine = Dassets::Sass::Engine.new
|
11
|
+
end
|
12
|
+
subject{ @engine }
|
13
|
+
|
14
|
+
should have_instance_method :syntax
|
15
|
+
|
16
|
+
should "be a Dassets engine" do
|
17
|
+
assert_kind_of Dassets::Engine, subject
|
18
|
+
assert_respond_to 'ext', subject
|
19
|
+
assert_respond_to 'compile', subject
|
20
|
+
end
|
21
|
+
|
22
|
+
should "default the syntax to `scss`" do
|
23
|
+
assert_equal 'scss', Dassets::Sass::Engine.new.syntax
|
24
|
+
end
|
25
|
+
|
26
|
+
should "allow specifying the engine syntax using engine opts" do
|
27
|
+
assert_equal 'sass', Dassets::Sass::Engine.new(:syntax => 'sass').syntax
|
28
|
+
end
|
29
|
+
|
30
|
+
should "transform any input extension to `css`" do
|
31
|
+
assert_equal 'css', subject.ext('scss')
|
32
|
+
assert_equal 'css', subject.ext('sass')
|
33
|
+
assert_equal 'css', subject.ext('sassycss')
|
34
|
+
assert_equal 'css', subject.ext('whatever')
|
35
|
+
end
|
36
|
+
|
37
|
+
should "compile any input content as Sass css" do
|
38
|
+
assert_equal @factory.scss_compiled, subject.compile(@factory.scss)
|
39
|
+
|
40
|
+
sass_engine = Dassets::Sass::Engine.new :syntax => 'sass'
|
41
|
+
assert_equal @factory.sass_compiled, sass_engine.compile(@factory.sass)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dassets-sass
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Kelly Redding
|
14
|
+
- Collin Redding
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2013-05-01 00:00:00 Z
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: assert
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: sass
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 5
|
44
|
+
segments:
|
45
|
+
- 3
|
46
|
+
- 1
|
47
|
+
version: "3.1"
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: dassets
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
type: :runtime
|
63
|
+
version_requirements: *id003
|
64
|
+
description: Dassets engine for compiling Sass
|
65
|
+
email:
|
66
|
+
- kelly@kellyredding.com
|
67
|
+
- collin.redding@me.com
|
68
|
+
executables: []
|
69
|
+
|
70
|
+
extensions: []
|
71
|
+
|
72
|
+
extra_rdoc_files: []
|
73
|
+
|
74
|
+
files:
|
75
|
+
- .gitignore
|
76
|
+
- Gemfile
|
77
|
+
- LICENSE.txt
|
78
|
+
- README.md
|
79
|
+
- Rakefile
|
80
|
+
- dassets-sass.gemspec
|
81
|
+
- lib/dassets-sass.rb
|
82
|
+
- lib/dassets-sass/version.rb
|
83
|
+
- log/.gitkeep
|
84
|
+
- 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
|
+
- 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
|
+
- test/unit/engine_tests.rb
|
93
|
+
- tmp/.gitkeep
|
94
|
+
homepage: http://github.com/redding/dassets-sass
|
95
|
+
licenses: []
|
96
|
+
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
hash: 3
|
108
|
+
segments:
|
109
|
+
- 0
|
110
|
+
version: "0"
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
hash: 3
|
117
|
+
segments:
|
118
|
+
- 0
|
119
|
+
version: "0"
|
120
|
+
requirements: []
|
121
|
+
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 1.8.24
|
124
|
+
signing_key:
|
125
|
+
specification_version: 3
|
126
|
+
summary: Dassets engine for compiling Sass
|
127
|
+
test_files:
|
128
|
+
- 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
|
+
- 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
|
+
- test/unit/engine_tests.rb
|