sass-archive-importer 1.0.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3fb28da4710afdafc69011ba433ab7526160a97e
4
+ data.tar.gz: fd5c4f71be7c2dccb8f1d1c8db7c54aa99a6de01
5
+ SHA512:
6
+ metadata.gz: 9cb13cae43ea0c1af4bc8d214235dc1ca8cfe69bade30b3e2454fa1f4317a4ca4a1b829d9605245d0ec586cc2d9cbafb989b293653c8c950cd82efdb8bafd723
7
+ data.tar.gz: 037103b6428ebccc39ca058ae9fe0eb46ea41aa7b07e4abfa65e565b8f4b61cdcba7000866954553f6d1a25c1e17d2454644600c8fa03753499216f0f4d58372
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ test/fixtures/jarred_files.jar
3
+ test/fixtures/zipped_files.zip
@@ -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'
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sass-archive-importer (1.0.0.beta.1)
5
+ rubyzip (~> 0.9.9)
6
+ sass (>= 3.1)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ rake (10.1.0)
12
+ rubyzip (0.9.9)
13
+ sass (3.3.3)
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ rake
20
+ sass-archive-importer!
data/LICENSE.txt ADDED
@@ -0,0 +1,175 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
data/README.markdown ADDED
@@ -0,0 +1,49 @@
1
+ # Sass Archive Importer Plugin
2
+
3
+ The Sass Archive Importer allows you to import CSS, Sass, and SCSS files
4
+ from a zip or jar file without unpacking it.
5
+
6
+ ## Stylesheet Syntax
7
+
8
+ This importer works with the standard filesystem based import syntax,
9
+ allowing you to import from a folder or archive file with the same code.
10
+ This allows you to develop against an unpacked version of a library but
11
+ also compile the stylesheets against a pre-built archive file (for example,
12
+ during a build process).
13
+
14
+ ## Installation
15
+
16
+ $ gem install --pre sass-archive-importer
17
+
18
+ ## Use with the Sass command line
19
+
20
+ $ sass -r sass-archive-importer -I path/to/archive.zip --watch sass_dir:css_dir
21
+
22
+ Note: several `-r` options can be given to the sass command line if you
23
+ need to require several libraries. Several `-I` options can be passed if
24
+ you need to import more than one zip or jar file.
25
+
26
+ ## Use with Compass
27
+
28
+ Add the following to your compass configuration:
29
+
30
+ require 'sass-archive-importer'
31
+ # Note: you can call add_import_path more than once.
32
+ add_import_path File.expand_path("path/to/archive.zip", File.dirname(__FILE__))
33
+ add_import_path File.expand_path("path/to/archive.jar", File.dirname(__FILE__))
34
+
35
+ # Legal Stuff
36
+
37
+ Copyright 2013 LinkedIn Corp. All rights reserved.
38
+
39
+ Licensed under the Apache License, Version 2.0 (the "License");
40
+ you may not use this file except in compliance with the License.
41
+ You may obtain a copy of the License at
42
+
43
+ http://www.apache.org/licenses/LICENSE-2.0
44
+
45
+ Unless required by applicable law or agreed to in writing, software
46
+ distributed under the License is distributed on an "AS IS" BASIS,
47
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
48
+ See the License for the specific language governing permissions and
49
+ limitations under the License.
data/Rakefile ADDED
@@ -0,0 +1,29 @@
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
12
+
13
+ task :test => ["test/fixtures/zipped_files.zip", "test/fixtures/jarred_files.jar"]
14
+
15
+ desc "Build the zip file fixture."
16
+ file "test/fixtures/zipped_files.zip" => FileList["test/fixtures/zipped_files/**/*"] do
17
+ puts "Zipping test/fixtures/zipped_files/"
18
+ Dir.chdir "test/fixtures/zipped_files" do
19
+ `zip -r ../zipped_files.zip .`
20
+ raise "failed to create test/fixtures/zipped_files.zip" unless $? == 0
21
+ end
22
+ end
23
+
24
+ desc "Build the jar file fixture."
25
+ file "test/fixtures/jarred_files.jar" => FileList["test/fixtures/zipped_files/**/*"] do
26
+ puts "Jarring test/fixtures/zipped_files/"
27
+ `jar -cf test/fixtures/jarred_files.jar -C test/fixtures/zipped_files .`
28
+ raise "failed to create test/fixtures/zipped_files.zip" unless $? == 0
29
+ end
@@ -0,0 +1,140 @@
1
+ # Copyright 2013 LinkedIn Corp. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ class Sass::ArchiveImporter::Importer < Sass::Importers::Base
16
+
17
+ attr_reader :archive_file
18
+ attr_reader :sub_folder
19
+
20
+ def extensions
21
+ {
22
+ ".scss" => :scss,
23
+ ".css" => :scss,
24
+ ".sass" => :sass
25
+ }
26
+ end
27
+
28
+ def initialize(archive_file, sub_folder = nil)
29
+ require 'zip/zip'
30
+ require 'pathname'
31
+ @archive_file = File.expand_path(archive_file)
32
+ @sub_folder = sub_folder
33
+ end
34
+
35
+ # Enable watching of css files in Sass 3.3+
36
+ def watched_directories
37
+ [File.dirname(archive_file)]
38
+ end
39
+
40
+ # Enable watching of css files in Sass 3.3+
41
+ def watched_file?(file)
42
+ archive_file == file
43
+ end
44
+
45
+ def find_relative(name, base, options)
46
+ base = base.split("!", 2).last
47
+ if entry = entry_for(name, base)
48
+ engine(entry, options)
49
+ end
50
+ end
51
+
52
+
53
+ def find(name, options)
54
+ if entry = entry_for(name)
55
+ engine(entry, options)
56
+ end
57
+ end
58
+
59
+ def engine(entry, options)
60
+ options[:syntax] = extensions.fetch(File.extname(entry.name), :scss)
61
+ options[:filename] = full_filename(entry)
62
+ options[:importer] = self
63
+ Sass::Engine.new(zip.read(entry), options)
64
+ end
65
+
66
+
67
+ def mtime(name, options)
68
+ if entry = entry_for(name)
69
+ entry.time
70
+ end
71
+ nil
72
+ end
73
+
74
+ def key(name, options)
75
+ name.split("!", 2)
76
+ end
77
+
78
+ def to_s
79
+ archive_file
80
+ end
81
+
82
+ def eql?(other)
83
+ other.class == self.class && other.archive_file == self.archive_file
84
+ end
85
+
86
+ protected
87
+
88
+ def full_filename(entry)
89
+ "#{archive_file}!#{entry.name}"
90
+ end
91
+
92
+ def entry_for(name, base = nil)
93
+ possible_names(name, base).each do |n|
94
+ n = "#{sub_folder}/#{n}" if sub_folder
95
+ if entry = zip.find_entry(n)
96
+ return entry
97
+ end
98
+ end
99
+ nil
100
+ end
101
+
102
+ def possible_names(name, base = nil)
103
+ if base
104
+ absolute_root = Pathname.new("/")
105
+ base_path = Pathname.new(base)
106
+ path = Pathname.new(name)
107
+ begin
108
+ name = absolute_root.join(base_path).dirname.join(path).relative_path_from(absolute_root).to_s
109
+ rescue
110
+ # couldn't create a relative path, so we'll just assume it's absolute or for a different importer.
111
+ return []
112
+ end
113
+ end
114
+ d, b = File.split(name)
115
+ names = if b.start_with?("_")
116
+ [name]
117
+ else
118
+ [name, d == "." ? "_#{b}" : "#{d}/_#{b}"]
119
+ end
120
+
121
+ names.map do |n|
122
+ if (ext = File.extname(n)).size > 0 && extensions.keys.include?(ext)
123
+ n
124
+ else
125
+ extensions.keys.map{|k| "#{n}#{k}" }
126
+ end
127
+ end.flatten
128
+ end
129
+
130
+ def zip
131
+ @zip ||= open_zip_file!
132
+ end
133
+
134
+ def open_zip_file!
135
+ z = Zip::ZipFile.open(archive_file)
136
+ at_exit { z.close }
137
+ z
138
+ end
139
+
140
+ end
@@ -0,0 +1,31 @@
1
+ # Copyright 2013 LinkedIn Corp. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'sass'
16
+
17
+ class Sass::Engine
18
+ alias initialize_without_archive_importer initialize
19
+
20
+ def initialize(template, options={})
21
+ if options[:load_paths]
22
+ options[:load_paths].map! do |load_path|
23
+ next load_path unless load_path.is_a?(::String) && load_path =~ /^(.*\.(?:zip|jar))(?:!(.+))?$/
24
+ Sass::ArchiveImporter::Importer.new($1, $2)
25
+ end
26
+ end
27
+
28
+ initialize_without_archive_importer(template, options)
29
+ end
30
+ end
31
+
@@ -0,0 +1,19 @@
1
+ # Copyright 2013 LinkedIn Corp. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Sass
16
+ module ArchiveImporter
17
+ VERSION = "1.0.0.beta.2"
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ # Copyright 2013 LinkedIn Corp. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Sass
16
+ module ArchiveImporter
17
+ end
18
+ end
19
+
20
+ require 'sass/archive_importer/importer';
21
+ require 'sass/archive_importer/monkey_patches';
@@ -0,0 +1,15 @@
1
+ # Copyright 2013 LinkedIn Corp. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'sass/archive_importer'
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("lib", File.dirname(__FILE__))
3
+ require "sass/archive_importer/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "sass-archive-importer"
7
+ s.version = Sass::ArchiveImporter::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Chris Eppstein"]
10
+ s.email = ["chris@eppsteins.net"]
11
+ s.homepage = "http://github.com/linkedin/sass-archive-importer"
12
+ s.summary = "Allows sass, scss, and css files within zip and jar files to be found " +
13
+ "using Sass @import directives."
14
+ s.description = "Allows sass, scss, and css files within zip and jar files to be found " +
15
+ "using Sass @import directives."
16
+ s.license = 'Apache 2.0'
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- test/*`.split("\n")
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_runtime_dependency 'sass', '>= 3.1'
23
+ s.add_runtime_dependency 'rubyzip', '~> 0.9.9'
24
+ end
@@ -0,0 +1 @@
1
+ zipped_files.zip
@@ -0,0 +1,7 @@
1
+ @import "css_partial";
2
+ @import "sass_partial";
3
+ @import "scss_partial";
4
+ @import "a_css_file";
5
+ @import "a_sass_file";
6
+ @import "a_scss_file";
7
+ @import "nested/nested";
@@ -0,0 +1 @@
1
+ @import "nested";
@@ -0,0 +1,3 @@
1
+ .css-partial {
2
+ color: black;
3
+ }
@@ -0,0 +1,2 @@
1
+ .sass-partial
2
+ partial: yep
@@ -0,0 +1,3 @@
1
+ .scss-partial {
2
+ partial: yes;
3
+ }
@@ -0,0 +1,3 @@
1
+ .css-file {
2
+ css: boring;
3
+ }
@@ -0,0 +1,2 @@
1
+ .sass-file
2
+ indented: yes
@@ -0,0 +1,3 @@
1
+ .scss-file {
2
+ curly-braces: omg;
3
+ }
@@ -0,0 +1,4 @@
1
+ @import "deeply_nested/deeply";
2
+ .nested-class {
3
+ nested: yep;
4
+ }
@@ -0,0 +1,3 @@
1
+ .deeply-nested {
2
+ deeply: nested;
3
+ }
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Copyright 2013 LinkedIn Corp. All rights reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
18
+ $: << lib_dir unless $:.include?(lib_dir)
19
+ require 'test/unit'
20
+ require 'zip/zip'
21
+ require 'pathname'
22
+ require 'fileutils'
23
+ require 'sass'
24
+ require 'sass-archive-importer'
25
+
26
+ class SassArchiveImporterTest < Test::Unit::TestCase
27
+ # These fixtures are created and kept up to date by the rakefile
28
+ # Run `rake test` to re-create them
29
+ ZIP_FIXTURE = File.expand_path(File.join(File.dirname(__FILE__), "fixtures", "zipped_files.zip"))
30
+ JAR_FIXTURE = File.expand_path(File.join(File.dirname(__FILE__), "fixtures", "jarred_files.jar"))
31
+
32
+ def test_can_import_files_from_zip
33
+ css = render_file_from_zip("imports_from_zip.scss")
34
+ assert_match(/\.css-partial/, css)
35
+ assert_match(/\.css-file/, css)
36
+ assert_match(/\.sass-partial/, css)
37
+ assert_match(/\.sass-file/, css)
38
+ assert_match(/\.scss-partial/, css)
39
+ assert_match(/\.scss-file/, css)
40
+ assert_match(/\.nested-class/, css)
41
+ assert_match(/\.deeply-nested/, css)
42
+ end
43
+
44
+ def test_can_import_files_from_jar
45
+ css = render_file_from_jar("imports_from_zip.scss")
46
+ assert_match(/\.css-partial/, css)
47
+ assert_match(/\.css-file/, css)
48
+ assert_match(/\.sass-partial/, css)
49
+ assert_match(/\.sass-file/, css)
50
+ assert_match(/\.scss-partial/, css)
51
+ assert_match(/\.scss-file/, css)
52
+ assert_match(/\.nested-class/, css)
53
+ assert_match(/\.deeply-nested/, css)
54
+ end
55
+
56
+ def test_can_import_files_from_jar_subfolder
57
+ results = render_file("imports_from_zip_subfolder.scss", "#{JAR_FIXTURE}!nested")
58
+ assert_equal <<CSS, results
59
+ .deeply-nested {
60
+ deeply: nested; }
61
+
62
+ .nested-class {
63
+ nested: yep; }
64
+ CSS
65
+ end
66
+
67
+ def test_can_import_files_from_zip_subfolder
68
+ results = render_file("imports_from_zip_subfolder.scss", "#{ZIP_FIXTURE}!nested")
69
+ assert_equal <<CSS, results
70
+ .deeply-nested {
71
+ deeply: nested; }
72
+
73
+ .nested-class {
74
+ nested: yep; }
75
+ CSS
76
+ end
77
+
78
+ private
79
+ def render_file(filename, fixture)
80
+ fixtures_dir = File.expand_path("fixtures", File.dirname(__FILE__))
81
+ full_filename = File.expand_path(filename, fixtures_dir)
82
+ syntax = File.extname(full_filename)[1..-1].to_sym
83
+ engine = Sass::Engine.new(File.read(full_filename),
84
+ :syntax => syntax,
85
+ :filename => full_filename,
86
+ :cache => false,
87
+ :read_cache => false,
88
+ :load_paths => [fixture])
89
+ engine.render
90
+ end
91
+
92
+ def render_file_from_zip(filename)
93
+ render_file(filename, ZIP_FIXTURE)
94
+ end
95
+
96
+ def render_file_from_jar(filename)
97
+ render_file(filename, JAR_FIXTURE)
98
+ end
99
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sass-archive-importer
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.beta.2
5
+ platform: ruby
6
+ authors:
7
+ - Chris Eppstein
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-25 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
+ - !ruby/object:Gem::Dependency
28
+ name: rubyzip
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.9
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.9
41
+ description: Allows sass, scss, and css files within zip and jar files to be found
42
+ using Sass @import directives.
43
+ email:
44
+ - chris@eppsteins.net
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - CHANGELOG.markdown
51
+ - Gemfile
52
+ - Gemfile.lock
53
+ - LICENSE.txt
54
+ - README.markdown
55
+ - Rakefile
56
+ - lib/sass-archive-importer.rb
57
+ - lib/sass/archive_importer.rb
58
+ - lib/sass/archive_importer/importer.rb
59
+ - lib/sass/archive_importer/monkey_patches.rb
60
+ - lib/sass/archive_importer/version.rb
61
+ - sass-archive-importer.gemspec
62
+ - test/fixtures/.gitignore
63
+ - test/fixtures/imports_from_zip.scss
64
+ - test/fixtures/imports_from_zip_subfolder.scss
65
+ - test/fixtures/zipped_files/_css_partial.css
66
+ - test/fixtures/zipped_files/_sass_partial.sass
67
+ - test/fixtures/zipped_files/_scss_partial.scss
68
+ - test/fixtures/zipped_files/a_css_file.css
69
+ - test/fixtures/zipped_files/a_sass_file.sass
70
+ - test/fixtures/zipped_files/a_scss_file.scss
71
+ - test/fixtures/zipped_files/nested/_nested.scss
72
+ - test/fixtures/zipped_files/nested/deeply_nested/_deeply.scss
73
+ - test/sass_archive_importer_test.rb
74
+ homepage: http://github.com/linkedin/sass-archive-importer
75
+ licenses:
76
+ - Apache 2.0
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - '>'
90
+ - !ruby/object:Gem::Version
91
+ version: 1.3.1
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.0.3
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Allows sass, scss, and css files within zip and jar files to be found using
98
+ Sass @import directives.
99
+ test_files:
100
+ - test/fixtures/.gitignore
101
+ - test/fixtures/imports_from_zip.scss
102
+ - test/fixtures/imports_from_zip_subfolder.scss
103
+ - test/fixtures/zipped_files/_css_partial.css
104
+ - test/fixtures/zipped_files/_sass_partial.sass
105
+ - test/fixtures/zipped_files/_scss_partial.scss
106
+ - test/fixtures/zipped_files/a_css_file.css
107
+ - test/fixtures/zipped_files/a_sass_file.sass
108
+ - test/fixtures/zipped_files/a_scss_file.scss
109
+ - test/fixtures/zipped_files/nested/_nested.scss
110
+ - test/fixtures/zipped_files/nested/deeply_nested/_deeply.scss
111
+ - test/sass_archive_importer_test.rb
112
+ has_rdoc: