cyborg 0.5.22 → 0.5.23
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f39879ff4f3fd4e28316d8e646c36b2ac90701f3
|
4
|
+
data.tar.gz: 4157d506118a428fbefae2f92ab69dc30d0c66fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37d029410fe756af1105607637bd13204781aefc738c70b7ceb681319f6e40df6c83f1c00400d3d9af491b6babb7b82e0163d405207781e08963d932ebcf9195
|
7
|
+
data.tar.gz: 037765fbc3c3f3a45120d1aeac7f1b002c6cb5a930f2e62078ce97dcd4240770a9d702110730bd71a30a4e8a8944fd6e962ca29367e5409c9d21b0eaf3693f58
|
@@ -54,8 +54,12 @@ module Cyborg
|
|
54
54
|
}.merge!(options.symbolize_keys))
|
55
55
|
end
|
56
56
|
|
57
|
-
def sass_data(key)
|
58
|
-
|
57
|
+
def sass_data(key=nil)
|
58
|
+
if key
|
59
|
+
Cyborg.plugin.stylesheets.data[key]
|
60
|
+
else
|
61
|
+
Cyborg.plugin.stylesheets.data
|
62
|
+
end
|
59
63
|
end
|
60
64
|
end
|
61
65
|
end
|
@@ -12,7 +12,7 @@ module Cyborg
|
|
12
12
|
def asset_tag(*args)
|
13
13
|
stylesheet_link_tag(args)
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def build(ext=nil)
|
17
17
|
files = find_files
|
18
18
|
files = files.reject {|f| !f.match(/\.#{ext}/) } if ext
|
@@ -67,7 +67,8 @@ module Cyborg
|
|
67
67
|
|
68
68
|
Dir[File.join(base, "**/*.yml")].each do |file|
|
69
69
|
key = file.sub(base+"/", '').sub(/^_/,'').sub('.yml','')
|
70
|
-
|
70
|
+
|
71
|
+
data[key] = SassParser.parse(file)
|
71
72
|
end
|
72
73
|
|
73
74
|
@data = data if Cyborg.production?
|
data/lib/cyborg/sass/engine.rb
CHANGED
@@ -12,8 +12,10 @@ class Sass::Engine
|
|
12
12
|
yaml_importer = self.options[:load_paths].find {|lp| lp.is_a?(Cyborg::Importer) }
|
13
13
|
|
14
14
|
unless yaml_importer
|
15
|
-
root
|
15
|
+
root = File.dirname(options[:filename] || ".")
|
16
|
+
plugin_root = Cyborg.plugin.stylesheets.base
|
16
17
|
self.options[:load_paths] << Cyborg::Importer.new(root)
|
18
|
+
self.options[:load_paths] << Cyborg::Importer.new(plugin_root)
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
data/lib/cyborg/sass/importer.rb
CHANGED
@@ -2,6 +2,49 @@ require 'sass'
|
|
2
2
|
require 'yaml'
|
3
3
|
|
4
4
|
module Cyborg
|
5
|
+
module SassParser
|
6
|
+
extend self
|
7
|
+
|
8
|
+
# Global vars beginning with underscore will have their children promoted to globals
|
9
|
+
# and will be assigned without the underscore
|
10
|
+
#
|
11
|
+
# For example: _colors: { yellow: '#fco' }
|
12
|
+
# becomes: colors: { yellow: '#fco'}, yellow: '#fco'
|
13
|
+
#
|
14
|
+
#
|
15
|
+
def load_yaml(data)
|
16
|
+
promote_globals YAML.load(data)
|
17
|
+
end
|
18
|
+
|
19
|
+
def read_file(file)
|
20
|
+
IO.read(file)
|
21
|
+
end
|
22
|
+
|
23
|
+
def promote_globals( data )
|
24
|
+
data.keys.select{|k| k.start_with?('_') }.each do |key|
|
25
|
+
data[key.sub(/^_/,'')] = data[key]
|
26
|
+
data = data.delete(key).merge(data)
|
27
|
+
end
|
28
|
+
|
29
|
+
data
|
30
|
+
end
|
31
|
+
|
32
|
+
def expand_vars(file)
|
33
|
+
content = read_file(file)
|
34
|
+
file_data = load_yaml(content)
|
35
|
+
|
36
|
+
content = content.gsub(/\$(?<var>\w+)/) do
|
37
|
+
file_data[$~[:var]].inspect
|
38
|
+
end
|
39
|
+
|
40
|
+
load_yaml content
|
41
|
+
end
|
42
|
+
|
43
|
+
def parse(file)
|
44
|
+
expand_vars file
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
5
48
|
class Importer < Sass::Importers::Filesystem
|
6
49
|
|
7
50
|
def watched_file?(uri)
|
@@ -27,7 +70,7 @@ module Cyborg
|
|
27
70
|
full_filename, syntax = Sass::Util.destructure(find_real_file(dir, name, options))
|
28
71
|
return unless full_filename && File.readable?(full_filename)
|
29
72
|
|
30
|
-
yaml =
|
73
|
+
yaml = SassParser.parse(full_filename)
|
31
74
|
variables = yaml.map { |key, value| "$#{key}: #{_convert_to_sass(value)};" }.join("\n")
|
32
75
|
|
33
76
|
Sass::Engine.new(variables, options.merge(
|
data/lib/cyborg/version.rb
CHANGED