compass-ls 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,135 @@
1
+ # compass-ls
2
+
3
+ A [Compass](http://compass-style.org/) plugin for listing the content of a
4
+ directory.
5
+
6
+ ## Installation
7
+
8
+ ```bash
9
+ gem install compass-ls
10
+ ```
11
+
12
+ To load the plugin, simply require it at the top of your configuration file:
13
+
14
+ ```ruby
15
+ require 'compass-ls'
16
+ ```
17
+
18
+ Next, import the `_compass-ls.scss` partial into your stylesheets:
19
+
20
+ ```sass
21
+ @import 'compass-ls';
22
+ ```
23
+
24
+ ## Function
25
+
26
+ ```sass
27
+ @function x-ls($files, $suffix: true) {
28
+ @return ...
29
+ }
30
+ ```
31
+
32
+ ### Parameters
33
+
34
+ #### $files
35
+
36
+ Type: `String`
37
+
38
+ The file or glob pattern to match against.
39
+
40
+ #### $suffix
41
+
42
+ Type: `Boolean`
43
+ Default: `true`
44
+
45
+ Lets you specify whether or not the file extension should be omitted from the
46
+ returning list items.
47
+
48
+ ### Return
49
+
50
+ Type: `List`
51
+
52
+ A comma separated list of file/folder names matching the file pattern.
53
+
54
+ ## Example usage
55
+
56
+ Given the following folder structure:
57
+
58
+ ```
59
+ .
60
+ ├── src
61
+ │ ├── img
62
+ │ │ ├── edit.svg
63
+ │ │ ├── forward.png
64
+ │ │ ├── minus.svg
65
+ │ │ ├── move.png
66
+ │ │ └── plus.svg
67
+ │ └── scss
68
+ └── config.rb
69
+ ```
70
+
71
+ ### Example 1: default, sans extension
72
+
73
+ ```sass
74
+ $icons: x-ls('src/img/*');
75
+ $png-icons: x-ls('src/img/*.png');
76
+ $svg-icons: x-ls('src/img/*.svg');
77
+
78
+ @debug($icons); // edit, forward, minus, move, plus
79
+ @debug($png-icons); // forward, move
80
+ @debug($svg-icons); // edit, minus, plus
81
+ ```
82
+
83
+ ### Example 2: with extension
84
+
85
+ ```sass
86
+ $icons: x-ls('src/img/*', false);
87
+ $png-icons: x-ls('src/img/*.png', false);
88
+ $svg-icons: x-ls('src/img/*.svg', false);
89
+
90
+ @debug($icons); // edit.svg, forward.png, minus.svg, move.png, plus.svg
91
+ @debug($png-icons); // forward.png, move.png
92
+ @debug($svg-icons); // edit.svg, minus.svg, plus.svg
93
+ ```
94
+
95
+ ### Example 3: single file
96
+
97
+ ```sass
98
+ $icon: x-ls('src/img/edit.svg');
99
+
100
+ @debug($icon); // edit
101
+ ```
102
+
103
+ ### Example 4: inline svg data-uri
104
+
105
+ ```sass
106
+ $icons: x-ls('src/img/*.svg', false);
107
+
108
+ @each $icon in $icons {
109
+ $icon-name: x-ls('src/img/#{$icon}');
110
+ .#{$icon-name} {
111
+ background-image: inline-image('#{$icon}');
112
+ }
113
+ }
114
+ ```
115
+
116
+ ### Example 5: using the compass-config plugin
117
+
118
+ Instead of hardcoding the images path we can use
119
+ [compass-config](https://github.com/stevenbenisek/compass-config) to fetch the
120
+ `images_path` property from the [Compass configuration](http://compass-style.org/help/tutorials/configuration-reference/#configuration-properties).
121
+
122
+ ```sass
123
+ $images-path: x-config('images_path');
124
+ $icons: x-ls('#{$images-path}/*');
125
+
126
+ @debug($icons); // edit, forward, minus, move, plus
127
+ ```
128
+
129
+ ## Contributing
130
+
131
+ 1. Fork it
132
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
133
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
134
+ 4. Push to the branch (`git push origin my-new-feature`)
135
+ 5. Create new Pull Request
@@ -0,0 +1,19 @@
1
+ # List required gems
2
+ require "compass"
3
+
4
+ # Register extension and provide location
5
+ extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
6
+ Compass::Frameworks.register("compass-ls", :path => extension_path)
7
+
8
+ # Custom SassScript
9
+ module Sass::Script::Functions
10
+ def x_compass_ls(files, suffix)
11
+ files = files.value
12
+ suffix = suffix.value
13
+ suffix = suffix ? '.*' : ''
14
+ return Sass::Script::List.new(
15
+ Dir.glob(files).map! { |x| Sass::Script::String.new(File.basename(x, suffix)) },
16
+ :comma
17
+ )
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ // @param {string} $files
2
+ // @param {boolean} [$suffix]
3
+ // @return {list}
4
+ // @api public
5
+ @function x-ls($files, $suffix: true) {
6
+ @return x_compass_ls($files, $suffix);
7
+ }
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: compass-ls
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Steven Benisek
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-01-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sass
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: compass
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 0.12.1
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.12.1
46
+ description: A Compass plugin for listing the content of a directory
47
+ email:
48
+ - steven.benisek@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - README.md
54
+ - lib/compass-ls.rb
55
+ - stylesheets/_compass-ls.scss
56
+ homepage: https://github.com/stevenbenisek/compass-ls
57
+ licenses:
58
+ - MIT
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 1.8.25
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: A Compass plugin for listing the content of a directory
81
+ test_files: []