jekyll-compass 0.2.2 → 0.2.3
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/compass_file.rb +6 -0
- data/lib/jekyll/compass/generator.rb +101 -9
- data/lib/jekyll/compass.rb +17 -1
- data/lib/jekyll-compass.rb +3 -2
- metadata +3 -3
- data/lib/jekyll/compass/core_ext.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc734c3951787df164f485ec108768f42e63455e
|
4
|
+
data.tar.gz: a1d70d24c2c9cd71cf8a490a7c94010a8ea75ca7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17f2e9358d732a149e6d4bd3031007fc01edd67470244816b78a0f7fde16f181e1920b7761cd19e4fb1a3476ede481c7acffa312051d3c1896a0f6192726ed35
|
7
|
+
data.tar.gz: 9863583fe8ffb6d13e628563e6151da9614a4029edaf2bccd249ba077506e75fb856727430288d9c497939d834e1593cf6bab8b9b76a987a950b6ef5b453b030
|
@@ -1,7 +1,13 @@
|
|
1
1
|
|
2
2
|
module Jekyll
|
3
3
|
module Compass
|
4
|
+
# This seemed to be necessary at the time, however I'm not sure now if it
|
5
|
+
# is or not. (very) minor performance boost.
|
4
6
|
class CompassFile < StaticFile
|
7
|
+
# Write the static file. Since this class is used to represent files that
|
8
|
+
# are purely conceptual we short-circuit to the inevitable failure.
|
9
|
+
#
|
10
|
+
# @return [boolean] false
|
5
11
|
def write(destination)
|
6
12
|
# Short-circuit to the inevitable
|
7
13
|
false
|
@@ -6,10 +6,20 @@ require 'fileutils'
|
|
6
6
|
|
7
7
|
module Jekyll
|
8
8
|
module Compass
|
9
|
+
# This is the main generator plugin for Jekyll. Jekyll finds these plugins
|
10
|
+
# itself, we just need to be setup by the user as a gem plugin for their
|
11
|
+
# website. The plugin will only do something if there is a `_sass` folder
|
12
|
+
# in the source folder of the Jekyll website.
|
9
13
|
class Generator < ::Jekyll::Generator
|
10
14
|
safe true
|
11
15
|
priority :high
|
12
16
|
|
17
|
+
# This is the entry point to our plugin from Jekyll. We setup a compass
|
18
|
+
# environment and force a full compilation directly into the Jekyll output
|
19
|
+
# folder.
|
20
|
+
#
|
21
|
+
# @param site [Jekyll::Site] The site to generate for
|
22
|
+
# @return [void]
|
13
23
|
def generate(site)
|
14
24
|
@site = site
|
15
25
|
input_directory = File.join(@site.source, '_sass')
|
@@ -17,15 +27,27 @@ module Jekyll
|
|
17
27
|
return unless File.exist? input_directory
|
18
28
|
puts
|
19
29
|
|
20
|
-
config = configuration(
|
30
|
+
config = configuration(
|
31
|
+
@site.source,
|
32
|
+
input_directory,
|
33
|
+
File.join(@site.config['destination'], 'css')
|
34
|
+
)
|
21
35
|
configure_compass(config)
|
22
36
|
|
23
|
-
::Compass::Commands::UpdateProject.new(site.config['source'], config).
|
37
|
+
::Compass::Commands::UpdateProject.new(site.config['source'], config).
|
38
|
+
execute
|
24
39
|
nil
|
25
40
|
end
|
26
41
|
|
27
42
|
private
|
28
43
|
|
44
|
+
# Compile a configuration Hash from sane defaults mixed with user input
|
45
|
+
# from `_config.yml` as well as `_data/compass.yml`.
|
46
|
+
#
|
47
|
+
# @param source [String] The project source folder
|
48
|
+
# @param input_directory [String] The folder containing the Sass files
|
49
|
+
# @param output_directory [String] The folder to output CSS files to
|
50
|
+
# @return [Hash]
|
29
51
|
def configuration(source, input_directory, output_directory)
|
30
52
|
config = {
|
31
53
|
:project_path => source,
|
@@ -40,30 +62,68 @@ module Jekyll
|
|
40
62
|
}
|
41
63
|
|
42
64
|
user_config = @site.config['compass']
|
43
|
-
config
|
65
|
+
config = deep_merge!(config, symbolize_keys(user_config)) if user_config
|
44
66
|
user_data = @site.data['compass']
|
45
|
-
config
|
67
|
+
config = deep_merge!(config, symbolize_keys(user_data)) if user_data
|
46
68
|
|
47
69
|
config
|
48
70
|
end
|
49
71
|
|
72
|
+
# Sets up event handlers with Compass and various other
|
73
|
+
# configuration setup needs
|
74
|
+
#
|
75
|
+
# @param config [Hash] Configuration to pass to Compass and Sass
|
76
|
+
# @return [void]
|
50
77
|
def configure_compass(config)
|
51
78
|
::Compass.add_configuration(config, 'Jekyll::Compass')
|
52
79
|
|
53
|
-
::Compass.configuration.on_stylesheet_saved
|
54
|
-
|
55
|
-
|
80
|
+
::Compass.configuration.on_stylesheet_saved(
|
81
|
+
&method(:on_stylesheet_saved)
|
82
|
+
)
|
83
|
+
::Compass.configuration.on_sprite_saved(
|
84
|
+
&method(:on_sprite_saved)
|
85
|
+
)
|
86
|
+
::Compass.configuration.on_sprite_removed(
|
87
|
+
&method(:on_sprite_removed)
|
88
|
+
)
|
89
|
+
nil
|
56
90
|
end
|
57
91
|
|
92
|
+
# Event handler triggered when Compass creates a new stylesheet
|
93
|
+
#
|
94
|
+
# @param filename [String] The name of the created stylesheet.
|
95
|
+
# @return [void]
|
58
96
|
def on_stylesheet_saved(filename)
|
59
97
|
source = @site.config['destination']
|
60
|
-
@site.static_files <<
|
98
|
+
@site.static_files <<
|
99
|
+
CompassFile.new(
|
100
|
+
@site,
|
101
|
+
source,
|
102
|
+
File.dirname(filename)[source.length..-1],
|
103
|
+
File.basename(filename)
|
104
|
+
)
|
105
|
+
nil
|
61
106
|
end
|
62
107
|
|
108
|
+
# Event handler triggered when Compass creates a new sprite image
|
109
|
+
#
|
110
|
+
# @param filename [String] The name of the created image.
|
111
|
+
# @return [void]
|
63
112
|
def on_sprite_saved(filename)
|
64
|
-
@site.static_files <<
|
113
|
+
@site.static_files <<
|
114
|
+
StaticFile.new(
|
115
|
+
@site,
|
116
|
+
@site.source,
|
117
|
+
File.dirname(filename)[@site.source.length..-1],
|
118
|
+
File.basename(filename)
|
119
|
+
)
|
120
|
+
nil
|
65
121
|
end
|
66
122
|
|
123
|
+
# Event handler triggered when Compass deletes a stylesheet
|
124
|
+
#
|
125
|
+
# @param filename [String] The name of the deleted stylesheet.
|
126
|
+
# @return [void]
|
67
127
|
def on_sprite_removed(filename)
|
68
128
|
@site.static_files = @site.static_files.select do |p|
|
69
129
|
if p.path == filename
|
@@ -74,6 +134,38 @@ module Jekyll
|
|
74
134
|
true
|
75
135
|
end
|
76
136
|
end
|
137
|
+
nil
|
138
|
+
end
|
139
|
+
|
140
|
+
# Merges a target hash with another hash, recursively.
|
141
|
+
#
|
142
|
+
# @param target [Hash] The target hash
|
143
|
+
# @param merge [Hash] The hash to merge into the target
|
144
|
+
# @return [Hash] Returns the merged target
|
145
|
+
def deep_merge!(target, merge)
|
146
|
+
merge.keys.each do |key|
|
147
|
+
if merge[key].is_a? Hash and target[key].is_a? Hash
|
148
|
+
target[key] = deep_merge!(target[key], merge[key])
|
149
|
+
else
|
150
|
+
target[key] = merge[key]
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
target
|
155
|
+
end
|
156
|
+
|
157
|
+
# Turn all String keys of a hash into symbols, and return in another Hash.
|
158
|
+
#
|
159
|
+
# @param hash [Hash] The hash to convert
|
160
|
+
# @return [Hash] Returns the symbolized copy of hash.
|
161
|
+
def symbolize_keys(hash)
|
162
|
+
target = hash.dup
|
163
|
+
|
164
|
+
target.keys.each do |key|
|
165
|
+
target[(key.to_sym rescue key) || key] = target.delete(key)
|
166
|
+
end
|
167
|
+
|
168
|
+
target
|
77
169
|
end
|
78
170
|
end
|
79
171
|
end
|
data/lib/jekyll/compass.rb
CHANGED
@@ -1,4 +1,20 @@
|
|
1
1
|
|
2
|
+
# This file serves as the main entry point for the plugin. We simply include
|
3
|
+
# all the various parts of the plugin so that everything just works.
|
4
|
+
|
5
|
+
# Jekyll is the static site builder that we are making a plugin for.
|
6
|
+
#
|
7
|
+
# @see http://jekyllrb.com/
|
8
|
+
module Jekyll
|
9
|
+
# Sass is a set of extensions to CSS that allows for things like mixins
|
10
|
+
# and variables. Compass is a library of Sass functions and code for use
|
11
|
+
# with your own websites.
|
12
|
+
#
|
13
|
+
# @see http://sass-lang.com/
|
14
|
+
# @see http://compass-style.org/
|
15
|
+
module Compass
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
2
19
|
require 'jekyll/compass/compass_file'
|
3
|
-
require 'jekyll/compass/core_ext'
|
4
20
|
require 'jekyll/compass/generator'
|
data/lib/jekyll-compass.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
|
2
|
-
# This is simply a router file. We don't do anything here except require the
|
3
|
-
# This is the file that jekyll requires by default.
|
2
|
+
# This is simply a router file. We don't do anything here except require the
|
3
|
+
# *actual* file for our gem. This is the file that jekyll requires by default.
|
4
|
+
# Ideally it shouldn't exist at all.
|
4
5
|
# @see http://guides.rubygems.org/name-your-gem/
|
5
6
|
require 'jekyll/compass'
|
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.2.
|
4
|
+
version: 0.2.3
|
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-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: compass
|
@@ -47,7 +47,6 @@ extensions: []
|
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
49
|
- lib/jekyll/compass/compass_file.rb
|
50
|
-
- lib/jekyll/compass/core_ext.rb
|
51
50
|
- lib/jekyll/compass/generator.rb
|
52
51
|
- lib/jekyll/compass.rb
|
53
52
|
- lib/jekyll-compass.rb
|
@@ -78,3 +77,4 @@ signing_key:
|
|
78
77
|
specification_version: 4
|
79
78
|
summary: Jekyll generator plugin to build Compass projects during site build
|
80
79
|
test_files: []
|
80
|
+
has_rdoc:
|
@@ -1,30 +0,0 @@
|
|
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
|