sass-globbing-pr-20 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.markdown +25 -0
- data/Gemfile +7 -0
- data/README.markdown +42 -0
- data/Rakefile +11 -0
- data/lib/sass-globbing.rb +1 -0
- data/lib/sass/globbing.rb +7 -0
- data/lib/sass/globbing/importer.rb +103 -0
- data/lib/sass/globbing/monkey_patches.rb +12 -0
- data/lib/sass/globbing/version.rb +5 -0
- data/sass-globbing.gemspec +21 -0
- data/test/fixtures/all.sass +2 -0
- data/test/fixtures/partials/_partial1.sass +4 -0
- data/test/fixtures/partials/nested/_nested.sass +2 -0
- data/test/fixtures/partials/nested/_nested_2.sass +2 -0
- data/test/fixtures/partials/nested/deeply_nested/_deeply.scss +3 -0
- data/test/sass_globbing_test.rb +26 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3984d1224fee7e67a16726e6a6988a88de501cfb
|
4
|
+
data.tar.gz: 7080fb1bb9819d5d7d8c27efde51ac95c5c91c40
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ee1a568db59f81f402317b0077d4d32a10fc2d51c0c3c4ad0c276c4402761705003f3087321a42c9ac23c0d07556100c5afde0e5315491574497d7f21dcf2cf9
|
7
|
+
data.tar.gz: bb64d38bcaa1dfbc9f12528ee4b4b28bd500a7a7c30129c55dac45493e650d3a9f53cb68e4ff78564b981951bdcdb6f89d83c546e1525d5aaef49311a0dfc398
|
data/.travis.yml
ADDED
data/CHANGELOG.markdown
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# 1.1.2
|
2
|
+
|
3
|
+
* Fix globbing importing path
|
4
|
+
|
5
|
+
# 1.1.1
|
6
|
+
|
7
|
+
* Fix importing issues when using import-once with sass-globbing
|
8
|
+
* Fix mtime checks so that globs don't force recompiles of unchanged
|
9
|
+
sass files.
|
10
|
+
|
11
|
+
# 1.1.0
|
12
|
+
|
13
|
+
* Add the ability for a glob to not match any files. Instead a css
|
14
|
+
comment is generated that explains that nothing was found (to enable
|
15
|
+
debugging).
|
16
|
+
|
17
|
+
Because of this behavior, it is imperitive that the globbing importer
|
18
|
+
come after the compass sprite importer in the sass load path. This is
|
19
|
+
done for you automatically, but it is something to keep in mind.
|
20
|
+
|
21
|
+
* Fix a globbing issue on windows.
|
22
|
+
|
23
|
+
# 1.0.0
|
24
|
+
|
25
|
+
Initial release.
|
data/Gemfile
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Sass Globbing Plugin
|
2
|
+
|
3
|
+
Sass globbing allows you to import many sass or scss files in a single import statement.
|
4
|
+
|
5
|
+
## Stylesheet Syntax
|
6
|
+
|
7
|
+
Import a folder of files:
|
8
|
+
|
9
|
+
@import "library/mixins/*"
|
10
|
+
|
11
|
+
Import a tree of files:
|
12
|
+
|
13
|
+
@import "library/**/*"
|
14
|
+
|
15
|
+
Globbed files are sorted alphabetically before importing them.
|
16
|
+
|
17
|
+
Globs are always relative to the current file. The ruby glob file syntax is used, read the [docs][globbing_docs] for more that you can do with it.
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
|
21
|
+
$ gem install sass-globbing
|
22
|
+
|
23
|
+
## Use with the Sass command line
|
24
|
+
|
25
|
+
$ sass -r sass-globbing --watch sass_dir:css_dir
|
26
|
+
|
27
|
+
## Use with compass
|
28
|
+
|
29
|
+
Add the following to your compass configuration:
|
30
|
+
|
31
|
+
require 'sass-globbing'
|
32
|
+
|
33
|
+
## Use with Ruby on Rails
|
34
|
+
|
35
|
+
Ruby on Rails has this capability out of the box starting in Rails 3.1. Do not install this plugin if you use Rails 3.1 or greater.
|
36
|
+
|
37
|
+
## Caveats
|
38
|
+
|
39
|
+
CSS is order dependent, as such, using this approach within your stylesheets to import styles that depend on the stylesheet's cascade creates an opportunity for styles to change more unpredictably than a manually asserted order. It is recommended that you only use globbing where order is unimportant; E.g. importing of library files.
|
40
|
+
|
41
|
+
|
42
|
+
[globbing_docs]: http://ruby-doc.org/core/classes/Dir.html#method-c-glob
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'sass/globbing'
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'singleton'
|
3
|
+
|
4
|
+
class Sass::Globbing::Importer < Sass::Importers::Filesystem
|
5
|
+
|
6
|
+
include Singleton
|
7
|
+
|
8
|
+
GLOB = /\*/
|
9
|
+
|
10
|
+
SASS_EXTENSIONS = {
|
11
|
+
".sass" => :sass,
|
12
|
+
".scss" => :scss
|
13
|
+
}
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
super(".")
|
17
|
+
end
|
18
|
+
|
19
|
+
def sass_file?(filename)
|
20
|
+
SASS_EXTENSIONS.has_key?(File.extname(filename.to_s))
|
21
|
+
end
|
22
|
+
|
23
|
+
def syntax(filename)
|
24
|
+
SASS_EXTENSIONS[File.extname(filename.to_s)]
|
25
|
+
end
|
26
|
+
|
27
|
+
def find_relative(name, base, options)
|
28
|
+
if name =~ GLOB
|
29
|
+
find_glob(name, base, options) { nil }
|
30
|
+
else
|
31
|
+
super(name, base, options)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def find(name, options)
|
36
|
+
if options[:filename] # globs must be relative
|
37
|
+
if name =~ GLOB
|
38
|
+
find_glob(name, options[:filename], options) { "/* No files to import found in #{comment_safe(name)} */" }
|
39
|
+
else
|
40
|
+
super(name, options)
|
41
|
+
end
|
42
|
+
else
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def each_globbed_file(glob, base_pathname, options)
|
48
|
+
Dir["#{base_pathname.dirname}/#{glob}"].sort.each do |filename|
|
49
|
+
next if filename == options[:filename]
|
50
|
+
yield filename if sass_file?(filename)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def mtime(name, options)
|
55
|
+
if name =~ GLOB && options[:filename]
|
56
|
+
mtime = nil
|
57
|
+
base_pathname = Pathname.new(options[:filename])
|
58
|
+
name_pathname = Pathname.new(name)
|
59
|
+
if name_pathname.absolute?
|
60
|
+
name = name_pathname.relative_path_from(base_pathname.dirname).to_s
|
61
|
+
end
|
62
|
+
each_globbed_file(name, base_pathname, options) do |p|
|
63
|
+
if mtime.nil?
|
64
|
+
mtime = File.mtime(p)
|
65
|
+
else
|
66
|
+
mtime = [mtime, File.mtime(p)].max
|
67
|
+
end
|
68
|
+
end
|
69
|
+
mtime
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def key(name, options)
|
74
|
+
["Glob:" + File.dirname(File.expand_path(name)), File.basename(name)]
|
75
|
+
end
|
76
|
+
|
77
|
+
def to_s
|
78
|
+
"Sass::Globbing::Importer"
|
79
|
+
end
|
80
|
+
|
81
|
+
protected
|
82
|
+
|
83
|
+
def find_glob(name, base, options)
|
84
|
+
contents = ""
|
85
|
+
base = base.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
|
86
|
+
base_pathname = Pathname.new(base)
|
87
|
+
each_globbed_file(name, base_pathname, options) do |filename|
|
88
|
+
contents << "@import #{Pathname.new(filename).relative_path_from(base_pathname.dirname).to_s.inspect};\n"
|
89
|
+
end
|
90
|
+
contents = yield if contents.empty?
|
91
|
+
return nil if contents.nil? || contents.empty?
|
92
|
+
Sass::Engine.new(contents, options.merge(
|
93
|
+
:filename => base_pathname.dirname.join(Pathname.new(name)).to_s,
|
94
|
+
:importer => self,
|
95
|
+
:load_paths => [base_pathname.dirname],
|
96
|
+
:syntax => :scss
|
97
|
+
))
|
98
|
+
end
|
99
|
+
|
100
|
+
def comment_safe(string)
|
101
|
+
string.gsub(%r{\*/}, "*\\/")
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'sass'
|
2
|
+
|
3
|
+
class Sass::Engine
|
4
|
+
alias old_initialize initialize
|
5
|
+
|
6
|
+
def initialize(template, options={})
|
7
|
+
old_initialize(template, options)
|
8
|
+
self.options[:load_paths].delete(Sass::Globbing::Importer.instance) # in case it's there
|
9
|
+
self.options[:load_paths] << Sass::Globbing::Importer.instance
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "sass/globbing/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "sass-globbing-pr-20"
|
7
|
+
s.version = Sass::Globbing::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Chris Eppstein"]
|
10
|
+
s.email = ["chris@eppsteins.net"]
|
11
|
+
s.homepage = "https://github.com/chriseppstein/sass-globbing/pull/20"
|
12
|
+
s.summary = %q{Allows use of globs in Sass @import directives.}
|
13
|
+
s.description = %q{Allows use of globs in Sass @import directives.}
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
s.add_runtime_dependency 'sass', '>= 3.1'
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'sass'
|
3
|
+
require 'sass-globbing'
|
4
|
+
|
5
|
+
class SassGlobbingTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def test_can_import_globbed_files
|
8
|
+
css = render_file("all.sass")
|
9
|
+
assert_match /deeply-nested/, css
|
10
|
+
assert_match %r{No files to import found in doesnotexist/\*\\/foo\.\*}, css
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def render_file(filename)
|
15
|
+
fixtures_dir = File.expand_path("fixtures", File.dirname(__FILE__))
|
16
|
+
full_filename = File.expand_path(filename, fixtures_dir)
|
17
|
+
syntax = File.extname(full_filename)[1..-1].to_sym
|
18
|
+
engine = Sass::Engine.new(File.read(full_filename),
|
19
|
+
:syntax => syntax,
|
20
|
+
:filename => full_filename,
|
21
|
+
:cache => false,
|
22
|
+
:read_cache => false,
|
23
|
+
:load_paths => [fixtures_dir])
|
24
|
+
engine.render
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sass-globbing-pr-20
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Eppstein
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sass
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
description: Allows use of globs in Sass @import directives.
|
28
|
+
email:
|
29
|
+
- chris@eppsteins.net
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- ".travis.yml"
|
36
|
+
- CHANGELOG.markdown
|
37
|
+
- Gemfile
|
38
|
+
- README.markdown
|
39
|
+
- Rakefile
|
40
|
+
- lib/sass-globbing.rb
|
41
|
+
- lib/sass/globbing.rb
|
42
|
+
- lib/sass/globbing/importer.rb
|
43
|
+
- lib/sass/globbing/monkey_patches.rb
|
44
|
+
- lib/sass/globbing/version.rb
|
45
|
+
- sass-globbing.gemspec
|
46
|
+
- test/fixtures/all.sass
|
47
|
+
- test/fixtures/partials/_partial1.sass
|
48
|
+
- test/fixtures/partials/nested/_nested.sass
|
49
|
+
- test/fixtures/partials/nested/_nested_2.sass
|
50
|
+
- test/fixtures/partials/nested/deeply_nested/_deeply.scss
|
51
|
+
- test/sass_globbing_test.rb
|
52
|
+
homepage: https://github.com/chriseppstein/sass-globbing/pull/20
|
53
|
+
licenses: []
|
54
|
+
metadata: {}
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
requirements: []
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 2.2.2
|
72
|
+
signing_key:
|
73
|
+
specification_version: 4
|
74
|
+
summary: Allows use of globs in Sass @import directives.
|
75
|
+
test_files:
|
76
|
+
- test/fixtures/all.sass
|
77
|
+
- test/fixtures/partials/_partial1.sass
|
78
|
+
- test/fixtures/partials/nested/_nested.sass
|
79
|
+
- test/fixtures/partials/nested/_nested_2.sass
|
80
|
+
- test/fixtures/partials/nested/deeply_nested/_deeply.scss
|
81
|
+
- test/sass_globbing_test.rb
|