cyborg 0.5.22 → 0.5.23

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: 81146b5c5d42c18d82d89720c63b63ae8c03513f
4
- data.tar.gz: 355163c3ad9d19551ba974e51f3a42345c892652
3
+ metadata.gz: f39879ff4f3fd4e28316d8e646c36b2ac90701f3
4
+ data.tar.gz: 4157d506118a428fbefae2f92ab69dc30d0c66fd
5
5
  SHA512:
6
- metadata.gz: a1d41793cbb1d1ad9a181c8849842b475cf2a4ddf2e0826646d18b92add2ea19ea12ef488041f8b49ee6eca382520c01b50c37ec64f15a6a456056e720a8dc5c
7
- data.tar.gz: d1a046acbe247d15b8838d097fd618809ac903b1bdff5b2fa9924627ba277980682131b2f90552fd5fec919acfc6e8177125ad73eb3b222ced263e8c5787b490
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
- Cyborg.plugin.stylesheets.data[key]
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
@@ -131,7 +131,7 @@ module Cyborg
131
131
  list = files.map { |f| f.sub(base+'/', '') }.join(" \n")
132
132
  list = " \n#{files}" if 1 < files.size
133
133
 
134
- list
134
+ list
135
135
  end
136
136
 
137
137
  def compress(file)
@@ -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
- data[key] = YAML.load(IO.read(file))
70
+
71
+ data[key] = SassParser.parse(file)
71
72
  end
72
73
 
73
74
  @data = data if Cyborg.production?
@@ -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 = File.dirname(options[:filename] || ".")
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
@@ -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 = YAML.load(IO.read(full_filename))
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(
@@ -1,3 +1,3 @@
1
1
  module Cyborg
2
- VERSION = "0.5.22"
2
+ VERSION = "0.5.23"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyborg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.22
4
+ version: 0.5.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis