sass_paths 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NDdjODBmYmU2NGRmYjRmMDk5Mjc3ZWNjZTgxZWNmYzk5MzA5NDgwNg==
5
+ data.tar.gz: !binary |-
6
+ ZmUwYzEyY2M4Y2IzYmExMGFiNThmYzBhYmIzNThkNzA5YWViOTUzMA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ OWQwYTliMWMwY2U2NzZlNWUwNjBhN2VkNGJiMzZlMWE5YWMxOTg5ZWFlOWI1
10
+ YjRjNDZmMGUyMjNjYWM3NDRhYzIzNjJmNGE4YzQ0ZmU4NjgwZmJjOTk2MGFj
11
+ MzllZDYwYjA3NTZkYjY0YTQyMjk3ZjYzN2FmYmU4ZjA5ZjFiODg=
12
+ data.tar.gz: !binary |-
13
+ ZTY5OTc0NzIxZmQ2OWJmOGNlZTdhMWZhOGM2NTBmYzAxZWQ2YzQ4YmQ0MjM3
14
+ NGIxZjRhNzBiM2NmZTVkMGE0ZjNmNjIyNzMyZTI4NmI2MWNmNmE2Yjg5N2Fj
15
+ NTY3NzNiYTc3NDA1ZGU2YzQzYzE4N2E4ZjYwOTJkYWI4OTQzNGY=
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ test/bower_components
@@ -0,0 +1,7 @@
1
+ ## Contributing
2
+
3
+ 1. Fork it ( https://github.com/customink/sass_paths/fork )
4
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
5
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
6
+ 4. Push to the branch (`git push origin my-new-feature`)
7
+ 5. Create a new Pull Request
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sass_paths.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Stafford Brunk
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,70 @@
1
+ # SassPaths
2
+
3
+ This gem provides helper methods for appending directories, gems, and bower
4
+ extensions to the `SASS_PATH` environment variable. This enables you to load
5
+ projects that do not themselves register with SASS.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+
12
+ ```ruby
13
+ gem 'sass_paths'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ ```shell
19
+ $ bundle
20
+ ```
21
+
22
+ Or install it yourself as:
23
+
24
+ ```shell
25
+ $ gem install sass_paths
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ #### Directories
31
+
32
+ To append a directory, simply call `append` with your list of directories that
33
+ you'd like appended.
34
+
35
+ ```ruby
36
+ SassPaths.append('/my/first/sass/path', '/my/second/sass/path', ...)
37
+ ```
38
+
39
+ #### Gems
40
+
41
+ In order to append a gem, call `append_gem_path` with the name of the gem as
42
+ well as the directory within the gem that contains the Sass files.
43
+
44
+ ```ruby
45
+ SassPaths.append_gem_path(gem_name, directory)
46
+ ```
47
+
48
+ #### Bower Components
49
+
50
+ In order to append the Sass files within a bower components directory, call
51
+ `append_bower_components` with the name of the directory where the components
52
+ are installed.
53
+
54
+ ```ruby
55
+ SassPaths.append_bower_components('directory')
56
+ ```
57
+
58
+ ### Rails
59
+
60
+ Create an initializer and utilize the above methods.
61
+
62
+ ### Not Rails
63
+
64
+ Use the above methods in some part of your application's boot process.
65
+
66
+ ## Testing
67
+
68
+ * Run `bundle install` to install development dependencies.
69
+ * Run `bower install` from `test/` to install bower components for testing.
70
+ * Run `rake test` to run all tests.
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ task :default => [:test]
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs << 'test'
8
+ t.pattern = "test/**/*_test.rb"
9
+ end
10
+
@@ -0,0 +1,42 @@
1
+ require "sass_paths/gem"
2
+ require "sass_paths/bower"
3
+ require "sass_paths/version"
4
+ require 'sass'
5
+
6
+ module SassPaths
7
+ class << self
8
+ include Gem
9
+ include Bower
10
+
11
+ def append(*paths)
12
+ existing_paths = paths.select { |path| Dir.exists? path }
13
+ new_paths = [env_path.split(File::PATH_SEPARATOR), existing_paths].flatten
14
+ .compact
15
+ .uniq
16
+ ENV["SASS_PATH"] = new_paths.join(File::PATH_SEPARATOR)
17
+ end
18
+
19
+ def append_gem_path(gem, path)
20
+ append(gem_sass_path(gem, path))
21
+ end
22
+
23
+ def append_bower_components(relative_bower_path)
24
+ sass_paths = get_bower_sass_paths(relative_bower_path)
25
+ append(*sass_paths)
26
+ end
27
+
28
+ def env_path
29
+ ENV["SASS_PATH"] || ""
30
+ end
31
+
32
+ def reload_paths!
33
+ append(*Sass.load_paths)
34
+ Sass.instance_variable_set('@load_paths', nil)
35
+ Sass.load_paths
36
+ end
37
+ end
38
+ end
39
+
40
+ if defined?(Rails)
41
+ require 'sass_paths/rails/engine'
42
+ end
@@ -0,0 +1,39 @@
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
@@ -0,0 +1,14 @@
1
+ module SassPaths
2
+ module Gem
3
+ private
4
+
5
+ def gem_sass_path(gem, directory)
6
+ require gem
7
+ File.join(gem_path(gem), directory)
8
+ end
9
+
10
+ def gem_path(gem)
11
+ ::Gem::Specification.find_all_by_name(gem).first.full_gem_path
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ module SassPaths
2
+ class Engine < ::Rails::Engine
3
+ config.after_initialize do
4
+ ::SassPaths.reload_paths!
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module SassPaths
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sass_paths/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sass_paths"
8
+ spec.version = SassPaths::VERSION
9
+ spec.authors = ["Stafford Brunk", "Jonathan Lehman"]
10
+ spec.email = ["sbrunk@customink.com", "jlehman@customink.com"]
11
+ spec.summary = %q{Helper methods to append directories to the SASS_PATH ENV variable}
12
+ spec.description = %q{This gem provides helper methods for appending directories, gems, and bower extensions to the SASS_PATH environment variable}
13
+ spec.homepage = "https://github.com/customink/sass_paths"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
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
+
26
+ spec.add_dependency "sass"
27
+ end
@@ -0,0 +1,3 @@
1
+ {
2
+ "directory": "bower_components"
3
+ }
@@ -0,0 +1,22 @@
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
+ }
@@ -0,0 +1,66 @@
1
+ require 'test_helper'
2
+
3
+ module SassPaths
4
+ describe '#append' do
5
+ it 'appends path to SASS_PATH ENV with existing paths' do
6
+ ENV['SASS_PATH'] = 'lib:lib/sass_paths'
7
+ SassPaths.append('lib/sass_paths/rails')
8
+ assert_equal 'lib:lib/sass_paths:lib/sass_paths/rails', ENV['SASS_PATH']
9
+ end
10
+
11
+ it 'appends without duplicates' do
12
+ ENV['SASS_PATH'] = 'lib:lib/sass_paths'
13
+ SassPaths.append('lib/sass_paths')
14
+ assert_equal 'lib:lib/sass_paths', ENV['SASS_PATH']
15
+ end
16
+
17
+ it 'appends to empty SASS_PATH ENV' do
18
+ ENV['SASS_PATH'] = ''
19
+ SassPaths.append('lib/sass_paths')
20
+ assert_equal 'lib/sass_paths', ENV['SASS_PATH']
21
+ end
22
+
23
+ it "won't append a path that does not exist" do
24
+ ENV['SASS_PATH'] = ''
25
+ SassPaths.append('this/is/not/a/real/path12321')
26
+ assert_equal '', ENV['SASS_PATH']
27
+ end
28
+ end
29
+
30
+ describe '#append_gem_path' do
31
+ it 'appends gem path to SASS_PATH ENV' do
32
+ ENV['SASS_PATH'] = 'lib/sass_paths:lib'
33
+ SassPaths.append_gem_path('susy', 'sass')
34
+ assert ENV['SASS_PATH'].include? 'lib/sass_paths:lib'
35
+ assert ENV['SASS_PATH'].match /gems\/susy-[\d\.]+\/sass/
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/
47
+ end
48
+ end
49
+
50
+ describe '#env_path' do
51
+ it 'returns SASS_PATH ENV' do
52
+ ENV['SASS_PATH'] = 'lib/sass_paths'
53
+ assert_equal 'lib/sass_paths', SassPaths.env_path
54
+ end
55
+ end
56
+
57
+ describe '#reload_paths!' do
58
+ it 'reloads the SASS_PATH' do
59
+ ENV['SASS_PATH'] = 'lib:lib/sass_paths'
60
+ SassPaths.reload_paths!
61
+ assert_equal ['lib', 'lib/sass_paths'], Sass.load_paths
62
+ assert_equal 'lib:lib/sass_paths', ENV['SASS_PATH']
63
+ end
64
+ end
65
+
66
+ end
@@ -0,0 +1,3 @@
1
+ require 'bundler'
2
+ require 'minitest/autorun'
3
+ require 'sass_paths'
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sass_paths
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Stafford Brunk
8
+ - Jonathan Lehman
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-10-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '1.6'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '1.6'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: minitest
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: susy
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: sass
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ description: This gem provides helper methods for appending directories, gems, and
85
+ bower extensions to the SASS_PATH environment variable
86
+ email:
87
+ - sbrunk@customink.com
88
+ - jlehman@customink.com
89
+ executables: []
90
+ extensions: []
91
+ extra_rdoc_files: []
92
+ files:
93
+ - .gitignore
94
+ - CONTRIBUTING.md
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - lib/sass_paths.rb
100
+ - lib/sass_paths/bower.rb
101
+ - lib/sass_paths/gem.rb
102
+ - lib/sass_paths/rails/engine.rb
103
+ - lib/sass_paths/version.rb
104
+ - sass_paths.gemspec
105
+ - test/.bowerrc
106
+ - test/bower.json
107
+ - test/sass_paths/sass_paths_test.rb
108
+ - test/test_helper.rb
109
+ homepage: https://github.com/customink/sass_paths
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.4.1
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Helper methods to append directories to the SASS_PATH ENV variable
133
+ test_files:
134
+ - test/.bowerrc
135
+ - test/bower.json
136
+ - test/sass_paths/sass_paths_test.rb
137
+ - test/test_helper.rb