jekyll-sass-converter 1.0.0.alpha.1 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/.travis.yml +8 -0
- data/README.md +11 -4
- data/jekyll-sass-converter.gemspec +1 -0
- data/lib/jekyll/converters/sass.rb +49 -40
- data/lib/jekyll-sass-converter/version.rb +1 -1
- data/lib/jekyll-sass-converter.rb +0 -2
- data/script/bootstrap +0 -0
- data/script/cibuild +0 -0
- data/script/release +0 -0
- data/spec/dest/css/main.css +2 -0
- data/spec/sass_coverter_spec.rb +118 -0
- data/spec/source/_sass/_grid.scss +1 -0
- data/spec/source/css/main.scss +4 -0
- data/spec/spec_helper.rb +34 -0
- metadata +28 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a5a330647c5fc08383c7fa2e975581efb5f5e2d
|
4
|
+
data.tar.gz: 70b8fbc1a5c00bfbfae9860505de0ef96471a6b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e295fa24ed3f62353c8f525a7f803f6139305a238f8b0fa554a163a3dedbc19c1a9f6ca6be0ef6bd13a57b11ad665aafe73c11106143a2b04fc974d46c5220e8
|
7
|
+
data.tar.gz: 03786d64805e0578ae2a52346c53a4f64e60ba52f1308b88ee6630304e029d10c2b17c193691f096172151587f460cc8889e8e96e2cae4bc34f2828c69fe96ea
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,9 +1,14 @@
|
|
1
|
-
# Jekyll
|
1
|
+
# Jekyll Sass Converter
|
2
2
|
|
3
|
-
|
3
|
+
Let Jekyll build your Sass and SCSS!
|
4
|
+
|
5
|
+
[![Build Status](https://travis-ci.org/jekyll/jekyll-sass-converter.png?branch=master)](https://travis-ci.org/jekyll/jekyll-sass-converter)
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
9
|
+
**Jekyll Sass Converter requires Jekyll 2.0.0 or greater and is bundled
|
10
|
+
with Jekyll so you don't need to install it if you're already using Jekyll.**
|
11
|
+
|
7
12
|
Add this line to your application's Gemfile:
|
8
13
|
|
9
14
|
gem 'jekyll-sass-converter'
|
@@ -18,11 +23,13 @@ Or install it yourself as:
|
|
18
23
|
|
19
24
|
## Usage
|
20
25
|
|
21
|
-
|
26
|
+
Jekyll Sass Converter comes bundled with Jekyll 2.0.0 and greater. For more
|
27
|
+
information about usage, visit the [Jekyll Assets Documentation
|
28
|
+
page](http://jekyllrb.com/docs/assets/).
|
22
29
|
|
23
30
|
## Contributing
|
24
31
|
|
25
|
-
1. Fork it ( http://github.com
|
32
|
+
1. Fork it ( http://github.com/jekyll/jekyll-sass-converter/fork )
|
26
33
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
34
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
35
|
4. Push to the branch (`git push origin my-new-feature`)
|
@@ -1,55 +1,64 @@
|
|
1
|
+
require 'sass'
|
2
|
+
|
1
3
|
module Jekyll
|
2
|
-
|
3
|
-
|
4
|
-
|
4
|
+
module Converters
|
5
|
+
class Sass < Converter
|
6
|
+
safe true
|
7
|
+
priority :low
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
+
def matches(ext)
|
10
|
+
ext =~ /^\.s(a|c)ss$/i
|
11
|
+
end
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
+
def output_ext(ext)
|
14
|
+
".css"
|
15
|
+
end
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
def jekyll_sass_configuration
|
18
|
+
@config["sass"] || {}
|
19
|
+
end
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
+
def sass_build_configuration_options(overrides)
|
22
|
+
jekyll_sass_configuration.deep_merge(overrides).symbolize_keys
|
23
|
+
end
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
def syntax_type_of_content(content)
|
26
|
+
if content.include?(";") || content.include?("{")
|
27
|
+
:scss
|
28
|
+
else
|
29
|
+
:sass
|
30
|
+
end
|
27
31
|
end
|
28
|
-
end
|
29
32
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
def sass_dir
|
34
|
+
return "_sass" if jekyll_sass_configuration["sass_dir"].to_s.empty?
|
35
|
+
jekyll_sass_configuration["sass_dir"]
|
36
|
+
end
|
34
37
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
+
def sass_dir_relative_to_site_source
|
39
|
+
# FIXME: Not Windows-safe. Can only change once Jekyll 2.0.0 is out
|
40
|
+
# Jekyll.sanitized_path(@config["source"], sass_dir)
|
41
|
+
File.join(
|
42
|
+
@config["source"],
|
43
|
+
File.expand_path(sass_dir, "/")
|
44
|
+
)
|
45
|
+
end
|
38
46
|
|
39
|
-
|
40
|
-
|
41
|
-
|
47
|
+
def allow_caching?
|
48
|
+
!@config["safe"]
|
49
|
+
end
|
42
50
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
51
|
+
def sass_configs(content = "")
|
52
|
+
sass_build_configuration_options({
|
53
|
+
"syntax" => syntax_type_of_content(content),
|
54
|
+
"cache" => allow_caching?,
|
55
|
+
"load_paths" => [sass_dir_relative_to_site_source]
|
56
|
+
})
|
57
|
+
end
|
50
58
|
|
51
|
-
|
52
|
-
|
59
|
+
def convert(content)
|
60
|
+
::Sass.compile(content, sass_configs(content))
|
61
|
+
end
|
53
62
|
end
|
54
63
|
end
|
55
64
|
end
|
data/script/bootstrap
CHANGED
File without changes
|
data/script/cibuild
CHANGED
File without changes
|
data/script/release
CHANGED
File without changes
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe(Jekyll::Converters::Sass) do
|
4
|
+
let(:site) do
|
5
|
+
Jekyll::Site.new(site_configuration)
|
6
|
+
end
|
7
|
+
let(:sass_content) do
|
8
|
+
<<-SASS
|
9
|
+
$font-stack: Helvetica, sans-serif
|
10
|
+
body
|
11
|
+
font-family: $font-stack
|
12
|
+
font-color: fuschia
|
13
|
+
SASS
|
14
|
+
end
|
15
|
+
let(:scss_content) do
|
16
|
+
<<-SCSS
|
17
|
+
$font-stack: Helvetica, sans-serif;
|
18
|
+
body {
|
19
|
+
font-family: $font-stack;
|
20
|
+
font-color: fuschia;
|
21
|
+
}
|
22
|
+
SCSS
|
23
|
+
end
|
24
|
+
let(:css_output) do
|
25
|
+
<<-CSS
|
26
|
+
body {\n font-family: Helvetica, sans-serif;\n font-color: fuschia; }
|
27
|
+
CSS
|
28
|
+
end
|
29
|
+
|
30
|
+
def converter(overrides = {})
|
31
|
+
Jekyll::Converters::Sass.new(site_configuration({"sass" => overrides}))
|
32
|
+
end
|
33
|
+
|
34
|
+
context "matching file extensions" do
|
35
|
+
it "matches .scss files" do
|
36
|
+
expect(converter.matches(".scss")).to be_true
|
37
|
+
end
|
38
|
+
|
39
|
+
it "matches .sass files" do
|
40
|
+
expect(converter.matches(".sass")).to be_true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "determining the output file extension" do
|
45
|
+
it "always outputs the .css file extension" do
|
46
|
+
expect(converter.output_ext(".always-css")).to eql(".css")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "when building configurations" do
|
51
|
+
it "not allow caching in safe mode" do
|
52
|
+
verter = converter
|
53
|
+
verter.instance_variable_get(:@config)["safe"] = true
|
54
|
+
expect(verter.sass_configs[:cache]).to be_false
|
55
|
+
end
|
56
|
+
|
57
|
+
it "allow caching in unsafe mode" do
|
58
|
+
expect(converter.sass_configs[:cache]).to be_true
|
59
|
+
end
|
60
|
+
|
61
|
+
it "set the load paths to the _sass dir relative to site source" do
|
62
|
+
expect(converter.sass_configs[:load_paths]).to eql([source_dir("_sass")])
|
63
|
+
end
|
64
|
+
|
65
|
+
it "allow the user to specify a different sass dir" do
|
66
|
+
expect(converter({"sass_dir" => "_scss"}).sass_configs[:load_paths]).to eql([source_dir("_scss")])
|
67
|
+
end
|
68
|
+
|
69
|
+
it "set syntax :scss when SCSS content" do
|
70
|
+
expect(converter.sass_configs(scss_content)[:syntax]).to eql(:scss)
|
71
|
+
end
|
72
|
+
|
73
|
+
it "set syntax :sass when Sass content" do
|
74
|
+
expect(converter.sass_configs(sass_content)[:syntax]).to eql(:sass)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "default to :sass syntax when content is empty" do
|
78
|
+
expect(converter.sass_configs[:syntax]).to eql(:sass)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "not allow sass_dirs outside of site source" do
|
82
|
+
expect(
|
83
|
+
converter({"sass_dir" => "/etc/passwd"}).sass_dir_relative_to_site_source
|
84
|
+
).to eql(source_dir("etc/passwd"))
|
85
|
+
end
|
86
|
+
|
87
|
+
it "override user-set syntax based on content" do
|
88
|
+
expect(
|
89
|
+
converter({"syntax" => :scss}).sass_configs(sass_content)[:syntax]
|
90
|
+
).to eql(:sass)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context "converting sass" do
|
95
|
+
it "produces CSS" do
|
96
|
+
expect(converter.convert(sass_content)).to eql(css_output)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "converting SCSS" do
|
101
|
+
it "produces CSS" do
|
102
|
+
expect(converter.convert(scss_content)).to eql(css_output)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context "importing partials" do
|
107
|
+
let(:test_css_file) { dest_dir("css/main.css") }
|
108
|
+
before(:each) { site.process }
|
109
|
+
|
110
|
+
it "outputs the CSS file" do
|
111
|
+
expect(File.exist?(test_css_file)).to be_true
|
112
|
+
end
|
113
|
+
|
114
|
+
it "imports SCSS partial" do
|
115
|
+
expect(File.read(test_css_file)).to eql(".half {\n width: 50%; }\n")
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
.half { width: 50%; }
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'fileutils'
|
3
|
+
require 'jekyll'
|
4
|
+
|
5
|
+
lib = File.expand_path('../lib', __FILE__)
|
6
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
7
|
+
require 'jekyll-sass-converter'
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
11
|
+
config.run_all_when_everything_filtered = true
|
12
|
+
config.filter_run :focus
|
13
|
+
config.order = 'random'
|
14
|
+
|
15
|
+
SOURCE_DIR = File.expand_path("../source", __FILE__)
|
16
|
+
DEST_DIR = File.expand_path("../dest", __FILE__)
|
17
|
+
FileUtils.rm_rf(DEST_DIR)
|
18
|
+
FileUtils.mkdir_p(DEST_DIR)
|
19
|
+
|
20
|
+
def source_dir(*files)
|
21
|
+
File.join(SOURCE_DIR, *files)
|
22
|
+
end
|
23
|
+
|
24
|
+
def dest_dir(*files)
|
25
|
+
File.join(DEST_DIR, *files)
|
26
|
+
end
|
27
|
+
|
28
|
+
def site_configuration(overrides = {})
|
29
|
+
Jekyll::Configuration::DEFAULTS.deep_merge(overrides).deep_merge({
|
30
|
+
"source" => source_dir,
|
31
|
+
"destination" => dest_dir
|
32
|
+
})
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-sass-converter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Parker Moore
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description:
|
70
84
|
email:
|
71
85
|
- parkrmoore@gmail.com
|
@@ -74,6 +88,8 @@ extensions: []
|
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
76
90
|
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
77
93
|
- Gemfile
|
78
94
|
- LICENSE.txt
|
79
95
|
- README.md
|
@@ -85,6 +101,11 @@ files:
|
|
85
101
|
- script/bootstrap
|
86
102
|
- script/cibuild
|
87
103
|
- script/release
|
104
|
+
- spec/dest/css/main.css
|
105
|
+
- spec/sass_coverter_spec.rb
|
106
|
+
- spec/source/_sass/_grid.scss
|
107
|
+
- spec/source/css/main.scss
|
108
|
+
- spec/spec_helper.rb
|
88
109
|
homepage: https://github.com/jekyll/jekyll-sass-converter
|
89
110
|
licenses:
|
90
111
|
- MIT
|
@@ -109,4 +130,9 @@ rubygems_version: 2.2.2
|
|
109
130
|
signing_key:
|
110
131
|
specification_version: 4
|
111
132
|
summary: A basic Sass converter for Jekyll.
|
112
|
-
test_files:
|
133
|
+
test_files:
|
134
|
+
- spec/dest/css/main.css
|
135
|
+
- spec/sass_coverter_spec.rb
|
136
|
+
- spec/source/_sass/_grid.scss
|
137
|
+
- spec/source/css/main.scss
|
138
|
+
- spec/spec_helper.rb
|