jekyll-sass-converter 1.0.0.rc4 → 2.0.0.pre.beta

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
- SHA1:
3
- metadata.gz: e62ef230908db14e202a28b5a34e94b977a8611b
4
- data.tar.gz: 02b00a0ed7815186816adb92740dc185755f8c96
2
+ SHA256:
3
+ metadata.gz: 32ee65ba1a116c08b27670f7927808870566b835f04f2e6306635feeab013d52
4
+ data.tar.gz: e92c052e3d395c0b9fe6ca3337a8815eb752b7db09805597988f1eabf02bc40e
5
5
  SHA512:
6
- metadata.gz: 2b5821d76557b12c224d9105d58d4ab68b44a53db9219bb82de0e79a2c6bcc5960d61467f6c9561b31e8f668a1a5e70ca278051fa6b1473f243c1e82e0ae9abe
7
- data.tar.gz: 04f8089e22e46c36193f6131166b9af599ba272d813fd67cbaf65ce5325c37d90731e0911dccc8e45a4afc4e18c9a882127eb791b8a517b903c8db92957aeda5
6
+ metadata.gz: 32b9663ca870b8a92a8abad9fe6e4cc1d3367821a08c4f9d78888e0e52444cb9469844148c2ba1de364b4022d70186dbbb3ef3ea264093a6c4980e7e26cb4b99
7
+ data.tar.gz: 5f2041e1f9b46900bad242431ce1a686dd8919657f0a9810c7256e93986dd7cec36f8506ebbc1a1261fb372ab56bcb230ee2645dfbe35134f7c88c5dec0b7589
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This module helps to get rid of the now deprecated
4
+ # [ruby-sass](https://github.com/sass/ruby-sass).
5
+ #
6
+ # Some modules used in jekyll depend on the function `Sass.load_paths`
7
+ # from ruby-sass. (see for example `Jekyll::Theme.configure_sass`).
8
+ #
9
+ # This module provides a workaround when ruby-sass is not installed
10
+ # by faking this functionality...
11
+ #
12
+ # Please note that this module should never be installed __together__ with ruby-sass.
13
+ module Sass
14
+ # The global load paths for Sass files. This is meant for plugins and libraries to register
15
+ # the paths to their Sass stylesheets to that they may be `@imported`. This load path is used
16
+ # by every instance of {Sass::Engine}.
17
+ # They are lower-precedence than any load paths passed in via the
18
+ # {file:SASS_REFERENCE.md#load_paths-option `:load_paths` option}.
19
+ #
20
+ # If the `SASS_PATH` environment variable is set, the initial value of `load_paths` will be
21
+ # initialized based on that. The variable should be a colon-separated list of path names
22
+ # (semicolon-separated on Windows).
23
+ #
24
+ # Note that files on the global load path are never compiled to CSS themselves, even if they
25
+ # aren't partials. They exist only to be imported.
26
+ #
27
+ # @example
28
+ # Sass.load_paths << File.dirname(__FILE__ + '/sass')
29
+ # @return [Array<String, Pathname, Sass::Importers::Base>]
30
+ def self.load_paths
31
+ @load_paths ||= ENV["SASS_PATH"].to_s.split(File::PATH_SEPARATOR)
32
+ end
33
+ end
@@ -1,4 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fake-sass"
1
4
  require "jekyll-sass-converter/version"
5
+ require "jekyll/converters/scss"
2
6
  require "jekyll/converters/sass"
3
7
 
4
8
  module JekyllSassConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module JekyllSassConverter
2
- VERSION = "1.0.0.rc4"
4
+ VERSION = "2.0.0.pre.beta"
3
5
  end
@@ -1,66 +1,19 @@
1
- require 'sass'
2
- require 'jekyll/utils'
1
+ # frozen_string_literal: true
2
+
3
+ require "sassc"
4
+ require "jekyll/utils"
5
+ require "jekyll/converters/scss"
3
6
 
4
7
  module Jekyll
5
8
  module Converters
6
- class Sass < Converter
9
+ class Sass < Scss
10
+ EXTENSION_PATTERN = %r!^\.sass$!i.freeze
11
+
7
12
  safe true
8
13
  priority :low
9
14
 
10
- def matches(ext)
11
- ext =~ /^\.s(a|c)ss$/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_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))
15
+ def syntax
16
+ :sass
64
17
  end
65
18
  end
66
19
  end
@@ -0,0 +1,286 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "sassc"
4
+ require "jekyll/utils"
5
+ require "jekyll/source_map_page"
6
+
7
+ module Jekyll
8
+ module Converters
9
+ class Scss < Converter
10
+ BYTE_ORDER_MARK = %r!^\xEF\xBB\xBF!.freeze
11
+ EXTENSION_PATTERN = %r!^\.scss$!i.freeze
12
+
13
+ SyntaxError = Class.new(ArgumentError)
14
+
15
+ safe true
16
+ priority :low
17
+
18
+ # This hook is triggered just before the method {#convert(content)} is executed, it
19
+ # associates the Scss (and Sass) converters with their respective sass_page objects.
20
+ Jekyll::Hooks.register :pages, :pre_render do |page|
21
+ page.converters.each do |converter|
22
+ converter.associate_page(page) if converter.is_a?(Jekyll::Converters::Scss)
23
+ end
24
+ end
25
+
26
+ # This hook is triggered just after the method {#convert(content)} has been executed, it
27
+ # dissociates the Scss (and Sass) converters with their respective sass_page objects.
28
+ Jekyll::Hooks.register :pages, :post_render do |page|
29
+ page.converters.each do |converter|
30
+ converter.dissociate_page(page) if converter.is_a?(Jekyll::Converters::Scss)
31
+ end
32
+ end
33
+
34
+ ALLOWED_STYLES = %w(nested expanded compact compressed).freeze
35
+
36
+ # Associate this Converter with the "page" object that manages input and output files for
37
+ # this converter.
38
+ #
39
+ # Note: changing the associated sass_page during the live time of this Converter instance
40
+ # may result in inconsistent results.
41
+ #
42
+ # @param [Jekyll:Page] page The sass_page for which this object acts as converter.
43
+ def associate_page(page)
44
+ if @sass_page
45
+ Jekyll.logger.debug "Sass Converter:",
46
+ "sass_page re-assigned: #{@sass_page.name} to #{page.name}"
47
+ dissociate_page(page)
48
+ return
49
+ end
50
+ @sass_page = page
51
+ end
52
+
53
+ # Dissociate this Converter with the "page" object.
54
+ #
55
+ # @param [Jekyll:Page] page The sass_page for which this object has acted as a converter.
56
+ def dissociate_page(page)
57
+ unless page.equal?(@sass_page)
58
+ Jekyll.logger.debug "Sass Converter:",
59
+ "dissociating a page that was never associated #{page.name}"
60
+ end
61
+
62
+ @source_map_page = nil
63
+ @sass_page = nil
64
+ @site = nil
65
+ end
66
+
67
+ def matches(ext)
68
+ ext =~ self.class::EXTENSION_PATTERN
69
+ end
70
+
71
+ def output_ext(_ext)
72
+ ".css"
73
+ end
74
+
75
+ def safe?
76
+ !!@config["safe"]
77
+ end
78
+
79
+ def jekyll_sass_configuration
80
+ @jekyll_sass_configuration ||= begin
81
+ options = @config["sass"] || {}
82
+ unless options["style"].nil?
83
+ options["style"] = options["style"].to_s.gsub(%r!\A:!, "").to_sym
84
+ end
85
+ options
86
+ end
87
+ end
88
+
89
+ def sass_build_configuration_options(overrides)
90
+ if safe?
91
+ overrides
92
+ else
93
+ Jekyll::Utils.symbolize_hash_keys(
94
+ Jekyll::Utils.deep_merge_hashes(
95
+ jekyll_sass_configuration,
96
+ overrides
97
+ )
98
+ )
99
+ end
100
+ end
101
+
102
+ def syntax
103
+ :scss
104
+ end
105
+
106
+ def sass_dir
107
+ return "_sass" if jekyll_sass_configuration["sass_dir"].to_s.empty?
108
+
109
+ jekyll_sass_configuration["sass_dir"]
110
+ end
111
+
112
+ def sass_style
113
+ style = jekyll_sass_configuration.fetch("style", :compact)
114
+ ALLOWED_STYLES.include?(style.to_s) ? style.to_sym : :compact
115
+ end
116
+
117
+ def user_sass_load_paths
118
+ Array(jekyll_sass_configuration["load_paths"])
119
+ end
120
+
121
+ def sass_dir_relative_to_site_source
122
+ Jekyll.sanitized_path(site_source, sass_dir)
123
+ end
124
+
125
+ # rubocop:disable Metrics/AbcSize
126
+ def sass_load_paths
127
+ paths = user_sass_load_paths +
128
+ [sass_dir_relative_to_site_source] +
129
+ Array(::Sass.load_paths)
130
+ paths << site.theme.sass_path if site.theme&.sass_path
131
+
132
+ if safe?
133
+ # Sanitize paths to prevent any attack vectors (.e.g. `/**/*`)
134
+ paths.map! { |path| Jekyll.sanitized_path(site_source, path) }
135
+ end
136
+
137
+ # Expand file globs (e.g. `node_modules/*/node_modules` )
138
+ Dir.chdir(site_source) do
139
+ paths = paths.map { |path| Dir.glob(path) }.flatten.uniq
140
+
141
+ paths.map! do |path|
142
+ if safe?
143
+ # Sanitize again in case globbing was able to do something crazy.
144
+ Jekyll.sanitized_path(site_source, path)
145
+ else
146
+ File.expand_path(path)
147
+ end
148
+ end
149
+ end
150
+
151
+ paths.select { |path| File.directory?(path) }
152
+ end
153
+ # rubocop:enable Metrics/AbcSize
154
+
155
+ def allow_caching?
156
+ !safe?
157
+ end
158
+
159
+ def add_charset?
160
+ !!jekyll_sass_configuration["add_charset"]
161
+ end
162
+
163
+ def sass_configs
164
+ sass_build_configuration_options(
165
+ :style => sass_style,
166
+ :syntax => syntax,
167
+ :filename => filename,
168
+ :output_path => output_path,
169
+ :source_map_file => source_map_file,
170
+ :load_paths => sass_load_paths,
171
+ :omit_source_map_url => !sourcemap_required?,
172
+ :source_map_contents => true,
173
+ :line_comments_option => line_comments_option
174
+ )
175
+ end
176
+
177
+ def convert(content)
178
+ config = sass_configs
179
+ engine = SassC::Engine.new(content.dup, config)
180
+ output = engine.render
181
+ generate_source_map(engine) if sourcemap_required?
182
+ replacement = add_charset? ? '@charset "UTF-8";' : ""
183
+ output.sub(BYTE_ORDER_MARK, replacement)
184
+ rescue SassC::SyntaxError => e
185
+ raise SyntaxError, e.to_s
186
+ end
187
+
188
+ private
189
+
190
+ # The Page instance for which this object acts as a converter.
191
+ attr_reader :sass_page
192
+
193
+ def associate_page_failed?
194
+ !sass_page
195
+ end
196
+
197
+ # The name of the input scss (or sass) file. This information will be used for error
198
+ # reporting and will written into the source map file as main source.
199
+ #
200
+ # Returns the name of the input file or "stdin" if #associate_page failed
201
+ def filename
202
+ return "stdin" if associate_page_failed?
203
+
204
+ sass_page.name
205
+ end
206
+
207
+ # The value of the `line_comments` option.
208
+ # When set to `true` causes the line number and filename of the source be emitted into the
209
+ # compiled CSS-file. Useful for debugging when the source-map is not available.
210
+ #
211
+ # Returns the value of the `line_comments`-option chosen by the user or 'false' by default.
212
+ def line_comments_option
213
+ jekyll_sass_configuration.fetch("line_comments", false)
214
+ end
215
+
216
+ # The value of the `sourcemap` option chosen by the user.
217
+ #
218
+ # This option controls when sourcemaps shall be generated or not.
219
+ #
220
+ # Returns the value of the `sourcemap`-option chosen by the user or ':always' by default.
221
+ def sourcemap_option
222
+ jekyll_sass_configuration.fetch("sourcemap", :always).to_sym
223
+ end
224
+
225
+ # Determines whether a sourcemap shall be generated or not.
226
+ #
227
+ # Returns `true` if a sourcemap shall be generated, `false` otherwise.
228
+ def sourcemap_required?
229
+ return false if associate_page_failed? || sourcemap_option == :never
230
+ return true if sourcemap_option == :always
231
+
232
+ !(sourcemap_option == :development && Jekyll.env != "development")
233
+ end
234
+
235
+ # The name of the generated css file. This information will be written into the source map
236
+ # file as a backward reference to the input.
237
+ #
238
+ # Returns the name of the css file or "stdin.css" if #associate_page failed
239
+ def output_path
240
+ return "stdin.css" if associate_page_failed?
241
+
242
+ sass_page.basename + ".css"
243
+ end
244
+
245
+ # The name of the generated source map file. This information will be written into the
246
+ # css file to reference to the source map.
247
+ #
248
+ # Returns the name of the css file or "" if #associate_page failed
249
+ def source_map_file
250
+ return "" if associate_page_failed?
251
+
252
+ sass_page.basename + ".css.map"
253
+ end
254
+
255
+ def source_map_page
256
+ return if associate_page_failed?
257
+
258
+ @source_map_page ||= SourceMapPage.new(sass_page)
259
+ end
260
+
261
+ # Reads the source-map from the engine and adds it to the source-map-page.
262
+ #
263
+ # @param [::SassC::Engine] engine The sass Compiler engine.
264
+ def generate_source_map(engine)
265
+ return if associate_page_failed?
266
+
267
+ source_map_page.source_map(engine.source_map)
268
+ site.pages << source_map_page
269
+ rescue ::SassC::NotRenderedError => e
270
+ Jekyll.logger.warn "Could not generate source map #{e.message} => #{e.cause}"
271
+ end
272
+
273
+ def site
274
+ if associate_page_failed?
275
+ Jekyll.sites.last
276
+ else
277
+ sass_page.site
278
+ end
279
+ end
280
+
281
+ def site_source
282
+ site.source
283
+ end
284
+ end
285
+ end
286
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ # A Jekyll::Page subclass to manage the source map file associated with
5
+ # a given scss / sass page.
6
+ class SourceMapPage < Page
7
+ # Initialize a new SourceMapPage.
8
+ #
9
+ # @param [Jekyll::Page] css_page The Page object that manages the css file.
10
+ def initialize(css_page)
11
+ @site = css_page.site
12
+ @dir = css_page.dir
13
+ @data = css_page.data
14
+ @name = css_page.basename + ".css.map"
15
+
16
+ process(@name)
17
+ Jekyll::Hooks.trigger :pages, :post_init, self
18
+ end
19
+
20
+ def source_map(map)
21
+ self.content = map
22
+ end
23
+
24
+ def ext
25
+ ".map"
26
+ end
27
+
28
+ def asset_file?
29
+ true
30
+ end
31
+
32
+ # @return[String] the object as a debug String.
33
+ def inspect
34
+ "#<#{self.class} @name=#{name.inspect}>"
35
+ end
36
+ end
37
+ end
metadata CHANGED
@@ -1,43 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-sass-converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc4
4
+ version: 2.0.0.pre.beta
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-04-27 00:00:00.000000000 Z
11
+ date: 2019-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: sass
14
+ name: sassc
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.2'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jekyll
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '1.5'
47
+ version: '3.0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '1.5'
54
+ version: '3.0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +80,20 @@ dependencies:
66
80
  - - ">="
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-jekyll
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.4'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.4'
69
97
  description:
70
98
  email:
71
99
  - parkrmoore@gmail.com
@@ -73,27 +101,12 @@ executables: []
73
101
  extensions: []
74
102
  extra_rdoc_files: []
75
103
  files:
76
- - ".gitignore"
77
- - ".rspec"
78
- - ".travis.yml"
79
- - Gemfile
80
- - History.markdown
81
- - LICENSE.txt
82
- - README.md
83
- - Rakefile
84
- - jekyll-sass-converter.gemspec
104
+ - lib/fake-sass.rb
85
105
  - lib/jekyll-sass-converter.rb
86
106
  - lib/jekyll-sass-converter/version.rb
87
107
  - lib/jekyll/converters/sass.rb
88
- - script/bootstrap
89
- - script/cibuild
90
- - script/release
91
- - spec/dest/css/main.css
92
- - spec/sass_coverter_spec.rb
93
- - spec/source/_config.yml
94
- - spec/source/_sass/_grid.scss
95
- - spec/source/css/main.scss
96
- - spec/spec_helper.rb
108
+ - lib/jekyll/converters/scss.rb
109
+ - lib/jekyll/source_map_page.rb
97
110
  homepage: https://github.com/jekyll/jekyll-sass-converter
98
111
  licenses:
99
112
  - MIT
@@ -106,22 +119,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
119
  requirements:
107
120
  - - ">="
108
121
  - !ruby/object:Gem::Version
109
- version: '0'
122
+ version: 2.4.0
110
123
  required_rubygems_version: !ruby/object:Gem::Requirement
111
124
  requirements:
112
125
  - - ">"
113
126
  - !ruby/object:Gem::Version
114
127
  version: 1.3.1
115
128
  requirements: []
116
- rubyforge_project:
117
- rubygems_version: 2.2.2
129
+ rubygems_version: 3.0.4
118
130
  signing_key:
119
131
  specification_version: 4
120
132
  summary: A basic Sass converter for Jekyll.
121
- test_files:
122
- - spec/dest/css/main.css
123
- - spec/sass_coverter_spec.rb
124
- - spec/source/_config.yml
125
- - spec/source/_sass/_grid.scss
126
- - spec/source/css/main.scss
127
- - spec/spec_helper.rb
133
+ test_files: []
data/.gitignore DELETED
@@ -1,18 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .sass-cache
6
- .yardoc
7
- Gemfile.lock
8
- InstalledFiles
9
- _yardoc
10
- coverage
11
- doc/
12
- lib/bundler/man
13
- pkg
14
- rdoc
15
- spec/reports
16
- test/tmp
17
- test/version_tmp
18
- tmp
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --format progress
@@ -1,8 +0,0 @@
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/Gemfile DELETED
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in jekyll-sass-converter.gemspec
4
- gemspec
5
-
6
- gem "jekyll", "2.0.0.alpha.2"
7
- gem "rouge"
@@ -1,5 +0,0 @@
1
- ## HEAD
2
-
3
- * Birthday!
4
- * Don't use core extensions (#2)
5
- * Allow users to set style of outputted CSS (#4)
@@ -1,22 +0,0 @@
1
- Copyright (c) 2014 Parker Moore
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 DELETED
@@ -1,36 +0,0 @@
1
- # Jekyll Sass Converter
2
-
3
- Let Jekyll build your Sass and SCSS!
4
-
5
- [![Build Status](https://travis-ci.org/jekyll/jekyll-sass-converter.svg?branch=master)](https://travis-ci.org/jekyll/jekyll-sass-converter)
6
-
7
- ## Installation
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
-
12
- Add this line to your application's Gemfile:
13
-
14
- gem 'jekyll-sass-converter'
15
-
16
- And then execute:
17
-
18
- $ bundle
19
-
20
- Or install it yourself as:
21
-
22
- $ gem install jekyll-sass-converter
23
-
24
- ## Usage
25
-
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/).
29
-
30
- ## Contributing
31
-
32
- 1. Fork it ( http://github.com/jekyll/jekyll-sass-converter/fork )
33
- 2. Create your feature branch (`git checkout -b my-new-feature`)
34
- 3. Commit your changes (`git commit -am 'Add some feature'`)
35
- 4. Push to the branch (`git push origin my-new-feature`)
36
- 5. Create new Pull Request
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"
@@ -1,25 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'jekyll-sass-converter/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "jekyll-sass-converter"
8
- spec.version = JekyllSassConverter::VERSION
9
- spec.authors = ["Parker Moore"]
10
- spec.email = ["parkrmoore@gmail.com"]
11
- spec.summary = %q{A basic Sass converter for Jekyll.}
12
- spec.homepage = "https://github.com/jekyll/jekyll-sass-converter"
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_runtime_dependency "sass", "~> 3.2"
21
-
22
- spec.add_development_dependency "bundler", "~> 1.5"
23
- spec.add_development_dependency "rake"
24
- spec.add_development_dependency "rspec"
25
- end
@@ -1,3 +0,0 @@
1
- #! /bin/bash
2
-
3
- bundle install
@@ -1,3 +0,0 @@
1
- #! /bin/bash
2
-
3
- bundle exec rspec
File without changes
@@ -1 +0,0 @@
1
- .half{width:50%}
@@ -1,132 +0,0 @@
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 compressed(content)
31
- content.gsub(/\s+/, '').gsub(/;}/, '}') + "\n"
32
- end
33
-
34
- def converter(overrides = {})
35
- Jekyll::Converters::Sass.new(site_configuration({"sass" => overrides}))
36
- end
37
-
38
- context "matching file extensions" do
39
- it "matches .scss files" do
40
- expect(converter.matches(".scss")).to be_true
41
- end
42
-
43
- it "matches .sass files" do
44
- expect(converter.matches(".sass")).to be_true
45
- end
46
- end
47
-
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
- context "converting sass" do
103
- it "produces CSS" do
104
- expect(converter.convert(sass_content)).to eql(compressed(css_output))
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))
111
- end
112
- end
113
-
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
- end
@@ -1,3 +0,0 @@
1
- sass:
2
- style: :compressed
3
- highlighter: rouge
@@ -1 +0,0 @@
1
- .half { width: 50%; }
@@ -1,4 +0,0 @@
1
- ---
2
- ---
3
-
4
- @import "grid";
@@ -1,36 +0,0 @@
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
- Jekyll.logger.log_level = Jekyll::Stevenson::ERROR
10
-
11
- RSpec.configure do |config|
12
- config.treat_symbols_as_metadata_keys_with_true_values = true
13
- config.run_all_when_everything_filtered = true
14
- config.filter_run :focus
15
- config.order = 'random'
16
-
17
- SOURCE_DIR = File.expand_path("../source", __FILE__)
18
- DEST_DIR = File.expand_path("../dest", __FILE__)
19
- FileUtils.rm_rf(DEST_DIR)
20
- FileUtils.mkdir_p(DEST_DIR)
21
-
22
- def source_dir(*files)
23
- File.join(SOURCE_DIR, *files)
24
- end
25
-
26
- def dest_dir(*files)
27
- File.join(DEST_DIR, *files)
28
- end
29
-
30
- def site_configuration(overrides = {})
31
- Jekyll.configuration(overrides.merge({
32
- "source" => source_dir,
33
- "destination" => dest_dir
34
- }))
35
- end
36
- end