bunto-sass-converter 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/bunto-sass-converter.rb +6 -0
- data/lib/bunto-sass-converter/version.rb +3 -0
- data/lib/bunto/converters/sass.rb +21 -0
- data/lib/bunto/converters/scss.rb +110 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a4a676949a713f5dae1edb81fc379202f708600d
|
4
|
+
data.tar.gz: 973df87db2745a8768f3e93386134ec770db52be
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 487caa451cc6df2b603915aa8406c34058ee86b05084d233181c44f58928b6185e7385b53ba294a89642d92ed22be533200bb112c16b63e3e0a1369a83f7a3e2
|
7
|
+
data.tar.gz: 18544ede9280a0900adebf5d6389826dd740d4d7f67f03a5e028566a40f2e6a3d7ff5cf2c47e61613610546f9c15a3ed57af455f71f1c7bb66d957d1170fd5ba
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'sass'
|
2
|
+
require 'bunto/utils'
|
3
|
+
require 'bunto/converters/scss'
|
4
|
+
|
5
|
+
module Bunto
|
6
|
+
module Converters
|
7
|
+
class Sass < Scss
|
8
|
+
safe true
|
9
|
+
priority :low
|
10
|
+
|
11
|
+
def matches(ext)
|
12
|
+
ext =~ /^\.sass$/i
|
13
|
+
end
|
14
|
+
|
15
|
+
def syntax
|
16
|
+
:sass
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
j
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'sass'
|
4
|
+
require 'bunto/utils'
|
5
|
+
|
6
|
+
module Bunto
|
7
|
+
module Converters
|
8
|
+
class Scss < Converter
|
9
|
+
BYTE_ORDER_MARK = /^\xEF\xBB\xBF/
|
10
|
+
SyntaxError = Class.new(ArgumentError)
|
11
|
+
|
12
|
+
safe true
|
13
|
+
priority :low
|
14
|
+
|
15
|
+
ALLOWED_STYLES = %w(nested expanded compact compressed).freeze
|
16
|
+
|
17
|
+
def matches(ext)
|
18
|
+
ext =~ /^\.scss$/i
|
19
|
+
end
|
20
|
+
|
21
|
+
def output_ext(ext)
|
22
|
+
".css"
|
23
|
+
end
|
24
|
+
|
25
|
+
def safe?
|
26
|
+
!!@config["safe"]
|
27
|
+
end
|
28
|
+
|
29
|
+
def bunto_sass_configuration
|
30
|
+
options = @config["sass"] || {}
|
31
|
+
unless options["style"].nil?
|
32
|
+
options["style"] = options["style"].to_s.gsub(/\A:/, '').to_sym
|
33
|
+
end
|
34
|
+
options
|
35
|
+
end
|
36
|
+
|
37
|
+
def sass_build_configuration_options(overrides)
|
38
|
+
if safe?
|
39
|
+
{
|
40
|
+
:load_paths => sass_load_paths,
|
41
|
+
:syntax => syntax,
|
42
|
+
:style => sass_style,
|
43
|
+
:cache => false
|
44
|
+
}
|
45
|
+
else
|
46
|
+
Bunto::Utils.symbolize_hash_keys(
|
47
|
+
Bunto::Utils.deep_merge_hashes(
|
48
|
+
bunto_sass_configuration,
|
49
|
+
overrides
|
50
|
+
)
|
51
|
+
)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def syntax
|
56
|
+
:scss
|
57
|
+
end
|
58
|
+
|
59
|
+
def sass_dir
|
60
|
+
return "_sass" if bunto_sass_configuration["sass_dir"].to_s.empty?
|
61
|
+
bunto_sass_configuration["sass_dir"]
|
62
|
+
end
|
63
|
+
|
64
|
+
def sass_style
|
65
|
+
style = bunto_sass_configuration.fetch("style", :compact)
|
66
|
+
ALLOWED_STYLES.include?(style.to_s) ? style.to_sym : :compact
|
67
|
+
end
|
68
|
+
|
69
|
+
def user_sass_load_paths
|
70
|
+
Array(bunto_sass_configuration["load_paths"])
|
71
|
+
end
|
72
|
+
|
73
|
+
def sass_dir_relative_to_site_source
|
74
|
+
Bunto.sanitized_path(@config["source"], sass_dir)
|
75
|
+
end
|
76
|
+
|
77
|
+
def sass_load_paths
|
78
|
+
if safe?
|
79
|
+
[sass_dir_relative_to_site_source]
|
80
|
+
else
|
81
|
+
(user_sass_load_paths + [sass_dir_relative_to_site_source]).uniq
|
82
|
+
end.select { |load_path| File.directory?(load_path) }
|
83
|
+
end
|
84
|
+
|
85
|
+
def allow_caching?
|
86
|
+
!safe?
|
87
|
+
end
|
88
|
+
|
89
|
+
def add_charset?
|
90
|
+
!!bunto_sass_configuration["add_charset"]
|
91
|
+
end
|
92
|
+
|
93
|
+
def sass_configs
|
94
|
+
sass_build_configuration_options({
|
95
|
+
"syntax" => syntax,
|
96
|
+
"cache" => allow_caching?,
|
97
|
+
"load_paths" => sass_load_paths
|
98
|
+
})
|
99
|
+
end
|
100
|
+
|
101
|
+
def convert(content)
|
102
|
+
output = ::Sass.compile(content, sass_configs)
|
103
|
+
replacement = add_charset? ? '@charset "UTF-8";' : ''
|
104
|
+
output.sub(BYTE_ORDER_MARK, replacement)
|
105
|
+
rescue ::Sass::SyntaxError => e
|
106
|
+
raise SyntaxError.new("#{e.to_s} on line #{e.sass_line}")
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bunto-sass-converter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Parker Moore
|
8
|
+
- Suriyaa Kudo
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-02-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: sass
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '3.4'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '3.4'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.5'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.5'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rspec
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: bunto
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '1.0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '1.0'
|
84
|
+
description:
|
85
|
+
email:
|
86
|
+
- parkrmoore@gmail.com
|
87
|
+
- SuriyaaKudoIsc@users.noreply.github.com
|
88
|
+
executables: []
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- lib/bunto-sass-converter.rb
|
93
|
+
- lib/bunto-sass-converter/version.rb
|
94
|
+
- lib/bunto/converters/sass.rb
|
95
|
+
- lib/bunto/converters/scss.rb
|
96
|
+
homepage: https://github.com/bunto/bunto-sass-converter
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.2.2
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: A basic Sass converter for Bunto.
|
120
|
+
test_files: []
|