lib/octopress-ink/plugin.rb in octopress-ink-1.0.0.rc.30 vs lib/octopress-ink/plugin.rb in octopress-ink-1.0.0.rc.31
- old
+ new
@@ -143,11 +143,11 @@
end
def disable_assets
disabled = []
config['disable'] ||= {}
- config['disable'].each do |key,val|
+ config['disable'].each do |key,val|
next unless can_disable.include? key
if !!val == val
disabled << key if val
elsif val.is_a? Array
val.each { |v| disabled << File.join(key, v) }
@@ -162,11 +162,11 @@
@config ||= Assets::Config.new(self, @config_file)
end
def can_disable
- [
+ [
'pages',
'sass',
'css',
'stylesheets',
'javascripts',
@@ -180,24 +180,24 @@
def assets
{
'layouts' => @layouts,
'includes' => @includes,
- 'pages' => @pages,
- 'sass' => @sass,
+ 'pages' => @pages,
+ 'sass' => @sass,
'css' => @css,
- 'js' => @js,
- 'minjs' => @no_compress_js,
- 'coffee' => @coffee,
- 'images' => @images,
- 'fonts' => @fonts,
+ 'js' => @js,
+ 'minjs' => @no_compress_js,
+ 'coffee' => @coffee,
+ 'images' => @images,
+ 'fonts' => @fonts,
'files' => @files,
'config-file' => [@config]
}
end
-
- # Return information about each asset
+
+ # Return information about each asset
def assets_list(options)
message = ''
no_assets = []
select_assets(options).each do |name, assets|
@@ -271,20 +271,20 @@
# Return selected assets
#
# input: options (an array ['type',...], hash {'type'=>true}
# or string of asset types)
- #
+ #
# Output a hash of assets instances {'files' => @files }
#
def select_assets(asset_types)
# Accept options from the CLI (as a hash of asset_name: true)
# Or from Ink modules as an array of asset names
#
if asset_types.is_a? Hash
-
+
# Show Sass and CSS when 'stylesheets' is chosen
if asset_types['stylesheets']
asset_types['css'] = true
asset_types['sass'] = true
asset_types.delete('stylesheets')
@@ -301,13 +301,13 @@
end
# Args should allow a single asset as a string too
#
if asset_types.is_a? String
- asset_types = [asset_types]
+ asset_types = [asset_types]
end
-
+
# Match asset_types against list of assets and
# remove asset_types which don't belong
#
asset_types.select!{|asset| assets.include?(asset)}
@@ -385,11 +385,11 @@
end
end
def glob_assets(dir)
return [] unless Dir.exist? dir
- Find.find(dir).to_a.reject do |file|
+ Find.find(dir).to_a.reject do |file|
File.directory?(file) || File.basename(file) =~ /^\./
end
end
def css
@@ -398,11 +398,24 @@
def sass
@sass.reject(&:disabled?).compact
end
+ # Internal: Remove Sass partials from Sass assets.
+ # Partials can be in "stylesheets" or its sub-directories.
+ #
+ # Examples
+ #
+ # _partial.scss is rejected
+ # dir/_partial.scss is rejected
+ # dir/dir/_partial.scss is rejected
+ # snake_case.scss is not rejected
+ # dir/snake_case.scss is not rejected
+ # dir/dir/snake_case.scss is not rejected
+ #
+ # Returns Sass assets not including partials.
def sass_without_partials
- sass.reject{|f| f.file =~ /^_/ }
+ sass.reject { |f| File.basename(f.file).start_with?('_') }
end
def js
@js.reject(&:disabled?).compact
end