archetype 0.0.1.pre.10 → 0.0.1.pre.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/archetype.rb +0 -4
- data/lib/archetype/functions/hash.rb +12 -28
- data/lib/archetype/functions/helpers.rb +13 -46
- data/lib/archetype/functions/styleguide_memoizer.rb +1 -9
- data/lib/archetype/sass_extensions/functions/lists.rb +42 -36
- data/lib/archetype/sass_extensions/functions/locale.rb +16 -32
- data/lib/archetype/sass_extensions/functions/styleguide.rb +39 -121
- data/lib/archetype/sass_extensions/functions/ui.rb +2 -3
- data/lib/archetype/sass_extensions/functions/version.rb +6 -11
- data/lib/archetype/sass_extensions/monkey_patches.rb +1 -1
- data/lib/archetype/version.rb +1 -1
- data/stylesheets/archetype/_base.scss +2 -7
- data/stylesheets/archetype/_config.scss +1 -8
- data/stylesheets/archetype/_hacks.scss +17 -51
- data/stylesheets/archetype/_ui.scss +5 -16
- data/stylesheets/archetype/base/_h5bp.scss +12 -12
- data/stylesheets/archetype/base/_normalize.scss +139 -178
- data/stylesheets/archetype/grid/_grid.scss +13 -13
- data/stylesheets/archetype/styleguide/components/_buttons.scss +0 -1
- data/stylesheets/archetype/util/_debug.scss +4 -4
- data/stylesheets/archetype/util/_lists.scss +1 -1
- data/stylesheets/archetype/util/_misc.scss +1 -1
- data/stylesheets/archetype/util/_rtl.scss +1 -1
- data/stylesheets/archetype/util/_spacing.scss +6 -6
- data/stylesheets/archetype/util/_styles.scss +10 -27
- data/stylesheets/archetype/util/_targeting.scss +1 -1
- data/test/fixtures/stylesheets/archetype/config.rb +0 -2
- data/test/fixtures/stylesheets/archetype/saved/styleguide/buttons.css +2027 -0
- data/test/fixtures/stylesheets/archetype/saved/styleguide/fallback_styles.css +9 -0
- data/test/fixtures/stylesheets/archetype/source/styleguide/buttons.scss +1 -5
- data/test/fixtures/stylesheets/archetype/source/styleguide/fallback_styles.scss +2 -1
- data/test/fixtures/stylesheets/archetype/source/styleguide/nested_styleguides.scss +1 -1
- data/test/fixtures/stylesheets/archetype/source/styleguide/selective_state.scss +1 -1
- data/test/fixtures/stylesheets/archetype/source/ui/glyph_icon.scss +0 -30
- data/test/fixtures/stylesheets/archetype/source/utilities/custom_output_styler.scss +3 -4
- data/test/fixtures/stylesheets/archetype/source/utilities/targeting/target-browser.scss +1 -8
- data/test/helpers/test_case.rb +2 -2
- data/test/integrations/archetype_test.rb +1 -3
- data/test/units/sass_extensions_test.rb +25 -18
- metadata +6 -29
- data/lib/archetype/actions/help.rb +0 -16
- data/lib/archetype/actions/theme.rb +0 -73
- data/lib/archetype/executor.rb +0 -27
- data/test/fixtures/stylesheets/archetype/saved/base.css +0 -349
- data/test/fixtures/stylesheets/archetype/saved/hacks/transparent_focusable.css +0 -4
- data/test/fixtures/stylesheets/archetype/saved/locale.css +0 -23
- data/test/fixtures/stylesheets/archetype/source/base.scss +0 -3
- data/test/fixtures/stylesheets/archetype/source/hacks/transparent_focusable.scss +0 -5
- data/test/fixtures/stylesheets/archetype/source/locale.scss +0 -43
- data/test/fixtures/stylesheets/archetype/source/styleguide/alerts.scss +0 -21
- data/test/fixtures/stylesheets/archetype/source/styleguide/drop.scss +0 -101
- data/test/fixtures/stylesheets/archetype/source/styleguide/extend.scss +0 -24
- data/test/fixtures/stylesheets/archetype/source/styleguide/invalid_structures.scss +0 -85
- data/test/fixtures/stylesheets/archetype/source/styleguide/multi_value.scss +0 -18
- data/test/fixtures/stylesheets/archetype/source/utilities/associative.scss +0 -24
@@ -1,4 +1,4 @@
|
|
1
|
-
@import "archetype";
|
1
|
+
@import "archetype";
|
2
2
|
|
3
3
|
@each $context in container, bristol, punchcut {
|
4
4
|
.#{$context} {
|
@@ -12,7 +12,3 @@
|
|
12
12
|
}
|
13
13
|
}
|
14
14
|
}
|
15
|
-
|
16
|
-
.test-exclude {
|
17
|
-
@include styleguide(small secondary button in a container, $exclude: width height border-radius padding font-size line-height cursor);
|
18
|
-
}
|
@@ -3,7 +3,7 @@
|
|
3
3
|
// - nested selectors
|
4
4
|
// - nested `styleguide` calls in nested selectors
|
5
5
|
|
6
|
-
@import "archetype";
|
6
|
+
@import "archetype";
|
7
7
|
|
8
8
|
@if not styleguide-component-exists(nested-styleguide-test, $CONFIG_THEME) {
|
9
9
|
$a-blackhole: styleguide-add-component(nested-styleguide-test, (), (
|
@@ -1,35 +1,5 @@
|
|
1
1
|
@import "archetype";
|
2
2
|
|
3
|
-
@include base-glyph();
|
4
|
-
|
5
3
|
.simple {
|
6
4
|
@include glyph-icon(caret-down);
|
7
5
|
}
|
8
|
-
|
9
|
-
.false {
|
10
|
-
@include glyph-icon(false, $placement: inline);
|
11
|
-
}
|
12
|
-
|
13
|
-
.size {
|
14
|
-
@include glyph-icon(caret-down, $size: 20px);
|
15
|
-
}
|
16
|
-
|
17
|
-
$CONFIG_GENERATED_TAG_INLINE: false;
|
18
|
-
.not-inline {
|
19
|
-
@include glyph-icon(caret-down);
|
20
|
-
}
|
21
|
-
|
22
|
-
.ie-uid {
|
23
|
-
@include glyph-icon(caret-down, $ie-uid: my-custom-id);
|
24
|
-
#{$archetype-glyph-selector} {
|
25
|
-
color: pink;
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
.content-block {
|
30
|
-
@include glyph-icon(caret-down) {
|
31
|
-
position: absolute;
|
32
|
-
top: 10px;
|
33
|
-
left: 10px;
|
34
|
-
}
|
35
|
-
}
|
@@ -1,5 +1,3 @@
|
|
1
|
-
@import "archetype";
|
2
|
-
|
3
1
|
// define the test function
|
4
2
|
@function has-custom-output-styler($property, $value, $method: pre) {
|
5
3
|
@if $property == color {
|
@@ -11,12 +9,13 @@
|
|
11
9
|
}
|
12
10
|
@return false;
|
13
11
|
}
|
14
|
-
|
15
12
|
// define the custom styler
|
16
13
|
@mixin custom-output-styler($property, $value, $method: pre) {
|
17
14
|
#{$property}: $value; /* #{$method} override */
|
18
15
|
}
|
19
16
|
|
17
|
+
@import "archetype";
|
18
|
+
|
20
19
|
.test {
|
21
20
|
@include styleguide(copy);
|
22
|
-
}
|
21
|
+
}
|
@@ -43,7 +43,7 @@
|
|
43
43
|
|
44
44
|
.target-ie-lte-9 {
|
45
45
|
@include target-browser(ie lte 9, border-color, #111);
|
46
|
-
@include target-browser(ie lte 9, background, #2c2c2b);
|
46
|
+
@include target-browser(ie lte 9, background, #2c2c2b);
|
47
47
|
}
|
48
48
|
|
49
49
|
.target-ie-7-8-9 {
|
@@ -68,10 +68,3 @@
|
|
68
68
|
.target-opera {
|
69
69
|
@include target-browser(opera, width, 82%);
|
70
70
|
}
|
71
|
-
|
72
|
-
.target-with-content-block {
|
73
|
-
@include target-browser(ie lte 8) {
|
74
|
-
/* testing content block */
|
75
|
-
color: red;
|
76
|
-
};
|
77
|
-
}
|
data/test/helpers/test_case.rb
CHANGED
@@ -24,7 +24,7 @@ module Compass
|
|
24
24
|
assert false, diff_as_string(before.inspect, after.inspect)
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
module ClassMethods
|
29
29
|
|
30
30
|
def let(method, &block)
|
@@ -51,7 +51,7 @@ module Compass
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
private
|
54
|
+
private
|
55
55
|
|
56
56
|
def underscore(string)
|
57
57
|
string.gsub(' ', '_')
|
@@ -1,11 +1,9 @@
|
|
1
1
|
# this is all take from Compass because they already did the awesome testing framework
|
2
2
|
require 'test_helper'
|
3
|
+
require 'fileutils'
|
3
4
|
require 'compass'
|
4
5
|
require 'compass/logger'
|
5
6
|
require 'sass/plugin'
|
6
|
-
unless ENV['CI']
|
7
|
-
require 'fileutils'
|
8
|
-
end
|
9
7
|
|
10
8
|
class ArchetypeTest < Test::Unit::TestCase
|
11
9
|
|
@@ -4,7 +4,6 @@ require 'archetype'
|
|
4
4
|
class SassExtensionsTest < Test::Unit::TestCase
|
5
5
|
setup do
|
6
6
|
Compass.reset_configuration!
|
7
|
-
Compass.configuration.testing = true
|
8
7
|
end
|
9
8
|
|
10
9
|
## VERSION
|
@@ -17,20 +16,20 @@ class SassExtensionsTest < Test::Unit::TestCase
|
|
17
16
|
assert_equal "true", evaluate("archetype-version('Compass >= 0.12')")
|
18
17
|
assert_equal "false", evaluate("archetype-version('Sass >= 99.0.0')")
|
19
18
|
assert_equal "true", evaluate("archetype-version('Sass gt 3.0')")
|
20
|
-
assert_equal "
|
19
|
+
assert_equal "false", evaluate("archetype-version(Archetype ne 99)")
|
21
20
|
end
|
22
21
|
|
23
22
|
|
24
23
|
## ENVIRONMENT
|
25
24
|
# test that archetype-env() is working correctly
|
26
25
|
def test_env
|
27
|
-
|
26
|
+
Compass.reset_configuration!
|
28
27
|
assert_equal "development", evaluate("archetype-env()")
|
29
28
|
Compass.configuration.environment = :production
|
30
29
|
assert_equal "production", evaluate("archetype-env()")
|
31
30
|
Compass.configuration.environment = :staging
|
32
31
|
assert_equal "staging", evaluate("archetype-env()")
|
33
|
-
|
32
|
+
Compass.reset_configuration!
|
34
33
|
end
|
35
34
|
|
36
35
|
|
@@ -50,6 +49,19 @@ class SassExtensionsTest < Test::Unit::TestCase
|
|
50
49
|
# TODO
|
51
50
|
end
|
52
51
|
|
52
|
+
# list-sort
|
53
|
+
#def test_list_sort
|
54
|
+
# assert_equal "1 2 3 4", evaluate("list-sort(2 4 3 1)")
|
55
|
+
# assert_equal "4 3 2 1", evaluate("list-sort(2 4 3 1, true)")
|
56
|
+
# assert_equal "a b c d", evaluate("list-sort(d a b c)")
|
57
|
+
#end
|
58
|
+
|
59
|
+
# list-reverse
|
60
|
+
#def test_list_reverse
|
61
|
+
# assert_equal "4 3 2 1", evaluate("list-reverse(1 2 3 4)")
|
62
|
+
# assert_equal "d c b a", evaluate("list-reverse(a b c d)")
|
63
|
+
#end
|
64
|
+
|
53
65
|
# list-add
|
54
66
|
def test_list_add
|
55
67
|
assert_equal "2 3 4", evaluate("list-add(1 2 3, 1)")
|
@@ -115,16 +127,16 @@ class SassExtensionsTest < Test::Unit::TestCase
|
|
115
127
|
## LOCALE
|
116
128
|
# locale
|
117
129
|
def test_locale
|
118
|
-
|
130
|
+
Compass.reset_configuration!
|
119
131
|
assert_equal "en_US", evaluate("locale()")
|
120
132
|
Compass.configuration.locale = "ja_JP"
|
121
133
|
assert_equal "ja_JP", evaluate("locale()")
|
122
|
-
|
134
|
+
Compass.reset_configuration!
|
123
135
|
end
|
124
136
|
|
125
137
|
# lang
|
126
138
|
def test_lang
|
127
|
-
|
139
|
+
Compass.reset_configuration!
|
128
140
|
assert_equal "true", evaluate("lang(en_US)")
|
129
141
|
assert_equal "true", evaluate("lang(fr_FR en_US)")
|
130
142
|
assert_equal "false", evaluate("lang(fr_FR)")
|
@@ -133,7 +145,7 @@ class SassExtensionsTest < Test::Unit::TestCase
|
|
133
145
|
assert_equal "true", evaluate("lang(ja_JP)")
|
134
146
|
assert_equal "true", evaluate("lang(CJK)")
|
135
147
|
assert_equal "true", evaluate("lang(CJK en_US)")
|
136
|
-
|
148
|
+
Compass.reset_configuration!
|
137
149
|
end
|
138
150
|
|
139
151
|
|
@@ -171,11 +183,11 @@ class SassExtensionsTest < Test::Unit::TestCase
|
|
171
183
|
## UI
|
172
184
|
# test generating unique tokens
|
173
185
|
def test_unique
|
174
|
-
assert_equal ".archetype-uid-
|
175
|
-
assert_equal ".archetype-uid-
|
176
|
-
assert_equal "\#archetype-uid-
|
177
|
-
assert_equal "my-prefix-archetype-uid-
|
178
|
-
assert_equal ".testing-archetype-uid-
|
186
|
+
assert_equal ".archetype-uid-1", evaluate("unique(class)")
|
187
|
+
assert_equal ".archetype-uid-2", evaluate("unique(class)")
|
188
|
+
assert_equal "\#archetype-uid-3", evaluate("unique(id)")
|
189
|
+
assert_equal "my-prefix-archetype-uid-4", evaluate("unique(my-prefix-)")
|
190
|
+
assert_equal ".testing-archetype-uid-5", evaluate("unique('.testing-')")
|
179
191
|
end
|
180
192
|
|
181
193
|
# test pseudo content escaping and formatting for innerHTML
|
@@ -192,9 +204,4 @@ protected
|
|
192
204
|
def evaluate(value)
|
193
205
|
Sass::Script::Parser.parse(value, 0, 0).perform(Sass::Environment.new).to_s
|
194
206
|
end
|
195
|
-
|
196
|
-
def reset
|
197
|
-
Compass.reset_configuration!
|
198
|
-
Compass.configuration.testing = true
|
199
|
-
end
|
200
207
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: archetype
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.pre.
|
4
|
+
version: 0.0.1.pre.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugene ONeill
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sass
|
@@ -79,9 +79,6 @@ files:
|
|
79
79
|
- bin/archetype
|
80
80
|
- lib/README.rdoc
|
81
81
|
- lib/archetype.rb
|
82
|
-
- lib/archetype/actions/help.rb
|
83
|
-
- lib/archetype/actions/theme.rb
|
84
|
-
- lib/archetype/executor.rb
|
85
82
|
- lib/archetype/functions.rb
|
86
83
|
- lib/archetype/functions/hash.rb
|
87
84
|
- lib/archetype/functions/helpers.rb
|
@@ -222,29 +219,19 @@ files:
|
|
222
219
|
- test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/sprites/hovercard_tip.png
|
223
220
|
- test/fixtures/stylesheets/archetype/config.rb
|
224
221
|
- test/fixtures/stylesheets/archetype/saved/b.css
|
225
|
-
- test/fixtures/stylesheets/archetype/saved/base.css
|
226
222
|
- test/fixtures/stylesheets/archetype/saved/hacks/ie_pseudo.css
|
227
|
-
- test/fixtures/stylesheets/archetype/saved/
|
228
|
-
- test/fixtures/stylesheets/archetype/saved/
|
223
|
+
- test/fixtures/stylesheets/archetype/saved/styleguide/buttons.css
|
224
|
+
- test/fixtures/stylesheets/archetype/saved/styleguide/fallback_styles.css
|
229
225
|
- test/fixtures/stylesheets/archetype/source/b.scss
|
230
|
-
- test/fixtures/stylesheets/archetype/source/base.scss
|
231
226
|
- test/fixtures/stylesheets/archetype/source/hacks/ie_pseudo.scss
|
232
|
-
- test/fixtures/stylesheets/archetype/source/hacks/transparent_focusable.scss
|
233
|
-
- test/fixtures/stylesheets/archetype/source/locale.scss
|
234
|
-
- test/fixtures/stylesheets/archetype/source/styleguide/alerts.scss
|
235
227
|
- test/fixtures/stylesheets/archetype/source/styleguide/buttons.scss
|
236
|
-
- test/fixtures/stylesheets/archetype/source/styleguide/drop.scss
|
237
|
-
- test/fixtures/stylesheets/archetype/source/styleguide/extend.scss
|
238
228
|
- test/fixtures/stylesheets/archetype/source/styleguide/fallback_styles.scss
|
239
|
-
- test/fixtures/stylesheets/archetype/source/styleguide/invalid_structures.scss
|
240
|
-
- test/fixtures/stylesheets/archetype/source/styleguide/multi_value.scss
|
241
229
|
- test/fixtures/stylesheets/archetype/source/styleguide/nested_styleguides.scss
|
242
230
|
- test/fixtures/stylesheets/archetype/source/styleguide/selective_state.scss
|
243
231
|
- test/fixtures/stylesheets/archetype/source/ui/glyph_icon.scss
|
244
232
|
- test/fixtures/stylesheets/archetype/source/ui/hide_element.scss
|
245
233
|
- test/fixtures/stylesheets/archetype/source/ui/stroke.scss
|
246
234
|
- test/fixtures/stylesheets/archetype/source/ui/triangle.scss
|
247
|
-
- test/fixtures/stylesheets/archetype/source/utilities/associative.scss
|
248
235
|
- test/fixtures/stylesheets/archetype/source/utilities/custom_output_styler.scss
|
249
236
|
- test/fixtures/stylesheets/archetype/source/utilities/if-set.scss
|
250
237
|
- test/fixtures/stylesheets/archetype/source/utilities/spacing/horizontal-spacing.scss
|
@@ -305,29 +292,19 @@ test_files:
|
|
305
292
|
- test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/sprites/hovercard_tip.png
|
306
293
|
- test/fixtures/stylesheets/archetype/config.rb
|
307
294
|
- test/fixtures/stylesheets/archetype/saved/b.css
|
308
|
-
- test/fixtures/stylesheets/archetype/saved/base.css
|
309
295
|
- test/fixtures/stylesheets/archetype/saved/hacks/ie_pseudo.css
|
310
|
-
- test/fixtures/stylesheets/archetype/saved/
|
311
|
-
- test/fixtures/stylesheets/archetype/saved/
|
296
|
+
- test/fixtures/stylesheets/archetype/saved/styleguide/buttons.css
|
297
|
+
- test/fixtures/stylesheets/archetype/saved/styleguide/fallback_styles.css
|
312
298
|
- test/fixtures/stylesheets/archetype/source/b.scss
|
313
|
-
- test/fixtures/stylesheets/archetype/source/base.scss
|
314
299
|
- test/fixtures/stylesheets/archetype/source/hacks/ie_pseudo.scss
|
315
|
-
- test/fixtures/stylesheets/archetype/source/hacks/transparent_focusable.scss
|
316
|
-
- test/fixtures/stylesheets/archetype/source/locale.scss
|
317
|
-
- test/fixtures/stylesheets/archetype/source/styleguide/alerts.scss
|
318
300
|
- test/fixtures/stylesheets/archetype/source/styleguide/buttons.scss
|
319
|
-
- test/fixtures/stylesheets/archetype/source/styleguide/drop.scss
|
320
|
-
- test/fixtures/stylesheets/archetype/source/styleguide/extend.scss
|
321
301
|
- test/fixtures/stylesheets/archetype/source/styleguide/fallback_styles.scss
|
322
|
-
- test/fixtures/stylesheets/archetype/source/styleguide/invalid_structures.scss
|
323
|
-
- test/fixtures/stylesheets/archetype/source/styleguide/multi_value.scss
|
324
302
|
- test/fixtures/stylesheets/archetype/source/styleguide/nested_styleguides.scss
|
325
303
|
- test/fixtures/stylesheets/archetype/source/styleguide/selective_state.scss
|
326
304
|
- test/fixtures/stylesheets/archetype/source/ui/glyph_icon.scss
|
327
305
|
- test/fixtures/stylesheets/archetype/source/ui/hide_element.scss
|
328
306
|
- test/fixtures/stylesheets/archetype/source/ui/stroke.scss
|
329
307
|
- test/fixtures/stylesheets/archetype/source/ui/triangle.scss
|
330
|
-
- test/fixtures/stylesheets/archetype/source/utilities/associative.scss
|
331
308
|
- test/fixtures/stylesheets/archetype/source/utilities/custom_output_styler.scss
|
332
309
|
- test/fixtures/stylesheets/archetype/source/utilities/if-set.scss
|
333
310
|
- test/fixtures/stylesheets/archetype/source/utilities/spacing/horizontal-spacing.scss
|
@@ -1,16 +0,0 @@
|
|
1
|
-
description = "Get help on an Archetype action"
|
2
|
-
if @description.nil?
|
3
|
-
# do stuff...
|
4
|
-
@help = true
|
5
|
-
|
6
|
-
if not ARGV[1].nil? and ARGV[1] != 'help'
|
7
|
-
action = File.join(@actions_path, ARGV[1])
|
8
|
-
begin
|
9
|
-
load "#{action}.rb"
|
10
|
-
rescue
|
11
|
-
puts "unknown action: #{ARGV[1]}"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
else
|
15
|
-
@description = description
|
16
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
description = "Generate a new Archetype theme"
|
3
|
-
|
4
|
-
if @description.nil?
|
5
|
-
options = {
|
6
|
-
:extends => 'archetype'
|
7
|
-
}
|
8
|
-
OptionParser.new do |opts|
|
9
|
-
opts.banner = description
|
10
|
-
opts.define_head "Usage: archetype theme [path] [options]"
|
11
|
-
opts.separator ""
|
12
|
-
opts.separator "Example usage:"
|
13
|
-
opts.separator " archetype theme /path/to/scss/ --name=myCustomTheme"
|
14
|
-
opts.separator " archetype theme --name=themes/myExtendedTheme --extends=themes/myBaseTheme"
|
15
|
-
|
16
|
-
opts.on('-n', '--name THEME', 'theme name') do |v|
|
17
|
-
options[:theme] = v
|
18
|
-
end
|
19
|
-
|
20
|
-
opts.on('-x', '--extends THEME', 'theme name to extend') do |v|
|
21
|
-
options[:extends] = v
|
22
|
-
end
|
23
|
-
|
24
|
-
opts.on('-h', '--help', 'shows this help message') do
|
25
|
-
puts opts
|
26
|
-
exit
|
27
|
-
end
|
28
|
-
|
29
|
-
if not @help.nil?
|
30
|
-
puts opts
|
31
|
-
exit
|
32
|
-
end
|
33
|
-
end.parse!
|
34
|
-
|
35
|
-
if not options[:theme].nil?
|
36
|
-
base = ARGV[1] || '.'
|
37
|
-
tmp = '/tmp/theme_' + rand(36**8).to_s(36)
|
38
|
-
theme_template = File.join(File.dirname(__FILE__), '../../../templates/_theme/')
|
39
|
-
theme_path = File.join(base, options[:theme])
|
40
|
-
extends = "#{options[:extends]}"
|
41
|
-
if options[:extends] != 'archetype'
|
42
|
-
extends = "#{extends}/core"
|
43
|
-
end
|
44
|
-
theme_name = File.basename(options[:theme])
|
45
|
-
# copy template files to tmp dir
|
46
|
-
FileUtils.mkdir_p(tmp)
|
47
|
-
FileUtils.cp_r(Dir["#{theme_template}/**"], tmp)
|
48
|
-
|
49
|
-
puts "Creating theme '#{theme_name}' in #{File.expand_path(theme_path)}..."
|
50
|
-
puts "extending from #{options[:extends]}" if options[:extends] != 'archetype'
|
51
|
-
|
52
|
-
# update all placeholders in template files
|
53
|
-
Dir.glob("#{tmp}/**/*.scss") do |filename|
|
54
|
-
out = File.read(filename).gsub(/__THEME_NAME__/, theme_name).gsub(/__THEME_EXTENDS__/, extends)
|
55
|
-
File.open(filename, "w") { |file| file.puts out }
|
56
|
-
end
|
57
|
-
|
58
|
-
# now move all the theme files to their destination
|
59
|
-
FileUtils.mkdir_p(theme_path)
|
60
|
-
FileUtils.cp_r(Dir["#{tmp}/**"], theme_path)
|
61
|
-
|
62
|
-
# create convenience file _<theme>.scss ...
|
63
|
-
File.open(File.join(File.dirname(theme_path), "_#{theme_name}.scss"), "w") { |file| file.puts "// #{theme_name} theme\n@import \"#{theme_name}/core\";\n" }
|
64
|
-
|
65
|
-
# remove tmp dir
|
66
|
-
FileUtils.rm_rf(tmp)
|
67
|
-
puts "Congratulations! Your new theme has been created!"
|
68
|
-
puts "Use @import \"#{options[:theme]}\" in your scss files."
|
69
|
-
exit
|
70
|
-
end
|
71
|
-
else
|
72
|
-
@description = description
|
73
|
-
end
|