dashy 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,275 @@
1
+ require 'sass/script/functions'
2
+
3
+ Sass::Script::Value = Sass::Script unless Sass::Script.const_defined? :Value, false
4
+
5
+ class Sass::Script::Value::String
6
+
7
+ prepend Module.new {
8
+
9
+ def to_s opt = {}
10
+ return @value# if :selector == @type
11
+ end
12
+
13
+ }
14
+
15
+ end
16
+ module Sass::Script::Functions
17
+
18
+ def is_wildcard value
19
+ '*' == value.to_s
20
+ end
21
+
22
+ def select *selectors
23
+ this = select_identifier ""
24
+ select_as this, *selectors
25
+ end
26
+ declare :select, [], :var_args => true
27
+
28
+ def select_as separator, *selectors
29
+ unquote = method :unquote
30
+ separator = separator.value
31
+ selectors = selectors.first if 1 == selectors.length
32
+ selectors = selectors.to_a.map { |selector| selector.to_a.map &unquote }
33
+ selectors = selectors.shift.product *selectors
34
+ Sass::Script::Value::List.new selectors.map! { |selector|
35
+ # selector = selector.reject &method(:is_wildcard) unless 1 == selector.length && is_wildcard(selector.first)
36
+ selector = selector.join separator
37
+ selector.gsub! /(?<=[\w\-\]])\*/, '' # Remove any wildcards after any words or attributes.
38
+ selector.gsub! /\*(?=[\w\.\#\[])/, '' # Remove any wildcards before any tags, classes, ids or attributes.
39
+ select_identifier selector
40
+ }, :comma
41
+ end
42
+ declare :select_with, [:string], :var_args => true
43
+
44
+ def select_as_descendants *selectors
45
+ descendants = select_identifier " "
46
+ select_as descendants, *selectors
47
+ end
48
+ declare :select_as_descendants, [], :var_args => true
49
+
50
+ def select_as_children *selectors
51
+ children = select_identifier ">"
52
+ select_as children, *selectors
53
+ end
54
+ declare :select_as_children, [], :var_args => true
55
+
56
+ def select_as_adjacent_siblings *selectors
57
+ adjacent_siblings = select_identifier "+"
58
+ select_as adjacent_siblings, *selectors
59
+ end
60
+ declare :select_as_adjacent_siblings, [], :var_args => true
61
+
62
+ def select_as_general_siblings *selectors
63
+ general_siblings = select_identifier "~"
64
+ select_as general_siblings, *selectors
65
+ end
66
+ declare :select_as_general_siblings, [], :var_args => true
67
+
68
+ def select_descendants selector = select_any
69
+ descendants = select_identifier " "
70
+ select descendants, selector
71
+ end
72
+ declare :select_descendants, [:string], :var_args => true
73
+
74
+ def select_children selector = select_any
75
+ children = select_identifier ">"
76
+ select children, selector
77
+ end
78
+ declare :select_children, [:string], :var_args => true
79
+
80
+ def select_adjacent_siblings selector = select_any
81
+ adjacent_siblings = select_identifier "+"
82
+ select adjacent_siblings, selector
83
+ end
84
+ declare :select_adjacent_siblings, [:string], :var_args => true
85
+
86
+ def select_general_siblings selector = select_any
87
+ general_siblings = select_identifier "~"
88
+ select general_siblings, selector
89
+ end
90
+ declare :select_general_siblings, [:string], :var_args => true
91
+
92
+ def select_either *selectors
93
+ selectors = selectors.first if 1 == selectors.length
94
+ selectors = selectors.map &:to_a
95
+ Sass::Script::Value::List.new selectors.flatten, :comma
96
+ end
97
+ declare :select_either, [], :var_args => true
98
+
99
+ def select_attribute attribute, *selectors
100
+ selectors = selectors.first if 1 == selectors.length
101
+ selectors = selectors.to_a.map { |selector| select_string "[#{ attribute }=\"#{ select_escaped! selector }\"]" }
102
+ Sass::Script::Value::List.new selectors, :comma
103
+ end
104
+
105
+ def select_spaced_attribute
106
+ raise 'bwoon'
107
+ end
108
+
109
+ def select_attribute_prefix attribute, *selectors
110
+ selectors = selectors.first if 1 == selectors.length
111
+ selectors = selectors.to_a.map { |selector|
112
+ [
113
+ (select_string "[#{ attribute }^=\"#{ select_escaped! selector }\"]"),
114
+ (select_string "[#{ attribute }*=\" #{ select_escaped! selector }\"]")
115
+ ]
116
+ }
117
+ Sass::Script::Value::List.new selectors.flatten, :comma
118
+ end
119
+
120
+ def select_attribute_suffix attribute, *selectors
121
+ selectors = selectors.first if 1 == selectors.length
122
+ selectors = selectors.to_a.map { |selector|
123
+ [
124
+ (select_string "[#{ attribute }$=\"#{ select_escaped! selector }\"]"),
125
+ (select_string "[#{ attribute }*=\"#{ select_escaped! selector } \"]")
126
+ ]
127
+ }
128
+ Sass::Script::Value::List.new selectors.flatten, :comma
129
+ end
130
+
131
+ def select_class_prefix *selectors
132
+ attribute = select_identifier "class"
133
+ select_attribute_prefix attribute, *selectors
134
+ end
135
+
136
+ def select_class_suffix *selectors
137
+ attribute = select_identifier "class"
138
+ select_attribute_suffix attribute, *selectors
139
+ end
140
+
141
+ def select_class selector
142
+ selectors = selector.to_a.map &:to_a
143
+ selectors = selectors.shift.product *selectors
144
+ selectors.map! { |selector| select_identifier "." + select_escaped!(selector.to_a.join "-") }
145
+ Sass::Script::Value::List.new selectors, :comma
146
+ end
147
+
148
+ def select_classes *selectors
149
+ select_either *(selectors.map! &(method :select_class))
150
+ end
151
+
152
+ def select_pseudoclass selector
153
+ select_identifier ":" + (selector.to_a.join "-")
154
+ end
155
+
156
+ def select_pseudoclasses *selectors
157
+ select_either *(selectors.map! &(method :select_pseudoclass))
158
+ end
159
+
160
+ def select_quasiclass selector
161
+ select_either select_class(selector), select_pseudoclass(selector)
162
+ end
163
+
164
+ def select_quasiclasses *selectors
165
+ select_either *(selectors.map! &(method :select_quasiclass))
166
+ end
167
+
168
+ def select_adjacent_odd_siblings limit, *selectors
169
+ selectors.push select_identifier '*' if selectors.empty?
170
+ selectors = selectors.first if 1 == selectors.length
171
+ selectors = (0 .. limit.value).select { |i| 1 == i % 2 }.map { |i| select select_identifier(" + * " * i + " + "), *selectors }
172
+ select_either *selectors
173
+ end
174
+
175
+ def select_odd_siblings limit, *selectors
176
+ select_either select_first_sibling, select(select_first_sibling, select_adjacent_odd_siblings(limit, *selectors))
177
+ end
178
+
179
+ def select_odd_children limit, *selectors
180
+ select_children select_odd_siblings(limit, *selectors)
181
+ end
182
+
183
+ def select_adjacent_even_siblings limit, *selectors
184
+ selectors.push select_identifier '*' if selectors.empty?
185
+ selectors = selectors.first if 1 == selectors.length
186
+ selectors = (0 .. limit.value).select { |i| 0 == i % 2 }.map { |i| select select_identifier(" + * " * i + " + "), *selectors }
187
+ select_either *selectors
188
+ end
189
+
190
+ def select_even_siblings limit, *selectors
191
+ select select_first_sibling, select_adjacent_even_siblings(limit, *selectors)
192
+ end
193
+
194
+ def select_even_children limit, *selectors
195
+ select_children select_even_siblings(limit, *selectors)
196
+ end
197
+
198
+ def select_first_child
199
+ select_children select_first_sibling
200
+ end
201
+
202
+ def select_first_sibling
203
+ select_identifier ":first_child"
204
+ end
205
+
206
+ def select_any
207
+ select_identifier "*"
208
+ end
209
+
210
+ def select_string selector
211
+ Sass::Script::Value::String.new selector.to_s, :string
212
+ end
213
+
214
+ def select_identifier selector
215
+ Sass::Script::Value::String.new selector.to_s, :identifier
216
+ end
217
+
218
+ def select_escaped! thing
219
+ thing.tap { |t|
220
+ case thing
221
+
222
+ when String
223
+ t.gsub! /(?<!\\)(?=[\=\$\%\/\?\!\.])/, "\\"
224
+
225
+ when Sass::Script::Value::String
226
+ select_escaped! t.value
227
+
228
+ end
229
+ }
230
+ end
231
+
232
+ def select_escaped_string selector
233
+ select_escaped! select_string selector
234
+ end
235
+
236
+ def select_escaped_identifier selector
237
+ select_escaped! select_identifier selector
238
+ end
239
+
240
+ def select_arguments namespace, *name_value_pairs
241
+ inputs = name_value_pairs.map { |name_value_pair|
242
+ name, value = name_value_pair.to_a
243
+ select select_identifier('input:checked'), select_attribute('form', namespace),
244
+ select_attribute('name', name),
245
+ select_attribute('value', value)
246
+ }
247
+ select_as_general_siblings *inputs
248
+
249
+ # $form: select-class($form);
250
+
251
+ # $left: select($input select-general-siblings($form));
252
+ # $right: select($form select-class($name $value));
253
+
254
+ # @return select-either($left, $right);
255
+ end
256
+
257
+ def list_of *lists
258
+ Sass::Script::Value::List.new lists.map { |list|
259
+ list = list.to_a
260
+ number = list.first
261
+ first, second, operator, *rest, last = list.map &:value
262
+ this = first
263
+ delta = second - first
264
+ case operator
265
+ when "_" then [].tap { |list| while this <= last; list << this; this += delta; end }
266
+ when "__" then [].tap { |list| while this < last; list << this; this += delta; end }
267
+ else list
268
+ end.map { |value| Sass::Script::Value::Number.new value, number.numerator_units, number.denominator_units }
269
+ }.flatten, :comma
270
+ end
271
+ declare :select_children, [:list], :var_args => true
272
+
273
+ end
274
+
275
+ # Gem structure adapted from thoughtbot/bourbon...
@@ -0,0 +1,22 @@
1
+ # Needed for pre-3.1.
2
+
3
+ require "fileutils"
4
+ require "find"
5
+
6
+ namespace :dashy do
7
+ desc "Move files to the Rails assets directory."
8
+ task :install, [:sass_path] do |t, args|
9
+ args.with_defaults(:sass_path => 'public/stylesheets/sass')
10
+ source_root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
11
+ FileUtils.mkdir_p("#{Rails.root}/#{args.sass_path}/dashy")
12
+ FileUtils.cp_r("#{source_root}/app/assets/stylesheets/.", "#{Rails.root}/#{args.sass_path}/dashy", { :preserve => true })
13
+ Find.find("#{Rails.root}/#{args.sass_path}/dashy") do |path|
14
+ if path.end_with?(".css.scss")
15
+ path_without_css_extension = path.gsub(/\.css\.scss$/, ".scss")
16
+ FileUtils.mv(path, path_without_css_extension)
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ # Gem structure adapted from thoughtbot/bourbon...
data/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "dashy",
3
+ "version": "0.0.1",
4
+ "description": "A simple and lightweight mixin library for Sass.",
5
+ "keywords": [
6
+ "css",
7
+ "mixins",
8
+ "sass",
9
+ "scss"
10
+ ],
11
+ "homepage": "http://github.com/tosyx/dashy",
12
+ "bugs": {
13
+ "url": "https://github.com/tosyx/dashy/issues"
14
+ },
15
+ "license": "MIT",
16
+ "author": {
17
+ "name": "tosyx",
18
+ "url": "http://tosyx.com"
19
+ },
20
+ "main": "app/assets/stylesheets/_dashy.scss",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/tosyx/dashy.git"
24
+ },
25
+ "scripts": {
26
+ "test": "echo \"No test specified\""
27
+ }
28
+ }
data/sache.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "Dashy",
3
+ "description": "A simple and lightweight mixin library for Sass.",
4
+ "tags": ["add-ons", "animation", "functions", "library", "mixins", "prefixing"]
5
+ }
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dashy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alex Goldsmith
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sass
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: aruba
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: |
70
+ Dashy provides...
71
+ email:
72
+ - alex.tosyx@gmail.com
73
+ executables:
74
+ - dashy
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ".npmignore"
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - app/assets/stylesheets/_dashy.scss
85
+ - app/assets/stylesheets/dashy/_color.scss
86
+ - app/assets/stylesheets/dashy/_corner.scss
87
+ - app/assets/stylesheets/dashy/_default.scss
88
+ - app/assets/stylesheets/dashy/_define.scss
89
+ - app/assets/stylesheets/dashy/_direction.scss
90
+ - app/assets/stylesheets/dashy/_font-family.scss
91
+ - app/assets/stylesheets/dashy/_is.scss
92
+ - app/assets/stylesheets/dashy/_line-height.scss
93
+ - app/assets/stylesheets/dashy/_list.scss
94
+ - app/assets/stylesheets/dashy/_number.scss
95
+ - app/assets/stylesheets/dashy/_opposite.scss
96
+ - app/assets/stylesheets/dashy/_select.scss
97
+ - app/assets/stylesheets/dashy/_set.scss
98
+ - app/assets/stylesheets/dashy/_side.scss
99
+ - bin/dashy
100
+ - dashy.gemspec
101
+ - dashy.json
102
+ - lib/dashy.rb
103
+ - lib/dashy/engine.rb
104
+ - lib/dashy/generator.rb
105
+ - lib/dashy/version.rb
106
+ - lib/sass/script/functions.rb
107
+ - lib/tasks/install.rake
108
+ - package.json
109
+ - sache.json
110
+ homepage: https://github.com/tosyx/dashy
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.4.4
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Selector combinators and other helpers for Sass.
134
+ test_files: []