doohickey 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg/
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Trond Arve Nordheim
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,54 @@
1
+ # Doohickey
2
+ A collection of [Sass][sass] mixins that I use in my projects.<br><br>
3
+ Partly based on and inspired by [Compass][compass].
4
+
5
+ # Installation
6
+ Install Doohickey as a plugin using:<br>
7
+ `script/plugin install http://github.com/tanordheim/doohickey.git`
8
+
9
+ Then you must create a initializer file in config/initializers/ containing the
10
+ following:<br>
11
+ `Doohickey::Initializer.initialize`
12
+
13
+ ## Usage
14
+ To import Doohickey into your Sass template, simply type:<br>
15
+ `@import doohickey/doohickey`
16
+
17
+ ## Available mixins
18
+
19
+ ### Accessibility mixins
20
+ * +accessible-image-link
21
+
22
+ ### CSS3 mixins
23
+ * +awesome-button
24
+ * +border-radius, +border-top-radius, +border-bottom-radius, +border-top-left-radius, +border-top-right-radius, +border-bottom-left-radius, +border-bottom-right-radius, +border-corner-radius
25
+ * +font-face
26
+ * +linear-gradient
27
+ * +box-shadow
28
+ * +text-shadow
29
+
30
+ ### Layout mixins
31
+ * +standard-body
32
+
33
+ ### List mixins
34
+ * +no-bullet, +no-bullets
35
+ * +horizontal-list, +horizontal-list-container, +horizontal-list-item
36
+
37
+ ### Tab mixins
38
+ * +horizontal-tabs
39
+
40
+ ### Utility mixins
41
+ * +clearfix
42
+ * +float-left, +float-right, +float-reset
43
+ * +has-layout
44
+ * +global-reset
45
+
46
+ ## Author
47
+ Written by Trond Arve Nordheim.<br>
48
+ Some code is borrowed from [Compass][compass] and written by Chris Eppstein.
49
+
50
+ ## License
51
+ Released under the MIT license
52
+
53
+ [sass]: http://sass-lang.com/ "Syntactically Awesome Stylesheets"
54
+ [compass]: http://compass-style.org/
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ require 'rake'
2
+ require 'rake/classic_namespace'
3
+ require 'rake/testtask'
4
+ require 'rake/rdoctask'
5
+
6
+ desc 'Default: run unit tests.'
7
+ task :default => :test
8
+
9
+ desc 'Test the doohickey plugin.'
10
+ Rake::TestTask.new(:test) do |t|
11
+ t.libs << 'lib'
12
+ t.libs << 'test'
13
+ t.pattern = 'test/**/*_test.rb'
14
+ t.verbose = true
15
+ end
16
+
17
+ desc 'Generate documentation for the doohickey plugin.'
18
+ Rake::RDocTask.new(:rdoc) do |rdoc|
19
+ rdoc.rdoc_dir = 'rdoc'
20
+ rdoc.title = 'Doohickey'
21
+ rdoc.options << '--line-numbers' << '--inline-source'
22
+ rdoc.rdoc_files.include('README')
23
+ rdoc.rdoc_files.include('lib/**/*.rb')
24
+ end
25
+
26
+ begin
27
+ require "jeweler"
28
+ Jeweler::Tasks.new do |gemspec|
29
+ gemspec.name = "doohickey"
30
+ gemspec.summary = "Easy to use SASS mixins for Rails projects"
31
+ gemspec.description = "Contains SASS mixins and a default SASS configuration for use in Ruby on Rails projects"
32
+ gemspec.email = "tanordheim@gmail.com"
33
+ gemspec.homepage = "http://github.com/tanordheim/doohickey"
34
+ gemspec.authors = ["Trond Arve Nordheim"]
35
+ end
36
+ Jeweler::GemcutterTasks.new
37
+ rescue LoadError
38
+ puts "Jeweler not available. Install it with: gem install jeweler"
39
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,40 @@
1
+ @import doohickey/settings.sass
2
+
3
+ //
4
+ // Utility mixins
5
+ // ----------------------------------------------------------------------------
6
+ @import doohickey/utils/hacks.sass
7
+ @import doohickey/utils/clearfix.sass
8
+ @import doohickey/utils/reset.sass
9
+ @import doohickey/utils/floats.sass
10
+
11
+ //
12
+ // Body mixins
13
+ // ----------------------------------------------------------------------------
14
+ @import doohickey/layout/body.sass
15
+
16
+ //
17
+ // List mixins
18
+ // ----------------------------------------------------------------------------
19
+ @import doohickey/lists/bullets.sass
20
+ @import doohickey/lists/horizontal.sass
21
+
22
+
23
+ //
24
+ // Tabs mixins
25
+ // ----------------------------------------------------------------------------
26
+ @import doohickey/tabs/horizontal.sass
27
+
28
+ //
29
+ // Accessibility
30
+ // ----------------------------------------------------------------------------
31
+ @import doohickey/accessibility/accessible_image_links.sass
32
+
33
+ //
34
+ // CSS3 mixins
35
+ // ----------------------------------------------------------------------------
36
+ @import doohickey/css3/font_face.sass
37
+ @import doohickey/css3/gradients.sass
38
+ @import doohickey/css3/shadows.sass
39
+ @import doohickey/css3/border_radius.sass
40
+ @import doohickey/css3/awesome_button.sass
@@ -0,0 +1,2 @@
1
+ // Directory where any 3rd party fonts can be found
2
+ !font_directory ||= "/fonts/"
@@ -0,0 +1,7 @@
1
+ =accessible-image-link(!width, !height, !offset_x = 0, !offset_y = 0)
2
+ text-indent: -5000px
3
+ display: block
4
+ width= !width
5
+ height= !height
6
+ background-repeat: no-repeat
7
+ background-position= !offset_x !offset_y
@@ -0,0 +1,21 @@
1
+ =awesome-button(!background_color, !text_color)
2
+ background= !background_color url("/images/button_overlay.png") "repeat-x"
3
+ display: inline-block
4
+ padding: 7px 10px 6px
5
+ color= !text_color
6
+ text-decoration: none
7
+ +border-radius(5px)
8
+ +box-shadow(rgba(0, 0, 0, 0.5), 0, 1px, 3px)
9
+ +text-shadow(rgba(0, 0, 0, 0.25), 0, -1px, 1px)
10
+ border-bottom: 1px solid rgba(0, 0, 0, 0.25)
11
+ position: relative
12
+ cursor: pointer
13
+ font-size: 1.1em
14
+ font-weight: bold
15
+ line-height: 1
16
+
17
+ &:hover
18
+ background-color= !background_color - #222
19
+
20
+ &:active
21
+ top: 1px
@@ -0,0 +1,37 @@
1
+ =border-radius(!radius)
2
+ border-radius= !radius
3
+ -moz-border-radius= !radius
4
+ -webkit-border-radius= !radius
5
+
6
+ =border-top-left-radius(!radius)
7
+ +border-corner-radius("top", "left", !radius)
8
+
9
+ =border-top-right-radius(!radius)
10
+ +border-corner-radius("top", "right", !radius)
11
+
12
+ =border-bottom-left-radius(!radius)
13
+ +border-corner-radius("bottom", "left", !radius)
14
+
15
+ =border-bottom-right-radius(!radius)
16
+ +border-corner-radius("bottom", "right", !radius)
17
+
18
+ =border-top-radius(!radius)
19
+ +border-top-left-radius(!radius)
20
+ +border-top-right-radius(!radius)
21
+
22
+ =border-bottom-radius(!radius)
23
+ +border-bottom-left-radius(!radius)
24
+ +border-bottom-right-radius(!radius)
25
+
26
+ =border-left-radius(!radius)
27
+ +border-top-left-radius(!radius)
28
+ +border-bottom-left-radius(!radius)
29
+
30
+ =border-right-radius(!radius)
31
+ +border-top-right-radius(!radius)
32
+ +border-bottom-right-radius(!radius)
33
+
34
+ =border-corner-radius(!vertical, !horizontal, !radius)
35
+ border-#{!vertical}-#{!horizontal}-radius= !radius
36
+ -moz-border-radius-#{!vertical}#{!horizontal}= !radius
37
+ -webkit-border-#{!vertical}#{!horizontal}= !radius
@@ -0,0 +1,6 @@
1
+ =font-face(!name, !file, !weight = "normal", !style = "normal")
2
+ @font-face
3
+ font-family: "#{!name}"
4
+ font-weight= !weight
5
+ font-style= !style
6
+ src: url(#{!font_directory + !file})
@@ -0,0 +1,5 @@
1
+ =linear-gradient(!color_stops, !start = "top")
2
+ !end = grad_opposite_position(!start)
3
+ background-color: #{first_color_stop(!color_stops)}
4
+ background-image: -webkit-gradient(linear, #{grad_point(!start)}, #{grad_point(!end)}, #{grad_color_stops(!color_stops)})
5
+ background-image: -moz-linear-gradient(#{!start}, #{!color_stops})
@@ -0,0 +1,7 @@
1
+ =box-shadow(!color, !horizontal_offset, !vertical_offset, !spread)
2
+ -webkit-box-shadow= !color !horizontal_offset !vertical_offset !spread
3
+ -moz-box-shadow= !color !horizontal_offset !vertical_offset !spread
4
+ box-shadow= !color !horizontal_offset !vertical_offset !spread
5
+
6
+ =text-shadow(!color, !horizontal_offset, !vertical_offset, !spread)
7
+ text-shadow= !horizontal_offset !vertical_offset !spread !color
@@ -0,0 +1,15 @@
1
+ =standard-body(!font_family = "Arial, sans-serif", !background = false, !color = false, !font_size = false, !line_height = false)
2
+ body
3
+ font-family= !font_family
4
+ @if !font_size
5
+ font-size= !font_size
6
+ @else
7
+ font-size: 62.5%
8
+ @if !line_height
9
+ line-height= !line_height
10
+ @else
11
+ line-height: 1.5em
12
+ @if !background
13
+ background= !background
14
+ @if !color
15
+ color= !color
@@ -0,0 +1,9 @@
1
+ // Turn off bullets for a list element
2
+ =no-bullet
3
+ list-style-type: none
4
+ margin-left: 0px
5
+
6
+ // Turn off bullets for an entire list
7
+ =no-bullets
8
+ li
9
+ +no-bullet
@@ -0,0 +1,13 @@
1
+ =horizontal-list
2
+ +horizontal-list-container
3
+ li
4
+ +horizontal-list-item
5
+
6
+ =horizontal-list-container
7
+ +reset-box-model
8
+ +clearfix
9
+
10
+ =horizontal-list-item
11
+ +no-bullet
12
+ white-space: nowrap
13
+ +float-left
@@ -0,0 +1,9 @@
1
+ =horizontal-tabs(!tab_padding = 0px, !tab_margin = 0px)
2
+ +horizontal-list
3
+
4
+ li
5
+ a
6
+ display: block
7
+ line-height: 1em
8
+ padding= !tab_padding
9
+ margin= !tab_margin
@@ -0,0 +1,3 @@
1
+ =clearfix
2
+ overflow: hidden
3
+ +has-layout
@@ -0,0 +1,12 @@
1
+ =float-left
2
+ +float("left")
3
+
4
+ =float-right
5
+ +float("right")
6
+
7
+ =float(!side = "left")
8
+ display: inline
9
+ float= !side
10
+
11
+ =float-reset
12
+ float: none !important
@@ -0,0 +1,6 @@
1
+ =has-layout
2
+ // This makes IE6 get layout
3
+ display: inline-block
4
+ // And this puts it back to a block
5
+ &
6
+ display: block
@@ -0,0 +1,80 @@
1
+ =global-reset
2
+ html, body, div, span, applet, object, iframe,
3
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
4
+ a, abbr, acronym, address, big, cite, code,
5
+ del, dfn, em, font, img, ins, kbd, q, s, samp,
6
+ small, strike, strong, sub, sup, tt, var,
7
+ dl, dt, dd, ol, ul, li,
8
+ fieldset, form, label, legend, button,
9
+ table, caption, tbody, tfoot, thead, tr, th, td
10
+ +reset-box-model
11
+ +reset-font
12
+
13
+ *:focus
14
+ +reset-focus
15
+
16
+ body
17
+ +reset-body
18
+
19
+ ol, ul, li
20
+ +reset-list-style
21
+
22
+ /* tables still need 'cellspacing="0"' in the markup
23
+ table
24
+ +reset-table
25
+
26
+ caption, th, td
27
+ +reset-table-cell
28
+
29
+ q, blockquote
30
+ +reset-quotation
31
+
32
+ a img
33
+ +reset-image-anchor-border
34
+
35
+ =reset-box-model
36
+ margin: 0
37
+ padding: 0
38
+ border: 0
39
+ outline: 0
40
+
41
+ =reset-font
42
+ font:
43
+ weight: inherit
44
+ style: inherit
45
+ size: 100%
46
+ family: inherit
47
+ vertical-align: baseline
48
+
49
+ =reset-focus
50
+ outline: 0
51
+
52
+ =reset-body
53
+ line-height: 1
54
+ color: #000
55
+ background: #fff
56
+
57
+ =reset-list-style
58
+ list-style: none
59
+
60
+ =reset-table
61
+ border-collapse: separate
62
+ border-spacing: 0
63
+ vertical-align: middle
64
+
65
+ =reset-table-cell
66
+ text-align: left
67
+ font-weight: normal
68
+ vertical-align: middle
69
+
70
+ =reset-quotation
71
+ quotes: "" ""
72
+ &:before, &:after
73
+ content: ""
74
+
75
+ =reset-image-anchor-border
76
+ border: none
77
+
78
+ =reset-html5
79
+ section, article, aside, header, footer, nav, dialog, figure
80
+ display: block
data/doohickey.gemspec ADDED
@@ -0,0 +1,70 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{doohickey}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Trond Arve Nordheim"]
12
+ s.date = %q{2010-05-26}
13
+ s.description = %q{Contains SASS mixins and a default SASS configuration for use in Ruby on Rails projects}
14
+ s.email = %q{tanordheim@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README.markdown"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "MIT-LICENSE",
21
+ "README.markdown",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "app/stylesheets/doohickey/_doohickey.sass",
25
+ "app/stylesheets/doohickey/_settings.sass",
26
+ "app/stylesheets/doohickey/accessibility/_accessible_image_links.sass",
27
+ "app/stylesheets/doohickey/css3/_awesome_button.sass",
28
+ "app/stylesheets/doohickey/css3/_border_radius.sass",
29
+ "app/stylesheets/doohickey/css3/_font_face.sass",
30
+ "app/stylesheets/doohickey/css3/_gradients.sass",
31
+ "app/stylesheets/doohickey/css3/_shadows.sass",
32
+ "app/stylesheets/doohickey/layout/_body.sass",
33
+ "app/stylesheets/doohickey/lists/_bullets.sass",
34
+ "app/stylesheets/doohickey/lists/_horizontal.sass",
35
+ "app/stylesheets/doohickey/tabs/_horizontal.sass",
36
+ "app/stylesheets/doohickey/utils/_clearfix.sass",
37
+ "app/stylesheets/doohickey/utils/_floats.sass",
38
+ "app/stylesheets/doohickey/utils/_hacks.sass",
39
+ "app/stylesheets/doohickey/utils/_reset.sass",
40
+ "doohickey.gemspec",
41
+ "init.rb",
42
+ "install.rb",
43
+ "lib/doohickey.rb",
44
+ "lib/doohickey/sass_extensions/gradients.rb",
45
+ "tasks/doohickey_tasks.rake",
46
+ "test/doohickey_test.rb",
47
+ "test/test_helper.rb",
48
+ "uninstall.rb"
49
+ ]
50
+ s.homepage = %q{http://github.com/tanordheim/doohickey}
51
+ s.rdoc_options = ["--charset=UTF-8"]
52
+ s.require_paths = ["lib"]
53
+ s.rubygems_version = %q{1.3.6}
54
+ s.summary = %q{Easy to use SASS mixins for Rails projects}
55
+ s.test_files = [
56
+ "test/test_helper.rb",
57
+ "test/doohickey_test.rb"
58
+ ]
59
+
60
+ if s.respond_to? :specification_version then
61
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
62
+ s.specification_version = 3
63
+
64
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
65
+ else
66
+ end
67
+ else
68
+ end
69
+ end
70
+
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require "doohickey"
data/install.rb ADDED
@@ -0,0 +1 @@
1
+ # Install hook code here
@@ -0,0 +1,212 @@
1
+ #
2
+ # This class is copied from the Compass CSS framework
3
+ # <http://compass-style.org/>
4
+ #
5
+ # All credits go to Chris Eppstein
6
+ #
7
+ # -----------------------------------------------------------------------------
8
+ module Doohickey
9
+ module SassExtensions
10
+ module Gradients
11
+
12
+ class List < Sass::Script::Literal
13
+ attr_accessor :values
14
+ def initialize(*values)
15
+ self.values = values
16
+ end
17
+ def inspect
18
+ values.map{|v| v.inspect}.join(", ")
19
+ end
20
+ def to_s
21
+ inspect
22
+ end
23
+ end
24
+
25
+ class ColorStop < Sass::Script::Literal
26
+ attr_accessor :color, :stop
27
+ def initialize(color, stop = nil)
28
+ self.color, self.stop = color, stop
29
+ end
30
+ def inspect
31
+ to_s
32
+ end
33
+ def to_s
34
+ s = color.inspect.dup
35
+ if stop
36
+ s << " "
37
+ if stop.unitless?
38
+ s << stop.times(Sass::Script::Number.new(100, ["%"])).inspect
39
+ else
40
+ s << stop.inspect
41
+ end
42
+ end
43
+ s
44
+ end
45
+ end
46
+
47
+ module Functions
48
+ # returns the opposite position of a side or corner.
49
+ def grad_opposite_position(position)
50
+ opposite = position.value.split(/ +/).map do |pos|
51
+ case pos
52
+ when "top" then "bottom"
53
+ when "bottom" then "top"
54
+ when "left" then "right"
55
+ when "right" then "left"
56
+ when "center" then "center"
57
+ else
58
+ raise Sass::SyntaxError, "Cannot determine the opposite of #{pos}"
59
+ end
60
+ end
61
+ Sass::Script::String.new(opposite.join(" "))
62
+ end
63
+
64
+ # Return the color of the first color stop
65
+ def first_color_stop(color_list)
66
+ color = color_list.values.first.color.inspect
67
+ Sass::Script::String.new(color)
68
+ end
69
+
70
+ # returns color-stop() calls for use in webkit.
71
+ def grad_color_stops(color_list)
72
+ assert_list(color_list)
73
+ normalize_stops!(color_list)
74
+ max = color_list.values.last.stop
75
+ color_stops = color_list.values.map do |pos|
76
+ # have to convert absolute units to percentages for use in color stop functions.
77
+ stop = pos.stop
78
+ stop = stop.div(max).times(Sass::Script::Number.new(100,["%"])) if stop.numerator_units == max.numerator_units
79
+ "color-stop(#{stop.inspect}, #{pos.color.inspect})"
80
+ end
81
+ Sass::Script::String.new(color_stops.join(", "))
82
+ end
83
+
84
+ # returns the end position of the gradient from the color stop
85
+ def grad_end_position(color_list, radial = Sass::Script::Bool.new(false))
86
+ assert_list(color_list)
87
+ default = Sass::Script::Number.new(100)
88
+ grad_position(color_list, Sass::Script::Number.new(color_list.values.size), default, radial)
89
+ end
90
+
91
+ def grad_position(color_list, index, default, radial = Sass::Script::Bool.new(false))
92
+ assert_list(color_list)
93
+ stop = color_list.values[index.value - 1].stop
94
+ if stop && radial.to_bool
95
+ orig_stop = stop
96
+ if stop.unitless?
97
+ if stop.value <= 1
98
+ # A unitless number is assumed to be a percentage when it's between 0 and 1
99
+ stop = stop.times(Sass::Script::Number.new(100, ["%"]))
100
+ else
101
+ # Otherwise, a unitless number is assumed to be in pixels
102
+ stop = stop.times(Sass::Script::Number.new(1, ["px"]))
103
+ end
104
+ end
105
+ if stop.numerator_units == ["%"] && color_list.values.last.stop && color_list.values.last.stop.numerator_units == ["px"]
106
+ stop = stop.times(color_list.values.last.stop).div(Sass::Script::Number.new(100, ["%"]))
107
+ end
108
+ stop.div(Sass::Script::Number.new(1, stop.numerator_units, stop.denominator_units))
109
+ elsif stop
110
+ stop
111
+ else
112
+ default
113
+ end
114
+ end
115
+
116
+ # the given a position, return a point in percents
117
+ def grad_point(position)
118
+ position = position.value
119
+ position = if position[" "]
120
+ if position =~ /(top|bottom|center) (left|right|center)/
121
+ "#{$2} #{$1}"
122
+ else
123
+ position
124
+ end
125
+ else
126
+ case position
127
+ when /top|bottom/
128
+ "left #{position}"
129
+ when /left|right/
130
+ "#{position} top"
131
+ else
132
+ position
133
+ end
134
+ end
135
+ Sass::Script::String.new(position.
136
+ gsub(/top/, "0%").
137
+ gsub(/bottom/, "100%").
138
+ gsub(/left/,"0%").
139
+ gsub(/right/,"100%").
140
+ gsub(/center/, "50%"))
141
+ end
142
+
143
+ def color_stops(*args)
144
+ List.new(*args.map do |arg|
145
+ case arg
146
+ when Sass::Script::Color
147
+ ColorStop.new(arg)
148
+ when Sass::Script::String
149
+ # We get a string as the result of concatenation
150
+ # So we have to reparse the expression
151
+ color = stop = nil
152
+ expr = Sass::Script::Parser.parse(arg.value, 0, 0)
153
+ case expr
154
+ when Sass::Script::Color
155
+ color = expr
156
+ when Sass::Script::Funcall
157
+ color = expr
158
+ when Sass::Script::Operation
159
+ unless expr.instance_variable_get("@operator") == :concat
160
+ # This should never happen.
161
+ raise Sass::SyntaxError, "Couldn't parse a color stop from: #{arg.value}"
162
+ end
163
+ color = expr.instance_variable_get("@operand1")
164
+ stop = expr.instance_variable_get("@operand2")
165
+ else
166
+ raise Sass::SyntaxError, "Couldn't parse a color stop from: #{arg.value}"
167
+ end
168
+ ColorStop.new(color, stop)
169
+ else
170
+ raise Sass::SyntaxError, "Not a valid color stop: #{arg}"
171
+ end
172
+ end)
173
+ end
174
+ private
175
+ def normalize_stops!(color_list)
176
+ positions = color_list.values
177
+ # fill in the start and end positions, if unspecified
178
+ positions.first.stop = Sass::Script::Number.new(0) unless positions.first.stop
179
+ positions.last.stop = Sass::Script::Number.new(100, ["%"]) unless positions.last.stop
180
+ # fill in empty values
181
+ for i in 0...positions.size
182
+ if positions[i].stop.nil?
183
+ num = 2.0
184
+ for j in (i+1)...positions.size
185
+ if positions[j].stop
186
+ positions[i].stop = positions[i-1].stop.plus((positions[j].stop.minus(positions[i-1].stop)).div(Sass::Script::Number.new(num)))
187
+ break
188
+ else
189
+ num += 1
190
+ end
191
+ end
192
+ end
193
+ end
194
+ # normalize unitless numbers
195
+ positions.each do |pos|
196
+ if pos.stop.unitless? && pos.stop.value <= 1
197
+ pos.stop = pos.stop.times(Sass::Script::Number.new(100, ["%"]))
198
+ elsif pos.stop.unitless?
199
+ pos.stop = pos.stop.times(Sass::Script::Number.new(1, ["px"]))
200
+ end
201
+ end
202
+ nil
203
+ end
204
+ def assert_list(value)
205
+ return if value.is_a?(List)
206
+ raise ArgumentError.new("#{value.inspect} is not a list of color stops. Expected: color_stops(<color> <number>?, ...)")
207
+ end
208
+ end
209
+
210
+ end
211
+ end
212
+ end
data/lib/doohickey.rb ADDED
@@ -0,0 +1,66 @@
1
+ # Require that sass is available
2
+ require "sass"
3
+
4
+ # Define our namespace
5
+ module Doohickey
6
+ module SassExtensions
7
+ end
8
+ end
9
+
10
+ # Load the Sass functionality extensions
11
+ %w(gradients).each do |function|
12
+ require "doohickey/sass_extensions/#{function}"
13
+ end
14
+
15
+ # Define the Doohickey initializer
16
+ module Doohickey
17
+ class Initializer
18
+
19
+ def self.rails_root
20
+ defined?(Rails.root) ? Rails.root : RAILS_ROOT
21
+ end
22
+
23
+ def self.rails_env
24
+ defined?(Rails.env) ? Rails.env : RAILS_ENV
25
+ end
26
+
27
+ def self.initialize
28
+
29
+ # Global Sass settings
30
+ # -----------------------------------------------------------------------------
31
+ template_locations = {}
32
+ template_locations["#{rails_root}/app/stylesheets"] = Sass::Plugin.options[:css_location]
33
+ template_locations[File.join(File.dirname(__FILE__), *%w[.. app stylesheets])] = Sass::Plugin.options[:css_location]
34
+
35
+ Sass::Plugin.options[:template_location] = template_locations
36
+
37
+ # Environment specific configurations
38
+ # -----------------------------------------------------------------------------
39
+ if %w(production staging).include?(rails_env)
40
+
41
+ # Compress CSS (small files suitable for production)
42
+ Sass::Plugin.options[:style] = :compressed
43
+
44
+ else
45
+
46
+ # Expand CSS
47
+ Sass::Plugin.options[:style] = :expanded
48
+
49
+ # Generate CSS from SASS every time a controller is accessed
50
+ Sass::Plugin.options[:always_update] = true
51
+
52
+ # Insert comments in the CSS about the line numbers of the Sass source
53
+ Sass::Plugin.options[:line_comments] = true
54
+
55
+ end
56
+
57
+ # Include the Sass functionality extensions
58
+ Sass::Script::Functions.send :include, Doohickey::SassExtensions::Gradients::Functions
59
+
60
+ # This has to be re-included to pick up submodules
61
+ Sass::Script::Functions::EvaluationContext.send :include, Sass::Script::Functions
62
+
63
+ end
64
+
65
+ end
66
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :doohickey do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class DoohickeyTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'active_support'
3
+ require 'active_support/test_case'
data/uninstall.rb ADDED
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: doohickey
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Trond Arve Nordheim
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-05-26 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Contains SASS mixins and a default SASS configuration for use in Ruby on Rails projects
22
+ email: tanordheim@gmail.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - README.markdown
29
+ files:
30
+ - .gitignore
31
+ - MIT-LICENSE
32
+ - README.markdown
33
+ - Rakefile
34
+ - VERSION
35
+ - app/stylesheets/doohickey/_doohickey.sass
36
+ - app/stylesheets/doohickey/_settings.sass
37
+ - app/stylesheets/doohickey/accessibility/_accessible_image_links.sass
38
+ - app/stylesheets/doohickey/css3/_awesome_button.sass
39
+ - app/stylesheets/doohickey/css3/_border_radius.sass
40
+ - app/stylesheets/doohickey/css3/_font_face.sass
41
+ - app/stylesheets/doohickey/css3/_gradients.sass
42
+ - app/stylesheets/doohickey/css3/_shadows.sass
43
+ - app/stylesheets/doohickey/layout/_body.sass
44
+ - app/stylesheets/doohickey/lists/_bullets.sass
45
+ - app/stylesheets/doohickey/lists/_horizontal.sass
46
+ - app/stylesheets/doohickey/tabs/_horizontal.sass
47
+ - app/stylesheets/doohickey/utils/_clearfix.sass
48
+ - app/stylesheets/doohickey/utils/_floats.sass
49
+ - app/stylesheets/doohickey/utils/_hacks.sass
50
+ - app/stylesheets/doohickey/utils/_reset.sass
51
+ - doohickey.gemspec
52
+ - init.rb
53
+ - install.rb
54
+ - lib/doohickey.rb
55
+ - lib/doohickey/sass_extensions/gradients.rb
56
+ - tasks/doohickey_tasks.rake
57
+ - test/doohickey_test.rb
58
+ - test/test_helper.rb
59
+ - uninstall.rb
60
+ has_rdoc: true
61
+ homepage: http://github.com/tanordheim/doohickey
62
+ licenses: []
63
+
64
+ post_install_message:
65
+ rdoc_options:
66
+ - --charset=UTF-8
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ segments:
81
+ - 0
82
+ version: "0"
83
+ requirements: []
84
+
85
+ rubyforge_project:
86
+ rubygems_version: 1.3.6
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: Easy to use SASS mixins for Rails projects
90
+ test_files:
91
+ - test/test_helper.rb
92
+ - test/doohickey_test.rb