jekyll-compass 0.3.0 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b48486097b59cef67758554dd741e1520d1872a
4
- data.tar.gz: a9dcd89043b048a3bf01ee0180ba7ede6cc50c2c
3
+ metadata.gz: 782d2feab522ed7e13d5b7e5829eb2e12ed2fa2a
4
+ data.tar.gz: f7c2439fb383b74a63124d74d12a45987405c4dc
5
5
  SHA512:
6
- metadata.gz: ab489d313433d8c11c68db1094f214b73b4ef55025749d3e673f35760a116114fde70f6059770c71662721c679b196734994714e6cf3e65b7b21377603068f79
7
- data.tar.gz: 62bb9c6363569e5f76fe3400fef75af7298132cce56d09ae2857debf8db738034fac8dadda0cface9931ea2fc642a0f18293b54ebfbb1c2a47fb1e38ab80be44
6
+ metadata.gz: 20400ffcd9c4878b2cd83c23870d8ab5eca0020f93d6ff5d96c8d0917d1d0190b9486e700633dcd90655c2c47c4568b906e2ddb5f0774a352be91b1a1609a695
7
+ data.tar.gz: e4f7118ae47a720ebb028b32cc9560864a79fe402f91332dcfc3c9b3535c5b2c8259736c68b42460e57a26735ecfd4a53f2a166bcfdcea684e57476be0c882de
data/README.md CHANGED
@@ -11,9 +11,8 @@ jekyll-compass: Compass generator for Jekyll websites
11
11
  Synopsis
12
12
  --------
13
13
 
14
- jekyll-compass is a jekyll plugin that provides an interface between Jekyll's building commands and the Compass
15
- libraries to automatically build your Compass Sass files during a regular website build. This means your CSS files
16
- end up directly in your `_site` output folder and never need to be checked into your version control.
14
+ jekyll-compass is a plugin for both jekyll and compass that provides an bi-directional interface between the two
15
+ applications, tightly integrating them and allowing each to work well when used directly.
17
16
 
18
17
  Installation
19
18
  ------------
@@ -32,14 +31,32 @@ This plugin has a very simple two step install:
32
31
  Usage
33
32
  -----
34
33
 
35
- Simply setup your SASS files in the `_sass` folder in your websites root folder. Then run `jekyll build` and watch the
36
- magic.
34
+ You may use compass to generate a layout and configuration for you. The site root is the folder where your `_config.yml`
35
+ lives.
36
+
37
+ compass create -r jekyll-compass --app=jekyll path/to/site/root
38
+
39
+ Other `compass` commands will work as per usual, however you will need to add the `-r jekyll-compass --app=jekyll`
40
+ parameters to make sure `compass` can find the files from this plugin that it needs. If you forget these parameters
41
+ then Compass will fail with an error message as it won't understand the project layout.
42
+
43
+ # Compiles all your Sass/Compass into the _site folder, you may also specify --css-path on the command line
44
+ compass compile -r jekyll-compass --app=jekyll
45
+ compass watch -r jekyll-compass --app=jekyll
46
+
47
+ You will also note that Compass will build your Sass files whenever jekyll builds the rest of your website, ensuring
48
+ that what you publish is always up to date.
49
+
50
+ # Compiles your entire website, including Sass/Compass
51
+ jekyll build
52
+ jekyll serve
37
53
 
38
54
  Configuration
39
55
  -------------
40
56
 
41
57
  You may add a file to your `_data` folder called `compass.yml`. This will contain overrides for the compass
42
- configuration, similar to the `config.rb` in a regular compass project. Any of the
58
+ configuration, similar to the `config.rb` in a regular compass project. If you generated a layout using compass above
59
+ then this file will already exist with some default settings setup for you. Any of the
43
60
  [regular configuration properties][compass-props] should be supported via the YAML file.
44
61
 
45
62
  Compass also provides a way to pass through options directly to Sass via the `sass_options` option. You can find
@@ -16,5 +16,13 @@ module Jekyll
16
16
  end
17
17
  end
18
18
 
19
- require 'jekyll/compass/compass_file'
20
- require 'jekyll/compass/generator'
19
+ # Require dependencies
20
+ require 'jekyll'
21
+ require 'sass/plugin'
22
+ require 'compass'
23
+ require 'compass/commands'
24
+
25
+ # Internal requires
26
+ %w{compass_configuration compass_file generator compass_app_integration}.each do |f|
27
+ require "jekyll/compass/#{f}"
28
+ end
@@ -0,0 +1,29 @@
1
+ require 'compass/app_integration'
2
+ require 'jekyll/compass/compass_installer'
3
+
4
+ module Jekyll
5
+ module Compass
6
+ # Integration class to manage a new project type in Compass
7
+ class CompassAppIntegration
8
+ def self.installer(*args)
9
+ CompassInstaller.new(*args)
10
+ end
11
+
12
+ def self.configuration
13
+ project_path = ::Compass.configuration.project_path
14
+ config_file = File.join(project_path, '_data/compass.yml')
15
+ if File.exist? config_file
16
+ config = CompassConfiguration.from_yaml_file config_file
17
+ config[:css_dir] = "_site/#{config[:css_dir]}"
18
+ else
19
+ config = CompassConfiguration.default_configuration
20
+ end
21
+ config[:config_file] = config_file
22
+ config.to_compass
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ # Register our project type with compass
29
+ ::Compass::AppIntegration.register(:jekyll, 'Jekyll::Compass::CompassAppIntegration')
@@ -0,0 +1,81 @@
1
+ require 'yaml'
2
+
3
+ module Jekyll
4
+ module Compass
5
+ # Abstracts Compass's configuration away from any particular process in our plugin
6
+ class CompassConfiguration
7
+ CONFIGURATION_NAME = 'Jekyll::Compass'
8
+
9
+ def extend(hash)
10
+ hash.each do |key, value|
11
+ self[key] = value
12
+ end
13
+ end
14
+
15
+ def delete(key)
16
+ @data.delete(key)
17
+ end
18
+
19
+ def has_key?(key)
20
+ @data.has_key?(key)
21
+ end
22
+
23
+ def []=(key, value)
24
+ key = key.to_sym unless key.is_a? Symbol
25
+ value = value.to_sym if SYMBOL_VALUES.include? key
26
+
27
+ if value.is_a? Hash
28
+ value.each do |subkey, subvalue|
29
+ subkey = subkey.to_sym unless subkey.is_a? Symbol
30
+ @data[key][subkey] = subvalue
31
+ end
32
+ end
33
+
34
+ @data[key] = value
35
+ end
36
+
37
+ def [](key)
38
+ @data[key]
39
+ end
40
+
41
+ def to_compass
42
+ ::Compass::Configuration::Data.new(CONFIGURATION_NAME, @data)
43
+ end
44
+
45
+ private
46
+
47
+ SYMBOL_VALUES = [
48
+ :project_type,
49
+ :environment,
50
+ :output_style,
51
+ :preferred_syntax,
52
+ :sprite_engine,
53
+ ]
54
+
55
+ def initialize(initial_hash = {})
56
+ @data = initial_hash
57
+ end
58
+
59
+ class << self
60
+ def default_configuration
61
+ new({
62
+ :default_project_type => :jekyll,
63
+ :http_path => '/',
64
+ :sass_dir => '_sass',
65
+ :css_dir => 'css',
66
+ :images_dir => 'images',
67
+ :javascripts_dir => 'javascripts',
68
+ })
69
+ end
70
+
71
+ def from_yaml_file(filename)
72
+ config = default_configuration
73
+ YAML.load_file(filename).each do |k, v|
74
+ config[k.to_sym] = v
75
+ end
76
+ config
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -14,4 +14,4 @@ module Jekyll
14
14
  end
15
15
  end
16
16
  end
17
- end
17
+ end
@@ -0,0 +1,91 @@
1
+ require 'compass/installers'
2
+ require 'yaml'
3
+
4
+ module Jekyll
5
+ module Compass
6
+ #
7
+ class CompassInstaller < ::Compass::AppIntegration::StandAlone::Installer
8
+ def write_configuration_files(config_file = nil)
9
+ config_file ||= targetize('_data/compass.yml')
10
+ unless File.exists? File.dirname(config_file)
11
+ directory File.dirname(config_file)
12
+ end
13
+ write_file config_file, config_contents
14
+ end
15
+
16
+ def config_files_exist?
17
+ File.exists? targetize('_data/compass.yml')
18
+ end
19
+
20
+ def config_contents
21
+ config = ::Compass.configuration
22
+ contents = {}
23
+
24
+ required = (config.required_libraries.to_a || [])
25
+ load = (config.loaded_frameworks.to_a || [])
26
+ discover = (config.framework_path.to_a || [])
27
+
28
+ contents['require'] = required if required.any?
29
+ contents['load'] = load if load.any?
30
+ contents['discover'] = discover if discover.any?
31
+
32
+ (::Compass::Configuration::ATTRIBUTES + ::Compass::Configuration::ARRAY_ATTRIBUTES).each do |prop|
33
+ process_property(config, prop, contents)
34
+ end
35
+
36
+ contents.to_yaml
37
+ end
38
+
39
+ def finalize(options = {})
40
+ if options[:create] && !manifest.welcome_message_options[:replace]
41
+ puts <<-NEXTSTEPS
42
+
43
+ *********************************************************************
44
+ Congratulations! Your jekyll-compass project has been created.
45
+
46
+ Don't forget to add jekyll-compass to the list of gem plugins in _config.yml.
47
+
48
+ You may now add and edit Sass stylesheets in the #{::Compass.configuration.sass_dir} subdirectory of your project.
49
+
50
+ Sass files beginning with an underscore are called partials and won't be
51
+ compiled to CSS, but they can be imported into other sass stylesheets.
52
+
53
+ You can configure your project by editing the _data/compass.yml configuration file.
54
+
55
+ You must compile your Sass stylesheets into CSS when they change.
56
+ This can be done in one of the following ways:
57
+ 1. To compile on demand:
58
+ compass compile --app=jekyll -r jekyll-compass (just compile your Sass)
59
+ jekyll build (compile your entire website, including Sass)
60
+ 2. To monitor your project for changes and automatically recompile:
61
+ compass watch --app=jekyll -r jekyll-compass (just watches your Sass)
62
+
63
+ More Resources:
64
+ * Website: http://compass-style.org/
65
+ * Sass: http://sass-lang.com
66
+ * Community: http://groups.google.com/group/compass-users/
67
+ * Jekyll: http://jekyllrb.com/
68
+ * jekyll-compass: https://github.com/mscharley/jekyll-compass
69
+ NEXTSTEPS
70
+ end
71
+ puts manifest.welcome_message if manifest.welcome_message
72
+ end
73
+
74
+ def process_property(config, prop, contents)
75
+ value = config.send("#{prop}_without_default")
76
+ if value.is_a?(Proc)
77
+ $stderr.puts "WARNING: #{prop} is code and cannot be written to a file. You'll need to copy it yourself."
78
+ return
79
+ end
80
+ return if [:project_path, :project_type].include? prop
81
+ return if value.nil?
82
+
83
+ if value.is_a? Symbol
84
+ contents[prop.to_s] = value.to_s
85
+ else
86
+ contents[prop.to_s] = value
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -1,7 +1,3 @@
1
-
2
- require 'sass/plugin'
3
- require 'compass'
4
- require 'compass/commands'
5
1
  require 'fileutils'
6
2
 
7
3
  module Jekyll
@@ -24,16 +20,15 @@ module Jekyll
24
20
  @site = site
25
21
 
26
22
  config = configuration(@site.source)
27
- puts "\rGenerating Compass: #{config[:sass_path]}" +
28
- " => #{config[:css_path]}"
29
- unless File.exist? config[:sass_path]
23
+ configure_compass(config)
24
+ puts "\rGenerating Compass: #{::Compass.configuration.sass_path}" +
25
+ " => #{::Compass.configuration.css_path}"
26
+ unless File.exist? ::Compass.configuration.sass_dir
30
27
  print " Generating... "
31
28
  return
32
29
  end
33
- configure_compass(config)
34
30
 
35
- ::Compass::Commands::UpdateProject.new(site.config['source'], config).
36
- execute
31
+ ::Compass::Commands::UpdateProject.new(@site.config['source'], {:project_type => :jekyll}).execute
37
32
 
38
33
  puts
39
34
  print " Generating... "
@@ -46,61 +41,24 @@ module Jekyll
46
41
  # from `_config.yml` as well as `_data/compass.yml`.
47
42
  #
48
43
  # @param source [String] The project source folder
49
- # @return [Hash]
44
+ # @return [::Compass::Configuration::Data]
50
45
  def configuration(source)
51
- config = {
52
- :project_path => source,
53
- :http_path => '/',
54
- :sass_dir => '_sass',
55
- :css_dir => 'css',
56
- :images_path => File.join(source, 'images'),
57
- :javascripts_path => File.join(source, 'js'),
58
- :environment => :production,
59
- :force => true,
60
- }
61
-
62
- user_config = @site.config['compass']
63
- config = deep_merge!(config, symbolize_keys(user_config)) if user_config
64
- user_data = @site.data['compass']
65
- config = deep_merge!(config, symbolize_keys(user_data)) if user_data
66
-
67
- unless config.key? :sass_path
68
- config[:sass_path] =
69
- File.join(source, config[:sass_dir])
70
- end
71
- unless config.key? :css_path
72
- config[:css_path] =
73
- File.join(@site.config['destination'], config[:css_dir])
74
- end
75
-
76
- symbolize_configuration!(config)
77
- end
78
-
79
- # Symbolize values for configuration values which require it.
80
- #
81
- # @param config [Hash]
82
- # @return [Hash]
83
- def symbolize_configuration!(config)
84
- [
85
- :project_type,
86
- :environment,
87
- :output_style,
88
- :preferred_syntax,
89
- :sprite_engine,
90
- ].each do |k|
91
- config[k] = config[k].to_sym if config.key? k
92
- end
93
-
94
- config
46
+ config = CompassConfiguration.default_configuration
47
+ config[:project_path] = source
48
+ config[:force] = true
49
+ config.extend(@site.config['compass'] || {})
50
+ config.extend(@site.data['compass'] || {})
51
+ config[:css_path] = File.join(@site.config['destination'], config[:css_dir]) unless config.has_key? :css_path
52
+ config.to_compass
95
53
  end
96
54
 
97
55
  # Sets up event handlers with Compass and various other
98
56
  # configuration setup needs
99
57
  #
100
- # @param config [Hash] Configuration to pass to Compass and Sass
58
+ # @param config [::Compass::Configuration::Data] Configuration to pass to Compass and Sass
101
59
  # @return [void]
102
60
  def configure_compass(config)
103
- ::Compass.add_configuration(config, 'Jekyll::Compass')
61
+ ::Compass.add_configuration(config)
104
62
 
105
63
  ::Compass.configuration.on_stylesheet_saved(
106
64
  &method(:on_stylesheet_saved)
@@ -161,41 +119,6 @@ module Jekyll
161
119
  end
162
120
  nil
163
121
  end
164
-
165
- # Merges a target hash with another hash, recursively.
166
- #
167
- # @param target [Hash] The target hash
168
- # @param merge [Hash] The hash to merge into the target
169
- # @return [Hash] Returns the merged target
170
- def deep_merge!(target, merge)
171
- merge.keys.each do |key|
172
- if merge[key].is_a? Hash and target[key].is_a? Hash
173
- target[key] = deep_merge!(target[key], merge[key])
174
- else
175
- target[key] = merge[key]
176
- end
177
- end
178
-
179
- target
180
- end
181
-
182
- # Turn all String keys of a hash into symbols, and return in another Hash.
183
- #
184
- # @param hash [Hash] The hash to convert
185
- # @return [Hash] Returns the symbolized copy of hash.
186
- def symbolize_keys(hash)
187
- target = hash.dup
188
-
189
- target.keys.each do |key|
190
- value = target.delete(key)
191
- if value.is_a? Hash
192
- value = symbolize_keys(value)
193
- end
194
- target[(key.to_sym rescue key) || key] = value
195
- end
196
-
197
- target
198
- end
199
122
  end
200
123
  end
201
124
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-compass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Scharley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-13 00:00:00.000000000 Z
11
+ date: 2014-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: compass
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.12'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.12'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: jekyll
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
41
  description: |2
@@ -46,7 +46,10 @@ executables: []
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
+ - lib/jekyll/compass/compass_app_integration.rb
50
+ - lib/jekyll/compass/compass_configuration.rb
49
51
  - lib/jekyll/compass/compass_file.rb
52
+ - lib/jekyll/compass/compass_installer.rb
50
53
  - lib/jekyll/compass/generator.rb
51
54
  - lib/jekyll/compass.rb
52
55
  - lib/jekyll-compass.rb
@@ -62,17 +65,17 @@ require_paths:
62
65
  - lib
63
66
  required_ruby_version: !ruby/object:Gem::Requirement
64
67
  requirements:
65
- - - '>='
68
+ - - ">="
66
69
  - !ruby/object:Gem::Version
67
70
  version: '0'
68
71
  required_rubygems_version: !ruby/object:Gem::Requirement
69
72
  requirements:
70
- - - '>='
73
+ - - ">="
71
74
  - !ruby/object:Gem::Version
72
75
  version: '0'
73
76
  requirements: []
74
77
  rubyforge_project:
75
- rubygems_version: 2.0.3
78
+ rubygems_version: 2.0.14
76
79
  signing_key:
77
80
  specification_version: 4
78
81
  summary: Jekyll generator plugin to build Compass projects during site build