sass-css-importer-load-paths 1.0.0.beta.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 54f40d7f0754c5abbecf88ca374ba33c31f88066
4
+ data.tar.gz: 274e9ca5cf250e8c150ae79c0c91b85c3a48f20b
5
+ SHA512:
6
+ metadata.gz: b858aa2ca6961b10dbe7fb0d88d18dcfadcf553dafcf4b47288b346ac949482ce6490bf99f6dc5fe7607eca1ec2c62e2915a234a3e61dd7f7844038ac09a1d35
7
+ data.tar.gz: 503b91af3977c7d8c99947eda49af8f6c394c709b02e8bdc74bd883730486e5af3e2c29d6c753e2a67853e9d36c70093e7e687f16b0a0165c4dd4084292bd73d
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ bin/
6
+ vendor/
@@ -0,0 +1,3 @@
1
+ # 1.0.0
2
+
3
+ Initial release.
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'rake'
@@ -0,0 +1,45 @@
1
+ # Sass CSS Importer Plugin
2
+
3
+ The Sass CSS Importer allows you to import a CSS file into Sass.
4
+
5
+ ## Stylesheet Syntax
6
+
7
+ The `.css` extension triggers special behavior in Sass so you cannot
8
+ import a file with a CSS extension. To work around this, you must use a
9
+ special prefix on the import string and omit the extension.
10
+
11
+ @import "CSS:some_folder/some_css_file"
12
+
13
+ ## Installation
14
+
15
+ $ gem install --pre sass-css-importer
16
+
17
+ ## Use with the Sass command line
18
+
19
+ $ sass -r sass-css-importer --watch sass_dir:css_dir
20
+
21
+ Note: several -r options can be given to the sass command line if you
22
+ need to require several libraries.
23
+
24
+ ## Use with compass
25
+
26
+ Add the following to your compass configuration:
27
+
28
+ require 'sass-css-importer'
29
+
30
+ ## More complex scenarios
31
+
32
+ This plugin assumes you want to import CSS files relative to a Sass
33
+ file. More complex scenarios are acheivable by adding a CSS Importer to
34
+ the Sass load path option explicitly.
35
+
36
+ For example, in compass you can do the following in your `config.rb`
37
+ file:
38
+
39
+ ```ruby
40
+ require 'sass-css-importer'
41
+ add_import_path Sass::CssImporter::Importer.new("/path/to/the/css/files")
42
+ ```
43
+
44
+
45
+
@@ -0,0 +1,11 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'lib'
8
+ t.libs << 'test'
9
+ t.pattern = 'test/**/*_test.rb'
10
+ t.verbose = false
11
+ end
@@ -0,0 +1 @@
1
+ require 'sass/css_importer'
@@ -0,0 +1,7 @@
1
+ module Sass
2
+ module CssImporter
3
+ end
4
+ end
5
+
6
+ require 'sass/css_importer/importer';
7
+ require 'sass/css_importer/monkey_patches';
@@ -0,0 +1,56 @@
1
+ require 'pathname'
2
+ require 'singleton'
3
+
4
+ class Sass::CssImporter::Importer < Sass::Importers::Filesystem
5
+
6
+ def initialize(root)
7
+ super(root)
8
+ end
9
+
10
+ # Enable watching of css files in Sass 3.3+
11
+ def watched_directories
12
+ [root]
13
+ end
14
+
15
+ # Enable watching of css files in Sass 3.3+
16
+ def watched_file?(file)
17
+ file.start_with?(root+File::SEPARATOR) && File.extname(file) == ".css"
18
+ end
19
+
20
+ def extensions
21
+ {'css' => :scss}
22
+ end
23
+
24
+ def find_relative(name, base, options)
25
+ super(strip_prefix(name), base, options)
26
+ end
27
+
28
+
29
+ def find(name, options)
30
+ super(strip_prefix(name), options)
31
+ end
32
+
33
+
34
+ def mtime(name, options)
35
+ super(strip_prefix(name), options)
36
+ end
37
+
38
+ def key(name, options)
39
+ super(strip_prefix(name), options)
40
+ end
41
+
42
+ def to_s
43
+ "Sass::CssImporter::Importer(#{root})"
44
+ end
45
+
46
+ def eql?(other)
47
+ other.class == self.class && other.root == self.root
48
+ end
49
+
50
+ protected
51
+
52
+ def strip_prefix(name)
53
+ name.start_with?("CSS:") ? name[4..-1] : name
54
+ end
55
+
56
+ end
@@ -0,0 +1,20 @@
1
+ require 'sass'
2
+
3
+ class Sass::Engine
4
+ alias initialize_without_css_importer initialize
5
+
6
+ def initialize(template, options={})
7
+ initialize_without_css_importer(template, options)
8
+
9
+ css_importer = self.options[:load_paths].find {|lp| lp.is_a?(Sass::CssImporter::Importer) }
10
+
11
+ unless css_importer
12
+ css_importers =
13
+ self.options[:load_paths].map do |importer|
14
+ Sass::CssImporter::Importer.new(importer.root)
15
+ end
16
+ self.options[:load_paths].concat css_importers
17
+ end
18
+ end
19
+ end
20
+
@@ -0,0 +1,5 @@
1
+ module Sass
2
+ module CssImporter
3
+ VERSION = "1.0.0.beta.0"
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "sass/css_importer/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "sass-css-importer-load-paths"
7
+ s.version = Sass::CssImporter::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Joe Fiorini"]
10
+ s.email = ["joe@joefiorini.com"]
11
+ s.homepage = "http://www.joefiorini.com"
12
+ s.summary = %q{Allows importing of css files using Sass @import directives.}
13
+ s.description = %q{Allows importing of css files using Sass @import directives. Fixes original Chris Eppstein version with support for additional load paths.}
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,2 @@
1
+ @import "CSS:some_css_files/partial";
2
+ @import "CSS:some_css_files/foo";
@@ -0,0 +1,3 @@
1
+ .css-partial {
2
+ color: black;
3
+ }
@@ -0,0 +1,3 @@
1
+ .css-file {
2
+ color: red;
3
+ }
@@ -0,0 +1,26 @@
1
+ require 'test/unit'
2
+ require 'sass'
3
+ require 'sass/css_importer'
4
+
5
+ class SassCssImporterTest < Test::Unit::TestCase
6
+
7
+ def test_can_import_css_files_files
8
+ css = render_file("imports_css.scss")
9
+ assert_match(/\.css-partial/, css)
10
+ assert_match(/\.css-file/, 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,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sass-css-importer-load-paths
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.beta.0
5
+ platform: ruby
6
+ authors:
7
+ - Joe Fiorini
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-23 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 importing of css files using Sass @import directives. Fixes original
28
+ Chris Eppstein version with support for additional load paths.
29
+ email:
30
+ - joe@joefiorini.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - .gitignore
36
+ - CHANGELOG.markdown
37
+ - Gemfile
38
+ - README.markdown
39
+ - Rakefile
40
+ - lib/sass-css-importer.rb
41
+ - lib/sass/css_importer.rb
42
+ - lib/sass/css_importer/importer.rb
43
+ - lib/sass/css_importer/monkey_patches.rb
44
+ - lib/sass/css_importer/version.rb
45
+ - sass-css-importer-load-paths.gemspec
46
+ - test/fixtures/imports_css.scss
47
+ - test/fixtures/some_css_files/_partial.css
48
+ - test/fixtures/some_css_files/foo.css
49
+ - test/sass_css_importer_test.rb
50
+ homepage: http://www.joefiorini.com
51
+ licenses: []
52
+ metadata: {}
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>'
65
+ - !ruby/object:Gem::Version
66
+ version: 1.3.1
67
+ requirements: []
68
+ rubyforge_project:
69
+ rubygems_version: 2.0.2
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: Allows importing of css files using Sass @import directives.
73
+ test_files:
74
+ - test/fixtures/imports_css.scss
75
+ - test/fixtures/some_css_files/_partial.css
76
+ - test/fixtures/some_css_files/foo.css
77
+ - test/sass_css_importer_test.rb