fangorn 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fangorn/haml.rb +26 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8fe96eca2dc1fd16a7230714e0d66a5d1f91d0b0
4
- data.tar.gz: e90793bd95d5a557f227ac2c08396ef316fb64b6
3
+ metadata.gz: 4374b0baf9be005520a143de2afda523694fdb19
4
+ data.tar.gz: 1581a98967e0973ea426e89349563b9665e55a44
5
5
  SHA512:
6
- metadata.gz: 819fa3af87082f8536d86543ec4debe7fb90fa1852a8b1aafb0d71ede4075030980bcd0ee5296ab650223654dd39f9bd69f88497d6ae67459495f320dfaab6ee
7
- data.tar.gz: 6a28920c077001c345dbc96448d81352502c6469d674758f7fe956e84a4f80e53d1f59170fbccd4d9f961c7250b7d8171bc6df0f7e15216c4c65cb56a54b0189
6
+ metadata.gz: 14a88677d289843dd33864a885e794d4ff405ea5d72346d4bf0efb78f0fdba1f76406fe1cd48acd6b068434498249e5391babe389c47a71887e4e0eb60c77efa
7
+ data.tar.gz: 365ccde62779b7f951b69a8029033486cec5ba17914a94b1566a41d9d433d57e4169001877f201194a7c448efd55d08502b241ebfeb094067f5e5f9c2e8591a6
data/lib/fangorn/haml.rb CHANGED
@@ -21,6 +21,18 @@ module Fangorn
21
21
  end
22
22
 
23
23
  def css_include(file)
24
+ copy_file file do |src, dest, css|
25
+ css.scan(/url\(["']([\w\-\.\/]+).*?["']\)/).flatten.uniq.each do |path|
26
+ reference = File.join(src, path)
27
+ if File.exists? reference
28
+ out = File.join(dest, path)
29
+ FileUtils.mkdir_p File.dirname(out)
30
+ File.open(out, 'w') do |f|
31
+ f.write File.read(reference)
32
+ end
33
+ end
34
+ end
35
+ end
24
36
  ::Haml::Engine.new("%link{ rel: 'stylesheet', type: 'text/css', href: '#{cache_update file}' }").render
25
37
  end
26
38
 
@@ -31,23 +43,30 @@ module Fangorn
31
43
  end
32
44
 
33
45
  def js_include(file)
46
+ copy_file file
47
+ ::Haml::Engine.new("%script{ src: '#{cache_update file}' }").render
48
+ end
49
+ def js_include_tree(dir)
50
+ Dir[File.join(Output::dest, dir, '**', '*.js')].sort_by(&:length).map do |file|
51
+ js_include file.sub File.join(Output::dest, ''), ''
52
+ end.join
53
+ end
54
+
55
+ def copy_file(file)
34
56
  SCRIPT_SOURCES.each do |refdir, sourcedir|
35
57
  src = file.sub /^#{refdir}\//, "#{sourcedir}/"
36
58
  if File.exists? src
37
59
  out = File.join(Output::dest, file)
38
60
  FileUtils.mkdir_p File.dirname(out)
39
61
  File.open(out, 'w') do |f|
40
- f.write File.read(src)
62
+ contents = File.read(src)
63
+ f.write contents
64
+
65
+ yield File.dirname(src), File.dirname(out), contents if block_given?
41
66
  end
42
67
  break
43
68
  end
44
69
  end
45
- ::Haml::Engine.new("%script{ src: '#{cache_update file}' }").render
46
- end
47
- def js_include_tree(dir)
48
- Dir[File.join(Output::dest, dir, '**', '*.js')].sort_by(&:length).map do |file|
49
- js_include file.sub File.join(Output::dest, ''), ''
50
- end.join
51
70
  end
52
71
 
53
72
  def cache_update(file)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fangorn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Calhoun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-01 00:00:00.000000000 Z
11
+ date: 2016-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: listen