archetype 0.0.1.pre.13 → 1.0.0.alpha.1
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/CHANGELOG.md +97 -24
- data/README.md +11 -5
- data/VERSION +1 -0
- data/lib/archetype.rb +30 -18
- data/lib/archetype/actions/migrate.rb +152 -0
- data/lib/archetype/actions/theme.rb +6 -7
- data/lib/archetype/executor.rb +21 -7
- data/lib/archetype/extensions.rb +57 -0
- data/lib/archetype/functions.rb +2 -3
- data/lib/archetype/functions/css.rb +70 -0
- data/lib/archetype/functions/css/constants.rb +247 -0
- data/lib/archetype/functions/css/helpers.rb +265 -0
- data/lib/archetype/functions/css/routers.rb +28 -0
- data/lib/archetype/functions/css/routers/animation.rb +55 -0
- data/lib/archetype/functions/css/routers/background.rb +38 -0
- data/lib/archetype/functions/css/routers/border.rb +151 -0
- data/lib/archetype/functions/css/routers/list.rb +63 -0
- data/lib/archetype/functions/css/routers/margin_padding.rb +40 -0
- data/lib/archetype/functions/css/routers/outline.rb +56 -0
- data/lib/archetype/functions/css/routers/overflow.rb +11 -0
- data/lib/archetype/functions/css/routers/target.rb +38 -0
- data/lib/archetype/functions/css/routers/transition.rb +48 -0
- data/lib/archetype/functions/css/shorthands.rb +43 -0
- data/lib/archetype/functions/css/shorthands/animation.rb +18 -0
- data/lib/archetype/functions/css/shorthands/background.rb +68 -0
- data/lib/archetype/functions/css/shorthands/border.rb +102 -0
- data/lib/archetype/functions/hash.rb +3 -149
- data/lib/archetype/functions/hash/extend.rb +74 -0
- data/lib/archetype/functions/hash/shim.rb +48 -0
- data/lib/archetype/functions/helpers.rb +231 -22
- data/lib/archetype/functions/styleguide_memoizer.rb +18 -1
- data/lib/archetype/sass_extensions.rb +1 -3
- data/lib/archetype/sass_extensions/functions.rb +15 -1
- data/lib/archetype/sass_extensions/functions/environment.rb +152 -1
- data/lib/archetype/sass_extensions/functions/lists.rb +95 -45
- data/lib/archetype/sass_extensions/functions/locale.rb +107 -28
- data/lib/archetype/sass_extensions/functions/numbers.rb +118 -4
- data/lib/archetype/sass_extensions/functions/strings.rb +53 -0
- data/lib/archetype/sass_extensions/functions/styleguide.rb +43 -375
- data/lib/archetype/sass_extensions/functions/styleguide/components.rb +25 -0
- data/lib/archetype/sass_extensions/functions/styleguide/constants.rb +27 -0
- data/lib/archetype/sass_extensions/functions/styleguide/grammar.rb +80 -0
- data/lib/archetype/sass_extensions/functions/styleguide/helpers.rb +36 -0
- data/lib/archetype/sass_extensions/functions/styleguide/resolve.rb +159 -0
- data/lib/archetype/sass_extensions/functions/styleguide/styles.rb +146 -0
- data/lib/archetype/sass_extensions/functions/styleguide/themes.rb +40 -0
- data/lib/archetype/sass_extensions/functions/ui.rb +7 -57
- data/lib/archetype/sass_extensions/functions/ui/glyphs.rb +118 -0
- data/lib/archetype/sass_extensions/functions/ui/scopes.rb +96 -0
- data/lib/archetype/sass_extensions/functions/util.rb +14 -0
- data/lib/archetype/sass_extensions/functions/util/debug.rb +22 -0
- data/lib/archetype/sass_extensions/functions/util/hacks.rb +44 -0
- data/lib/archetype/sass_extensions/functions/util/images.rb +132 -0
- data/lib/archetype/sass_extensions/functions/util/misc.rb +220 -0
- data/lib/archetype/sass_extensions/functions/util/spacing.rb +83 -0
- data/lib/archetype/sass_extensions/functions/version.rb +12 -17
- data/lib/archetype/version.rb +1 -1
- data/stylesheets/archetype/_config.scss +1 -389
- data/stylesheets/archetype/_core.scss +15 -0
- data/stylesheets/archetype/_hacks.scss +4 -120
- data/stylesheets/archetype/_init.scss +4 -22
- data/stylesheets/archetype/_required.scss +3 -0
- data/stylesheets/archetype/_reset.scss +3 -0
- data/stylesheets/archetype/_styleguide.scss +2 -6
- data/stylesheets/archetype/_ui.scss +2 -358
- data/stylesheets/archetype/_util.scss +3 -10
- data/stylesheets/archetype/config/_core.scss +14 -0
- data/stylesheets/archetype/config/_environment.scss +19 -0
- data/stylesheets/archetype/config/_formatting.scss +63 -0
- data/stylesheets/archetype/config/_glyphs.scss +252 -0
- data/stylesheets/archetype/config/_resets.scss +7 -0
- data/stylesheets/archetype/config/_resolution.scss +3 -0
- data/stylesheets/archetype/config/_spacing.scss +5 -0
- data/stylesheets/archetype/config/_targeting.scss +18 -0
- data/stylesheets/archetype/config/_theme.scss +3 -0
- data/stylesheets/archetype/config/_typography.scss +56 -0
- data/stylesheets/archetype/config/_units.scss +2 -0
- data/stylesheets/archetype/config/_vars.scss +10 -0
- data/stylesheets/archetype/hacks/_core.scss +4 -0
- data/stylesheets/archetype/hacks/_hacks.scss +160 -0
- data/stylesheets/archetype/hacks/_init.scss +2 -0
- data/stylesheets/archetype/styleguide/_core.scss +4 -0
- data/stylesheets/archetype/styleguide/_init.scss +1 -0
- data/stylesheets/archetype/styleguide/_styleguide.scss +41 -18
- data/stylesheets/archetype/ui/_accessibility.scss +41 -0
- data/stylesheets/archetype/ui/_breakpoints.scss +19 -0
- data/stylesheets/archetype/ui/_core.scss +10 -0
- data/stylesheets/archetype/ui/_elements.scss +98 -0
- data/stylesheets/archetype/ui/_glyphs.scss +244 -0
- data/stylesheets/archetype/ui/_init.scss +5 -0
- data/stylesheets/archetype/ui/_layout.scss +37 -0
- data/stylesheets/archetype/ui/_locale.scss +12 -0
- data/stylesheets/archetype/ui/_scopes.scss +42 -0
- data/stylesheets/archetype/util/_core.scss +8 -0
- data/stylesheets/archetype/util/_debug.scss +9 -21
- data/stylesheets/archetype/util/_init.scss +1 -0
- data/stylesheets/archetype/util/_misc.scss +21 -86
- data/stylesheets/archetype/util/_spacing.scss +9 -40
- data/stylesheets/archetype/util/_styles.scss +189 -178
- data/stylesheets/archetype/util/_targeting.scss +51 -68
- data/templates/example/manifest.rb +2 -2
- data/templates/example/screen.scss +0 -1
- data/templates/project/manifest.rb +3 -8
- metadata +93 -263
- data/bin/archetype +0 -3
- data/lib/archetype/sass_extensions/monkey_patches.rb +0 -3
- data/lib/archetype/sass_extensions/monkey_patches/handle_include_loop.rb +0 -13
- data/stylesheets/archetype/_base.scss +0 -54
- data/stylesheets/archetype/_grid.scss +0 -3
- data/stylesheets/archetype/base/_h5bp.scss +0 -307
- data/stylesheets/archetype/base/_hybrid.scss +0 -25
- data/stylesheets/archetype/base/_normalize.scss +0 -634
- data/stylesheets/archetype/base/_reset.scss +0 -72
- data/stylesheets/archetype/grid/_config.scss +0 -14
- data/stylesheets/archetype/grid/_grid.scss +0 -391
- data/stylesheets/archetype/styleguide/_components.scss +0 -25
- data/stylesheets/archetype/styleguide/_helpers.scss +0 -215
- data/stylesheets/archetype/styleguide/_primitives.scss +0 -10
- data/stylesheets/archetype/styleguide/components/_alerts.scss +0 -59
- data/stylesheets/archetype/styleguide/components/_annotations.scss +0 -27
- data/stylesheets/archetype/styleguide/components/_bristol.scss +0 -15
- data/stylesheets/archetype/styleguide/components/_button_groups.scss +0 -47
- data/stylesheets/archetype/styleguide/components/_button_toolbars.scss +0 -17
- data/stylesheets/archetype/styleguide/components/_buttons.scss +0 -339
- data/stylesheets/archetype/styleguide/components/_canvas.scss +0 -15
- data/stylesheets/archetype/styleguide/components/_carets.scss +0 -336
- data/stylesheets/archetype/styleguide/components/_closes.scss +0 -63
- data/stylesheets/archetype/styleguide/components/_container.scss +0 -27
- data/stylesheets/archetype/styleguide/components/_copy.scss +0 -85
- data/stylesheets/archetype/styleguide/components/_flyouts.scss +0 -52
- data/stylesheets/archetype/styleguide/components/_headings.scss +0 -33
- data/stylesheets/archetype/styleguide/components/_headlines.scss +0 -64
- data/stylesheets/archetype/styleguide/components/_hovercards.scss +0 -27
- data/stylesheets/archetype/styleguide/components/_icons.scss +0 -17
- data/stylesheets/archetype/styleguide/components/_identities.scss +0 -34
- data/stylesheets/archetype/styleguide/components/_links.scss +0 -68
- data/stylesheets/archetype/styleguide/components/_loaders.scss +0 -154
- data/stylesheets/archetype/styleguide/components/_menu_items.scss +0 -31
- data/stylesheets/archetype/styleguide/components/_module.scss +0 -15
- data/stylesheets/archetype/styleguide/components/_pullquotes.scss +0 -29
- data/stylesheets/archetype/styleguide/components/_punchcut.scss +0 -18
- data/stylesheets/archetype/styleguide/components/_tooltips.scss +0 -28
- data/stylesheets/archetype/styleguide/primitives/_animations.scss +0 -17
- data/stylesheets/archetype/styleguide/primitives/_dimensions.scss +0 -50
- data/stylesheets/archetype/styleguide/primitives/_glyphs.scss +0 -11
- data/stylesheets/archetype/styleguide/primitives/_misc.scss +0 -8
- data/stylesheets/archetype/styleguide/primitives/_palettes.scss +0 -94
- data/stylesheets/archetype/styleguide/primitives/_shadows.scss +0 -23
- data/stylesheets/archetype/styleguide/primitives/_sprites.scss +0 -46
- data/stylesheets/archetype/styleguide/primitives/_textures.scss +0 -10
- data/stylesheets/archetype/styleguide/primitives/_typography.scss +0 -56
- data/stylesheets/archetype/util/_lists.scss +0 -57
- data/stylesheets/archetype/util/_rtl.scss +0 -279
- data/stylesheets/archetype/util/_units.scss +0 -18
- data/templates/project/screen.scss +0 -1
- data/templates/project/vendor/archetype/animations/loaders/large/large.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/large/large_dark.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/large/large_dark_static.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/large/large_static.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/medium/medium.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/medium/medium_dark.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/medium/medium_dark_static.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/medium/medium_static.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/small/small.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/small/small_dark.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/small/small_dark_static.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/small/small_static.png +0 -0
- data/templates/project/vendor/archetype/fontawesome-webfont.eot +0 -0
- data/templates/project/vendor/archetype/fontawesome-webfont.svg +0 -255
- data/templates/project/vendor/archetype/fontawesome-webfont.ttf +0 -0
- data/templates/project/vendor/archetype/fontawesome-webfont.woff +0 -0
- data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.eot +0 -0
- data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.svg +0 -255
- data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.woff +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders-s7889ccc8c1.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large_dark.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large_dark_static.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large_static.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium_dark.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium_dark_static.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium_static.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small_dark.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small_dark_static.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small_static.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/sprites/hovercard_tip.png +0 -0
- data/test/fixtures/stylesheets/archetype/config.rb +0 -21
- data/test/fixtures/stylesheets/archetype/source/b.scss +0 -9
- data/test/fixtures/stylesheets/archetype/source/base.scss +0 -3
- data/test/fixtures/stylesheets/archetype/source/hacks/ie_pseudo.scss +0 -13
- 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/buttons.scss +0 -18
- 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/fallback_styles.scss +0 -23
- 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/styleguide/nested_styleguides.scss +0 -40
- data/test/fixtures/stylesheets/archetype/source/styleguide/selective_state.scss +0 -22
- data/test/fixtures/stylesheets/archetype/source/ui/glyph_icon.scss +0 -35
- data/test/fixtures/stylesheets/archetype/source/ui/hide_element.scss +0 -5
- data/test/fixtures/stylesheets/archetype/source/ui/stroke.scss +0 -13
- data/test/fixtures/stylesheets/archetype/source/ui/triangle.scss +0 -13
- data/test/fixtures/stylesheets/archetype/source/utilities/associative.scss +0 -24
- data/test/fixtures/stylesheets/archetype/source/utilities/custom_output_styler.scss +0 -22
- data/test/fixtures/stylesheets/archetype/source/utilities/if-set.scss +0 -16
- data/test/fixtures/stylesheets/archetype/source/utilities/spacing/horizontal-spacing.scss +0 -27
- data/test/fixtures/stylesheets/archetype/source/utilities/spacing/vertical-spacing.scss +0 -27
- data/test/fixtures/stylesheets/archetype/source/utilities/styles/filter.scss +0 -9
- data/test/fixtures/stylesheets/archetype/source/utilities/styles/font-family.scss +0 -9
- data/test/fixtures/stylesheets/archetype/source/utilities/styles/z-index.scss +0 -18
- data/test/fixtures/stylesheets/archetype/source/utilities/targeting/target-browser.scss +0 -77
- data/test/fixtures/stylesheets/archetype/source/utilities/targeting/target-os.scss +0 -42
- data/test/fixtures/stylesheets/archetype/tmp/b.css +0 -14
- data/test/fixtures/stylesheets/archetype/tmp/base.css +0 -349
- data/test/fixtures/stylesheets/archetype/tmp/hacks/ie_pseudo.css +0 -11
- data/test/fixtures/stylesheets/archetype/tmp/hacks/transparent_focusable.css +0 -4
- data/test/fixtures/stylesheets/archetype/tmp/locale.css +0 -23
- data/test/fixtures/stylesheets/archetype/tmp/styleguide/alerts.css +0 -711
- data/test/fixtures/stylesheets/archetype/tmp/styleguide/buttons.css +0 -2119
- data/test/fixtures/stylesheets/archetype/tmp/styleguide/drop.css +0 -63
- data/test/fixtures/stylesheets/archetype/tmp/styleguide/extend.css +0 -11
- data/test/fixtures/stylesheets/archetype/tmp/styleguide/fallback_styles.css +0 -10
- data/test/fixtures/stylesheets/archetype/tmp/styleguide/invalid_structures.css +0 -21
- data/test/fixtures/stylesheets/archetype/tmp/styleguide/multi_value.css +0 -13
- data/test/fixtures/stylesheets/archetype/tmp/styleguide/nested_styleguides.css +0 -28
- data/test/fixtures/stylesheets/archetype/tmp/styleguide/selective_state.css +0 -177
- data/test/fixtures/stylesheets/archetype/tmp/ui/glyph_icon.css +0 -127
- data/test/fixtures/stylesheets/archetype/tmp/ui/hide_element.css +0 -8
- data/test/fixtures/stylesheets/archetype/tmp/ui/stroke.css +0 -17
- data/test/fixtures/stylesheets/archetype/tmp/ui/triangle.css +0 -35
- data/test/fixtures/stylesheets/archetype/tmp/utilities/associative.css +0 -9
- data/test/fixtures/stylesheets/archetype/tmp/utilities/custom_output_styler.css +0 -8
- data/test/fixtures/stylesheets/archetype/tmp/utilities/if-set.css +0 -9
- data/test/fixtures/stylesheets/archetype/tmp/utilities/spacing/horizontal-spacing.css +0 -29
- data/test/fixtures/stylesheets/archetype/tmp/utilities/spacing/vertical-spacing.css +0 -29
- data/test/fixtures/stylesheets/archetype/tmp/utilities/styles/filter.css +0 -11
- data/test/fixtures/stylesheets/archetype/tmp/utilities/styles/font-family.css +0 -16
- data/test/fixtures/stylesheets/archetype/tmp/utilities/styles/z-index.css +0 -15
- data/test/fixtures/stylesheets/archetype/tmp/utilities/targeting/target-browser.css +0 -105
- data/test/fixtures/stylesheets/archetype/tmp/utilities/targeting/target-os.css +0 -55
- data/test/helpers/diff.rb +0 -49
- data/test/helpers/io.rb +0 -36
- data/test/helpers/test_case.rb +0 -62
- data/test/integrations/archetype_test.rb +0 -126
- data/test/test_helper.rb +0 -26
- data/test/units/sass_extensions_test.rb +0 -200
|
@@ -20,7 +20,7 @@ private
|
|
|
20
20
|
#
|
|
21
21
|
def self.tokenize(theme, extensions, id, modifiers, state)
|
|
22
22
|
return nil if extensions.nil? or id.nil?
|
|
23
|
-
return "#{id}::#{(modifiers.to_a.sort + extensions).join('$')}::#{state}"
|
|
23
|
+
return "#{id}::#{(modifiers.to_a.sort + extensions).join('$')}::#{state}".hash
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
#
|
|
@@ -49,6 +49,23 @@ private
|
|
|
49
49
|
return (@components[theme] ||= {})[token]
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
+
#
|
|
53
|
+
# fetch a value from the memoizer if available, otherwise execute the block and create it
|
|
54
|
+
#
|
|
55
|
+
# *Parameters*:
|
|
56
|
+
# - <tt>theme</tt> {String} the theme name
|
|
57
|
+
# - <tt>token</tt> {Fixnum} the token to lookup
|
|
58
|
+
# *Returns*:
|
|
59
|
+
# - <tt>value</tt> {Hash} the value from the memoizer
|
|
60
|
+
#
|
|
61
|
+
def self.fetch_or_create(theme, token)
|
|
62
|
+
fetched = self.fetch(theme, token)
|
|
63
|
+
return fetched if fetched
|
|
64
|
+
fetched = yield if block_given?
|
|
65
|
+
self.add(theme, token, fetched)
|
|
66
|
+
return fetched
|
|
67
|
+
end
|
|
68
|
+
|
|
52
69
|
#
|
|
53
70
|
# invalidate the memoizer for the theme
|
|
54
71
|
#
|
|
@@ -1,14 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
# leverage Sass::Script::Value::Helpers
|
|
2
|
+
require 'sass/script/value/helpers'
|
|
3
|
+
|
|
4
|
+
%w(lists strings styleguide ui locale numbers version environment util).each do |func|
|
|
2
5
|
require "archetype/sass_extensions/functions/#{func}"
|
|
3
6
|
end
|
|
4
7
|
|
|
5
8
|
# :stopdoc:
|
|
6
9
|
module Sass::Script::Functions
|
|
10
|
+
include Archetype::SassExtensions::Util
|
|
7
11
|
include Archetype::SassExtensions::Lists
|
|
12
|
+
include Archetype::SassExtensions::Strings
|
|
8
13
|
include Archetype::SassExtensions::Styleguide
|
|
9
14
|
include Archetype::SassExtensions::UI
|
|
10
15
|
include Archetype::SassExtensions::Locale
|
|
11
16
|
include Archetype::SassExtensions::Numbers
|
|
12
17
|
include Archetype::SassExtensions::Version
|
|
13
18
|
include Archetype::SassExtensions::Environment
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
# shortcut to Archetype::Functions::Helpers
|
|
22
|
+
def helpers
|
|
23
|
+
Archetype::Functions::Helpers
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# include the Sass::Script::Value::Helpers in the context for all included modules
|
|
27
|
+
include Sass::Script::Value::Helpers
|
|
14
28
|
end
|
|
@@ -9,6 +9,157 @@ module Archetype::SassExtensions::Environment
|
|
|
9
9
|
# - {String} the current environment the compiler is running in
|
|
10
10
|
#
|
|
11
11
|
def archetype_env
|
|
12
|
-
return
|
|
12
|
+
return identifier((Compass.configuration.environment || :development).to_s)
|
|
13
13
|
end
|
|
14
|
+
|
|
15
|
+
#
|
|
16
|
+
# namespaces a string
|
|
17
|
+
#
|
|
18
|
+
# *Parameters*:
|
|
19
|
+
# - <tt>$string</tt> {String} the string to namespace
|
|
20
|
+
# *Returns*:
|
|
21
|
+
# - {String} the namespaced string
|
|
22
|
+
#
|
|
23
|
+
def archetype_namespace(string)
|
|
24
|
+
namespace = environment.var('CONFIG_NAMESPACE')
|
|
25
|
+
return string if is_null(namespace).value
|
|
26
|
+
return identifier(namespace.value + '_' + string.value)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
#
|
|
30
|
+
# gets the value of the given key from the `meta` config map
|
|
31
|
+
#
|
|
32
|
+
# *Parameters*:
|
|
33
|
+
# - <tt>$key</tt> {String} the key to lookup
|
|
34
|
+
# *Returns*:
|
|
35
|
+
# - {*} the value from the meta map
|
|
36
|
+
#
|
|
37
|
+
def archetype_meta(key)
|
|
38
|
+
# if `$CONFIG_META` is set, use it, otherwise, use the one set on the configuration object
|
|
39
|
+
meta = environment.var('CONFIG_META') || Compass.configuration.archetype_meta || {}
|
|
40
|
+
# convert it to a hash
|
|
41
|
+
meta = helpers.map_to_hash(meta)
|
|
42
|
+
# fetch the value for the key
|
|
43
|
+
value = meta[key.value]
|
|
44
|
+
# if we got nothing...
|
|
45
|
+
if value.nil?
|
|
46
|
+
# return `null`
|
|
47
|
+
return null
|
|
48
|
+
# if it's a Sass::Script value...
|
|
49
|
+
elsif value.is_a?(Sass::Script::Value::Base)
|
|
50
|
+
# just return it
|
|
51
|
+
return value
|
|
52
|
+
# otherwise...
|
|
53
|
+
else
|
|
54
|
+
# convert it to a Sass::Script::String
|
|
55
|
+
return identifier(helpers.to_str(value))
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
#
|
|
60
|
+
# registers an Archetype module as active
|
|
61
|
+
#
|
|
62
|
+
# *Parameters*:
|
|
63
|
+
# - <tt>$name</tt> {String} the module name
|
|
64
|
+
# *Returns*:
|
|
65
|
+
# - {List} the list of current registered modules
|
|
66
|
+
#
|
|
67
|
+
def register_archetype_module(name)
|
|
68
|
+
registry = archetype_modules_registry
|
|
69
|
+
# if it's already in the registry, just return the current list
|
|
70
|
+
return list(registry, :comma) if archetype_modules_registry.include?(name)
|
|
71
|
+
# update the registry with the module name
|
|
72
|
+
registry = list(registry.dup.push(name), :comma)
|
|
73
|
+
environment.global_env.set_var('ARCHETYPE_MODULES_REGISTRY', registry)
|
|
74
|
+
# return the registry
|
|
75
|
+
return registry
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
#
|
|
79
|
+
# checks to see if a required module is loaded or not
|
|
80
|
+
# if not, throws an error
|
|
81
|
+
#
|
|
82
|
+
# *Parameters*:
|
|
83
|
+
# - <tt>$name</tt> {String} the module name
|
|
84
|
+
# *Returns*:
|
|
85
|
+
# - {Boolean} whether or not all the modules are registered
|
|
86
|
+
#
|
|
87
|
+
def require_archetype_modules(*names)
|
|
88
|
+
return check_archetype_modules(names, true)
|
|
89
|
+
end
|
|
90
|
+
alias_method :require_archetype_module, :require_archetype_modules
|
|
91
|
+
|
|
92
|
+
#
|
|
93
|
+
# checks whether or not a module has been registered
|
|
94
|
+
#
|
|
95
|
+
# *Parameters*:
|
|
96
|
+
# - <tt>$name</tt> {String} the module name
|
|
97
|
+
# *Returns*:
|
|
98
|
+
# - {Boolean} whether or not all the modules are registered
|
|
99
|
+
#
|
|
100
|
+
def has_archetype_modules(*names)
|
|
101
|
+
return check_archetype_modules(names, false)
|
|
102
|
+
end
|
|
103
|
+
alias_method :has_archetype_module, :has_archetype_modules
|
|
104
|
+
|
|
105
|
+
#
|
|
106
|
+
# sets the intialization state of Archetype
|
|
107
|
+
#
|
|
108
|
+
# *Parameters*
|
|
109
|
+
# - <tt>$state</tt> {*} the state to set
|
|
110
|
+
# *Returns*:
|
|
111
|
+
# - {*} the state that was just set
|
|
112
|
+
#
|
|
113
|
+
def init_archetype(state = identifier('done'))
|
|
114
|
+
environment.global_env.set_var('ARCHETYPE_INIT', state)
|
|
115
|
+
return state
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
#
|
|
119
|
+
# sets the intialization state of Archetype to `skip`
|
|
120
|
+
#
|
|
121
|
+
# *Returns*:
|
|
122
|
+
# - {String} the state `skip` that was just set
|
|
123
|
+
#
|
|
124
|
+
def skip_archetype_init
|
|
125
|
+
init_archetype(identifier('skip'))
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
#
|
|
129
|
+
# sets the intialization state of Archetype to `null`
|
|
130
|
+
#
|
|
131
|
+
# *Returns*:
|
|
132
|
+
# - {Null} the state `null` that was just set
|
|
133
|
+
#
|
|
134
|
+
def force_archetype_init
|
|
135
|
+
init_archetype(null)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
#
|
|
139
|
+
# gets Archetype's current initialization state
|
|
140
|
+
#
|
|
141
|
+
# *Returns*:
|
|
142
|
+
# - {*} Archetype's current initialization state
|
|
143
|
+
#
|
|
144
|
+
def archetype_init_state
|
|
145
|
+
return environment.var('ARCHETYPE_INIT') || null
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
private
|
|
149
|
+
|
|
150
|
+
def check_archetype_modules(names, warn = false)
|
|
151
|
+
missing = []
|
|
152
|
+
names.each do |name|
|
|
153
|
+
missing << name unless archetype_modules_registry.include?(name)
|
|
154
|
+
end
|
|
155
|
+
if missing.count > 0 and warn
|
|
156
|
+
helpers.logger.record(:error, "[archetype:module:missing] the required module#{missing.count > 1 ? 's are' : ' is'} missing: #{helpers.to_str(missing)}")
|
|
157
|
+
end
|
|
158
|
+
return bool(missing.count == 0)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def archetype_modules_registry
|
|
162
|
+
(environment.var('ARCHETYPE_MODULES_REGISTRY') || []).to_a
|
|
163
|
+
end
|
|
164
|
+
|
|
14
165
|
end
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
require 'archetype/functions/helpers'
|
|
2
|
-
|
|
3
1
|
#
|
|
4
|
-
# This module provides a set of Sass functions for working with Sass::List
|
|
2
|
+
# This module provides a set of Sass functions for working with Sass::Script::Value::List
|
|
5
3
|
#
|
|
6
4
|
module Archetype::SassExtensions::Lists
|
|
7
5
|
#
|
|
@@ -17,18 +15,19 @@ module Archetype::SassExtensions::Lists
|
|
|
17
15
|
#
|
|
18
16
|
def list_replace(list, idx = false, value = nil, separator = nil)
|
|
19
17
|
# return early if the index is invalid (no operation)
|
|
20
|
-
return list if (
|
|
21
|
-
separator ||= list.separator if list.is_a?(Sass::Script::List)
|
|
22
|
-
# if $value is `nil`, make sure we can use it
|
|
23
|
-
value = nil if value == Sass::Script::String.new('nil')
|
|
18
|
+
return list if (!idx || is_null(idx).value || idx.value == false)
|
|
19
|
+
separator ||= list.separator if list.is_a?(Sass::Script::Value::List)
|
|
24
20
|
# cast and zero-index $idx
|
|
25
21
|
idx = (idx.value) - 1
|
|
26
22
|
# cast list to a ruby array
|
|
27
|
-
list = list.to_a
|
|
23
|
+
list = list.to_a.dup
|
|
28
24
|
# remove or replace the given value
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
if value.nil? or value == null
|
|
26
|
+
list.delete_at(idx)
|
|
27
|
+
else
|
|
28
|
+
list[idx] = value
|
|
29
|
+
end
|
|
30
|
+
return Sass::Script::Value::List.new(list, separator)
|
|
32
31
|
end
|
|
33
32
|
Sass::Script::Functions.declare :list_replace, [:list, :idx]
|
|
34
33
|
Sass::Script::Functions.declare :list_replace, [:list, :idx, :value]
|
|
@@ -75,7 +74,7 @@ module Archetype::SassExtensions::Lists
|
|
|
75
74
|
# add values(s) to a list
|
|
76
75
|
#
|
|
77
76
|
# *Parameters*:
|
|
78
|
-
# - <tt>$list</tt> {List} the list operate on
|
|
77
|
+
# - <tt>$list</tt> {List} the list operate to on
|
|
79
78
|
# - <tt>$values</tt> {List|Number|String} the value(s) to add to the list
|
|
80
79
|
# *Returns*:
|
|
81
80
|
# - {List} the final list
|
|
@@ -83,12 +82,13 @@ module Archetype::SassExtensions::Lists
|
|
|
83
82
|
def list_add(list, values)
|
|
84
83
|
return list_math(list, values, :plus)
|
|
85
84
|
end
|
|
85
|
+
Sass::Script::Functions.declare :list_add, [:list, :values]
|
|
86
86
|
|
|
87
87
|
#
|
|
88
88
|
# subtract values(s) from a list
|
|
89
89
|
#
|
|
90
90
|
# *Parameters*:
|
|
91
|
-
# - <tt>$list</tt> {List} the list operate on
|
|
91
|
+
# - <tt>$list</tt> {List} the list operate to on
|
|
92
92
|
# - <tt>$values</tt> {List|Number|String} the value(s) to subtract from the list
|
|
93
93
|
# *Returns*:
|
|
94
94
|
# - {List} the final list
|
|
@@ -96,12 +96,13 @@ module Archetype::SassExtensions::Lists
|
|
|
96
96
|
def list_subtract(list, values)
|
|
97
97
|
return list_math(list, values, :minus)
|
|
98
98
|
end
|
|
99
|
+
Sass::Script::Functions.declare :list_subtract, [:list, :values]
|
|
99
100
|
|
|
100
101
|
#
|
|
101
102
|
# multiply values(s) into a list
|
|
102
103
|
#
|
|
103
104
|
# *Parameters*:
|
|
104
|
-
# - <tt>$list</tt> {List} the list operate on
|
|
105
|
+
# - <tt>$list</tt> {List} the list operate to on
|
|
105
106
|
# - <tt>$values</tt> {List|Number|String} the value(s) to multiply into the list
|
|
106
107
|
# *Returns*:
|
|
107
108
|
# - {List} the final list
|
|
@@ -109,12 +110,13 @@ module Archetype::SassExtensions::Lists
|
|
|
109
110
|
def list_multiply(list, values)
|
|
110
111
|
return list_math(list, values, :times)
|
|
111
112
|
end
|
|
113
|
+
Sass::Script::Functions.declare :list_multiply, [:list, :values]
|
|
112
114
|
|
|
113
115
|
#
|
|
114
116
|
# divide values(s) into a list
|
|
115
117
|
#
|
|
116
118
|
# *Parameters*:
|
|
117
|
-
# - <tt>$list</tt> {List} the list operate on
|
|
119
|
+
# - <tt>$list</tt> {List} the list operate to on
|
|
118
120
|
# - <tt>$values</tt> {List|Number|String} the value(s) to divide into the list
|
|
119
121
|
# *Returns*:
|
|
120
122
|
# - {List} the final list
|
|
@@ -122,12 +124,13 @@ module Archetype::SassExtensions::Lists
|
|
|
122
124
|
def list_divide(list, values)
|
|
123
125
|
return list_math(list, values, :div)
|
|
124
126
|
end
|
|
127
|
+
Sass::Script::Functions.declare :list_divide, [:list, :values]
|
|
125
128
|
|
|
126
129
|
#
|
|
127
130
|
# list modulus value(s)
|
|
128
131
|
#
|
|
129
132
|
# *Parameters*:
|
|
130
|
-
# - <tt>$list</tt> {List} the list operate on
|
|
133
|
+
# - <tt>$list</tt> {List} the list to operate on
|
|
131
134
|
# - <tt>$values</tt> {List|Number|String} the value(s) to modulus into the list
|
|
132
135
|
# *Returns*:
|
|
133
136
|
# - {List} the final list
|
|
@@ -135,6 +138,23 @@ module Archetype::SassExtensions::Lists
|
|
|
135
138
|
def list_mod(list, values)
|
|
136
139
|
return list_math(list, values, :mod)
|
|
137
140
|
end
|
|
141
|
+
Sass::Script::Functions.declare :list_mod, [:list, :values]
|
|
142
|
+
|
|
143
|
+
#
|
|
144
|
+
# joins a list into a string with the separator given
|
|
145
|
+
#
|
|
146
|
+
# *Parameters*:
|
|
147
|
+
# - <tt>$list</tt> {List} the list operate to on
|
|
148
|
+
# - <tt>$separator</tt> {String} the separator to insert between each item
|
|
149
|
+
# *Returns*:
|
|
150
|
+
# - {String} string conversions of all list item joined into one string
|
|
151
|
+
#
|
|
152
|
+
def list_join(list, separator = ', ')
|
|
153
|
+
list = list.to_a
|
|
154
|
+
separator = (separator.respond_to?(:value) ? separator.value : separator).to_s
|
|
155
|
+
return identifier(list.join(separator))
|
|
156
|
+
end
|
|
157
|
+
Sass::Script::Functions.declare :list_join, [:list, :separator]
|
|
138
158
|
|
|
139
159
|
#
|
|
140
160
|
# find if any set of values is in a list
|
|
@@ -151,11 +171,12 @@ module Archetype::SassExtensions::Lists
|
|
|
151
171
|
needle = needle.to_a
|
|
152
172
|
index = haystack.index(haystack.detect { |i| needle.include?(i) })
|
|
153
173
|
if index
|
|
154
|
-
return
|
|
174
|
+
return number(index + 1)
|
|
155
175
|
else
|
|
156
176
|
return Sass::Script::Bool.new(false)
|
|
157
177
|
end
|
|
158
178
|
end
|
|
179
|
+
Sass::Script::Functions.declare :index2, [:haystack, :needle]
|
|
159
180
|
|
|
160
181
|
#
|
|
161
182
|
# treats a list cyclically (never out of bounds, just wraps around)
|
|
@@ -167,10 +188,12 @@ module Archetype::SassExtensions::Lists
|
|
|
167
188
|
# - {*} the nth item in the List
|
|
168
189
|
#
|
|
169
190
|
def nth_cyclic(list, n = 1)
|
|
170
|
-
n = n.to_i if n.is_a?(Sass::Script::Number)
|
|
191
|
+
n = n.to_i if n.is_a?(Sass::Script::Value::Number)
|
|
171
192
|
list = list.to_a
|
|
172
193
|
return list[(n - 1) % list.size]
|
|
173
194
|
end
|
|
195
|
+
Sass::Script::Functions.declare :nth_cyclic, [:list]
|
|
196
|
+
Sass::Script::Functions.declare :nth_cyclic, [:list, :n]
|
|
174
197
|
|
|
175
198
|
#
|
|
176
199
|
# find a key within a nested list of ordered pairs
|
|
@@ -183,11 +206,11 @@ module Archetype::SassExtensions::Lists
|
|
|
183
206
|
# - {*} the data associated with $key
|
|
184
207
|
#
|
|
185
208
|
def associative(list, key, strict = false)
|
|
186
|
-
separator = list.separator if list.is_a?(Sass::Script::List)
|
|
209
|
+
separator = list.separator if list.is_a?(Sass::Script::Value::List)
|
|
187
210
|
list = helpers.list_to_hash(list)
|
|
188
211
|
item = list[helpers.to_str(key, ' ' , :quotes)]
|
|
189
212
|
item ||= list.first[1] if not strict
|
|
190
|
-
return Sass::Script::List.new([], separator) if item.nil?
|
|
213
|
+
return Sass::Script::Value::List.new([], separator) if item.nil?
|
|
191
214
|
return helpers.hash_to_list(item, 0, separator) if item.is_a?(Array) or item.is_a?(Hash)
|
|
192
215
|
# no conversion needed, so just return
|
|
193
216
|
return item
|
|
@@ -205,7 +228,7 @@ module Archetype::SassExtensions::Lists
|
|
|
205
228
|
# - <tt>$list</tt> {List} the extended list
|
|
206
229
|
#
|
|
207
230
|
def associative_merge(list, extender, kwargs = {})
|
|
208
|
-
separator = list.separator if list.is_a?(Sass::Script::List)
|
|
231
|
+
separator = list.separator if list.is_a?(Sass::Script::Value::List)
|
|
209
232
|
list = helpers.list_to_hash(list)
|
|
210
233
|
extender = helpers.list_to_hash(extender)
|
|
211
234
|
list = list.rmerge(extender)
|
|
@@ -213,6 +236,47 @@ module Archetype::SassExtensions::Lists
|
|
|
213
236
|
end
|
|
214
237
|
Sass::Script::Functions.declare :associative_merge, [:list, :extender]
|
|
215
238
|
|
|
239
|
+
#
|
|
240
|
+
# map collection items to conform to a well defined collection
|
|
241
|
+
# this is primarily used to convert shorthand notations into symmetrical longhand notations
|
|
242
|
+
#
|
|
243
|
+
# *Parameters*:
|
|
244
|
+
# - <tt>$list</tt> {List} input list
|
|
245
|
+
# - <tt>$components</tt> {List} list of components
|
|
246
|
+
# - <tt>$min</tt> {List} the minimum length of the collection
|
|
247
|
+
# *Returns*:
|
|
248
|
+
# - {List} formatted collection
|
|
249
|
+
#
|
|
250
|
+
def get_collection(list = bool(false), components = [], min = number(1))
|
|
251
|
+
list = list.value ? list.to_a : components.to_a
|
|
252
|
+
while(list.length < min.value)
|
|
253
|
+
list = list.concat(list)
|
|
254
|
+
end
|
|
255
|
+
return list(list, :space)
|
|
256
|
+
end
|
|
257
|
+
Sass::Script::Functions.declare :get_collection, [:list]
|
|
258
|
+
Sass::Script::Functions.declare :get_collection, [:components]
|
|
259
|
+
Sass::Script::Functions.declare :get_collection, [:list, :min]
|
|
260
|
+
Sass::Script::Functions.declare :get_collection, [:components, :min]
|
|
261
|
+
Sass::Script::Functions.declare :get_collection, [:list, :components, :min]
|
|
262
|
+
|
|
263
|
+
# Returns a list object from a value that was passed.
|
|
264
|
+
# This can be used to unpack a space separated list that got turned
|
|
265
|
+
# into a string by sass before it was passed to a mixin.
|
|
266
|
+
# this is shamelessly stolen from Compass :)
|
|
267
|
+
#
|
|
268
|
+
# *Parameters*:
|
|
269
|
+
# - <tt>$arg</tt> {*} the item to cast to a list
|
|
270
|
+
# *Returns*:
|
|
271
|
+
# - <tt>$list</tt> {List} the item as a list
|
|
272
|
+
#
|
|
273
|
+
def _archetype_list(arg)
|
|
274
|
+
# if it's already a list, just return it
|
|
275
|
+
return arg if arg.is_a?(Sass::Script::Value::List)
|
|
276
|
+
# otherwise, we'll try to cast it
|
|
277
|
+
return list(arg, :space)
|
|
278
|
+
end
|
|
279
|
+
|
|
216
280
|
#
|
|
217
281
|
# given a string of styles, convert it into a key-value pair list
|
|
218
282
|
#
|
|
@@ -231,48 +295,34 @@ module Archetype::SassExtensions::Lists
|
|
|
231
295
|
tmp.each do |rule|
|
|
232
296
|
kvp = []
|
|
233
297
|
rule.split(':').each do |str|
|
|
234
|
-
kvp.push
|
|
298
|
+
kvp.push identifier(str)
|
|
235
299
|
end
|
|
236
|
-
styles.push Sass::Script::List.new(kvp, :comma)
|
|
300
|
+
styles.push Sass::Script::Value::List.new(kvp, :comma)
|
|
237
301
|
end
|
|
238
|
-
#
|
|
239
|
-
return Sass::Script::List.new(styles, :comma)
|
|
302
|
+
# then recompose the list
|
|
303
|
+
return Sass::Script::Value::List.new(styles, :comma)
|
|
240
304
|
end
|
|
241
305
|
|
|
242
306
|
private
|
|
243
|
-
def helpers
|
|
244
|
-
@helpers ||= Archetype::Functions::Helpers
|
|
245
|
-
end
|
|
246
307
|
|
|
247
308
|
#
|
|
248
309
|
# perform math operations on a list
|
|
249
310
|
#
|
|
250
311
|
# *Parameters*:
|
|
251
|
-
# - <tt>list</tt> {Sass::List} the list operate on
|
|
252
|
-
# - <tt>values</tt> {Sass::List|Sass::Number|Sass::String} the value(s) perform with
|
|
312
|
+
# - <tt>list</tt> {Sass::Script::Value::List} the list operate to on
|
|
313
|
+
# - <tt>values</tt> {Sass::Script::Value::List|Sass::Script::Value::Number|Sass::Script::Value::String} the value(s) perform with
|
|
253
314
|
# - <tt>method</tt> {Symbol} the method to perform [:plus|:minus|:times|:div|:mod]
|
|
254
315
|
# *Returns*:
|
|
255
|
-
# - {Sass::List} the final list
|
|
316
|
+
# - {Sass::Script::Value::List} the final list
|
|
256
317
|
#
|
|
257
318
|
def list_math(list, values, method = :plus)
|
|
258
|
-
separator = list.separator if list.is_a?(Sass::Script::List)
|
|
319
|
+
separator = list.separator if list.is_a?(Sass::Script::Value::List)
|
|
259
320
|
values = values.to_a
|
|
260
321
|
list = list.to_a
|
|
261
322
|
values.fill(values[0], 0..(list.size - 1)) if values.size < list.size
|
|
262
323
|
list = [list, values].transpose.map do |x|
|
|
263
|
-
|
|
264
|
-
when :plus
|
|
265
|
-
x[0].plus(x[1])
|
|
266
|
-
when :minus
|
|
267
|
-
x[0].minus(x[1])
|
|
268
|
-
when :times
|
|
269
|
-
x[0].times(x[1])
|
|
270
|
-
when :div
|
|
271
|
-
x[0].div(x[1])
|
|
272
|
-
when :mod
|
|
273
|
-
x[0].mod(x[1])
|
|
274
|
-
end
|
|
324
|
+
x[0].method(method).call(x[1])
|
|
275
325
|
end
|
|
276
|
-
return Sass::Script::List.new(list, separator)
|
|
326
|
+
return Sass::Script::Value::List.new(list, separator)
|
|
277
327
|
end
|
|
278
328
|
end
|