roger_sassc 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.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.hound.yml +2 -0
- data/.rubocop.yml +47 -0
- data/.travis.yml +8 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +39 -0
- data/Rakefile +16 -0
- data/lib/roger_sassc.rb +25 -0
- data/lib/roger_sassc/middleware.rb +91 -0
- data/lib/roger_sassc/processor.rb +65 -0
- data/lib/roger_sassc/version.rb +4 -0
- data/roger_sassc.gemspec +29 -0
- data/test/fixtures/errors/syntax.css +15 -0
- data/test/fixtures/errors/syntax.scss +2 -0
- data/test/fixtures/general.scss +7 -0
- data/test/fixtures/output.css +2 -0
- data/test/fixtures/src/_variables.scss +1 -0
- data/test/helpers/fixture_helper.rb +12 -0
- data/test/middleware_test.rb +52 -0
- data/test/processor_test.rb +62 -0
- data/test/roger_sassc_test.rb +39 -0
- data/test/test_helper.rb +18 -0
- metadata +189 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 74af9a2eab61dd1e6d6cd0e664d9f1add0cea02c
|
4
|
+
data.tar.gz: 279f73bb14f17ca137b8e911f20b98a235970522
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 41c887c26b17c9cb2916096152f868f1c64c4f7ab164bdf7faf7372ac7e27856243eb48fbba9445444f9298783b03996b82fa0c53a19de38169762c280752acf
|
7
|
+
data.tar.gz: 521ec4ca5ef968a0c370ff1bbaa24014e0bb8a8422f8f3464b33480f670207ccbace54bc1affe4ec62d95dc85322ba069d9e80b87c30fe01ff82c8d95de655fe
|
data/.gitignore
ADDED
data/.hound.yml
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
LineLength:
|
2
|
+
Description: 'Limit lines to 100 characters.'
|
3
|
+
Max: 100
|
4
|
+
Enabled: true
|
5
|
+
|
6
|
+
StringLiterals:
|
7
|
+
EnforcedStyle: double_quotes
|
8
|
+
Enabled: true
|
9
|
+
|
10
|
+
Style/DotPosition:
|
11
|
+
EnforcedStyle: trailing
|
12
|
+
Enabled: true
|
13
|
+
|
14
|
+
Metrics/MethodLength:
|
15
|
+
CountComments: false # count full line comments?
|
16
|
+
Max: 20
|
17
|
+
|
18
|
+
Metrics/AbcSize:
|
19
|
+
Max: 20
|
20
|
+
|
21
|
+
Style/ClassAndModuleChildren:
|
22
|
+
EnforcedStyle: compact
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
# By default, the rails cops are not run. Override in project or home
|
26
|
+
# directory .rubocop.yml files, or by giving the -R/--rails option.
|
27
|
+
AllCops:
|
28
|
+
RunRailsCops: false
|
29
|
+
|
30
|
+
# Disabled cops
|
31
|
+
Metrics/ClassLength:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
Metrics/ModuleLength:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
Style/EachWithObject:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
Style/AccessorMethodName:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
Lint/AssignmentInCondition:
|
44
|
+
Enabled: false
|
45
|
+
|
46
|
+
Style/SingleLineBlockParams:
|
47
|
+
Enabled: false
|
data/.travis.yml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.0.0
|
4
|
+
- 2.1.0
|
5
|
+
- 2.2.0
|
6
|
+
env:
|
7
|
+
global:
|
8
|
+
secure: YQqXPnIl7q89YU1DGiL8JeVk5gSET4CjbiyQ3uGiMyoPPQW+N95JnBAjUNNr+6hoRIDv+vIxh+qpcm/oPV1yhebx9UWazGYVXRfAzgsgRk1PS9xReSejiQInnvIJhDO6dCfziZI1mpW18XoMi//9FvoHZUyGJry8XEpfTzkcnpf0niagbv+cr4pVjQgTDyEtuhBwkGeQOuhz5CQh2LjlmxOM0/tkNFDKLudZPS0U2RUIfBU5bYgBc0GkAsBoLZRPVlMlGZMV3HfiggdWTdcdRf4PiA0iUujv+d1FXFRA6FBdsFwmayn6fi9+8tOlRbidYoYQaC1wWwHmuAE+DJpa+mxXwzuCoxGZeN3qfSMSlxwGXM+d9QcM6uAAcgt14Dc4OSCalinR8ObPkAy5huylGfdKMdCqJfzbOhaOsAPRhImhXpUg44Odz6Be0MEQxIblloVrMh1f7rqLRz8hGAuRRIWfUmRmgHkJyLF5JUeYQ4CW8xvDSqWJGcZuU/xT08PPHB9u+GE6i9f967CiijyO2VJ9sY8asbbjbtbFkB/fXVDzAryrw83Co6WJy2mdDs98kK/4NcQGvf21Q1eVNaJM+eSAss+rNcpQVPnyh2OlgM7ub5NRXnFBbyusFZPdg72H+XL3ZqSaZAR7e0VS6OG6Th1aNhcYRvOZYj+is3sQMF8=
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Edwin van der Graaf
|
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,39 @@
|
|
1
|
+
# RogerSassc
|
2
|
+
|
3
|
+
Scss with libsass.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'roger_sassc'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install roger_sassc
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Work in progress
|
26
|
+
|
27
|
+
* Fix documentation
|
28
|
+
|
29
|
+
## Notes
|
30
|
+
|
31
|
+
The wrapper around libsass does not support ruby < 2.0.0.
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/digitpaint/roger_sassc/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
require "rubocop/rake_task"
|
4
|
+
|
5
|
+
task default: [:test, :rubocop]
|
6
|
+
|
7
|
+
desc "Run rubocop"
|
8
|
+
task :rubocop do
|
9
|
+
RuboCop::RakeTask.new
|
10
|
+
end
|
11
|
+
|
12
|
+
Rake::TestTask.new do |t|
|
13
|
+
t.libs << "test"
|
14
|
+
t.test_files = FileList["test/*_test.rb"]
|
15
|
+
t.verbose = false
|
16
|
+
end
|
data/lib/roger_sassc.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require "roger_sassc/version"
|
2
|
+
|
3
|
+
# The RogerSassc namespace
|
4
|
+
module RogerSassc
|
5
|
+
DEFAULT_LOAD_PATHS = ["html/stylesheets", "bower_components"]
|
6
|
+
|
7
|
+
class << self
|
8
|
+
attr_accessor :load_paths
|
9
|
+
|
10
|
+
# Add one or more paths to the array,
|
11
|
+
# that will be given to libsass
|
12
|
+
def append_path(*paths)
|
13
|
+
@load_paths.push(*(paths.flatten))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Add some sensible paths, convention over configuration
|
19
|
+
RogerSassc.load_paths = RogerSassc::DEFAULT_LOAD_PATHS.dup
|
20
|
+
|
21
|
+
# Legacy Sass load_paths copy
|
22
|
+
RogerSassc.append_path(Sass.load_paths) if defined?(Sass.load_paths)
|
23
|
+
|
24
|
+
require "roger_sassc/middleware"
|
25
|
+
require "roger_sassc/processor"
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require "sassc"
|
2
|
+
require "roger/resolver"
|
3
|
+
require "rack"
|
4
|
+
|
5
|
+
module RogerSassc
|
6
|
+
# Rack Middleware for Roger Sassc
|
7
|
+
#
|
8
|
+
# This middleware transforms a given url scss -> css. It does this
|
9
|
+
# by checking if the .css can be resolved to .scss file, if so it
|
10
|
+
# compiles (with the help of libsass) the scss.
|
11
|
+
class Middleware
|
12
|
+
attr_writer :resolver
|
13
|
+
|
14
|
+
def initialize(app, options = {})
|
15
|
+
@app = app
|
16
|
+
|
17
|
+
defaults = {
|
18
|
+
load_paths: RogerSassc.load_paths
|
19
|
+
}
|
20
|
+
|
21
|
+
@options = defaults.update(options)
|
22
|
+
end
|
23
|
+
|
24
|
+
def call(env)
|
25
|
+
@project = env["roger.project"]
|
26
|
+
|
27
|
+
url = ::Rack::Utils.unescape(env["PATH_INFO"].to_s).sub(%r{^/}, "")
|
28
|
+
|
29
|
+
# Convert the url to an absolute path,
|
30
|
+
# which is used to retrieve compile the scss
|
31
|
+
if url.end_with?(".css") && scss_path = resolve_url(url)
|
32
|
+
env["rack.errors"].puts "Invoking ruby-sassc for #{scss_path}"
|
33
|
+
|
34
|
+
begin
|
35
|
+
css = compile_scss(scss_path)
|
36
|
+
respond(css)
|
37
|
+
rescue SassC::SyntaxError, SassC::NotRenderedError, SassC::InvalidStyleError => sassc_error
|
38
|
+
respond(debug_css(sassc_error))
|
39
|
+
end
|
40
|
+
else
|
41
|
+
@app.call(env)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def resolve_url(url)
|
48
|
+
# A .css file is requested in the browser
|
49
|
+
url = url[0..-4] + "scss"
|
50
|
+
|
51
|
+
# Use the resolver to translate urls to file paths
|
52
|
+
# returns nill when no file is found via url
|
53
|
+
resolver.url_to_path url, exact_match: true
|
54
|
+
end
|
55
|
+
|
56
|
+
def compile_scss(scss_path)
|
57
|
+
SassC::Engine.new(File.read(scss_path), @options).render
|
58
|
+
end
|
59
|
+
|
60
|
+
def debug_css(sassc_error)
|
61
|
+
# Replace regular line-ends with css compat strings
|
62
|
+
# via: http://stackoverflow.com/questions/9062988/newline-character-sequence-in-css-content-property
|
63
|
+
sassc_error_css_string = sassc_error.to_s.gsub("\n", "\\A")
|
64
|
+
|
65
|
+
# Build debug string
|
66
|
+
debug = "/*\n"
|
67
|
+
debug << "#{sassc_error}\n\n"
|
68
|
+
debug << "Load paths: \n"
|
69
|
+
debug << "#{@options[:load_paths]}\n\n"
|
70
|
+
debug << "*/\n"
|
71
|
+
debug << "body:before {\n"
|
72
|
+
debug << " white-space: pre;\n"
|
73
|
+
debug << " font-family: monospace;\n"
|
74
|
+
debug << " content: '#{sassc_error_css_string}'; }\n"
|
75
|
+
end
|
76
|
+
|
77
|
+
def resolver
|
78
|
+
@resolver ||= Roger::Resolver.new(@project.html_path)
|
79
|
+
end
|
80
|
+
|
81
|
+
def respond(css)
|
82
|
+
resp = ::Rack::Response.new do |res|
|
83
|
+
res.status = 200
|
84
|
+
res.headers["Content-Type"] = "text/css"
|
85
|
+
# last modified header
|
86
|
+
res.write css
|
87
|
+
end
|
88
|
+
resp.finish
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "sassc"
|
2
|
+
require "roger/release"
|
3
|
+
|
4
|
+
require "fileutils"
|
5
|
+
require "pathname"
|
6
|
+
|
7
|
+
module RogerSassc
|
8
|
+
# The Roger Processor for LibSass
|
9
|
+
class Processor < ::Roger::Release::Processors::Base
|
10
|
+
def initialize(options = {})
|
11
|
+
@options = {
|
12
|
+
match: ["stylesheets/**/*.scss"],
|
13
|
+
skip: [%r{/_.*\.scss\Z}],
|
14
|
+
load_paths: RogerSassc.load_paths
|
15
|
+
}.update(options)
|
16
|
+
end
|
17
|
+
|
18
|
+
# @option options [Hash]
|
19
|
+
# :build_files
|
20
|
+
def call(release, options = {})
|
21
|
+
@release = release
|
22
|
+
@options = @options.update(options)
|
23
|
+
|
24
|
+
match = @options.delete(:match)
|
25
|
+
skip = @options.delete(:skip)
|
26
|
+
|
27
|
+
@options[:load_paths] = @options[:load_paths].map do |path|
|
28
|
+
build_path + path
|
29
|
+
end
|
30
|
+
|
31
|
+
# Sassify SCSS files
|
32
|
+
files = release.get_files(match)
|
33
|
+
|
34
|
+
files.each do |f|
|
35
|
+
# Doing skip by hand, so that we can clean the skipped ones
|
36
|
+
next if skip.detect { |r| r.match(f) }
|
37
|
+
|
38
|
+
release.log(self, "Processing: #{f}")
|
39
|
+
# Compile SCSS
|
40
|
+
compile_file(f)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Remove source file
|
44
|
+
clean_files(files)
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def clean_files(files)
|
50
|
+
files.each { |f| File.unlink(f) }
|
51
|
+
end
|
52
|
+
|
53
|
+
def build_path
|
54
|
+
@release.project.path
|
55
|
+
end
|
56
|
+
|
57
|
+
def compile_file(path)
|
58
|
+
scss = File.read(path)
|
59
|
+
|
60
|
+
File.open(path.gsub(/\.scss$/, ".css"), "w+") do |file|
|
61
|
+
file.write(SassC::Engine.new(scss, @options).render)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/roger_sassc.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "roger_sassc/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "roger_sassc"
|
7
|
+
spec.version = RogerSassc::VERSION
|
8
|
+
|
9
|
+
spec.authors = ["Edwin van der Graaf"]
|
10
|
+
spec.email = ["edwin@digitpaint.nl"]
|
11
|
+
spec.summary = "Sass plugin for Roger based on libsass"
|
12
|
+
spec.homepage = "https://github.com/DigitPaint/roger_sassc"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "sassc", "~> 1.2.0"
|
21
|
+
spec.add_dependency "roger", "~> 1.0"
|
22
|
+
spec.add_dependency "rack"
|
23
|
+
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "mocha", "~> 1.1.0"
|
26
|
+
spec.add_development_dependency "test-unit", "~> 3.1.2"
|
27
|
+
spec.add_development_dependency "simplecov", "~> 0.10.0"
|
28
|
+
spec.add_development_dependency "rubocop", "~> 0.31.0"
|
29
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
Error: invalid property name
|
3
|
+
on line 2 of stdin
|
4
|
+
>> background: #fff;
|
5
|
+
-------------------^
|
6
|
+
|
7
|
+
|
8
|
+
Load paths:
|
9
|
+
["html/stylesheets", "bower_components", "test/fixtures"]
|
10
|
+
|
11
|
+
*/
|
12
|
+
body:before {
|
13
|
+
white-space: pre;
|
14
|
+
font-family: monospace;
|
15
|
+
content: 'Error: invalid property name\A on line 2 of stdin\A>> background: #fff;\A -------------------^\A'; }
|
@@ -0,0 +1 @@
|
|
1
|
+
$black: #000;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Fixture helper for tests
|
2
|
+
module FixtureHelper
|
3
|
+
FIXTURE_ROOT = File.expand_path(File.join(File.dirname(__FILE__), "../fixtures"))
|
4
|
+
|
5
|
+
def fixture(path)
|
6
|
+
File.read(fixture_path(path))
|
7
|
+
end
|
8
|
+
|
9
|
+
def fixture_path(path)
|
10
|
+
File.join(FIXTURE_ROOT, path)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "./lib/roger_sassc/middleware"
|
3
|
+
|
4
|
+
module RogerSassc
|
5
|
+
# Testing the middleware functionality
|
6
|
+
# which transforms on a request based .scss to .css
|
7
|
+
class TestMiddleware < ::Test::Unit::TestCase
|
8
|
+
include FixtureHelper
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@app = proc { [200, {}, ["YAM"]] } # Yet another middleware
|
12
|
+
@middleware = Middleware.new @app
|
13
|
+
|
14
|
+
@request = Rack::MockRequest.new(@middleware)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_middleware_can_be_called
|
18
|
+
assert(@middleware.respond_to?(:call))
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_calls_rest_of_stack_when_not_css
|
22
|
+
assert_equal @request.get("/my.js").body, "YAM"
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_doesn_t_compile_scss_when_no_scss_file
|
26
|
+
@middleware.resolver = mock_resolver("not-excisting.scss", nil)
|
27
|
+
assert_equal @request.get("/not-excisting.css").body, "YAM"
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_respons_with_css
|
31
|
+
path = fixture_path "general.scss"
|
32
|
+
expected_css = fixture "output.css"
|
33
|
+
@middleware.resolver = mock_resolver("test/fixtures/general.scss", path)
|
34
|
+
assert_equal @request.get("/test/fixtures/general.css").body, expected_css
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_debug_error
|
38
|
+
path = fixture_path "errors/syntax.scss"
|
39
|
+
expected_css = fixture "errors/syntax.css"
|
40
|
+
@middleware.resolver = mock_resolver("test/fixtures/errors/syntax.scss", path)
|
41
|
+
assert_equal expected_css, @request.get("test/fixtures/errors/syntax.css").body
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def mock_resolver(input_url, file_path)
|
47
|
+
resolver = mock
|
48
|
+
resolver.expects(:url_to_path).with(equals(input_url), anything).returns(file_path)
|
49
|
+
resolver
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "fileutils"
|
3
|
+
require "./lib/roger_sassc/processor"
|
4
|
+
|
5
|
+
module RogerSassc
|
6
|
+
# Test the processor
|
7
|
+
class TestProcessor < ::Test::Unit::TestCase
|
8
|
+
include FixtureHelper
|
9
|
+
|
10
|
+
TEST_OUTPUT = "../../tmp/test/fixtures/"
|
11
|
+
|
12
|
+
def setup
|
13
|
+
@processor = Processor.new {}
|
14
|
+
@processor.stubs(:build_path).returns("./")
|
15
|
+
|
16
|
+
# Copy fixtures files to fixtures/out
|
17
|
+
output_path = fixture_path(TEST_OUTPUT)
|
18
|
+
FileUtils.rm_rf output_path
|
19
|
+
FileUtils.mkdir_p output_path
|
20
|
+
FileUtils.cp_r fixture_path("."), output_path
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_processor_can_be_called
|
24
|
+
assert(@processor.respond_to?(:call))
|
25
|
+
end
|
26
|
+
|
27
|
+
# Meh :(
|
28
|
+
def test_call_processor
|
29
|
+
release, files = release_mock_with_file
|
30
|
+
expected_css = fixture "output.css"
|
31
|
+
@processor.call release
|
32
|
+
|
33
|
+
# File is created
|
34
|
+
assert_path_exist fixture_path(TEST_OUTPUT + "general.css")
|
35
|
+
|
36
|
+
# And matches earlier output
|
37
|
+
assert_equal fixture(TEST_OUTPUT + "general.css"), expected_css
|
38
|
+
|
39
|
+
# Check clean up
|
40
|
+
assert_path_not_exist files[0]
|
41
|
+
assert_path_not_exist files[1]
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_processor_raises_on_compilation_errors
|
45
|
+
pend "Validate that the processors just raises with errors in scss files"
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def release_mock_with_file
|
51
|
+
files = [
|
52
|
+
fixture_path(TEST_OUTPUT + "general.scss"),
|
53
|
+
fixture_path(TEST_OUTPUT + "src/_variables.scss")
|
54
|
+
]
|
55
|
+
|
56
|
+
release = mock(get_files: files,
|
57
|
+
log: ->(_s, _m) {})
|
58
|
+
|
59
|
+
[release, files]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "roger_sassc"
|
2
|
+
|
3
|
+
module RogerSassc
|
4
|
+
# Main module tests
|
5
|
+
# Maintaining the load paths
|
6
|
+
class TestRogerSassc < ::Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
RogerSassc.load_paths = RogerSassc::DEFAULT_LOAD_PATHS.dup
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
# Reset back to default
|
13
|
+
RogerSassc.load_paths = RogerSassc::DEFAULT_LOAD_PATHS.dup
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_append_load_path
|
17
|
+
RogerSassc.append_path("a/b")
|
18
|
+
assert_equal RogerSassc.load_paths,
|
19
|
+
["html/stylesheets", "bower_components", "a/b"]
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_append_load_path_with_multiple_params
|
23
|
+
RogerSassc.append_path("a/b", "b/c")
|
24
|
+
assert_equal RogerSassc.load_paths,
|
25
|
+
["html/stylesheets", "bower_components", "a/b", "b/c"]
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_append_load_path_with_array
|
29
|
+
RogerSassc.append_path(["a/b", "b/c"])
|
30
|
+
assert_equal RogerSassc.load_paths,
|
31
|
+
["html/stylesheets", "bower_components", "a/b", "b/c"]
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_default_load_path
|
35
|
+
assert_equal RogerSassc.load_paths,
|
36
|
+
["html/stylesheets", "bower_components"]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Trying is knowing
|
2
|
+
if ENV["CODECLIMATE_REPO_TOKEN"]
|
3
|
+
require "codeclimate-test-reporter"
|
4
|
+
CodeClimate::TestReporter.start
|
5
|
+
else
|
6
|
+
require "simplecov"
|
7
|
+
SimpleCov.start
|
8
|
+
end
|
9
|
+
|
10
|
+
require "test/unit"
|
11
|
+
require "mocha/test_unit"
|
12
|
+
require "pry"
|
13
|
+
|
14
|
+
require "roger_sassc"
|
15
|
+
|
16
|
+
require File.dirname(__FILE__) + "/helpers/fixture_helper"
|
17
|
+
|
18
|
+
RogerSassc.append_path "test/fixtures"
|
metadata
ADDED
@@ -0,0 +1,189 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: roger_sassc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Edwin van der Graaf
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sassc
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: roger
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rack
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: mocha
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.1.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.1.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: test-unit
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 3.1.2
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.1.2
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.10.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.10.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.31.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.31.0
|
125
|
+
description:
|
126
|
+
email:
|
127
|
+
- edwin@digitpaint.nl
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- ".hound.yml"
|
134
|
+
- ".rubocop.yml"
|
135
|
+
- ".travis.yml"
|
136
|
+
- Gemfile
|
137
|
+
- LICENSE.txt
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- lib/roger_sassc.rb
|
141
|
+
- lib/roger_sassc/middleware.rb
|
142
|
+
- lib/roger_sassc/processor.rb
|
143
|
+
- lib/roger_sassc/version.rb
|
144
|
+
- roger_sassc.gemspec
|
145
|
+
- test/fixtures/errors/syntax.css
|
146
|
+
- test/fixtures/errors/syntax.scss
|
147
|
+
- test/fixtures/general.scss
|
148
|
+
- test/fixtures/output.css
|
149
|
+
- test/fixtures/src/_variables.scss
|
150
|
+
- test/helpers/fixture_helper.rb
|
151
|
+
- test/middleware_test.rb
|
152
|
+
- test/processor_test.rb
|
153
|
+
- test/roger_sassc_test.rb
|
154
|
+
- test/test_helper.rb
|
155
|
+
homepage: https://github.com/DigitPaint/roger_sassc
|
156
|
+
licenses:
|
157
|
+
- MIT
|
158
|
+
metadata: {}
|
159
|
+
post_install_message:
|
160
|
+
rdoc_options: []
|
161
|
+
require_paths:
|
162
|
+
- lib
|
163
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
requirements: []
|
174
|
+
rubyforge_project:
|
175
|
+
rubygems_version: 2.2.2
|
176
|
+
signing_key:
|
177
|
+
specification_version: 4
|
178
|
+
summary: Sass plugin for Roger based on libsass
|
179
|
+
test_files:
|
180
|
+
- test/fixtures/errors/syntax.css
|
181
|
+
- test/fixtures/errors/syntax.scss
|
182
|
+
- test/fixtures/general.scss
|
183
|
+
- test/fixtures/output.css
|
184
|
+
- test/fixtures/src/_variables.scss
|
185
|
+
- test/helpers/fixture_helper.rb
|
186
|
+
- test/middleware_test.rb
|
187
|
+
- test/processor_test.rb
|
188
|
+
- test/roger_sassc_test.rb
|
189
|
+
- test/test_helper.rb
|