sass-css-importer 1.0.0.beta.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2ecf9aeaafed3527166ee753da76ea3dd36ce8d5
4
+ data.tar.gz: 9e9d46d28b58df82948a10255af25950fee4bc32
5
+ SHA512:
6
+ metadata.gz: 08228ba2b5d0c2162e0a117503eb92e8bfd502a84f9a67c087af489314feaa8fcd724f644c4b6f0ab5f6238468d31025e80d87759148c52272ec7d02aa77fe8b
7
+ data.tar.gz: 45d857f3372f5b96c28afb50cd84f9b070c4b802aafcc596373a67f85a62e96deefa5aeda2022153ba95629b909d168046b6d411d197d87615c797fb34984924
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
@@ -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:library/some_css_file"
12
+
13
+ ## Installation
14
+
15
+ $ gem install 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,17 @@
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
+ root = File.dirname(options[:filename] || ".")
13
+ self.options[:load_paths] << Sass::CssImporter::Importer.new(root)
14
+ end
15
+ end
16
+ end
17
+
@@ -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"
7
+ s.version = Sass::CssImporter::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Chris Eppstein"]
10
+ s.email = ["chris@eppsteins.net"]
11
+ s.homepage = "http://chriseppstein.github.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.}
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
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.beta.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Eppstein
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-01 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.
28
+ email:
29
+ - chris@eppsteins.net
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - .gitignore
35
+ - CHANGELOG.markdown
36
+ - Gemfile
37
+ - README.markdown
38
+ - Rakefile
39
+ - lib/sass-css-importer.rb
40
+ - lib/sass/css_importer.rb
41
+ - lib/sass/css_importer/importer.rb
42
+ - lib/sass/css_importer/monkey_patches.rb
43
+ - lib/sass/css_importer/version.rb
44
+ - sass-css-importer.gemspec
45
+ - test/fixtures/imports_css.scss
46
+ - test/fixtures/some_css_files/_partial.css
47
+ - test/fixtures/some_css_files/foo.css
48
+ - test/sass_css_importer_test.rb
49
+ homepage: http://chriseppstein.github.com/
50
+ licenses: []
51
+ metadata: {}
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - '>'
64
+ - !ruby/object:Gem::Version
65
+ version: 1.3.1
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 2.0.0.rc.2
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: Allows importing of css files using Sass @import directives.
72
+ test_files:
73
+ - test/fixtures/imports_css.scss
74
+ - test/fixtures/some_css_files/_partial.css
75
+ - test/fixtures/some_css_files/foo.css
76
+ - test/sass_css_importer_test.rb
77
+ has_rdoc: