jekyll-sass-converter 1.0.0.rc4 → 1.0.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 +4 -4
- data/History.markdown +3 -0
- data/lib/jekyll-sass-converter.rb +1 -0
- data/lib/jekyll-sass-converter/version.rb +1 -1
- data/lib/jekyll/converters/sass.rb +4 -52
- data/lib/jekyll/converters/scss.rb +63 -0
- data/spec/sass_coverter_spec.rb +5 -91
- data/spec/scss_converter_spec.rb +101 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa33b7fb6d5090ac41ac28b7a66caf53bbaa2679
|
4
|
+
data.tar.gz: 08eab1bad34f5d3ceb7d95f320f414b32a60e4cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a7888bd4ae43c7c83d20fa46c9664a45f278c58561704f4d0dbc646b8b368c985a0b1a01490a7c55d44af930978e800cd75e97ef4f5702de45510ae141de6c5
|
7
|
+
data.tar.gz: add1ac2e2f6d4ba6c06487af52c556ad40139e1008221f5c9b5d1d16e752857da492a088b733b9f963884853df12962befd225158a8105b80895aebbc64adb73
|
data/History.markdown
CHANGED
@@ -3,64 +3,16 @@ require 'jekyll/utils'
|
|
3
3
|
|
4
4
|
module Jekyll
|
5
5
|
module Converters
|
6
|
-
class Sass <
|
6
|
+
class Sass < Scss
|
7
7
|
safe true
|
8
8
|
priority :low
|
9
9
|
|
10
10
|
def matches(ext)
|
11
|
-
ext =~ /^\.
|
11
|
+
ext =~ /^\.sass$/i
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
def jekyll_sass_configuration
|
19
|
-
options = @config["sass"] || {}
|
20
|
-
unless options["style"].nil?
|
21
|
-
options["style"] = options["style"].to_s.gsub(/\A:/, '').to_sym
|
22
|
-
end
|
23
|
-
options
|
24
|
-
end
|
25
|
-
|
26
|
-
def sass_build_configuration_options(overrides)
|
27
|
-
Jekyll::Utils.symbolize_hash_keys(
|
28
|
-
Jekyll::Utils.deep_merge_hashes(jekyll_sass_configuration, overrides)
|
29
|
-
)
|
30
|
-
end
|
31
|
-
|
32
|
-
def syntax_type_of_content(content)
|
33
|
-
if content.include?(";") || content.include?("{")
|
34
|
-
:scss
|
35
|
-
else
|
36
|
-
:sass
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def sass_dir
|
41
|
-
return "_sass" if jekyll_sass_configuration["sass_dir"].to_s.empty?
|
42
|
-
jekyll_sass_configuration["sass_dir"]
|
43
|
-
end
|
44
|
-
|
45
|
-
def sass_dir_relative_to_site_source
|
46
|
-
# FIXME: Not Windows-safe. Can only change once Jekyll 2.0.0 is out
|
47
|
-
Jekyll.sanitized_path(@config["source"], sass_dir)
|
48
|
-
end
|
49
|
-
|
50
|
-
def allow_caching?
|
51
|
-
!@config["safe"]
|
52
|
-
end
|
53
|
-
|
54
|
-
def sass_configs(content = "")
|
55
|
-
sass_build_configuration_options({
|
56
|
-
"syntax" => syntax_type_of_content(content),
|
57
|
-
"cache" => allow_caching?,
|
58
|
-
"load_paths" => [sass_dir_relative_to_site_source]
|
59
|
-
})
|
60
|
-
end
|
61
|
-
|
62
|
-
def convert(content)
|
63
|
-
::Sass.compile(content, sass_configs(content))
|
14
|
+
def syntax
|
15
|
+
:sass
|
64
16
|
end
|
65
17
|
end
|
66
18
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'sass'
|
2
|
+
require 'jekyll/utils'
|
3
|
+
|
4
|
+
module Jekyll
|
5
|
+
module Converters
|
6
|
+
class Scss < Converter
|
7
|
+
safe true
|
8
|
+
priority :low
|
9
|
+
|
10
|
+
def matches(ext)
|
11
|
+
ext =~ /^\.scss$/i
|
12
|
+
end
|
13
|
+
|
14
|
+
def output_ext(ext)
|
15
|
+
".css"
|
16
|
+
end
|
17
|
+
|
18
|
+
def jekyll_sass_configuration
|
19
|
+
options = @config["sass"] || {}
|
20
|
+
unless options["style"].nil?
|
21
|
+
options["style"] = options["style"].to_s.gsub(/\A:/, '').to_sym
|
22
|
+
end
|
23
|
+
options
|
24
|
+
end
|
25
|
+
|
26
|
+
def sass_build_configuration_options(overrides)
|
27
|
+
Jekyll::Utils.symbolize_hash_keys(
|
28
|
+
Jekyll::Utils.deep_merge_hashes(jekyll_sass_configuration, overrides)
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
def syntax
|
33
|
+
:scss
|
34
|
+
end
|
35
|
+
|
36
|
+
def sass_dir
|
37
|
+
return "_sass" if jekyll_sass_configuration["sass_dir"].to_s.empty?
|
38
|
+
jekyll_sass_configuration["sass_dir"]
|
39
|
+
end
|
40
|
+
|
41
|
+
def sass_dir_relative_to_site_source
|
42
|
+
# FIXME: Not Windows-safe. Can only change once Jekyll 2.0.0 is out
|
43
|
+
Jekyll.sanitized_path(@config["source"], sass_dir)
|
44
|
+
end
|
45
|
+
|
46
|
+
def allow_caching?
|
47
|
+
!@config["safe"]
|
48
|
+
end
|
49
|
+
|
50
|
+
def sass_configs(content = "")
|
51
|
+
sass_build_configuration_options({
|
52
|
+
"syntax" => syntax,
|
53
|
+
"cache" => allow_caching?,
|
54
|
+
"load_paths" => [sass_dir_relative_to_site_source]
|
55
|
+
})
|
56
|
+
end
|
57
|
+
|
58
|
+
def convert(content)
|
59
|
+
::Sass.compile(content, sass_configs(content))
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/spec/sass_coverter_spec.rb
CHANGED
@@ -4,22 +4,14 @@ describe(Jekyll::Converters::Sass) do
|
|
4
4
|
let(:site) do
|
5
5
|
Jekyll::Site.new(site_configuration)
|
6
6
|
end
|
7
|
-
let(:
|
7
|
+
let(:content) do
|
8
8
|
<<-SASS
|
9
|
+
// tl;dr some sass
|
9
10
|
$font-stack: Helvetica, sans-serif
|
10
11
|
body
|
11
12
|
font-family: $font-stack
|
12
13
|
font-color: fuschia
|
13
14
|
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
15
|
end
|
24
16
|
let(:css_output) do
|
25
17
|
<<-CSS
|
@@ -36,8 +28,8 @@ CSS
|
|
36
28
|
end
|
37
29
|
|
38
30
|
context "matching file extensions" do
|
39
|
-
it "
|
40
|
-
expect(converter.matches(".scss")).to
|
31
|
+
it "does not match .scss files" do
|
32
|
+
expect(converter.matches(".scss")).to be_false
|
41
33
|
end
|
42
34
|
|
43
35
|
it "matches .sass files" do
|
@@ -45,88 +37,10 @@ CSS
|
|
45
37
|
end
|
46
38
|
end
|
47
39
|
|
48
|
-
context "determining the output file extension" do
|
49
|
-
it "always outputs the .css file extension" do
|
50
|
-
expect(converter.output_ext(".always-css")).to eql(".css")
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context "when building configurations" do
|
55
|
-
it "not allow caching in safe mode" do
|
56
|
-
verter = converter
|
57
|
-
verter.instance_variable_get(:@config)["safe"] = true
|
58
|
-
expect(verter.sass_configs[:cache]).to be_false
|
59
|
-
end
|
60
|
-
|
61
|
-
it "allow caching in unsafe mode" do
|
62
|
-
expect(converter.sass_configs[:cache]).to be_true
|
63
|
-
end
|
64
|
-
|
65
|
-
it "set the load paths to the _sass dir relative to site source" do
|
66
|
-
expect(converter.sass_configs[:load_paths]).to eql([source_dir("_sass")])
|
67
|
-
end
|
68
|
-
|
69
|
-
it "allow the user to specify a different sass dir" do
|
70
|
-
expect(converter({"sass_dir" => "_scss"}).sass_configs[:load_paths]).to eql([source_dir("_scss")])
|
71
|
-
end
|
72
|
-
|
73
|
-
it "set syntax :scss when SCSS content" do
|
74
|
-
expect(converter.sass_configs(scss_content)[:syntax]).to eql(:scss)
|
75
|
-
end
|
76
|
-
|
77
|
-
it "set syntax :sass when Sass content" do
|
78
|
-
expect(converter.sass_configs(sass_content)[:syntax]).to eql(:sass)
|
79
|
-
end
|
80
|
-
|
81
|
-
it "default to :sass syntax when content is empty" do
|
82
|
-
expect(converter.sass_configs[:syntax]).to eql(:sass)
|
83
|
-
end
|
84
|
-
|
85
|
-
it "allow for other styles" do
|
86
|
-
expect(converter({"style" => :compressed}).sass_configs[:style]).to eql(:compressed)
|
87
|
-
end
|
88
|
-
|
89
|
-
it "not allow sass_dirs outside of site source" do
|
90
|
-
expect(
|
91
|
-
converter({"sass_dir" => "/etc/passwd"}).sass_dir_relative_to_site_source
|
92
|
-
).to eql(source_dir("etc/passwd"))
|
93
|
-
end
|
94
|
-
|
95
|
-
it "override user-set syntax based on content" do
|
96
|
-
expect(
|
97
|
-
converter({"syntax" => :scss}).sass_configs(sass_content)[:syntax]
|
98
|
-
).to eql(:sass)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
40
|
context "converting sass" do
|
103
41
|
it "produces CSS" do
|
104
|
-
expect(converter.convert(
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
context "converting SCSS" do
|
109
|
-
it "produces CSS" do
|
110
|
-
expect(converter.convert(scss_content)).to eql(compressed(css_output))
|
42
|
+
expect(converter.convert(content)).to eql(compressed(css_output))
|
111
43
|
end
|
112
44
|
end
|
113
45
|
|
114
|
-
context "importing partials" do
|
115
|
-
let(:test_css_file) { dest_dir("css/main.css") }
|
116
|
-
before(:each) { site.process }
|
117
|
-
|
118
|
-
it "outputs the CSS file" do
|
119
|
-
expect(File.exist?(test_css_file)).to be_true
|
120
|
-
end
|
121
|
-
|
122
|
-
it "imports SCSS partial" do
|
123
|
-
expect(File.read(test_css_file)).to eql(compressed(".half {\n width: 50%; }\n"))
|
124
|
-
end
|
125
|
-
|
126
|
-
it "uses a compressed style" do
|
127
|
-
instance = site.getConverterImpl(Jekyll::Converters::Sass)
|
128
|
-
expect(instance.jekyll_sass_configuration).to eql({"style" => :compressed})
|
129
|
-
expect(instance.sass_configs[:style]).to eql(:compressed)
|
130
|
-
end
|
131
|
-
end
|
132
46
|
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe(Jekyll::Converters::Scss) do
|
4
|
+
let(:site) do
|
5
|
+
Jekyll::Site.new(site_configuration)
|
6
|
+
end
|
7
|
+
let(:content) do
|
8
|
+
<<-SCSS
|
9
|
+
$font-stack: Helvetica, sans-serif;
|
10
|
+
body {
|
11
|
+
font-family: $font-stack;
|
12
|
+
font-color: fuschia;
|
13
|
+
}
|
14
|
+
SCSS
|
15
|
+
end
|
16
|
+
let(:css_output) do
|
17
|
+
<<-CSS
|
18
|
+
body {\n font-family: Helvetica, sans-serif;\n font-color: fuschia; }
|
19
|
+
CSS
|
20
|
+
end
|
21
|
+
|
22
|
+
def compressed(content)
|
23
|
+
content.gsub(/\s+/, '').gsub(/;}/, '}') + "\n"
|
24
|
+
end
|
25
|
+
|
26
|
+
def converter(overrides = {})
|
27
|
+
Jekyll::Converters::Scss.new(site_configuration({"sass" => overrides}))
|
28
|
+
end
|
29
|
+
|
30
|
+
context "matching file extensions" do
|
31
|
+
it "matches .scss files" do
|
32
|
+
expect(converter.matches(".scss")).to be_true
|
33
|
+
end
|
34
|
+
|
35
|
+
it "does not match .sass files" do
|
36
|
+
expect(converter.matches(".sass")).to be_false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "determining the output file extension" do
|
41
|
+
it "always outputs the .css file extension" do
|
42
|
+
expect(converter.output_ext(".always-css")).to eql(".css")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "when building configurations" do
|
47
|
+
it "not allow caching in safe mode" do
|
48
|
+
verter = converter
|
49
|
+
verter.instance_variable_get(:@config)["safe"] = true
|
50
|
+
expect(verter.sass_configs[:cache]).to be_false
|
51
|
+
end
|
52
|
+
|
53
|
+
it "allow caching in unsafe mode" do
|
54
|
+
expect(converter.sass_configs[:cache]).to be_true
|
55
|
+
end
|
56
|
+
|
57
|
+
it "set the load paths to the _sass dir relative to site source" do
|
58
|
+
expect(converter.sass_configs[:load_paths]).to eql([source_dir("_sass")])
|
59
|
+
end
|
60
|
+
|
61
|
+
it "allow the user to specify a different sass dir" do
|
62
|
+
expect(converter({"sass_dir" => "_scss"}).sass_configs[:load_paths]).to eql([source_dir("_scss")])
|
63
|
+
end
|
64
|
+
|
65
|
+
it "allow for other styles" do
|
66
|
+
expect(converter({"style" => :compressed}).sass_configs[:style]).to eql(:compressed)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "not allow sass_dirs outside of site source" do
|
70
|
+
expect(
|
71
|
+
converter({"sass_dir" => "/etc/passwd"}).sass_dir_relative_to_site_source
|
72
|
+
).to eql(source_dir("etc/passwd"))
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "converting SCSS" do
|
77
|
+
it "produces CSS" do
|
78
|
+
expect(converter.convert(content)).to eql(compressed(css_output))
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context "importing partials" do
|
83
|
+
let(:test_css_file) { dest_dir("css/main.css") }
|
84
|
+
before(:each) { site.process }
|
85
|
+
|
86
|
+
it "outputs the CSS file" do
|
87
|
+
expect(File.exist?(test_css_file)).to be_true
|
88
|
+
end
|
89
|
+
|
90
|
+
it "imports SCSS partial" do
|
91
|
+
expect(File.read(test_css_file)).to eql(compressed(".half {\n width: 50%; }\n"))
|
92
|
+
end
|
93
|
+
|
94
|
+
it "uses a compressed style" do
|
95
|
+
instance = site.getConverterImpl(Jekyll::Converters::Scss)
|
96
|
+
expect(instance.jekyll_sass_configuration).to eql({"style" => :compressed})
|
97
|
+
expect(instance.sass_configs[:style]).to eql(:compressed)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Parker Moore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sass
|
@@ -85,11 +85,13 @@ files:
|
|
85
85
|
- lib/jekyll-sass-converter.rb
|
86
86
|
- lib/jekyll-sass-converter/version.rb
|
87
87
|
- lib/jekyll/converters/sass.rb
|
88
|
+
- lib/jekyll/converters/scss.rb
|
88
89
|
- script/bootstrap
|
89
90
|
- script/cibuild
|
90
91
|
- script/release
|
91
92
|
- spec/dest/css/main.css
|
92
93
|
- spec/sass_coverter_spec.rb
|
94
|
+
- spec/scss_converter_spec.rb
|
93
95
|
- spec/source/_config.yml
|
94
96
|
- spec/source/_sass/_grid.scss
|
95
97
|
- spec/source/css/main.scss
|
@@ -109,9 +111,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
109
111
|
version: '0'
|
110
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
113
|
requirements:
|
112
|
-
- - "
|
114
|
+
- - ">="
|
113
115
|
- !ruby/object:Gem::Version
|
114
|
-
version:
|
116
|
+
version: '0'
|
115
117
|
requirements: []
|
116
118
|
rubyforge_project:
|
117
119
|
rubygems_version: 2.2.2
|
@@ -121,6 +123,7 @@ summary: A basic Sass converter for Jekyll.
|
|
121
123
|
test_files:
|
122
124
|
- spec/dest/css/main.css
|
123
125
|
- spec/sass_coverter_spec.rb
|
126
|
+
- spec/scss_converter_spec.rb
|
124
127
|
- spec/source/_config.yml
|
125
128
|
- spec/source/_sass/_grid.scss
|
126
129
|
- spec/source/css/main.scss
|