sass-archive-importer 1.0.0.beta.2 → 1.0.0.beta.3
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.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/Gemfile.lock +5 -4
- data/Rakefile +87 -4
- data/lib/org/sass/archive_importer/ClassLoaderImporter.rb +158 -0
- data/lib/sass-archive-importer.rb +1 -1
- data/lib/{sass/archive_importer → sass_archive_importer}/importer.rb +6 -2
- data/lib/{sass/archive_importer → sass_archive_importer}/monkey_patches.rb +1 -1
- data/lib/{sass/archive_importer → sass_archive_importer}/version.rb +2 -4
- data/lib/sass_archive_importer.rb +19 -0
- data/sass-archive-importer.gemspec +5 -4
- data/test/class_loader_importer_test.java +166 -0
- data/test/fixtures/jruby-complete-1.6.5.jar +0 -0
- data/test/fixtures/zipped_files/has_missing_import.scss +1 -0
- data/test/sass_archive_importer_test.rb +3 -2
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c0c4de769bbc705e7197d64484bba78ba8098e5
|
4
|
+
data.tar.gz: e0c329a73043ac55bff9959d583cfe85622597da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de5fc2052f4fec4c70ccf40084b01916f9148f129dea8dba3e64ec8906996a01e6cc4bd4d0870fc459d3c26ab9e555a96d03753ae4b3642f7e0585797921a749
|
7
|
+
data.tar.gz: 80b8e6457dbdae079bbba09b83e6cea16d72935431768a3b3f40ac25ada2e049d89d6c5e710dff21bd177e81eec65319c699449dd11213c524c0b964c5af85d0
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sass-archive-importer (1.0.0.beta.
|
4
|
+
sass-archive-importer (1.0.0.beta.2)
|
5
5
|
rubyzip (~> 0.9.9)
|
6
|
-
sass (>= 3.1)
|
6
|
+
sass (>= 3.1, < 3.4)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
10
10
|
specs:
|
11
|
-
rake (10.
|
11
|
+
rake (10.2.2)
|
12
12
|
rubyzip (0.9.9)
|
13
|
-
sass (3.3.
|
13
|
+
sass (3.3.4)
|
14
14
|
|
15
15
|
PLATFORMS
|
16
|
+
java
|
16
17
|
ruby
|
17
18
|
|
18
19
|
DEPENDENCIES
|
data/Rakefile
CHANGED
@@ -1,16 +1,90 @@
|
|
1
1
|
require 'bundler'
|
2
|
+
require 'bundler/setup'
|
2
3
|
Bundler::GemHelper.install_tasks
|
3
4
|
|
4
5
|
require 'rake/testtask'
|
5
6
|
|
6
|
-
|
7
|
+
def with_env(env)
|
8
|
+
old_env = ENV.dup
|
9
|
+
ENV.update(env)
|
10
|
+
yield
|
11
|
+
ensure
|
12
|
+
ENV.replace(old_env)
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute_or_fail(command, message = "Execution")
|
16
|
+
#puts "Executing: #{command}"
|
17
|
+
system command
|
18
|
+
raise "#{message} failed." unless $?.exitstatus == 0
|
19
|
+
end
|
20
|
+
|
21
|
+
task :test => [:java_test, :mri_test]
|
22
|
+
|
23
|
+
directory "test/fixtures/tmpjava"
|
24
|
+
directory "test/fixtures/tmpjava/org/sass/archive_importer"
|
25
|
+
|
26
|
+
file "test/fixtures/tmpjava/specifications/sass-3.2.19.gemspec" => "test/fixtures/tmpjava" do
|
27
|
+
cwd = Dir.getwd
|
28
|
+
Dir.chdir ".." do
|
29
|
+
# this is done withing a chdir because the Gemfile in this folder was causing issues
|
30
|
+
execute_or_fail("gem install sass-archive-importer/test/fixtures/sass-3.2.19.gem -i #{cwd}/test/fixtures/tmpjava --no-rdoc --no-ri",
|
31
|
+
"Sass 3.2 Install")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
file "test/fixtures/tmpjava/org/sass/archive_importer/ClassLoaderImporter.rb" =>
|
36
|
+
%w(test/fixtures/tmpjava/org/sass/archive_importer
|
37
|
+
lib/org/sass/archive_importer/ClassLoaderImporter.rb) do
|
38
|
+
FileUtils.cp "lib/org/sass/archive_importer/ClassLoaderImporter.rb",
|
39
|
+
"test/fixtures/tmpjava/org/sass/archive_importer"
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
desc "Compile the Ruby class to Java using JRuby"
|
44
|
+
file "test/fixtures/tmpjava/org/sass/archive_importer/ClassLoaderImporter.class" =>
|
45
|
+
%w(test/fixtures/tmpjava
|
46
|
+
test/fixtures/tmpjava/org/sass/archive_importer) +
|
47
|
+
FileList["test/fixtures/tmpjava/org/sass/archive_importer/ClassLoaderImporter.rb"] do
|
48
|
+
Dir.chdir("test/fixtures/tmpjava") do
|
49
|
+
# I don't know how to make jruby compile correctly to a target folder correctly.
|
50
|
+
execute_or_fail("jrubyc --javac org/sass/archive_importer/ClassLoaderImporter.rb",
|
51
|
+
"JRuby compilation")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "Copy sass artifacts to the jar directory"
|
56
|
+
task :copy_sass_artifacts do
|
57
|
+
FileUtils.cp_r Dir.glob("test/fixtures/zipped_files/*"), "test/fixtures/tmpjava"
|
58
|
+
FileUtils.cp_r "test/fixtures/zipped_files", "test/fixtures/tmpjava/sass_files"
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "Build the java test jar"
|
62
|
+
file "test/fixtures/class_loader_importer_test.jar" =>
|
63
|
+
%w(test/fixtures/tmpjava/org/sass/archive_importer/ClassLoaderImporter.rb
|
64
|
+
test/fixtures/tmpjava/specifications/sass-3.2.19.gemspec) +
|
65
|
+
FileList["test/fixtures/zipped_files/**/*"] +
|
66
|
+
FileList["test/class_loader_importer_test.java"] +
|
67
|
+
[:copy_sass_artifacts] do
|
68
|
+
|
69
|
+
execute_or_fail("javac -Xlint:deprecation -cp test/fixtures/tmpjava:test/fixtures/jruby-complete-1.6.5.jar test/class_loader_importer_test.java -d test/fixtures/tmpjava",
|
70
|
+
"Java compilation")
|
71
|
+
execute_or_fail("jar -cf test/fixtures/class_loader_importer_test.jar -C test/fixtures/tmpjava .",
|
72
|
+
"Jar creation")
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "Run java tests"
|
76
|
+
task :java_test => "test/fixtures/class_loader_importer_test.jar" do
|
77
|
+
execute_or_fail("java -cp test/fixtures/jruby-complete-1.6.5.jar:test/fixtures/class_loader_importer_test.jar ClassLoaderImporterTest",
|
78
|
+
"Java test")
|
79
|
+
end
|
80
|
+
|
81
|
+
Rake::TestTask.new(:mri_test) do |t|
|
7
82
|
t.libs << 'lib'
|
8
83
|
t.libs << 'test'
|
9
|
-
t.pattern = 'test
|
84
|
+
t.pattern = 'test/*_test.rb'
|
10
85
|
t.verbose = false
|
11
86
|
end
|
12
|
-
|
13
|
-
task :test => ["test/fixtures/zipped_files.zip", "test/fixtures/jarred_files.jar"]
|
87
|
+
task :mri_test => ["test/fixtures/zipped_files.zip", "test/fixtures/jarred_files.jar"]
|
14
88
|
|
15
89
|
desc "Build the zip file fixture."
|
16
90
|
file "test/fixtures/zipped_files.zip" => FileList["test/fixtures/zipped_files/**/*"] do
|
@@ -27,3 +101,12 @@ file "test/fixtures/jarred_files.jar" => FileList["test/fixtures/zipped_files/**
|
|
27
101
|
`jar -cf test/fixtures/jarred_files.jar -C test/fixtures/zipped_files .`
|
28
102
|
raise "failed to create test/fixtures/zipped_files.zip" unless $? == 0
|
29
103
|
end
|
104
|
+
|
105
|
+
desc "Remove files generated during build or testing"
|
106
|
+
task :clean do
|
107
|
+
FileUtils.rm_f "test/fixtures/jarred_files.jar"
|
108
|
+
FileUtils.rm_f "test/fixtures/zipped_files.zip"
|
109
|
+
FileUtils.rm_f "test/fixtures/class_loader_importer_test.jar"
|
110
|
+
FileUtils.rm_rf "test/fixtures/tmpjava"
|
111
|
+
end
|
112
|
+
|
@@ -0,0 +1,158 @@
|
|
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 'rubygems'
|
16
|
+
require 'sass'
|
17
|
+
require 'sass/engine'
|
18
|
+
require 'sass/importers'
|
19
|
+
require 'java'
|
20
|
+
|
21
|
+
java_package "org.sass.archive_importer"
|
22
|
+
|
23
|
+
class ClassLoaderImporter < Sass::Importers::Base
|
24
|
+
include Java
|
25
|
+
|
26
|
+
attr_reader :sub_folder
|
27
|
+
|
28
|
+
def extensions
|
29
|
+
{
|
30
|
+
".scss" => :scss,
|
31
|
+
".css" => :scss,
|
32
|
+
".sass" => :sass
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
class Entry < Struct.new(:name, :stream)
|
37
|
+
def read
|
38
|
+
return @result if @result
|
39
|
+
reader = java.io.BufferedReader.new(java.io.InputStreamReader.new(stream, "utf8"));
|
40
|
+
@result = ""
|
41
|
+
while (line = reader.read_line)
|
42
|
+
@result << line
|
43
|
+
@result << "\n"
|
44
|
+
end
|
45
|
+
@result
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def initialize(sub_folder = nil)
|
50
|
+
require 'pathname'
|
51
|
+
@sub_folder = sub_folder
|
52
|
+
end
|
53
|
+
|
54
|
+
# Enable watching of css files in Sass 3.3+
|
55
|
+
def watched_directories
|
56
|
+
[]
|
57
|
+
end
|
58
|
+
|
59
|
+
# Enable watching of css files in Sass 3.3+
|
60
|
+
java_signature 'boolean isWatchedFile(String)'
|
61
|
+
def watched_file?(file)
|
62
|
+
false
|
63
|
+
end
|
64
|
+
|
65
|
+
def find_relative(name, base, options)
|
66
|
+
base = base.split("<ClassLoaderImporter>#{'/' if sub_folder}#{sub_folder}", 2).last
|
67
|
+
if entry = entry_for(name, base)
|
68
|
+
engine(entry, options)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def find(name, options)
|
74
|
+
if entry = entry_for(name)
|
75
|
+
engine(entry, options)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def engine(entry, options)
|
80
|
+
options[:syntax] = extensions.fetch(File.extname(entry.name), :scss)
|
81
|
+
options[:filename] = full_filename(entry)
|
82
|
+
options[:importer] = self
|
83
|
+
content = entry.read
|
84
|
+
Sass::Engine.new(content, options)
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
def mtime(name, options)
|
89
|
+
if entry = entry_for(name)
|
90
|
+
entry.time
|
91
|
+
end
|
92
|
+
nil
|
93
|
+
end
|
94
|
+
|
95
|
+
def key(name, options)
|
96
|
+
name.split("!", 2)
|
97
|
+
end
|
98
|
+
|
99
|
+
java_signature 'boolean isEql(IRubyObject)'
|
100
|
+
def eql?(other)
|
101
|
+
other.class == self.class &&
|
102
|
+
other.sub_folder == self.sub_folder
|
103
|
+
end
|
104
|
+
|
105
|
+
def to_s
|
106
|
+
"<ClassLoaderImporter#{'/' if sub_folder}#{sub_folder}>"
|
107
|
+
end
|
108
|
+
|
109
|
+
protected
|
110
|
+
|
111
|
+
def full_filename(entry)
|
112
|
+
"<ClassLoaderImporter>/#{entry.name}"
|
113
|
+
end
|
114
|
+
|
115
|
+
def entry_for(name, base = nil)
|
116
|
+
possible_names(name, base).each do |n|
|
117
|
+
n = "#{sub_folder}/#{n}" if sub_folder
|
118
|
+
if entry = find_entry(n)
|
119
|
+
return entry
|
120
|
+
end
|
121
|
+
end
|
122
|
+
nil
|
123
|
+
end
|
124
|
+
|
125
|
+
def find_entry(name)
|
126
|
+
stream = self.to_java.java_class.getResourceAsStream("/"+name)
|
127
|
+
return unless stream
|
128
|
+
Entry.new(name, stream)
|
129
|
+
end
|
130
|
+
|
131
|
+
def possible_names(name, base = nil)
|
132
|
+
if base
|
133
|
+
absolute_root = Pathname.new("/")
|
134
|
+
base_path = Pathname.new(base)
|
135
|
+
path = Pathname.new(name)
|
136
|
+
begin
|
137
|
+
name = absolute_root.join(base_path).dirname.join(path).relative_path_from(absolute_root).to_s
|
138
|
+
rescue
|
139
|
+
# couldn't create a relative path, so we'll just assume it's absolute or for a different importer.
|
140
|
+
return []
|
141
|
+
end
|
142
|
+
end
|
143
|
+
d, b = File.split(name)
|
144
|
+
names = if b.start_with?("_")
|
145
|
+
[name]
|
146
|
+
else
|
147
|
+
[name, d == "." ? "_#{b}" : "#{d}/_#{b}"]
|
148
|
+
end
|
149
|
+
|
150
|
+
names.map do |n|
|
151
|
+
if (ext = File.extname(n)).size > 0 && extensions.keys.include?(ext)
|
152
|
+
n
|
153
|
+
else
|
154
|
+
extensions.keys.map{|k| "#{n}#{k}" }
|
155
|
+
end
|
156
|
+
end.flatten
|
157
|
+
end
|
158
|
+
end
|
@@ -12,7 +12,9 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
|
15
|
+
require 'sass'
|
16
|
+
|
17
|
+
class SassArchiveImporter::Importer < Sass::Importers::Base
|
16
18
|
|
17
19
|
attr_reader :archive_file
|
18
20
|
attr_reader :sub_folder
|
@@ -80,7 +82,9 @@ class Sass::ArchiveImporter::Importer < Sass::Importers::Base
|
|
80
82
|
end
|
81
83
|
|
82
84
|
def eql?(other)
|
83
|
-
other.class == self.class &&
|
85
|
+
other.class == self.class &&
|
86
|
+
other.archive_file == self.archive_file
|
87
|
+
other.sub_folder == self.sub_folder
|
84
88
|
end
|
85
89
|
|
86
90
|
protected
|
@@ -21,7 +21,7 @@ class Sass::Engine
|
|
21
21
|
if options[:load_paths]
|
22
22
|
options[:load_paths].map! do |load_path|
|
23
23
|
next load_path unless load_path.is_a?(::String) && load_path =~ /^(.*\.(?:zip|jar))(?:!(.+))?$/
|
24
|
-
|
24
|
+
SassArchiveImporter::Importer.new($1, $2)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -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 SassArchiveImporter
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'sass_archive_importer/importer'
|
19
|
+
require 'sass_archive_importer/monkey_patches'
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("lib", File.dirname(__FILE__))
|
3
|
-
require "
|
3
|
+
require "sass_archive_importer/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "sass-archive-importer"
|
7
|
-
s.version =
|
7
|
+
s.version = SassArchiveImporter::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Chris Eppstein"]
|
10
10
|
s.email = ["chris@eppsteins.net"]
|
@@ -12,13 +12,14 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.summary = "Allows sass, scss, and css files within zip and jar files to be found " +
|
13
13
|
"using Sass @import directives."
|
14
14
|
s.description = "Allows sass, scss, and css files within zip and jar files to be found " +
|
15
|
-
"using Sass @import directives."
|
15
|
+
"using Sass @import directives. Also supports loading sass files in " +
|
16
|
+
"JRuby from the java class loader."
|
16
17
|
s.license = 'Apache 2.0'
|
17
18
|
|
18
19
|
s.files = `git ls-files`.split("\n")
|
19
20
|
s.test_files = `git ls-files -- test/*`.split("\n")
|
20
21
|
s.require_paths = ["lib"]
|
21
22
|
|
22
|
-
s.add_runtime_dependency 'sass', '>= 3.1'
|
23
|
+
s.add_runtime_dependency 'sass', '>= 3.1', '< 3.4'
|
23
24
|
s.add_runtime_dependency 'rubyzip', '~> 0.9.9'
|
24
25
|
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
//import org.sass.archive_importer.ClassLoaderImporter;
|
2
|
+
import org.jruby.Ruby;
|
3
|
+
|
4
|
+
class ClassLoaderImporterTest {
|
5
|
+
//public void testJavaInstantiation() {
|
6
|
+
//ClassLoaderImporter importer = new ClassLoaderImporter(null);
|
7
|
+
//}
|
8
|
+
|
9
|
+
public void testClassLoaderImporter() {
|
10
|
+
final Ruby runtime = Ruby.newInstance();
|
11
|
+
String script =
|
12
|
+
"# The next three lines make sure no system gems are loaded.\n" +
|
13
|
+
"$:.reject!{|f| !f.start_with?('file:') }\n" +
|
14
|
+
"ENV['GEM_HOME'] = nil\n" +
|
15
|
+
"ENV['GEM_PATH'] = nil\n" +
|
16
|
+
"require 'rubygems'\n" +
|
17
|
+
"require 'sass'\n" +
|
18
|
+
"require 'java'\n" +
|
19
|
+
"require 'org/sass/archive_importer/ClassLoaderImporter'\n" +
|
20
|
+
"class_path_importer = ClassLoaderImporter.new\n" +
|
21
|
+
"sass_file_contents = %Q{\n" +
|
22
|
+
"@import \"css_partial\";\n" +
|
23
|
+
"@import \"sass_partial\";\n" +
|
24
|
+
"@import \"scss_partial\";\n" +
|
25
|
+
"@import \"a_css_file\";\n" +
|
26
|
+
"@import \"a_sass_file\";\n" +
|
27
|
+
"@import \"a_scss_file\";\n" +
|
28
|
+
"@import \"nested/nested\";\n" +
|
29
|
+
"}\n" +
|
30
|
+
"engine = Sass::Engine.new(sass_file_contents,\n" +
|
31
|
+
" :syntax => :scss,\n" +
|
32
|
+
" :filename => 'class_loader_import_test_script.java',\n" +
|
33
|
+
" :cache => false,\n" +
|
34
|
+
" :read_cache => false,\n" +
|
35
|
+
" :load_paths => [class_path_importer])\n" +
|
36
|
+
"result = engine.render\n" +
|
37
|
+
"fail %Q{Unexpected output: #{result}} unless result == <<CSS\n" +
|
38
|
+
".css-partial {\n" +
|
39
|
+
" color: black; }\n" +
|
40
|
+
"\n" +
|
41
|
+
".sass-partial {\n" +
|
42
|
+
" partial: yep; }\n" +
|
43
|
+
"\n" +
|
44
|
+
".scss-partial {\n" +
|
45
|
+
" partial: yes; }\n" +
|
46
|
+
"\n" +
|
47
|
+
".css-file {\n" +
|
48
|
+
" css: boring; }\n" +
|
49
|
+
"\n" +
|
50
|
+
".sass-file {\n" +
|
51
|
+
" indented: yes; }\n" +
|
52
|
+
"\n" +
|
53
|
+
".scss-file {\n" +
|
54
|
+
" curly-braces: omg; }\n" +
|
55
|
+
"\n" +
|
56
|
+
".deeply-nested {\n" +
|
57
|
+
" deeply: nested; }\n" +
|
58
|
+
"\n" +
|
59
|
+
".nested-class {\n" +
|
60
|
+
" nested: yep; }\n" +
|
61
|
+
"CSS\n"+
|
62
|
+
"\n";
|
63
|
+
runtime.evalScriptlet(script);
|
64
|
+
}
|
65
|
+
|
66
|
+
public void testClassLoaderImporterNestedContext() {
|
67
|
+
final Ruby runtime = Ruby.newInstance();
|
68
|
+
String script =
|
69
|
+
"# The next three lines make sure no system gems are loaded.\n" +
|
70
|
+
"$:.reject!{|f| !f.start_with?('file:') }\n" +
|
71
|
+
"ENV['GEM_HOME'] = nil\n" +
|
72
|
+
"ENV['GEM_PATH'] = nil\n" +
|
73
|
+
"require 'rubygems'\n" +
|
74
|
+
"require 'sass'\n" +
|
75
|
+
"require 'java'\n" +
|
76
|
+
"require 'org/sass/archive_importer/ClassLoaderImporter'\n" +
|
77
|
+
"class_path_importer = ClassLoaderImporter.new('sass_files')\n" +
|
78
|
+
"sass_file_contents = %Q{\n" +
|
79
|
+
"@import \"css_partial\";\n" +
|
80
|
+
"@import \"sass_partial\";\n" +
|
81
|
+
"@import \"scss_partial\";\n" +
|
82
|
+
"@import \"a_css_file\";\n" +
|
83
|
+
"@import \"a_sass_file\";\n" +
|
84
|
+
"@import \"a_scss_file\";\n" +
|
85
|
+
"@import \"nested/nested\";\n" +
|
86
|
+
"}\n" +
|
87
|
+
"engine = Sass::Engine.new(sass_file_contents,\n" +
|
88
|
+
" :syntax => :scss,\n" +
|
89
|
+
" :filename => 'class_loader_import_test_script.java',\n" +
|
90
|
+
" :cache => false,\n" +
|
91
|
+
" :read_cache => false,\n" +
|
92
|
+
" :load_paths => [class_path_importer])\n" +
|
93
|
+
"result = engine.render\n" +
|
94
|
+
"fail %Q{Unexpected output: #{result}} unless result == <<CSS\n" +
|
95
|
+
".css-partial {\n" +
|
96
|
+
" color: black; }\n" +
|
97
|
+
"\n" +
|
98
|
+
".sass-partial {\n" +
|
99
|
+
" partial: yep; }\n" +
|
100
|
+
"\n" +
|
101
|
+
".scss-partial {\n" +
|
102
|
+
" partial: yes; }\n" +
|
103
|
+
"\n" +
|
104
|
+
".css-file {\n" +
|
105
|
+
" css: boring; }\n" +
|
106
|
+
"\n" +
|
107
|
+
".sass-file {\n" +
|
108
|
+
" indented: yes; }\n" +
|
109
|
+
"\n" +
|
110
|
+
".scss-file {\n" +
|
111
|
+
" curly-braces: omg; }\n" +
|
112
|
+
"\n" +
|
113
|
+
".deeply-nested {\n" +
|
114
|
+
" deeply: nested; }\n" +
|
115
|
+
"\n" +
|
116
|
+
".nested-class {\n" +
|
117
|
+
" nested: yep; }\n" +
|
118
|
+
"CSS\n"+
|
119
|
+
"\n";
|
120
|
+
runtime.evalScriptlet(script);
|
121
|
+
}
|
122
|
+
|
123
|
+
public void testClassLoaderImporterMissingImport() {
|
124
|
+
final Ruby runtime = Ruby.newInstance();
|
125
|
+
String script =
|
126
|
+
"# The next three lines make sure no system gems are loaded.\n" +
|
127
|
+
"$:.reject!{|f| !f.start_with?('file:') }\n" +
|
128
|
+
"ENV['GEM_HOME'] = nil\n" +
|
129
|
+
"ENV['GEM_PATH'] = nil\n" +
|
130
|
+
"require 'rubygems'\n" +
|
131
|
+
"require 'sass'\n" +
|
132
|
+
"require 'java'\n" +
|
133
|
+
"require 'org/sass/archive_importer/ClassLoaderImporter'\n" +
|
134
|
+
"class_path_importer = ClassLoaderImporter.new\n" +
|
135
|
+
"sass_file_contents = %Q{\n" +
|
136
|
+
"@import \"has_missing_import\";\n" +
|
137
|
+
"}\n" +
|
138
|
+
"engine = Sass::Engine.new(sass_file_contents,\n" +
|
139
|
+
" :syntax => :scss,\n" +
|
140
|
+
" :filename => 'class_loader_import_test_script.java',\n" +
|
141
|
+
" :cache => false,\n" +
|
142
|
+
" :read_cache => false,\n" +
|
143
|
+
" :load_paths => [class_path_importer])\n" +
|
144
|
+
"begin\n" +
|
145
|
+
" engine.render\n" +
|
146
|
+
" fail 'Exception expected'\n" +
|
147
|
+
"rescue => e\n" +
|
148
|
+
" fail 'Expected a Sass::SyntaxError' unless e.is_a?(Sass::SyntaxError)\n" +
|
149
|
+
" fail %Q{expected message but got: #{e.message}} unless e.message == <<MSG.strip\n" +
|
150
|
+
"File to import not found or unreadable: this_does_not_exist.\n" +
|
151
|
+
"Load path: <ClassLoaderImporter>\n" +
|
152
|
+
"MSG\n" +
|
153
|
+
"end\n" +
|
154
|
+
"\n";
|
155
|
+
runtime.evalScriptlet(script);
|
156
|
+
}
|
157
|
+
|
158
|
+
public static void main(String [] args) {
|
159
|
+
ClassLoaderImporterTest test = new ClassLoaderImporterTest();
|
160
|
+
//test.testJavaInstantiation();
|
161
|
+
test.testClassLoaderImporter();
|
162
|
+
test.testClassLoaderImporterNestedContext();
|
163
|
+
test.testClassLoaderImporterMissingImport();
|
164
|
+
System.out.println("ALL Java Tests Passed");
|
165
|
+
}
|
166
|
+
}
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "this_does_not_exist";
|
@@ -24,10 +24,11 @@ require 'sass'
|
|
24
24
|
require 'sass-archive-importer'
|
25
25
|
|
26
26
|
class SassArchiveImporterTest < Test::Unit::TestCase
|
27
|
+
FIXTURES_DIR = File.expand_path(File.join(File.dirname(__FILE__), "fixtures"))
|
27
28
|
# These fixtures are created and kept up to date by the rakefile
|
28
29
|
# Run `rake test` to re-create them
|
29
|
-
ZIP_FIXTURE = File.
|
30
|
-
JAR_FIXTURE = File.
|
30
|
+
ZIP_FIXTURE = File.join(FIXTURES_DIR, "zipped_files.zip")
|
31
|
+
JAR_FIXTURE = File.join(FIXTURES_DIR, "jarred_files.jar")
|
31
32
|
|
32
33
|
def test_can_import_files_from_zip
|
33
34
|
css = render_file_from_zip("imports_from_zip.scss")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sass-archive-importer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.beta.
|
4
|
+
version: 1.0.0.beta.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Eppstein
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sass
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.1'
|
20
|
+
- - <
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3.4'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
- - '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '3.1'
|
30
|
+
- - <
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.4'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: rubyzip
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +45,8 @@ dependencies:
|
|
39
45
|
- !ruby/object:Gem::Version
|
40
46
|
version: 0.9.9
|
41
47
|
description: Allows sass, scss, and css files within zip and jar files to be found
|
42
|
-
using Sass @import directives.
|
48
|
+
using Sass @import directives. Also supports loading sass files in JRuby from the
|
49
|
+
java class loader.
|
43
50
|
email:
|
44
51
|
- chris@eppsteins.net
|
45
52
|
executables: []
|
@@ -53,21 +60,26 @@ files:
|
|
53
60
|
- LICENSE.txt
|
54
61
|
- README.markdown
|
55
62
|
- Rakefile
|
63
|
+
- lib/org/sass/archive_importer/ClassLoaderImporter.rb
|
56
64
|
- lib/sass-archive-importer.rb
|
57
65
|
- lib/sass/archive_importer.rb
|
58
|
-
- lib/
|
59
|
-
- lib/
|
60
|
-
- lib/
|
66
|
+
- lib/sass_archive_importer.rb
|
67
|
+
- lib/sass_archive_importer/importer.rb
|
68
|
+
- lib/sass_archive_importer/monkey_patches.rb
|
69
|
+
- lib/sass_archive_importer/version.rb
|
61
70
|
- sass-archive-importer.gemspec
|
71
|
+
- test/class_loader_importer_test.java
|
62
72
|
- test/fixtures/.gitignore
|
63
73
|
- test/fixtures/imports_from_zip.scss
|
64
74
|
- test/fixtures/imports_from_zip_subfolder.scss
|
75
|
+
- test/fixtures/jruby-complete-1.6.5.jar
|
65
76
|
- test/fixtures/zipped_files/_css_partial.css
|
66
77
|
- test/fixtures/zipped_files/_sass_partial.sass
|
67
78
|
- test/fixtures/zipped_files/_scss_partial.scss
|
68
79
|
- test/fixtures/zipped_files/a_css_file.css
|
69
80
|
- test/fixtures/zipped_files/a_sass_file.sass
|
70
81
|
- test/fixtures/zipped_files/a_scss_file.scss
|
82
|
+
- test/fixtures/zipped_files/has_missing_import.scss
|
71
83
|
- test/fixtures/zipped_files/nested/_nested.scss
|
72
84
|
- test/fixtures/zipped_files/nested/deeply_nested/_deeply.scss
|
73
85
|
- test/sass_archive_importer_test.rb
|
@@ -97,15 +109,18 @@ specification_version: 4
|
|
97
109
|
summary: Allows sass, scss, and css files within zip and jar files to be found using
|
98
110
|
Sass @import directives.
|
99
111
|
test_files:
|
112
|
+
- test/class_loader_importer_test.java
|
100
113
|
- test/fixtures/.gitignore
|
101
114
|
- test/fixtures/imports_from_zip.scss
|
102
115
|
- test/fixtures/imports_from_zip_subfolder.scss
|
116
|
+
- test/fixtures/jruby-complete-1.6.5.jar
|
103
117
|
- test/fixtures/zipped_files/_css_partial.css
|
104
118
|
- test/fixtures/zipped_files/_sass_partial.sass
|
105
119
|
- test/fixtures/zipped_files/_scss_partial.scss
|
106
120
|
- test/fixtures/zipped_files/a_css_file.css
|
107
121
|
- test/fixtures/zipped_files/a_sass_file.sass
|
108
122
|
- test/fixtures/zipped_files/a_scss_file.scss
|
123
|
+
- test/fixtures/zipped_files/has_missing_import.scss
|
109
124
|
- test/fixtures/zipped_files/nested/_nested.scss
|
110
125
|
- test/fixtures/zipped_files/nested/deeply_nested/_deeply.scss
|
111
126
|
- test/sass_archive_importer_test.rb
|