teejayvanslyke-sassafras 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,298 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
4
+ <head>
5
+ <title>Sassafras Swatch</title>
6
+ <meta http-equiv="content-type" content="text/xhtml; charset=utf-8" />
7
+ <meta http-equiv="imagetoolbar" content="no" />
8
+ <meta name="distribution" content="all" />
9
+ <meta name="robots" content="all" />
10
+ <meta name="resource-type" content="document" />
11
+ <meta name="MSSmartTagsPreventParsing" content="true" />
12
+ <style type="text/css">
13
+ body {
14
+ font-family: Helvetica, Verdana, Sans-serif;
15
+ text-align: center;
16
+ }
17
+ .container {
18
+ width: 600px;
19
+ }
20
+ th {
21
+ text-align: left;
22
+ }
23
+ td.swatch {
24
+ width: 10em;
25
+ }
26
+ td.hex {
27
+ font-family: "Courier New", Fixed;
28
+ }
29
+ pre {
30
+ text-align: left;
31
+ }
32
+ </style>
33
+ </head>
34
+ <body>
35
+ <div align="center">
36
+ <div class="container">
37
+ <h1>Sassafras</h1>
38
+ <table width="100%">
39
+
40
+ <tr>
41
+ <th colspan="3">complement1</td>
42
+ </tr>
43
+
44
+ <tr>
45
+ <td>
46
+ dark
47
+ </td>
48
+ <td class="hex">
49
+ #80002b
50
+ </td>
51
+ <td class="swatch" style="background-color: #80002b;">&nbsp;</td>
52
+ </tr>
53
+
54
+ <tr>
55
+ <td>
56
+ darker
57
+ </td>
58
+ <td class="hex">
59
+ #4d001a
60
+ </td>
61
+ <td class="swatch" style="background-color: #4d001a;">&nbsp;</td>
62
+ </tr>
63
+
64
+ <tr>
65
+ <td>
66
+ light
67
+ </td>
68
+ <td class="hex">
69
+ #ff80aa
70
+ </td>
71
+ <td class="swatch" style="background-color: #ff80aa;">&nbsp;</td>
72
+ </tr>
73
+
74
+ <tr>
75
+ <td>
76
+ lightest
77
+ </td>
78
+ <td class="hex">
79
+ #ffe6ee
80
+ </td>
81
+ <td class="swatch" style="background-color: #ffe6ee;">&nbsp;</td>
82
+ </tr>
83
+
84
+ <tr>
85
+ <td>
86
+ lighter
87
+ </td>
88
+ <td class="hex">
89
+ #ffb3cc
90
+ </td>
91
+ <td class="swatch" style="background-color: #ffb3cc;">&nbsp;</td>
92
+ </tr>
93
+
94
+ <tr>
95
+ <td>
96
+ mid
97
+ </td>
98
+ <td class="hex">
99
+ #ff0055
100
+ </td>
101
+ <td class="swatch" style="background-color: #ff0055;">&nbsp;</td>
102
+ </tr>
103
+
104
+ <tr>
105
+ <td>
106
+ darkest
107
+ </td>
108
+ <td class="hex">
109
+ #1a0009
110
+ </td>
111
+ <td class="swatch" style="background-color: #1a0009;">&nbsp;</td>
112
+ </tr>
113
+
114
+
115
+ <tr>
116
+ <th colspan="3">complement2</td>
117
+ </tr>
118
+
119
+ <tr>
120
+ <td>
121
+ dark
122
+ </td>
123
+ <td class="hex">
124
+ #00802b
125
+ </td>
126
+ <td class="swatch" style="background-color: #00802b;">&nbsp;</td>
127
+ </tr>
128
+
129
+ <tr>
130
+ <td>
131
+ darker
132
+ </td>
133
+ <td class="hex">
134
+ #004d1a
135
+ </td>
136
+ <td class="swatch" style="background-color: #004d1a;">&nbsp;</td>
137
+ </tr>
138
+
139
+ <tr>
140
+ <td>
141
+ light
142
+ </td>
143
+ <td class="hex">
144
+ #80ffaa
145
+ </td>
146
+ <td class="swatch" style="background-color: #80ffaa;">&nbsp;</td>
147
+ </tr>
148
+
149
+ <tr>
150
+ <td>
151
+ lightest
152
+ </td>
153
+ <td class="hex">
154
+ #e6ffee
155
+ </td>
156
+ <td class="swatch" style="background-color: #e6ffee;">&nbsp;</td>
157
+ </tr>
158
+
159
+ <tr>
160
+ <td>
161
+ lighter
162
+ </td>
163
+ <td class="hex">
164
+ #b3ffcc
165
+ </td>
166
+ <td class="swatch" style="background-color: #b3ffcc;">&nbsp;</td>
167
+ </tr>
168
+
169
+ <tr>
170
+ <td>
171
+ mid
172
+ </td>
173
+ <td class="hex">
174
+ #00ff55
175
+ </td>
176
+ <td class="swatch" style="background-color: #00ff55;">&nbsp;</td>
177
+ </tr>
178
+
179
+ <tr>
180
+ <td>
181
+ darkest
182
+ </td>
183
+ <td class="hex">
184
+ #001a09
185
+ </td>
186
+ <td class="swatch" style="background-color: #001a09;">&nbsp;</td>
187
+ </tr>
188
+
189
+
190
+ <tr>
191
+ <th colspan="3">base</td>
192
+ </tr>
193
+
194
+ <tr>
195
+ <td>
196
+ dark
197
+ </td>
198
+ <td class="hex">
199
+ #000080
200
+ </td>
201
+ <td class="swatch" style="background-color: #000080;">&nbsp;</td>
202
+ </tr>
203
+
204
+ <tr>
205
+ <td>
206
+ darker
207
+ </td>
208
+ <td class="hex">
209
+ #00004d
210
+ </td>
211
+ <td class="swatch" style="background-color: #00004d;">&nbsp;</td>
212
+ </tr>
213
+
214
+ <tr>
215
+ <td>
216
+ light
217
+ </td>
218
+ <td class="hex">
219
+ #8080ff
220
+ </td>
221
+ <td class="swatch" style="background-color: #8080ff;">&nbsp;</td>
222
+ </tr>
223
+
224
+ <tr>
225
+ <td>
226
+ lightest
227
+ </td>
228
+ <td class="hex">
229
+ #e6e6ff
230
+ </td>
231
+ <td class="swatch" style="background-color: #e6e6ff;">&nbsp;</td>
232
+ </tr>
233
+
234
+ <tr>
235
+ <td>
236
+ lighter
237
+ </td>
238
+ <td class="hex">
239
+ #b3b3ff
240
+ </td>
241
+ <td class="swatch" style="background-color: #b3b3ff;">&nbsp;</td>
242
+ </tr>
243
+
244
+ <tr>
245
+ <td>
246
+ mid
247
+ </td>
248
+ <td class="hex">
249
+ #0000ff
250
+ </td>
251
+ <td class="swatch" style="background-color: #0000ff;">&nbsp;</td>
252
+ </tr>
253
+
254
+ <tr>
255
+ <td>
256
+ darkest
257
+ </td>
258
+ <td class="hex">
259
+ #00001a
260
+ </td>
261
+ <td class="swatch" style="background-color: #00001a;">&nbsp;</td>
262
+ </tr>
263
+
264
+
265
+ </table>
266
+ <pre># Generated by Sassafras
267
+ # complement1
268
+ !complement1_dark = #80002b
269
+ !complement1_darker = #4d001a
270
+ !complement1_light = #ff80aa
271
+ !complement1_lightest = #ffe6ee
272
+ !complement1_lighter = #ffb3cc
273
+ !complement1_mid = #ff0055
274
+ !complement1_darkest = #1a0009
275
+
276
+ # complement2
277
+ !complement2_dark = #00802b
278
+ !complement2_darker = #004d1a
279
+ !complement2_light = #80ffaa
280
+ !complement2_lightest = #e6ffee
281
+ !complement2_lighter = #b3ffcc
282
+ !complement2_mid = #00ff55
283
+ !complement2_darkest = #001a09
284
+
285
+ # base
286
+ !base_dark = #000080
287
+ !base_darker = #00004d
288
+ !base_light = #8080ff
289
+ !base_lightest = #e6e6ff
290
+ !base_lighter = #b3b3ff
291
+ !base_mid = #0000ff
292
+ !base_darkest = #00001a
293
+
294
+ </pre>
295
+ </div>
296
+ </div>
297
+ </body>
298
+ </html>
@@ -0,0 +1,60 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
4
+ <head>
5
+ <title>Sassafras Swatch</title>
6
+ <meta http-equiv="content-type" content="text/xhtml; charset=utf-8" />
7
+ <meta http-equiv="imagetoolbar" content="no" />
8
+ <meta name="distribution" content="all" />
9
+ <meta name="robots" content="all" />
10
+ <meta name="resource-type" content="document" />
11
+ <meta name="MSSmartTagsPreventParsing" content="true" />
12
+ <style type="text/css">
13
+ body {
14
+ font-family: Helvetica, Verdana, Sans-serif;
15
+ text-align: center;
16
+ }
17
+ .container {
18
+ width: 600px;
19
+ }
20
+ th {
21
+ text-align: left;
22
+ }
23
+ td.swatch {
24
+ width: 10em;
25
+ }
26
+ td.hex {
27
+ font-family: "Courier New", Fixed;
28
+ }
29
+ pre {
30
+ text-align: left;
31
+ }
32
+ </style>
33
+ </head>
34
+ <body>
35
+ <div align="center">
36
+ <div class="container">
37
+ <h1>Sassafras</h1>
38
+ <table width="100%">
39
+ <% colors.each do |set, variations| %>
40
+ <tr>
41
+ <th colspan="3"><%= set %></td>
42
+ </tr>
43
+ <% variations.each do |name, hex| %>
44
+ <tr>
45
+ <td>
46
+ <%= name %>
47
+ </td>
48
+ <td class="hex">
49
+ <%= hex %>
50
+ </td>
51
+ <td class="swatch" style="background-color: <%= hex %>;">&nbsp;</td>
52
+ </tr>
53
+ <% end %>
54
+ <% end %>
55
+ </table>
56
+ <pre><%= sass %></pre>
57
+ </div>
58
+ </div>
59
+ </body>
60
+ </html>
@@ -0,0 +1,9 @@
1
+ module Sassafras
2
+ module VERSION #:nodoc:
3
+ MAJOR = 0
4
+ MINOR = 1
5
+ TINY = 0
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end
data/lib/sassafras.rb ADDED
@@ -0,0 +1,238 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'rubygems'
5
+
6
+ gem 'color-tools'
7
+ require 'color'
8
+
9
+ gem 'activesupport'
10
+ require 'activesupport'
11
+
12
+ require 'erb'
13
+
14
+ module Sassafras
15
+
16
+ class Theme
17
+
18
+ attr_reader :base_rgb
19
+
20
+ class << self
21
+ def create(type, base)
22
+ Theme.send(type, base)
23
+ end
24
+
25
+ def colors
26
+ @colors
27
+ end
28
+
29
+ def basic(base)
30
+ BasicTheme.new(base)
31
+ end
32
+
33
+ def complementary(base)
34
+ ComplementaryTheme.new(base)
35
+ end
36
+
37
+ def analogous(base)
38
+ AnalogousTheme.new(base)
39
+ end
40
+
41
+ def triadic(base)
42
+ TriadicTheme.new(base)
43
+ end
44
+
45
+ def split_complementary(base)
46
+ SplitComplementaryTheme.new(base)
47
+ end
48
+
49
+ def rectangle(base)
50
+ RectangleTheme.new(base)
51
+ end
52
+
53
+ def square(base)
54
+ SquareTheme.new(base)
55
+ end
56
+ end
57
+
58
+ def initialize(base)
59
+ @base_rgb = Color::RGB.const_get(base.to_s.camelize)
60
+ @colors = { 'base' =>
61
+ Tints.new(@base_rgb).colors.merge(
62
+ Shades.new(@base_rgb).colors)
63
+ }
64
+ return unless self.class.colors
65
+ self.class.colors.each do |name, steps|
66
+ color = self.hue_adjusted_base_rgb(steps)
67
+ @colors[name] =
68
+ Tints. new(color).colors.merge(
69
+ Shades.new(color).colors)
70
+ end
71
+ end
72
+
73
+ def base
74
+ @base_rgb.html
75
+ end
76
+
77
+ def colors(name=nil)
78
+ return @colors[name.to_s] if name
79
+ @colors
80
+ end
81
+
82
+ def sass
83
+ returning "# Generated by Sassafras\n" do |str|
84
+ colors.each do |set, colors|
85
+ str << "# #{set}\n"
86
+ colors.each do |name, hex|
87
+ str << "!#{set}_#{name} = #{hex}\n"
88
+ end
89
+ str << "\n"
90
+ end
91
+ end
92
+ end
93
+
94
+ def get_binding; binding; end
95
+
96
+ protected
97
+
98
+ def hue_adjusted_base_rgb(steps)
99
+ one_step = 0.0555555555555
100
+
101
+ hue = base_rgb.to_hsl.h
102
+ sat = base_rgb.to_hsl.s
103
+ lum = base_rgb.to_hsl.l
104
+
105
+ hue += one_step * steps
106
+ if hue > 1.0
107
+ hue -= 1.0
108
+ elsif hue < 0.0
109
+ hue += 1.0
110
+ end
111
+
112
+ Color::HSL.from_fraction(hue, sat, lum).to_rgb
113
+ end
114
+
115
+ def self.color(name, block)
116
+ instance_eval do
117
+ @colors ||= {}
118
+ @colors[name] = block
119
+ end
120
+ end
121
+
122
+ end
123
+
124
+ class ColorSet
125
+
126
+ def initialize(base_rgb, prefix=nil)
127
+ @rgb = base_rgb
128
+ @prefix = prefix
129
+ @colors = {}
130
+ end
131
+
132
+ def colors
133
+ returning Hash.new do |hash|
134
+ @colors.each do |name, hex|
135
+ if @prefix
136
+ hash["#{@prefix}_#{name}"] = hex
137
+ else
138
+ hash[name] = hex
139
+ end
140
+ end
141
+ end
142
+ end
143
+
144
+ def method_missing(method, *args)
145
+ return @colors[method.to_s] if @colors[method.to_s]
146
+ super
147
+ end
148
+
149
+ end
150
+
151
+
152
+ class Tints < ColorSet
153
+
154
+ def initialize(base_rgb, prefix=nil)
155
+ super(base_rgb, prefix)
156
+ @colors = {
157
+ 'mid' => @rgb.html,
158
+ 'light' => @rgb.lighten_by(50).html,
159
+ 'lighter' => @rgb.lighten_by(30).html,
160
+ 'lightest' => @rgb.lighten_by(10).html
161
+ }
162
+ end
163
+
164
+ end
165
+
166
+ class Shades < ColorSet
167
+
168
+ def initialize(base_rgb, prefix=nil)
169
+ super(base_rgb, prefix)
170
+ @colors = {
171
+ 'mid' => @rgb.html,
172
+ 'dark' => @rgb.darken_by(50).html,
173
+ 'darker' => @rgb.darken_by(30).html,
174
+ 'darkest' => @rgb.darken_by(10).html
175
+ }
176
+ end
177
+
178
+ end
179
+
180
+ class BasicTheme < Theme
181
+
182
+ end
183
+
184
+ class ComplementaryTheme < Theme
185
+
186
+ color 'complementary', +6
187
+
188
+ end
189
+
190
+ class AnalogousTheme < Theme
191
+
192
+ color 'support', -1
193
+ color 'accent', +1
194
+
195
+ end
196
+
197
+ class TriadicTheme < Theme
198
+
199
+ color 'accent1', +4
200
+ color 'accent2', -4
201
+
202
+ end
203
+
204
+ class SplitComplementaryTheme < Theme
205
+
206
+ color 'complement1', +5
207
+ color 'complement2', -5
208
+
209
+ end
210
+
211
+ class RectangleTheme < Theme
212
+
213
+ color 'accent1', +2
214
+ color 'accent2', +6
215
+ color 'accent3', -4
216
+
217
+ end
218
+
219
+ class SquareTheme < Theme
220
+
221
+ color 'accent1', +3
222
+ color 'complement', +6
223
+ color 'accent2', +9
224
+
225
+ end
226
+
227
+ class HTMLSwatch
228
+
229
+ def initialize(theme)
230
+ @theme = theme
231
+ File.open(File.dirname(__FILE__) + '/sassafras/swatch.html.erb') do |f|
232
+ erb = ERB.new(f.read)
233
+ erb.run(@theme.get_binding)
234
+ end
235
+ end
236
+ end
237
+
238
+ end
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/sassafras.rb'}"
9
+ puts "Loading sassafras gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)