sass_paths 1.0.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/README.md +13 -8
- data/Rakefile +4 -5
- data/lib/sass_paths.rb +27 -17
- data/lib/sass_paths/version.rb +1 -1
- data/sass_paths.gemspec +13 -13
- data/test/sass_paths/sass_paths_test.rb +31 -12
- metadata +18 -23
- data/lib/sass_paths/bower.rb +0 -39
- data/test/.bowerrc +0 -3
- data/test/bower.json +0 -22
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NWIyNGUyOTExMjkwZmM0YTFmOGJlMWIxN2Y1MDQyN2I4MjZkMDQ4YQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c46e300a723afb573af1e55facf66b1d98f5742f
|
4
|
+
data.tar.gz: 713fa03b1b629e69444331e9b81e9ba1d1523d1d
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
YTJkYWNmMjJmYTAxYTNlODlkYTA1NDgzZTQ1MDAxYmI1NWI5MmNmMDUxYTcx
|
11
|
-
M2Q2MmIyZDQ3ZjFlODVjOGI3YTEzY2I4M2Y4ZjU3MjViZWQ5NjA=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MGIyMzk4ZjI3NGY5MmFkNjAzNWM4MzE5ODc0NmJhZTRlNTJhZTY4MWFiYWM2
|
14
|
-
NjU3YmYzOGNjOTkzMTM4ZmIyOGE0MGY2YzliNmY4YzQzZmExYTRlMWVmZWU5
|
15
|
-
NzRjZmNjYmQ2MjA4YWQxOGM0YjQwZTI4OWEzNGU4ZTg0MGYyODc=
|
6
|
+
metadata.gz: 2517481edad37c238d9d460add9ebb77b917d532870a1306279e0366ad0275f9416f9ae59edc683a9a5f84eb73579982789058a603d6c04ef666466498314fe3
|
7
|
+
data.tar.gz: 5f2ca50b7d1ddb53cf78031e75258e5ab9fe255089db125352ee1bd1de75e00311251b2afd46645043ddacbc6bf879dff84d940aeb907d45b06d7049b5f5d97f
|
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# SassPaths
|
2
2
|
|
3
|
-
This gem provides helper methods for appending directories
|
4
|
-
extensions to the `SASS_PATH` environment variable. This enables you to load
|
3
|
+
This gem provides helper methods for appending directories and gems to the `SASS_PATH` environment variable. This enables you to load
|
5
4
|
projects that do not themselves register with SASS.
|
6
5
|
|
7
6
|
## Installation
|
@@ -45,16 +44,23 @@ well as the directory within the gem that contains the Sass files.
|
|
45
44
|
SassPaths.append_gem_path(gem_name, directory)
|
46
45
|
```
|
47
46
|
|
48
|
-
####
|
47
|
+
#### Temporary Replacements
|
49
48
|
|
50
|
-
|
51
|
-
`append_bower_components` with the name of the directory where the components
|
52
|
-
are installed.
|
49
|
+
Sometimes it can be fun to change the Sass paths for the duration of a block. For example, this would swap out using [Neat](http://neat.bourbon.io) versions.
|
53
50
|
|
54
51
|
```ruby
|
55
|
-
|
52
|
+
replacements = {
|
53
|
+
"/gems/neat-1.8.0/app/assets/stylesheets" => "/gems/neat-2.0.0/core"
|
54
|
+
}
|
55
|
+
SassPaths.with_replacements(replacements) do
|
56
|
+
options = { load_paths: Sass.load_paths }
|
57
|
+
Sass::Engine.new(template, options).render
|
58
|
+
end
|
56
59
|
```
|
57
60
|
|
61
|
+
The `with_replacements` takes no responsiblity for knowing about the paths passed in as being valid or not.
|
62
|
+
|
63
|
+
|
58
64
|
### Rails
|
59
65
|
|
60
66
|
Create an initializer and utilize the above methods.
|
@@ -66,5 +72,4 @@ Use the above methods in some part of your application's boot process.
|
|
66
72
|
## Testing
|
67
73
|
|
68
74
|
* Run `bundle install` to install development dependencies.
|
69
|
-
* Run `bower install` from `test/` to install bower components for testing.
|
70
75
|
* Run `rake test` to run all tests.
|
data/Rakefile
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
3
|
|
4
|
-
task :
|
4
|
+
task default: [:test]
|
5
5
|
|
6
6
|
Rake::TestTask.new do |t|
|
7
7
|
t.libs << 'test'
|
8
|
-
t.pattern =
|
8
|
+
t.pattern = 'test/**/*_test.rb'
|
9
9
|
end
|
10
|
-
|
data/lib/sass_paths.rb
CHANGED
@@ -1,32 +1,30 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require "sass_paths/version"
|
1
|
+
require 'sass_paths/gem'
|
2
|
+
require 'sass_paths/version'
|
4
3
|
require 'sass'
|
5
4
|
|
6
5
|
module SassPaths
|
7
6
|
class << self
|
8
7
|
include Gem
|
9
|
-
include Bower
|
10
8
|
|
11
9
|
def append(*paths)
|
12
|
-
existing_paths = paths.select { |path| Dir.
|
13
|
-
new_paths = [
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
existing_paths = paths.select { |path| Dir.exist? path }
|
11
|
+
new_paths = [
|
12
|
+
env_path.split(File::PATH_SEPARATOR),
|
13
|
+
existing_paths
|
14
|
+
].flatten.compact.uniq
|
15
|
+
self.env_path = new_paths
|
17
16
|
end
|
18
17
|
|
19
18
|
def append_gem_path(gem, path)
|
20
19
|
append(gem_sass_path(gem, path))
|
21
20
|
end
|
22
21
|
|
23
|
-
def
|
24
|
-
|
25
|
-
append(*sass_paths)
|
22
|
+
def env_path
|
23
|
+
ENV['SASS_PATH'] || ''
|
26
24
|
end
|
27
25
|
|
28
|
-
def env_path
|
29
|
-
ENV[
|
26
|
+
def env_path=(*paths)
|
27
|
+
ENV['SASS_PATH'] = paths.join(File::PATH_SEPARATOR)
|
30
28
|
end
|
31
29
|
|
32
30
|
def reload_paths!
|
@@ -34,9 +32,21 @@ module SassPaths
|
|
34
32
|
Sass.instance_variable_set('@load_paths', nil)
|
35
33
|
Sass.load_paths
|
36
34
|
end
|
35
|
+
|
36
|
+
def with_replacements(replacements = {})
|
37
|
+
reload_paths!
|
38
|
+
old_paths = Sass.load_paths.dup
|
39
|
+
tmp_paths = old_paths.map do |path|
|
40
|
+
replacements[path] ? replacements[path] : path
|
41
|
+
end
|
42
|
+
self.env_path = tmp_paths
|
43
|
+
reload_paths!
|
44
|
+
yield
|
45
|
+
ensure
|
46
|
+
self.env_path = old_paths
|
47
|
+
reload_paths!
|
48
|
+
end
|
37
49
|
end
|
38
50
|
end
|
39
51
|
|
40
|
-
if defined?(Rails)
|
41
|
-
require 'sass_paths/rails/engine'
|
42
|
-
end
|
52
|
+
require 'sass_paths/rails/engine' if defined?(Rails)
|
data/lib/sass_paths/version.rb
CHANGED
data/sass_paths.gemspec
CHANGED
@@ -4,24 +4,24 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'sass_paths/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'sass_paths'
|
8
8
|
spec.version = SassPaths::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
9
|
+
spec.authors = ['Stafford Brunk', 'Jonathan Lehman']
|
10
|
+
spec.email = ['sbrunk@customink.com', 'jlehman@customink.com']
|
11
|
+
spec.summary = 'Helper methods to append directories to the SASS_PATH ENV variable'
|
12
|
+
spec.description = 'This gem provides helper methods for appending directories, and gems to the SASS_PATH environment variable'
|
13
|
+
spec.homepage = 'https://github.com/customink/sass_paths'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
spec.add_development_dependency 'minitest'
|
24
|
+
spec.add_development_dependency 'susy'
|
25
25
|
|
26
|
-
spec.add_dependency
|
26
|
+
spec.add_dependency 'sass', '~> 3.2'
|
27
27
|
end
|
@@ -32,18 +32,7 @@ module SassPaths
|
|
32
32
|
ENV['SASS_PATH'] = 'lib/sass_paths:lib'
|
33
33
|
SassPaths.append_gem_path('susy', 'sass')
|
34
34
|
assert ENV['SASS_PATH'].include? 'lib/sass_paths:lib'
|
35
|
-
assert ENV['SASS_PATH'].match
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe '#append_bower_components' do
|
40
|
-
it 'appends bower paths to SASS_PATH ENV' do
|
41
|
-
ENV['SASS_PATH'] = 'lib/sass_paths:lib'
|
42
|
-
SassPaths.append_bower_components('.')
|
43
|
-
assert ENV['SASS_PATH'].include? 'lib/sass_paths:lib'
|
44
|
-
assert ENV['SASS_PATH'].match /bower_components\/susy\/sass/
|
45
|
-
assert ENV['SASS_PATH'].match /bower_components\/sassy-maps\/sass/
|
46
|
-
refute ENV['SASS_PATH'].match /bower_components\/jquery/
|
35
|
+
assert ENV['SASS_PATH'].match(/gems\/susy-[\d\.]+\/sass/)
|
47
36
|
end
|
48
37
|
end
|
49
38
|
|
@@ -63,4 +52,34 @@ module SassPaths
|
|
63
52
|
end
|
64
53
|
end
|
65
54
|
|
55
|
+
describe '#with_replacements' do
|
56
|
+
it 'can swap out paths' do
|
57
|
+
neatv1 = 'neat-1.8.0/stylesheets'
|
58
|
+
neatv2 = 'neat-2.0.0/stylesheets'
|
59
|
+
brbnv4 = 'bourbon-4.3.3/stylesheets'
|
60
|
+
brbnv5 = 'bourbon-5.0.0/stylesheets'
|
61
|
+
ENV['SASS_PATH'] = "lib:#{neatv1}:lib/sass:#{brbnv4}"
|
62
|
+
SassPaths.reload_paths!
|
63
|
+
assert_equal 'lib', Sass.load_paths[0]
|
64
|
+
assert_equal neatv1, Sass.load_paths[1]
|
65
|
+
assert_equal 'lib/sass', Sass.load_paths[2]
|
66
|
+
assert_equal brbnv4, Sass.load_paths[3]
|
67
|
+
replacements = {
|
68
|
+
neatv1 => neatv2,
|
69
|
+
brbnv4 => brbnv5
|
70
|
+
}
|
71
|
+
SassPaths.with_replacements(replacements) do
|
72
|
+
assert_equal 'lib', Sass.load_paths[0]
|
73
|
+
assert_equal neatv2, Sass.load_paths[1]
|
74
|
+
assert_equal 'lib/sass', Sass.load_paths[2]
|
75
|
+
assert_equal brbnv5, Sass.load_paths[3]
|
76
|
+
ENV['SASS_PATH'] = "lib:#{neatv2}:lib/sass:#{brbnv5}"
|
77
|
+
end
|
78
|
+
assert_equal 'lib', Sass.load_paths[0]
|
79
|
+
assert_equal neatv1, Sass.load_paths[1]
|
80
|
+
assert_equal 'lib/sass', Sass.load_paths[2]
|
81
|
+
assert_equal brbnv4, Sass.load_paths[3]
|
82
|
+
ENV['SASS_PATH'] = "lib:#{neatv1}:lib/sass:#{brbnv4}"
|
83
|
+
end
|
84
|
+
end
|
66
85
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sass_paths
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stafford Brunk
|
@@ -9,80 +9,80 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-03-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '1.6'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - ~>
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.6'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: minitest
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: susy
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: sass
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - ~>
|
74
|
+
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '3.2'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- - ~>
|
81
|
+
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '3.2'
|
84
|
-
description: This gem provides helper methods for appending directories, gems
|
85
|
-
|
84
|
+
description: This gem provides helper methods for appending directories, and gems
|
85
|
+
to the SASS_PATH environment variable
|
86
86
|
email:
|
87
87
|
- sbrunk@customink.com
|
88
88
|
- jlehman@customink.com
|
@@ -90,20 +90,17 @@ executables: []
|
|
90
90
|
extensions: []
|
91
91
|
extra_rdoc_files: []
|
92
92
|
files:
|
93
|
-
- .gitignore
|
93
|
+
- ".gitignore"
|
94
94
|
- CONTRIBUTING.md
|
95
95
|
- Gemfile
|
96
96
|
- LICENSE.txt
|
97
97
|
- README.md
|
98
98
|
- Rakefile
|
99
99
|
- lib/sass_paths.rb
|
100
|
-
- lib/sass_paths/bower.rb
|
101
100
|
- lib/sass_paths/gem.rb
|
102
101
|
- lib/sass_paths/rails/engine.rb
|
103
102
|
- lib/sass_paths/version.rb
|
104
103
|
- sass_paths.gemspec
|
105
|
-
- test/.bowerrc
|
106
|
-
- test/bower.json
|
107
104
|
- test/sass_paths/sass_paths_test.rb
|
108
105
|
- test/test_helper.rb
|
109
106
|
homepage: https://github.com/customink/sass_paths
|
@@ -116,22 +113,20 @@ require_paths:
|
|
116
113
|
- lib
|
117
114
|
required_ruby_version: !ruby/object:Gem::Requirement
|
118
115
|
requirements:
|
119
|
-
- -
|
116
|
+
- - ">="
|
120
117
|
- !ruby/object:Gem::Version
|
121
118
|
version: '0'
|
122
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
120
|
requirements:
|
124
|
-
- -
|
121
|
+
- - ">="
|
125
122
|
- !ruby/object:Gem::Version
|
126
123
|
version: '0'
|
127
124
|
requirements: []
|
128
125
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
126
|
+
rubygems_version: 2.6.8
|
130
127
|
signing_key:
|
131
128
|
specification_version: 4
|
132
129
|
summary: Helper methods to append directories to the SASS_PATH ENV variable
|
133
130
|
test_files:
|
134
|
-
- test/.bowerrc
|
135
|
-
- test/bower.json
|
136
131
|
- test/sass_paths/sass_paths_test.rb
|
137
132
|
- test/test_helper.rb
|
data/lib/sass_paths/bower.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module SassPaths
|
4
|
-
module Bower
|
5
|
-
|
6
|
-
private
|
7
|
-
|
8
|
-
PERMITTED_FILE_EXTENSIONS = ['.scss', '.sass'].freeze
|
9
|
-
|
10
|
-
def get_bower_sass_paths(bower_path)
|
11
|
-
sass_paths = []
|
12
|
-
Dir["#{bower_path}/**/.bower.json"].each do |f|
|
13
|
-
get_main_paths(f).each do |path|
|
14
|
-
sass_paths << path
|
15
|
-
end
|
16
|
-
end
|
17
|
-
sass_paths
|
18
|
-
end
|
19
|
-
|
20
|
-
def get_main_paths(file_name)
|
21
|
-
base_directory = File.dirname(file_name)
|
22
|
-
bower_json = JSON.parse(File.read(file_name))
|
23
|
-
|
24
|
-
main_files = wrap_in_array(bower_json['main'])
|
25
|
-
.select { |main_file| PERMITTED_FILE_EXTENSIONS.include? File.extname(main_file) }
|
26
|
-
.map { |main_file| "#{base_directory}/#{File.dirname(main_file)}" }
|
27
|
-
end
|
28
|
-
|
29
|
-
def wrap_in_array(object)
|
30
|
-
if object.nil?
|
31
|
-
[]
|
32
|
-
elsif object.respond_to?(:to_ary)
|
33
|
-
object.to_ary || [object]
|
34
|
-
else
|
35
|
-
[object]
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/test/.bowerrc
DELETED
data/test/bower.json
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "sass_paths",
|
3
|
-
"version": "0.0.0",
|
4
|
-
"homepage": "https://github.com/customink/sass-paths",
|
5
|
-
"authors": [
|
6
|
-
"Jonathan Lehman <jonathan.lehman91@gmail.com>"
|
7
|
-
],
|
8
|
-
"license": "MIT",
|
9
|
-
"ignore": [
|
10
|
-
"**/.*",
|
11
|
-
"node_modules",
|
12
|
-
"bower_components",
|
13
|
-
"app/bower_components",
|
14
|
-
"test",
|
15
|
-
"tests"
|
16
|
-
],
|
17
|
-
"devDependencies": {
|
18
|
-
"susy": "~2.1.3",
|
19
|
-
"sassy-maps": "~0.4.0",
|
20
|
-
"jquery": "~2.1.1"
|
21
|
-
}
|
22
|
-
}
|