jekyll-sass-converter 1.0.0 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa33b7fb6d5090ac41ac28b7a66caf53bbaa2679
4
- data.tar.gz: 08eab1bad34f5d3ceb7d95f320f414b32a60e4cf
3
+ metadata.gz: 2378debab502ac8be28921965bf56e8090f3c871
4
+ data.tar.gz: 5a71a60854bef153d688423634a9f7d70fff67d1
5
5
  SHA512:
6
- metadata.gz: 3a7888bd4ae43c7c83d20fa46c9664a45f278c58561704f4d0dbc646b8b368c985a0b1a01490a7c55d44af930978e800cd75e97ef4f5702de45510ae141de6c5
7
- data.tar.gz: add1ac2e2f6d4ba6c06487af52c556ad40139e1008221f5c9b5d1d16e752857da492a088b733b9f963884853df12962befd225158a8105b80895aebbc64adb73
6
+ metadata.gz: 21b5e7c01f43a6423f0e7013fde7952aa8b3f8f80d897da80e3f111da68be399eabe906cab23a1e7d623686bf3e909981249395b15b8cca811d3bacca3600193
7
+ data.tar.gz: 5c8f0cfd2b0c1ca3116f3de158b4f34f0a265f9f6156a19881e4d26662a3ac0eb35d9abab9830e0e8fa7c11be9582e3f4657b04cda8a587fec9d0834de520347
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ spec/reports
16
16
  test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
+ spec/dest/css*
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
1
  --color
2
- --format progress
2
+ --format doc
data/Gemfile CHANGED
@@ -1,7 +1,2 @@
1
1
  source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in jekyll-sass-converter.gemspec
4
2
  gemspec
5
-
6
- gem "jekyll", "2.0.0.alpha.2"
7
- gem "rouge"
@@ -1,8 +1,13 @@
1
- ## HEAD
1
+ ## 1.1.0 / 2014-07-29
2
+
3
+ ### Minor Enhancements
4
+
5
+ * Implement custom load paths (#14)
6
+ * Lock down sass configuration when in safe mode. (#15)
2
7
 
3
8
  ## 1.0.0 / 2014-05-06
4
9
 
5
- * Birthday!
6
- * Don't use core extensions (#2)
7
- * Allow users to set style of outputted CSS (#4)
8
- * Determine input syntax based on file extension (#9)
10
+ * Birthday!
11
+ * Don't use core extensions (#2)
12
+ * Allow users to set style of outputted CSS (#4)
13
+ * Determine input syntax based on file extension (#9)
@@ -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 "rspec"
25
+ spec.add_development_dependency "jekyll", "~> 2.0"
25
26
  end
@@ -1,3 +1,3 @@
1
1
  module JekyllSassConverter
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -15,6 +15,10 @@ module Jekyll
15
15
  ".css"
16
16
  end
17
17
 
18
+ def safe?
19
+ !!@config["safe"]
20
+ end
21
+
18
22
  def jekyll_sass_configuration
19
23
  options = @config["sass"] || {}
20
24
  unless options["style"].nil?
@@ -24,9 +28,20 @@ module Jekyll
24
28
  end
25
29
 
26
30
  def sass_build_configuration_options(overrides)
27
- Jekyll::Utils.symbolize_hash_keys(
28
- Jekyll::Utils.deep_merge_hashes(jekyll_sass_configuration, overrides)
29
- )
31
+ if safe?
32
+ {
33
+ :load_paths => sass_load_paths,
34
+ :syntax => syntax,
35
+ :cache => false
36
+ }
37
+ else
38
+ Jekyll::Utils.symbolize_hash_keys(
39
+ Jekyll::Utils.deep_merge_hashes(
40
+ jekyll_sass_configuration,
41
+ overrides
42
+ )
43
+ )
44
+ end
30
45
  end
31
46
 
32
47
  def syntax
@@ -38,25 +53,36 @@ module Jekyll
38
53
  jekyll_sass_configuration["sass_dir"]
39
54
  end
40
55
 
56
+ def user_sass_load_paths
57
+ Array(jekyll_sass_configuration["load_paths"])
58
+ end
59
+
41
60
  def sass_dir_relative_to_site_source
42
- # FIXME: Not Windows-safe. Can only change once Jekyll 2.0.0 is out
43
61
  Jekyll.sanitized_path(@config["source"], sass_dir)
44
62
  end
45
63
 
64
+ def sass_load_paths
65
+ if safe?
66
+ [sass_dir_relative_to_site_source]
67
+ else
68
+ (user_sass_load_paths + [sass_dir_relative_to_site_source]).uniq
69
+ end
70
+ end
71
+
46
72
  def allow_caching?
47
- !@config["safe"]
73
+ !safe?
48
74
  end
49
75
 
50
- def sass_configs(content = "")
76
+ def sass_configs
51
77
  sass_build_configuration_options({
52
78
  "syntax" => syntax,
53
79
  "cache" => allow_caching?,
54
- "load_paths" => [sass_dir_relative_to_site_source]
80
+ "load_paths" => sass_load_paths
55
81
  })
56
82
  end
57
83
 
58
84
  def convert(content)
59
- ::Sass.compile(content, sass_configs(content))
85
+ ::Sass.compile(content, sass_configs)
60
86
  end
61
87
  end
62
88
  end
@@ -0,0 +1,4 @@
1
+ ---
2
+ ---
3
+
4
+ @import "color";
@@ -29,11 +29,11 @@ CSS
29
29
 
30
30
  context "matching file extensions" do
31
31
  it "does not match .scss files" do
32
- expect(converter.matches(".scss")).to be_false
32
+ expect(converter.matches(".scss")).to be_falsey
33
33
  end
34
34
 
35
35
  it "matches .sass files" do
36
- expect(converter.matches(".sass")).to be_true
36
+ expect(converter.matches(".sass")).to be_truthy
37
37
  end
38
38
  end
39
39
 
@@ -29,11 +29,11 @@ CSS
29
29
 
30
30
  context "matching file extensions" do
31
31
  it "matches .scss files" do
32
- expect(converter.matches(".scss")).to be_true
32
+ expect(converter.matches(".scss")).to be_truthy
33
33
  end
34
34
 
35
35
  it "does not match .sass files" do
36
- expect(converter.matches(".sass")).to be_false
36
+ expect(converter.matches(".sass")).to be_falsey
37
37
  end
38
38
  end
39
39
 
@@ -44,14 +44,9 @@ CSS
44
44
  end
45
45
 
46
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
47
 
53
48
  it "allow caching in unsafe mode" do
54
- expect(converter.sass_configs[:cache]).to be_true
49
+ expect(converter.sass_configs[:cache]).to be_truthy
55
50
  end
56
51
 
57
52
  it "set the load paths to the _sass dir relative to site source" do
@@ -71,6 +66,26 @@ CSS
71
66
  converter({"sass_dir" => "/etc/passwd"}).sass_dir_relative_to_site_source
72
67
  ).to eql(source_dir("etc/passwd"))
73
68
  end
69
+
70
+ context "in safe mode" do
71
+ let(:verter) {
72
+ c = converter
73
+ c.instance_variable_get(:@config)["safe"] = true
74
+ c
75
+ }
76
+
77
+ it "does not allow caching" do
78
+ expect(verter.sass_configs[:cache]).to be_falsey
79
+ end
80
+
81
+ it "forces load_paths to be just the local load path" do
82
+ expect(verter.sass_configs[:load_paths]).to eql([source_dir("_sass")])
83
+ end
84
+
85
+ it "only contains :syntax, :cache, and :load_paths keys" do
86
+ expect(verter.sass_configs.keys).to eql([:load_paths, :syntax, :cache])
87
+ end
88
+ end
74
89
  end
75
90
 
76
91
  context "converting SCSS" do
@@ -84,7 +99,7 @@ CSS
84
99
  before(:each) { site.process }
85
100
 
86
101
  it "outputs the CSS file" do
87
- expect(File.exist?(test_css_file)).to be_true
102
+ expect(File.exist?(test_css_file)).to be_truthy
88
103
  end
89
104
 
90
105
  it "imports SCSS partial" do
@@ -98,4 +113,73 @@ CSS
98
113
  end
99
114
  end
100
115
 
116
+ context "importing from external libraries" do
117
+ let(:external_library) { source_dir("_sass") }
118
+ let(:verter) { site.getConverterImpl(Jekyll::Converters::Scss) }
119
+ let(:test_css_file) { dest_dir('css', 'main.css') }
120
+
121
+ context "unsafe mode" do
122
+ let(:site) do
123
+ Jekyll::Site.new(site_configuration.merge({
124
+ "source" => sass_lib,
125
+ "sass" => {
126
+ "load_paths" => external_library
127
+ }
128
+ }))
129
+ end
130
+
131
+ it "recognizes the new load path" do
132
+ expect(verter.sass_load_paths).to include(external_library)
133
+ end
134
+
135
+ it "ensures the sass_dir is still in the load path" do
136
+ expect(verter.sass_load_paths).to include(sass_lib("_sass"))
137
+ end
138
+
139
+ it "brings in the grid partial" do
140
+ site.process
141
+ expect(File.read(test_css_file)).to eql("a {\n color: #999999; }\n")
142
+ end
143
+
144
+ context "with the sass_dir specified twice" do
145
+ let(:site) do
146
+ Jekyll::Site.new(site_configuration.merge({
147
+ "source" => sass_lib,
148
+ "sass" => {
149
+ "load_paths" => [
150
+ external_library,
151
+ sass_lib("_sass")
152
+ ]
153
+ }
154
+ }))
155
+ end
156
+
157
+ it "ensures the sass_dir only occurrs once in the load path" do
158
+ expect(verter.sass_load_paths).to eql([external_library, sass_lib("_sass")])
159
+ end
160
+ end
161
+ end
162
+
163
+ context "safe mode" do
164
+ let(:site) do
165
+ Jekyll::Site.new(site_configuration.merge({
166
+ "safe" => true,
167
+ "source" => sass_lib,
168
+ "sass" => {
169
+ "load_paths" => external_library
170
+ }
171
+ }))
172
+ end
173
+
174
+ it "ignores the new load path" do
175
+ expect(verter.sass_load_paths).not_to include(external_library)
176
+ end
177
+
178
+ it "ensures the sass_dir is the entire load path" do
179
+ expect(verter.sass_load_paths).to eql([sass_lib("_sass")])
180
+ end
181
+ end
182
+
183
+ end
184
+
101
185
  end
@@ -0,0 +1,2 @@
1
+ $black: #999;
2
+ a { color: $black; }
@@ -6,16 +6,20 @@ lib = File.expand_path('../lib', __FILE__)
6
6
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
7
7
  require 'jekyll-sass-converter'
8
8
 
9
- Jekyll.logger.log_level = Jekyll::Stevenson::ERROR
9
+ if Jekyll::VERSION > "1"
10
+ Jekyll.logger.log_level = :error
11
+ else
12
+ Jekyll.logger.log_level = Jekyll::Stevenson::ERROR
13
+ end
10
14
 
11
15
  RSpec.configure do |config|
12
- config.treat_symbols_as_metadata_keys_with_true_values = true
13
16
  config.run_all_when_everything_filtered = true
14
17
  config.filter_run :focus
15
18
  config.order = 'random'
16
19
 
17
- SOURCE_DIR = File.expand_path("../source", __FILE__)
18
- DEST_DIR = File.expand_path("../dest", __FILE__)
20
+ SOURCE_DIR = File.expand_path("../source", __FILE__)
21
+ DEST_DIR = File.expand_path("../dest", __FILE__)
22
+ SASS_LIB_DIR = File.expand_path("../other_sass_library", __FILE__)
19
23
  FileUtils.rm_rf(DEST_DIR)
20
24
  FileUtils.mkdir_p(DEST_DIR)
21
25
 
@@ -27,6 +31,10 @@ RSpec.configure do |config|
27
31
  File.join(DEST_DIR, *files)
28
32
  end
29
33
 
34
+ def sass_lib(*files)
35
+ File.join(SASS_LIB_DIR, *files)
36
+ end
37
+
30
38
  def site_configuration(overrides = {})
31
39
  Jekyll.configuration(overrides.merge({
32
40
  "source" => source_dir,
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.1.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-05-07 00:00:00.000000000 Z
11
+ date: 2014-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: jekyll
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
69
83
  description:
70
84
  email:
71
85
  - parkrmoore@gmail.com
@@ -89,10 +103,11 @@ files:
89
103
  - script/bootstrap
90
104
  - script/cibuild
91
105
  - script/release
92
- - spec/dest/css/main.css
106
+ - spec/other_sass_library/css/main.scss
93
107
  - spec/sass_coverter_spec.rb
94
108
  - spec/scss_converter_spec.rb
95
109
  - spec/source/_config.yml
110
+ - spec/source/_sass/_color.scss
96
111
  - spec/source/_sass/_grid.scss
97
112
  - spec/source/css/main.scss
98
113
  - spec/spec_helper.rb
@@ -121,10 +136,11 @@ signing_key:
121
136
  specification_version: 4
122
137
  summary: A basic Sass converter for Jekyll.
123
138
  test_files:
124
- - spec/dest/css/main.css
139
+ - spec/other_sass_library/css/main.scss
125
140
  - spec/sass_coverter_spec.rb
126
141
  - spec/scss_converter_spec.rb
127
142
  - spec/source/_config.yml
143
+ - spec/source/_sass/_color.scss
128
144
  - spec/source/_sass/_grid.scss
129
145
  - spec/source/css/main.scss
130
146
  - spec/spec_helper.rb
@@ -1 +0,0 @@
1
- .half{width:50%}