jekyll-compass 0.1.1 → 0.2
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 +4 -4
- data/lib/jekyll/compass/core_ext.rb +30 -0
- data/lib/jekyll/compass.rb +50 -34
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4f08a754e0245590b9fb9cadd5185c6eebfc1d2
|
4
|
+
data.tar.gz: 01bfe21b9ff8e152de5f104d0f3056016797aa56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4891eb6b6c8fdb020c675fa0e94436722738fc39e501189bfda816b1d03511fc73621a6f2cfd587cba6e628e4112969f3f64624a06308779dd4c7b8d24517bbf
|
7
|
+
data.tar.gz: 81b74704078e9a640e23ba6c592eb7caec613a24d6c3124a0ecc3f8d0a87f2b806832d0532d87b8a7e4c396de523cbede8f430cdba8af1970ec867d697d7a81f
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class Hash
|
2
|
+
# Merges self with another hash, recursively.
|
3
|
+
#
|
4
|
+
# Returns the merged self.
|
5
|
+
def deep_merge!(hash)
|
6
|
+
hash.keys.each do |key|
|
7
|
+
if hash[key].is_a? Hash and self[key].is_a? Hash
|
8
|
+
self[key] = self[key].deep_merge!(hash[key])
|
9
|
+
next
|
10
|
+
end
|
11
|
+
|
12
|
+
self[key] = hash[key]
|
13
|
+
end
|
14
|
+
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
# Turn all String keys of into symbols, and return in other Hash.
|
19
|
+
#
|
20
|
+
# Returns the symbolized copy of self.
|
21
|
+
def symbolize_keys
|
22
|
+
target = self.dup
|
23
|
+
|
24
|
+
keys.each do |key|
|
25
|
+
self[(key.to_sym rescue key) || key] = delete(key)
|
26
|
+
end
|
27
|
+
|
28
|
+
target
|
29
|
+
end
|
30
|
+
end
|
data/lib/jekyll/compass.rb
CHANGED
@@ -4,6 +4,8 @@ require 'compass'
|
|
4
4
|
require 'compass/commands'
|
5
5
|
require 'fileutils'
|
6
6
|
|
7
|
+
require 'jekyll/compass/core_ext'
|
8
|
+
|
7
9
|
module Jekyll
|
8
10
|
class CompassFile < StaticFile
|
9
11
|
def write(destination)
|
@@ -17,54 +19,68 @@ module Jekyll
|
|
17
19
|
priority :high
|
18
20
|
|
19
21
|
def generate(site)
|
20
|
-
|
22
|
+
@site = site
|
23
|
+
input_directory = File.join(@site.source, '_sass')
|
21
24
|
|
22
|
-
return unless File.exist?
|
25
|
+
return unless File.exist? input_directory
|
23
26
|
puts
|
24
27
|
|
25
|
-
|
28
|
+
config = configuration(@site.source, input_directory, File.join(@site.config['destination'], 'css'))
|
29
|
+
configure_compass(config)
|
30
|
+
|
31
|
+
::Compass::Commands::UpdateProject.new(site.config['source'], config).execute
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
26
36
|
|
37
|
+
def configuration(source, input_directory, output_directory)
|
27
38
|
config = {
|
28
|
-
:project_path =>
|
39
|
+
:project_path => source,
|
29
40
|
:http_path => '/',
|
30
|
-
:sass_path =>
|
31
|
-
:css_path =>
|
32
|
-
:images_path => File.join(
|
33
|
-
:javascripts_path => File.join(
|
34
|
-
:line_comments => false,
|
41
|
+
:sass_path => input_directory,
|
42
|
+
:css_path => output_directory,
|
43
|
+
:images_path => File.join(source, 'images'),
|
44
|
+
:javascripts_path => File.join(source, 'js'),
|
35
45
|
:environment => :production,
|
36
46
|
:output_style => :compact,
|
37
|
-
:force => true,
|
38
|
-
#:quiet => true,
|
39
|
-
:sass_options => {
|
40
|
-
:unix_newlines => true,
|
41
|
-
},
|
42
47
|
}
|
43
48
|
|
49
|
+
user_config = @site.config['compass']
|
50
|
+
config.deep_merge!(user_config.symbolize_keys) if user_config
|
51
|
+
user_data = @site.data['compass']
|
52
|
+
config.deep_merge!(user_data.symbolize_keys) if user_data
|
53
|
+
|
54
|
+
config
|
55
|
+
end
|
56
|
+
|
57
|
+
def configure_compass(config)
|
44
58
|
::Compass.add_configuration(config, 'Jekyll::Compass')
|
45
|
-
::Compass.configuration.on_sprite_saved do |filename|
|
46
|
-
site.static_files << StaticFile.new(site, site.source, File.dirname(filename)[site.source.length..-1], File.basename(filename))
|
47
|
-
end
|
48
|
-
::Compass.configuration.on_stylesheet_saved do |filename|
|
49
|
-
source = site.config['destination']
|
50
|
-
site.static_files << CompassFile.new(site, source, File.dirname(filename)[source.length..-1], File.basename(filename))
|
51
|
-
end
|
52
59
|
|
53
|
-
|
54
|
-
::Compass.configuration.
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
::Compass.configuration.on_stylesheet_saved &method(:on_stylesheet_saved)
|
61
|
+
::Compass.configuration.on_sprite_saved &method(:on_sprite_saved)
|
62
|
+
::Compass.configuration.on_sprite_removed &method(:on_sprite_removed)
|
63
|
+
end
|
64
|
+
|
65
|
+
def on_stylesheet_saved(filename)
|
66
|
+
source = @site.config['destination']
|
67
|
+
@site.static_files << CompassFile.new(@site, source, File.dirname(filename)[source.length..-1], File.basename(filename))
|
68
|
+
end
|
69
|
+
|
70
|
+
def on_sprite_saved(filename)
|
71
|
+
@site.static_files << StaticFile.new(@site, @site.source, File.dirname(filename)[@site.source.length..-1], File.basename(filename))
|
72
|
+
end
|
73
|
+
|
74
|
+
def on_sprite_removed(filename)
|
75
|
+
@site.static_files = @site.static_files.select do |p|
|
76
|
+
if p.path == filename
|
77
|
+
sprite_output = p.destination(@site.config['destination'])
|
78
|
+
File.delete sprite_output if File.exist? sprite_output
|
79
|
+
false
|
80
|
+
else
|
81
|
+
true
|
63
82
|
end
|
64
83
|
end
|
65
|
-
|
66
|
-
::Compass::Commands::UpdateProject.new(site.config['source'], config).execute
|
67
|
-
nil
|
68
84
|
end
|
69
85
|
end
|
70
86
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-compass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Scharley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: compass
|
@@ -46,6 +46,7 @@ executables: []
|
|
46
46
|
extensions: []
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
|
+
- lib/jekyll/compass/core_ext.rb
|
49
50
|
- lib/jekyll/compass.rb
|
50
51
|
- lib/jekyll-compass.rb
|
51
52
|
- README.md
|