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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82e58fdd63ea4f8cfb532b9eb0c9bb38d4f7fdb9
4
- data.tar.gz: 611747a8002674cb0d09a015bae27bcf03f86432
3
+ metadata.gz: 4a5a330647c5fc08383c7fa2e975581efb5f5e2d
4
+ data.tar.gz: 70b8fbc1a5c00bfbfae9860505de0ef96471a6b3
5
5
  SHA512:
6
- metadata.gz: 20434be7cdd16f2afb7ddc29fd615ff851e5711a595d8d54e114faafb5348dd98a93bb9cc313c20718d6b504741362a5a6d3cc6e8991a7845f1b31eb8128a077
7
- data.tar.gz: a3aa0f296be45cde68c54db43f9d392da0d8c43c3cb0fbd4e781fbc3b7c6bf3fc3cc92898ffe3ad821ca7397079744acdc22a64d6f54e6f7b87670cd1f986518
6
+ metadata.gz: e295fa24ed3f62353c8f525a7f803f6139305a238f8b0fa554a163a3dedbc19c1a9f6ca6be0ef6bd13a57b11ad665aafe73c11106143a2b04fc974d46c5220e8
7
+ data.tar.gz: 03786d64805e0578ae2a52346c53a4f64e60ba52f1308b88ee6630304e029d10c2b17c193691f096172151587f460cc8889e8e96e2cae4bc34f2828c69fe96ea
data/.gitignore CHANGED
@@ -2,6 +2,7 @@
2
2
  *.rbc
3
3
  .bundle
4
4
  .config
5
+ .sass-cache
5
6
  .yardoc
6
7
  Gemfile.lock
7
8
  InstalledFiles
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ script : script/cibuild
3
+ rvm:
4
+ - 2.1.0
5
+ - 2.0.0
6
+ - 1.9.3
7
+ notifications:
8
+ email: false
data/README.md CHANGED
@@ -1,9 +1,14 @@
1
- # Jekyll::Sass::Converter
1
+ # Jekyll Sass Converter
2
2
 
3
- TODO: Write a gem description
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
- TODO: Write usage instructions here
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/<my-github-username>/jekyll-sass-converter/fork )
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`)
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.5"
23
23
  spec.add_development_dependency "rake"
24
24
  spec.add_development_dependency "jekyll"
25
+ spec.add_development_dependency "rspec"
25
26
  end
@@ -1,55 +1,64 @@
1
+ require 'sass'
2
+
1
3
  module Jekyll
2
- class Sass < Converter
3
- safe true
4
- priority :low
4
+ module Converters
5
+ class Sass < Converter
6
+ safe true
7
+ priority :low
5
8
 
6
- def matches(ext)
7
- ext =~ /^\.s(a|c)ss$/i
8
- end
9
+ def matches(ext)
10
+ ext =~ /^\.s(a|c)ss$/i
11
+ end
9
12
 
10
- def output_ext(ext)
11
- ".css"
12
- end
13
+ def output_ext(ext)
14
+ ".css"
15
+ end
13
16
 
14
- def jekyll_sass_configuration
15
- @config["sass"] || {}
16
- end
17
+ def jekyll_sass_configuration
18
+ @config["sass"] || {}
19
+ end
17
20
 
18
- def sass_build_configuration_options(overrides)
19
- jekyll_sass_configuration.deep_merge(overrides).symbolize_keys
20
- end
21
+ def sass_build_configuration_options(overrides)
22
+ jekyll_sass_configuration.deep_merge(overrides).symbolize_keys
23
+ end
21
24
 
22
- def syntax_type_of_content(content)
23
- if content.include?(";") || content.include?("{")
24
- :scss
25
- else
26
- :sass
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
- def sass_dir
31
- return "_sass" if jekyll_sass_configuration["sass_dir"].to_s.empty?
32
- jekyll_sass_configuration["sass_dir"]
33
- end
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
- def sass_dir_relative_to_site_source
36
- Jekyll.sanitized_path(@config["source"], sass_dir)
37
- end
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
- def allow_caching?
40
- !@config["safe"]
41
- end
47
+ def allow_caching?
48
+ !@config["safe"]
49
+ end
42
50
 
43
- def sass_configs(content = "")
44
- sass_build_configuration_options({
45
- "syntax" => syntax_type_of_content(content),
46
- "cache" => allow_caching?,
47
- "load_paths" => [sass_dir_relative_to_site_source]
48
- })
49
- end
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
- def convert(content)
52
- ::Sass.compile(content, sass_configs(content))
59
+ def convert(content)
60
+ ::Sass.compile(content, sass_configs(content))
61
+ end
53
62
  end
54
63
  end
55
64
  end
@@ -1,3 +1,3 @@
1
1
  module JekyllSassConverter
2
- VERSION = "1.0.0.alpha.1"
2
+ VERSION = "1.0.0.rc1"
3
3
  end
@@ -1,6 +1,4 @@
1
1
  require "jekyll-sass-converter/version"
2
-
3
- require "jekyll"
4
2
  require "jekyll/converters/sass"
5
3
 
6
4
  module JekyllSassConverter
data/script/bootstrap CHANGED
File without changes
data/script/cibuild CHANGED
File without changes
data/script/release CHANGED
File without changes
@@ -0,0 +1,2 @@
1
+ .half {
2
+ width: 50%; }
@@ -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%; }
@@ -0,0 +1,4 @@
1
+ ---
2
+ ---
3
+
4
+ @import "grid";
@@ -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.alpha.1
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