cyborg 0.5.21 → 0.5.22

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: e39111c9fef46b63f7172aa6f57774a5ce4669ae
4
- data.tar.gz: 00fa74b1ba044a4052f148ff45a29f0533ac5700
3
+ metadata.gz: 81146b5c5d42c18d82d89720c63b63ae8c03513f
4
+ data.tar.gz: 355163c3ad9d19551ba974e51f3a42345c892652
5
5
  SHA512:
6
- metadata.gz: e0bc57a862058cfa6f14b3817bde0a8a194a7a5599e657f56b3cd9629931767590fbab2e71e8c8142890f59d2ebd9c9252ed2a07fbe4199989376283ad0d04c4
7
- data.tar.gz: 3e85227a72c2764eb62977381c9f869859395a1dbb3b4d353749571decf3411554b7e5e871f3b9ad312bd458a59e90726ee049060ae7d29061003e9a03f49906
6
+ metadata.gz: a1d41793cbb1d1ad9a181c8849842b475cf2a4ddf2e0826646d18b92add2ea19ea12ef488041f8b49ee6eca382520c01b50c37ec64f15a6a456056e720a8dc5c
7
+ data.tar.gz: d1a046acbe247d15b8838d097fd618809ac903b1bdff5b2fa9924627ba277980682131b2f90552fd5fec919acfc6e8177125ad73eb3b222ced263e8c5787b490
@@ -6,6 +6,8 @@ require "cyborg/command"
6
6
  require "cyborg/version"
7
7
  require "cyborg/plugin"
8
8
  require "cyborg/assets"
9
+ require "cyborg/sass/engine"
10
+ require "cyborg/sass/importer"
9
11
 
10
12
  module Cyborg
11
13
  extend self
@@ -53,6 +53,10 @@ module Cyborg
53
53
  :href => cyborg_asset_url(source)
54
54
  }.merge!(options.symbolize_keys))
55
55
  end
56
+
57
+ def sass_data(key)
58
+ Cyborg.plugin.stylesheets.data[key]
59
+ end
56
60
  end
57
61
  end
58
62
  end
@@ -120,8 +120,8 @@ module Cyborg
120
120
  end
121
121
 
122
122
  def change(modified, added, removed)
123
- puts "Added: #{file_event(added)}".colorize(:light_green) unless added.empty?
124
- puts "Removed: #{file_event(removed)}".colorize(:light_red) unless removed.empty?
123
+ puts "Added: #{file_event(added)}".colorize(:light_green) unless added.empty?
124
+ puts "Removed: #{file_event(removed)}".colorize(:light_red) unless removed.empty?
125
125
  puts "Modified: #{file_event(modified)}".colorize(:light_yellow) unless modified.empty?
126
126
 
127
127
  build
@@ -59,6 +59,22 @@ module Cyborg
59
59
  compress(dest)
60
60
  end
61
61
 
62
+ def data
63
+ if @data
64
+ @data
65
+ else
66
+ data = {}
67
+
68
+ Dir[File.join(base, "**/*.yml")].each do |file|
69
+ key = file.sub(base+"/", '').sub(/^_/,'').sub('.yml','')
70
+ data[key] = YAML.load(IO.read(file))
71
+ end
72
+
73
+ @data = data if Cyborg.production?
74
+ data
75
+ end
76
+ end
77
+
62
78
  # Convert extension
63
79
  def versioned(file)
64
80
  super(file.sub(/(\.css)?\.s[ca]ss$/i,'.css'))
@@ -0,0 +1,19 @@
1
+ require 'cyborg/sass/importer'
2
+
3
+ # Taken from https://github.com/chriseppstein/sass-css-importer/blob/master/lib/sass/css_importer/monkey_patches.rb
4
+ # TODO: This feels wrong, surely there must be a better way to handle this
5
+
6
+ class Sass::Engine
7
+ alias initialize_without_yaml_importer initialize
8
+
9
+ def initialize(template, options={})
10
+ initialize_without_yaml_importer(template, options)
11
+
12
+ yaml_importer = self.options[:load_paths].find {|lp| lp.is_a?(Cyborg::Importer) }
13
+
14
+ unless yaml_importer
15
+ root = File.dirname(options[:filename] || ".")
16
+ self.options[:load_paths] << Cyborg::Importer.new(root)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,60 @@
1
+ require 'sass'
2
+ require 'yaml'
3
+
4
+ module Cyborg
5
+ class Importer < Sass::Importers::Filesystem
6
+
7
+ def watched_file?(uri)
8
+ !!(uri =~ /\.yml$/ &&
9
+ uri.start_with?(root + File::SEPARATOR))
10
+ end
11
+
12
+ protected
13
+
14
+ def extensions
15
+ {'yml' => :scss}
16
+ end
17
+
18
+ def yaml?(name)
19
+ File.extname(name) == '.yml'
20
+ end
21
+
22
+ private
23
+
24
+ def _find(dir, name, options)
25
+ return unless yaml? name
26
+
27
+ full_filename, syntax = Sass::Util.destructure(find_real_file(dir, name, options))
28
+ return unless full_filename && File.readable?(full_filename)
29
+
30
+ yaml = YAML.load(IO.read(full_filename))
31
+ variables = yaml.map { |key, value| "$#{key}: #{_convert_to_sass(value)};" }.join("\n")
32
+
33
+ Sass::Engine.new(variables, options.merge(
34
+ :filename => full_filename,
35
+ :importer => self,
36
+ :syntax => :scss
37
+ ))
38
+ end
39
+
40
+ def _convert_to_sass(item)
41
+ if item.is_a? Array
42
+ _make_list(item)
43
+ elsif item.is_a? Hash
44
+ _make_map(item)
45
+ else
46
+ item.to_s
47
+ end
48
+ end
49
+
50
+ def _make_list(item)
51
+ '(' + item.map { |i| _convert_to_sass(i) }.join(',') + ')'
52
+ end
53
+
54
+ def _make_map(item)
55
+ '(' + item.map {|key, value| key.to_s + ':' + _convert_to_sass(value) }.join(',') + ')'
56
+ end
57
+ end
58
+
59
+ end
60
+
@@ -1,3 +1,3 @@
1
1
  module Cyborg
2
- VERSION = "0.5.21"
2
+ VERSION = "0.5.22"
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.21
4
+ version: 0.5.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
@@ -201,6 +201,8 @@ files:
201
201
  - lib/cyborg/plugin/assets/javascripts.rb
202
202
  - lib/cyborg/plugin/assets/stylesheets.rb
203
203
  - lib/cyborg/plugin/assets/svgs.rb
204
+ - lib/cyborg/sass/engine.rb
205
+ - lib/cyborg/sass/importer.rb
204
206
  - lib/cyborg/version.rb
205
207
  homepage: https://github.com/compose-ui/cyborg
206
208
  licenses: