bundler-sass 0.1.2
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 +7 -0
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +63 -0
- data/LICENSE +20 -0
- data/README.md +4 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/bin/bundler-sass +11 -0
- data/bundler-sass.gemspec +67 -0
- data/lib/bundler-sass.rb +0 -0
- data/lib/sass_creator.rb +34 -0
- data/lib/sass_reader.rb +26 -0
- data/lib/sass_sort.rb +25 -0
- data/spec/sass_creator_spec.rb +68 -0
- data/spec/sass_reader_spec.rb +103 -0
- data/spec/sass_sort_spec.rb +88 -0
- data/spec/spec_helper.rb +23 -0
- metadata +121 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b011def13a0856c92353a20703a1d99c2e22d8d8
|
4
|
+
data.tar.gz: 0652e99a3709242e7fd68b39af4d901f0eb35304
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bb3b811ca6ec20ac1ee81667c5eb73f344da26bff702d1dd8bec0ab8731dcdfcf5d44568ae0410bb479669ee451de96b090a8f2c9e65d41cfee9719c4adc365a
|
7
|
+
data.tar.gz: e55161a22bdc55540d4d3c278960f06cb40ee9118b90045518e73bfa6dbc7eaf7f796ac06f5de6ec3da69c7343682414e59e9a3c1646fcf9f58012fbeb72ecd3
|
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "rspec", "~> 2.8.0"
|
10
|
+
gem "rdoc", "~> 3.12"
|
11
|
+
gem "bundler", "~> 1.0"
|
12
|
+
gem "jeweler", "~> 1.8.7"
|
13
|
+
#gem "rcov", ">= 0"
|
14
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
addressable (2.3.5)
|
5
|
+
builder (3.2.2)
|
6
|
+
diff-lcs (1.1.3)
|
7
|
+
faraday (0.8.8)
|
8
|
+
multipart-post (~> 1.2.0)
|
9
|
+
git (1.2.6)
|
10
|
+
github_api (0.10.1)
|
11
|
+
addressable
|
12
|
+
faraday (~> 0.8.1)
|
13
|
+
hashie (>= 1.2)
|
14
|
+
multi_json (~> 1.4)
|
15
|
+
nokogiri (~> 1.5.2)
|
16
|
+
oauth2
|
17
|
+
hashie (2.0.5)
|
18
|
+
highline (1.6.20)
|
19
|
+
httpauth (0.2.0)
|
20
|
+
jeweler (1.8.8)
|
21
|
+
builder
|
22
|
+
bundler (~> 1.0)
|
23
|
+
git (>= 1.2.5)
|
24
|
+
github_api (= 0.10.1)
|
25
|
+
highline (>= 1.6.15)
|
26
|
+
nokogiri (= 1.5.10)
|
27
|
+
rake
|
28
|
+
rdoc
|
29
|
+
json (1.8.1)
|
30
|
+
jwt (0.1.8)
|
31
|
+
multi_json (>= 1.5)
|
32
|
+
multi_json (1.8.2)
|
33
|
+
multi_xml (0.5.5)
|
34
|
+
multipart-post (1.2.0)
|
35
|
+
nokogiri (1.5.10)
|
36
|
+
oauth2 (0.9.2)
|
37
|
+
faraday (~> 0.8)
|
38
|
+
httpauth (~> 0.2)
|
39
|
+
jwt (~> 0.1.4)
|
40
|
+
multi_json (~> 1.0)
|
41
|
+
multi_xml (~> 0.5)
|
42
|
+
rack (~> 1.2)
|
43
|
+
rack (1.5.2)
|
44
|
+
rake (10.1.0)
|
45
|
+
rdoc (3.12.2)
|
46
|
+
json (~> 1.4)
|
47
|
+
rspec (2.8.0)
|
48
|
+
rspec-core (~> 2.8.0)
|
49
|
+
rspec-expectations (~> 2.8.0)
|
50
|
+
rspec-mocks (~> 2.8.0)
|
51
|
+
rspec-core (2.8.0)
|
52
|
+
rspec-expectations (2.8.0)
|
53
|
+
diff-lcs (~> 1.1.2)
|
54
|
+
rspec-mocks (2.8.0)
|
55
|
+
|
56
|
+
PLATFORMS
|
57
|
+
ruby
|
58
|
+
|
59
|
+
DEPENDENCIES
|
60
|
+
bundler (~> 1.0)
|
61
|
+
jeweler (~> 1.8.7)
|
62
|
+
rdoc (~> 3.12)
|
63
|
+
rspec (~> 2.8.0)
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Adam Hendricksen
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/lib/sass_creator')
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/lib/sass_sort')
|
4
|
+
require 'rubygems'
|
5
|
+
require 'bundler'
|
6
|
+
begin
|
7
|
+
Bundler.setup(:default, :development)
|
8
|
+
rescue Bundler::BundlerError => e
|
9
|
+
$stderr.puts e.message
|
10
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
11
|
+
exit e.status_code
|
12
|
+
end
|
13
|
+
require 'rake'
|
14
|
+
|
15
|
+
require 'jeweler'
|
16
|
+
Jeweler::Tasks.new do |gem|
|
17
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
18
|
+
gem.name = "bundler-sass"
|
19
|
+
gem.homepage = "http://github.com/vogelbek/bundler-sass"
|
20
|
+
gem.license = "MIT"
|
21
|
+
gem.summary = %Q{Builds a manifest file for all your sass partials}
|
22
|
+
gem.description = %Q{As opposed to manually building a manifest file for all those sass partials, let this rake task take care of it.}
|
23
|
+
gem.email = "adam@nird.us"
|
24
|
+
gem.authors = ["Adam Hendricksen"]
|
25
|
+
# dependencies defined in Gemfile
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rspec/core'
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
32
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
33
|
+
end
|
34
|
+
|
35
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
36
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
37
|
+
spec.rcov = true
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
42
|
+
require 'rdoc/task'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = "bundler-sass #{version}"
|
48
|
+
rdoc.rdoc_files.include('README*')
|
49
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
end
|
51
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.2
|
data/bin/bundler-sass
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/sass_sort')
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/sass_creator')
|
4
|
+
|
5
|
+
include SassSort
|
6
|
+
include SassCreator
|
7
|
+
file_name = "manifest.sass"
|
8
|
+
import_array = SassSort.import_order
|
9
|
+
manifest_hash = {file_name => import_array}
|
10
|
+
manifest = SassCreator::SassFile.new manifest_hash
|
11
|
+
manifest.build_imports
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "bundler-sass"
|
8
|
+
s.version = "0.1.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Adam Hendricksen"]
|
12
|
+
s.date = "2013-12-11"
|
13
|
+
s.description = "As opposed to manually building a manifest file for all those sass partials, let this rake task take care of it."
|
14
|
+
s.email = "adam@nird.us"
|
15
|
+
s.executables = ["bundler-sass"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE",
|
18
|
+
"README.md"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
".rspec",
|
23
|
+
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
25
|
+
"LICENSE",
|
26
|
+
"README.md",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"bin/bundler-sass",
|
30
|
+
"bundler-sass.gemspec",
|
31
|
+
"lib/bundler-sass.rb",
|
32
|
+
"lib/sass_creator.rb",
|
33
|
+
"lib/sass_reader.rb",
|
34
|
+
"lib/sass_sort.rb",
|
35
|
+
"spec/sass_creator_spec.rb",
|
36
|
+
"spec/sass_reader_spec.rb",
|
37
|
+
"spec/sass_sort_spec.rb",
|
38
|
+
"spec/spec_helper.rb"
|
39
|
+
]
|
40
|
+
s.homepage = "http://github.com/vogelbek/bundler-sass"
|
41
|
+
s.licenses = ["MIT"]
|
42
|
+
s.require_paths = ["lib"]
|
43
|
+
s.rubygems_version = "2.0.3"
|
44
|
+
s.summary = "Builds a manifest file for all your sass partials"
|
45
|
+
|
46
|
+
if s.respond_to? :specification_version then
|
47
|
+
s.specification_version = 4
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
51
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
52
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
53
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
56
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
57
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
58
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
|
59
|
+
end
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
62
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
63
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
64
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
data/lib/bundler-sass.rb
ADDED
File without changes
|
data/lib/sass_creator.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module SassCreator
|
2
|
+
class SassFile
|
3
|
+
def initialize file_hash
|
4
|
+
file_hash.each do |file, dependency_list|
|
5
|
+
File.open file, 'w'
|
6
|
+
end
|
7
|
+
@dependencies = file_hash
|
8
|
+
end
|
9
|
+
|
10
|
+
def build_import_comments
|
11
|
+
@dependencies.each do |file, dependency_list|
|
12
|
+
|
13
|
+
File.open(file, 'r+') do |file|
|
14
|
+
dependency_list.each do |dependency|
|
15
|
+
file.write "//import \"#{dependency.to_s}\"\n"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def build_imports
|
23
|
+
@dependencies.each do |file, dependency_list|
|
24
|
+
|
25
|
+
File.open(file, 'r+') do |file|
|
26
|
+
dependency_list.each do |dependency|
|
27
|
+
file.write "@import \"#{dependency.to_s}\"\n"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/sass_reader.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module SassReader
|
2
|
+
def self.dependencies file
|
3
|
+
array = File.open(file, 'r').inject(Array.new) do |array, line|
|
4
|
+
array << line if line =~ /\/\/import /
|
5
|
+
end
|
6
|
+
if array.empty?
|
7
|
+
hash = {file => []}
|
8
|
+
else
|
9
|
+
clean_array = array.map do |entry|
|
10
|
+
entry.gsub(/\/\/import\s\"/,"").gsub(/\"/,"").gsub(/\n/,"")
|
11
|
+
end
|
12
|
+
hash = {file => clean_array}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.list_partials
|
17
|
+
Dir['**/*.*'].select{|partial| partial =~ /_\S+s[ac]ss\z/}
|
18
|
+
#http://rubular.com/r/YCT1k8IaIv, but not at the start of string (for nested files)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.build_dependency_hash partials
|
22
|
+
partials.inject({}) do |hash, partial|
|
23
|
+
hash.merge self.dependencies(partial)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/sass_sort.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/sass_reader')
|
2
|
+
|
3
|
+
module SassSort
|
4
|
+
include SassReader
|
5
|
+
|
6
|
+
|
7
|
+
def self.import_order
|
8
|
+
unsorted = SassReader.list_partials
|
9
|
+
unsorted.inject([]) do |ordered, file|
|
10
|
+
ordered = ordered | depth_first(file, ordered)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def self.depth_first file, sorted
|
16
|
+
local_hash = SassReader.dependencies file
|
17
|
+
local_depends = local_hash.values
|
18
|
+
local_depends.each do |partial|
|
19
|
+
unless partial.empty? or sorted.include?(partial[0])
|
20
|
+
sorted = sorted | depth_first(partial[0], sorted)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
sorted << file
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/sass_creator')
|
3
|
+
|
4
|
+
describe "SassCreator module" do
|
5
|
+
before(:all) do
|
6
|
+
@test_directory = "test_files"
|
7
|
+
@root_directory = Dir.getwd
|
8
|
+
Dir.mkdir @test_directory
|
9
|
+
end
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
Dir.chdir @test_directory
|
13
|
+
end
|
14
|
+
|
15
|
+
context "create partials" do
|
16
|
+
|
17
|
+
it "should create multiple Sass files" do
|
18
|
+
SassCreator::SassFile.new({"_1.sass" => [], "_2.sass" => []})
|
19
|
+
Dir.chdir(@root_directory)
|
20
|
+
Dir.entries(@test_directory).include?("_2.sass").should eq true
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should make any kind of Sass file" do
|
24
|
+
SassCreator::SassFile.new({"1.sass" => [], "2.sass.css" => [], "3.sass" => []})
|
25
|
+
Dir.chdir(@root_directory)
|
26
|
+
Dir.entries(@test_directory).include?("2.sass.css").should eq true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "create files with dependencies" do
|
31
|
+
it "should create a file with an //import statement" do
|
32
|
+
@partial = SassCreator::SassFile.new({"_1.sass" => ["_2.sass"], "_2.sass" => []})
|
33
|
+
@partial.build_import_comments
|
34
|
+
File.open("_1.sass", 'r').each do |line|
|
35
|
+
line.chomp.should eq '//import "_2.sass"'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should create a file with many //import comments" do
|
40
|
+
@partial = SassCreator::SassFile.new({"_1.sass" => ["_2.sass", "_3.sass", "_4.sass"]})
|
41
|
+
@partial.build_import_comments
|
42
|
+
@lines = String.new
|
43
|
+
File.open("_1.sass", 'r').each_with_index do |line, index|
|
44
|
+
@lines << line
|
45
|
+
end
|
46
|
+
@lines.should eq "//import \"_2.sass\"\n//import \"_3.sass\"\n//import \"_4.sass\"\n"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "create files with @import directives" do
|
51
|
+
it "should create a file with @import directives" do
|
52
|
+
@build = SassCreator::SassFile.new({"manifest.sass" => ["_1.sass", "_3.sass", "_2.sass"]})
|
53
|
+
@build.build_imports
|
54
|
+
@lines = String.new
|
55
|
+
File.open("manifest.sass", 'r').each do |line|
|
56
|
+
@lines << line
|
57
|
+
end
|
58
|
+
@lines.should eq "@import \"_1.sass\"\n@import \"_3.sass\"\n@import \"_2.sass\"\n"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
after(:each) do
|
63
|
+
Dir.chdir @root_directory
|
64
|
+
end
|
65
|
+
after(:all) do
|
66
|
+
teardown_test_directory @test_directory
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/sass_creator')
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/sass_reader')
|
4
|
+
|
5
|
+
describe "SassReader" do
|
6
|
+
before(:all) do
|
7
|
+
@test_directory = "test_files"
|
8
|
+
@root_directory = Dir.getwd
|
9
|
+
Dir.mkdir @test_directory
|
10
|
+
end
|
11
|
+
before(:each) do
|
12
|
+
Dir.chdir @test_directory
|
13
|
+
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
context "build a dependency hash" do
|
18
|
+
|
19
|
+
before(:each) do
|
20
|
+
@filename_1 = "_1.sass"
|
21
|
+
@dependencies_1 = ["_2.sass", "_3.sass"]
|
22
|
+
@hash_1 = build_file_and_hash @filename_1, @dependencies_1
|
23
|
+
|
24
|
+
@filename_2 = "_empty.sass"
|
25
|
+
@dependencies_2 = []
|
26
|
+
@hash_2 = build_file_and_hash @filename_2, @dependencies_2
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should read all //import comments into an hash" do
|
30
|
+
SassReader.dependencies(@filename_1).should eq @hash_1
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should be cool with a file without dependencies" do
|
34
|
+
SassReader.dependencies(@filename_2).should eq @hash_2
|
35
|
+
end
|
36
|
+
|
37
|
+
after(:all) do
|
38
|
+
teardown_test_directory @test_directory
|
39
|
+
|
40
|
+
Dir.mkdir @test_directory
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "process all the sass partials in a directory" do
|
45
|
+
before(:each) do
|
46
|
+
@filename_1 = "_1.sass"
|
47
|
+
@dependencies_1 = ["_2.sass"]
|
48
|
+
@hash_1 = build_file_and_hash @filename_1, @dependencies_1
|
49
|
+
|
50
|
+
@filename_2 = "A.sass"
|
51
|
+
@dependencies_2 = ["_1.sass"]
|
52
|
+
@hash_2 = build_file_and_hash @filename_2, @dependencies_2
|
53
|
+
|
54
|
+
@filename_3 = "_2.sass"
|
55
|
+
@dependencies_3 = []
|
56
|
+
@hash_3 = build_file_and_hash @filename_3, @dependencies_3
|
57
|
+
end
|
58
|
+
it "should create an array of partial filenames in a directory" do
|
59
|
+
SassReader.list_partials.should eq [@filename_1, @filename_3]
|
60
|
+
end
|
61
|
+
it "should create an array of partial filenames in subdirectories" do
|
62
|
+
@local_root = Dir.getwd
|
63
|
+
@nested_directory = "nest"
|
64
|
+
Dir.mkdir @nested_directory
|
65
|
+
Dir.chdir @nested_directory
|
66
|
+
|
67
|
+
@filename_4 = "_1_nest.css.sass"
|
68
|
+
@dependencies_4 = ["_2.sass"]
|
69
|
+
@hash_4 = build_file_and_hash @filename_4, @dependencies_4
|
70
|
+
|
71
|
+
@filename_5 = "_2_nest.scss"
|
72
|
+
@dependencies_5 = ["#{@nested_directory}/_1_nest.sass"]
|
73
|
+
@hash_5 = build_file_and_hash @filename_5, @dependencies_5
|
74
|
+
|
75
|
+
@second_nested = "secondnest"
|
76
|
+
Dir.mkdir @second_nested
|
77
|
+
Dir.chdir @second_nested
|
78
|
+
|
79
|
+
@filename_6 = "_3_nest_nest.scss"
|
80
|
+
@dependencies_6 = ["#{@nested_directory}/_1_nest.sass"]
|
81
|
+
@hash_6 = build_file_and_hash @filename_6, @dependencies_6
|
82
|
+
|
83
|
+
Dir.chdir @local_root
|
84
|
+
SassReader.list_partials.should eq [@filename_1,
|
85
|
+
@filename_3,
|
86
|
+
"#{@nested_directory}/#{@filename_4}",
|
87
|
+
"#{@nested_directory}/#{@filename_5}",
|
88
|
+
"#{@nested_directory}/#{@second_nested}/#{@filename_6}"]
|
89
|
+
end
|
90
|
+
it "should create a dependency hashe for all the partials in the array" do
|
91
|
+
@dependency_hash = {@filename_1 => @dependencies_1,
|
92
|
+
@filename_3 => @dependencies_3}
|
93
|
+
SassReader.build_dependency_hash([@filename_1, @filename_3]).should eq @dependency_hash
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
after(:each) do
|
98
|
+
Dir.chdir @root_directory
|
99
|
+
end
|
100
|
+
after(:all) do
|
101
|
+
teardown_test_directory @test_directory
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/sass_sort')
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/sass_creator')
|
4
|
+
|
5
|
+
describe "SassTree" do
|
6
|
+
before(:all) do
|
7
|
+
@test_directory = "test_files"
|
8
|
+
@root_directory = Dir.getwd
|
9
|
+
Dir.mkdir @test_directory
|
10
|
+
Dir.chdir @test_directory
|
11
|
+
@directories = ["0_nest",
|
12
|
+
"0_nest/1_nest_a",
|
13
|
+
"0_nest/1_nest_b",
|
14
|
+
"0_nest/1_nest_a/2_nest"]
|
15
|
+
|
16
|
+
@directories.each {|directory| Dir.mkdir(directory)}
|
17
|
+
Dir.chdir @root_directory
|
18
|
+
|
19
|
+
end
|
20
|
+
before(:each) do
|
21
|
+
Dir.chdir @test_directory
|
22
|
+
end
|
23
|
+
|
24
|
+
context "Directed Acyclic Graph" do
|
25
|
+
it "should be able to sort a non-nested file structure" do
|
26
|
+
@files = ["_0.scss",
|
27
|
+
"_1.css.sass",
|
28
|
+
"_2.css.scss"]
|
29
|
+
@dependencies = [ [@files[2]],
|
30
|
+
[@files[0]],
|
31
|
+
[]]
|
32
|
+
@files.each.with_index do |file, index|
|
33
|
+
build_file_and_hash file, @dependencies[index]
|
34
|
+
end
|
35
|
+
|
36
|
+
# This particular dependency graph only has a single order it can be loaded in
|
37
|
+
SassSort.import_order.should eq [@files[2], @files[0], @files[1]]
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should be able to sort a nested file structure" do
|
41
|
+
@files = ["_0.scss",
|
42
|
+
"_1.css.sass",
|
43
|
+
"_2.css.scss",
|
44
|
+
"#{@directories[0]}/_3.sass",
|
45
|
+
"#{@directories[0]}/_4.sass",
|
46
|
+
"#{@directories[1]}/_5.sass",
|
47
|
+
"#{@directories[2]}/_6.sass",
|
48
|
+
"#{@directories[3]}/_7.sass"]
|
49
|
+
@dependencies = [ [], #_0.sass
|
50
|
+
["#{@directories[0]}/_3.sass"], #_1.sass
|
51
|
+
["#{@directories[0]}/_4.sass"], #_2.sass
|
52
|
+
["_2.css.scss", "#{@directories[1]}/_5.sass"], #_3.sass
|
53
|
+
["#{@directories[1]}/_5.sass", "#{@directories[2]}/_6.sass"], #_4.sass
|
54
|
+
[], #_5.sass
|
55
|
+
["#{@directories[3]}/_7.sass"], #_6.sass
|
56
|
+
["#{@directories[1]}/_5.sass"]] #_7.sass
|
57
|
+
@files.each.with_index do |file, index|
|
58
|
+
build_file_and_hash file, @dependencies[index]
|
59
|
+
end
|
60
|
+
|
61
|
+
@ordered_list = SassSort.import_order
|
62
|
+
|
63
|
+
@ordered_list.first.should eq @files[5]
|
64
|
+
@ordered_list.index(@files[7]).should be < @ordered_list.index(@files[6])
|
65
|
+
@ordered_list.index(@files[4]).should be < @ordered_list.index(@files[2])
|
66
|
+
@ordered_list.index(@files[3]).should be < @ordered_list.index(@files[1])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "Cyclic Graph" do
|
71
|
+
it "should throw an error when a cyclic graph is detected" do
|
72
|
+
@files = ["_0.scss",
|
73
|
+
"_1.css.sass",
|
74
|
+
"_2.css.scss"]
|
75
|
+
@dependencies = [ [@files[2]],
|
76
|
+
[@files[0]],
|
77
|
+
[@files[0]]] #No independent node, graph contains a cycle
|
78
|
+
pending "such a graph should be impossible in a Sass project"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
after(:each) do
|
83
|
+
Dir.chdir @root_directory
|
84
|
+
end
|
85
|
+
after(:all) do
|
86
|
+
teardown_test_directory @test_directory
|
87
|
+
end
|
88
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'bundler-sass'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
# Requires supporting files with custom matchers and macros, etc,
|
8
|
+
# in ./support/ and its subdirectories.
|
9
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
|
13
|
+
def teardown_test_directory directory
|
14
|
+
FileUtils.rm_rf directory
|
15
|
+
end
|
16
|
+
|
17
|
+
def build_file_and_hash filename, dependencies
|
18
|
+
hash = {filename => dependencies}
|
19
|
+
file = SassCreator::SassFile.new(hash)
|
20
|
+
file.build_import_comments
|
21
|
+
hash
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bundler-sass
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adam Hendricksen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.8.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.8.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jeweler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.8.7
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.8.7
|
69
|
+
description: As opposed to manually building a manifest file for all those sass partials,
|
70
|
+
let this rake task take care of it.
|
71
|
+
email: adam@nird.us
|
72
|
+
executables:
|
73
|
+
- bundler-sass
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files:
|
76
|
+
- LICENSE
|
77
|
+
- README.md
|
78
|
+
files:
|
79
|
+
- .document
|
80
|
+
- .rspec
|
81
|
+
- Gemfile
|
82
|
+
- Gemfile.lock
|
83
|
+
- LICENSE
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- VERSION
|
87
|
+
- bin/bundler-sass
|
88
|
+
- bundler-sass.gemspec
|
89
|
+
- lib/bundler-sass.rb
|
90
|
+
- lib/sass_creator.rb
|
91
|
+
- lib/sass_reader.rb
|
92
|
+
- lib/sass_sort.rb
|
93
|
+
- spec/sass_creator_spec.rb
|
94
|
+
- spec/sass_reader_spec.rb
|
95
|
+
- spec/sass_sort_spec.rb
|
96
|
+
- spec/spec_helper.rb
|
97
|
+
homepage: http://github.com/vogelbek/bundler-sass
|
98
|
+
licenses:
|
99
|
+
- MIT
|
100
|
+
metadata: {}
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 2.0.3
|
118
|
+
signing_key:
|
119
|
+
specification_version: 4
|
120
|
+
summary: Builds a manifest file for all your sass partials
|
121
|
+
test_files: []
|