archetype 0.0.1.pre.3.90263a7 → 0.0.1.pre.3.811928f

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/CHANGELOG.md +1 -24
  2. data/LICENSE +1 -1
  3. data/README.md +1 -1
  4. data/VERSION.yml +1 -1
  5. data/lib/archetype.rb +0 -4
  6. data/lib/archetype/functions/hash.rb +12 -28
  7. data/lib/archetype/functions/helpers.rb +13 -56
  8. data/lib/archetype/functions/styleguide_memoizer.rb +1 -9
  9. data/lib/archetype/sass_extensions.rb +0 -1
  10. data/lib/archetype/sass_extensions/functions/lists.rb +40 -34
  11. data/lib/archetype/sass_extensions/functions/locale.rb +16 -32
  12. data/lib/archetype/sass_extensions/functions/styleguide.rb +37 -115
  13. data/lib/archetype/sass_extensions/functions/ui.rb +2 -3
  14. data/lib/archetype/sass_extensions/functions/version.rb +6 -11
  15. data/lib/archetype/version.rb +12 -19
  16. data/stylesheets/archetype/_base.scss +0 -3
  17. data/stylesheets/archetype/_config.scss +5 -22
  18. data/stylesheets/archetype/_hacks.scss +21 -62
  19. data/stylesheets/archetype/_ui.scss +11 -56
  20. data/stylesheets/archetype/base/_h5bp.scss +12 -12
  21. data/stylesheets/archetype/base/_normalize.scss +139 -178
  22. data/stylesheets/archetype/styleguide/_helpers.scss +4 -1
  23. data/stylesheets/archetype/styleguide/components/_alerts.scss +1 -1
  24. data/stylesheets/archetype/styleguide/components/_buttons.scss +6 -7
  25. data/stylesheets/archetype/styleguide/components/_closes.scss +2 -2
  26. data/stylesheets/archetype/util/_styles.scss +7 -45
  27. data/stylesheets/archetype/util/_targeting.scss +0 -2
  28. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders-s7889ccc8c1.png +0 -0
  29. data/test/fixtures/stylesheets/archetype/config.rb +0 -2
  30. data/test/fixtures/stylesheets/archetype/expected/hacks/ie_pseudo.css +3 -3
  31. data/test/fixtures/stylesheets/archetype/expected/styleguide/buttons.css +18 -110
  32. data/test/fixtures/stylesheets/archetype/expected/styleguide/selective_state.css +0 -3
  33. data/test/fixtures/stylesheets/archetype/expected/ui/glyph_icon.css +2 -116
  34. data/test/fixtures/stylesheets/archetype/expected/utilities/targeting/target-browser.css +0 -5
  35. data/test/fixtures/stylesheets/archetype/source/styleguide/buttons.scss +1 -5
  36. data/test/fixtures/stylesheets/archetype/source/styleguide/fallback_styles.scss +1 -1
  37. data/test/fixtures/stylesheets/archetype/source/styleguide/nested_styleguides.scss +1 -1
  38. data/test/fixtures/stylesheets/archetype/source/styleguide/selective_state.scss +1 -1
  39. data/test/fixtures/stylesheets/archetype/source/ui/glyph_icon.scss +0 -30
  40. data/test/fixtures/stylesheets/archetype/source/utilities/targeting/target-browser.scss +1 -8
  41. data/test/helpers/test_case.rb +2 -2
  42. data/test/integrations/archetype_test.rb +1 -3
  43. data/test/units/sass_extensions_test.rb +25 -18
  44. metadata +23 -80
  45. checksums.yaml +0 -7
  46. data/bin/archetype +0 -3
  47. data/lib/archetype/actions/help.rb +0 -16
  48. data/lib/archetype/actions/theme.rb +0 -73
  49. data/lib/archetype/executor.rb +0 -27
  50. data/lib/archetype/sass_extensions/monkey_patches.rb +0 -3
  51. data/lib/archetype/sass_extensions/monkey_patches/handle_include_loop.rb +0 -41
  52. data/templates/_theme/_components.scss +0 -3
  53. data/templates/_theme/_config.scss +0 -1
  54. data/templates/_theme/_core.scss +0 -13
  55. data/templates/_theme/_helpers.scss +0 -1
  56. data/templates/_theme/_primitives.scss +0 -3
  57. data/templates/_theme/components/README +0 -1
  58. data/templates/_theme/primitives/README +0 -1
  59. data/test/fixtures/stylesheets/archetype/expected/base.css +0 -349
  60. data/test/fixtures/stylesheets/archetype/expected/hacks/transparent_focusable.css +0 -4
  61. data/test/fixtures/stylesheets/archetype/expected/locale.css +0 -23
  62. data/test/fixtures/stylesheets/archetype/expected/styleguide/alerts.css +0 -675
  63. data/test/fixtures/stylesheets/archetype/expected/styleguide/drop.css +0 -63
  64. data/test/fixtures/stylesheets/archetype/expected/styleguide/extend.css +0 -7
  65. data/test/fixtures/stylesheets/archetype/expected/styleguide/invalid_structures.css +0 -21
  66. data/test/fixtures/stylesheets/archetype/expected/styleguide/multi_value.css +0 -13
  67. data/test/fixtures/stylesheets/archetype/expected/utilities/associative.css +0 -9
  68. data/test/fixtures/stylesheets/archetype/expected/utilities/custom_output_styler.css +0 -8
  69. data/test/fixtures/stylesheets/archetype/source/base.scss +0 -3
  70. data/test/fixtures/stylesheets/archetype/source/hacks/transparent_focusable.scss +0 -5
  71. data/test/fixtures/stylesheets/archetype/source/locale.scss +0 -43
  72. data/test/fixtures/stylesheets/archetype/source/styleguide/alerts.scss +0 -21
  73. data/test/fixtures/stylesheets/archetype/source/styleguide/drop.scss +0 -101
  74. data/test/fixtures/stylesheets/archetype/source/styleguide/extend.scss +0 -23
  75. data/test/fixtures/stylesheets/archetype/source/styleguide/invalid_structures.scss +0 -85
  76. data/test/fixtures/stylesheets/archetype/source/styleguide/multi_value.scss +0 -18
  77. data/test/fixtures/stylesheets/archetype/source/utilities/associative.scss +0 -24
  78. data/test/fixtures/stylesheets/archetype/source/utilities/custom_output_styler.scss +0 -21
@@ -4,36 +4,13 @@
4
4
 
5
5
  - initial public release
6
6
 
7
- ## 0.0.1.pre.3 (pre-released)
7
+ ## 0.0.1.pre.3 (unreleased)
8
8
 
9
9
  ### New Features:
10
10
 
11
11
  - added `styleguide-component-exists()` method to check if a component/extension has already been registered in the theme
12
12
  - added `memoize` compiler configuration to allow enabling/disabling the internal styleguide memoizer
13
- - `glyph-icon()` can now take `false` as an icon name and not output anything
14
- - added `unstyled-button()` method to remove default styling from a `<button>` element
15
- - added `prefixed-tag()` method for consistency when generating tag names
16
- - added Chinese font stacks
17
- - added wildcard support to `locale()` function (e.g. `locale(en_ ja_JP _DE)`)
18
- - added `transparent-focusable()` mixin for transparent background support in older IE
19
- - added ability to customize `output-style()` with `custom-output-styler()` mixin and `has-custom-output-styler()` function (NEEDS DOCUMENTATION)
20
- - added better support for targeting IE6/7 glyphs and `ie-pseudo()` generated elements (NEEDS DOCUMENTATION)
21
- - making `unique()` generated IDs genuinely unique
22
- - adding support for a `testing` config flag
23
- - adding support for `@extend` from a styleguide component
24
-
25
- ### Resolved Issues:
26
-
27
- - quotes on strings passed to `associative()` weren't being stripped correctly
28
- - fixed some minor glyph issues
29
- - out-of-order CSS issues in Ruby 1.8.7 are fixed using `Hashery::OrderedHash`
30
- - fixed issue with `archetype-version()` incorrectly matching comparators
31
-
32
- ### Tests:
33
-
34
13
  - added test case for fallback CSS properties
35
- - added test case for generating loading spinner keyframe animations
36
- - updated test cases for minor changes
37
14
 
38
15
  ## 0.0.1.pre.2 (unreleased)
39
16
 
data/LICENSE CHANGED
@@ -1,5 +1,5 @@
1
1
  Archetype
2
- Copyright (c) 2013 LinkedIn Corp. All rights reserved.
2
+ Copyright (c) 2012 LinkedIn
3
3
  Apache Software License 2.0
4
4
 
5
5
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Archetype
2
2
 
3
- [![Build Status](https://travis-ci.org/linkedin/archetype.png)](https://travis-ci.org/linkedin/archetype) [![Gem Version](https://badge.fury.io/rb/archetype.png)](http://badge.fury.io/rb/archetype)
3
+ [![Build Status](https://travis-ci.org/eoneill/archetype.png)](https://travis-ci.org/eoneill/archetype)
4
4
 
5
5
  Archetype is a UI pattern and component library for quickly iterating on and maintaining scalable web interfaces.
6
6
 
@@ -3,4 +3,4 @@
3
3
  :minor: 0
4
4
  :build: 1
5
5
  :state: pre
6
- :iteration: 3
6
+ :iteration: 3
@@ -33,10 +33,6 @@ module Archetype
33
33
  Compass::Configuration.add_configuration_property(:memoize, "should the memoizer be used to improve compilation speed") do
34
34
  not (Compass.configuration.environment || :development).to_s.include?('dev')
35
35
  end
36
- # testing (for running unit tests)
37
- Compass::Configuration.add_configuration_property(:testing, "is this a testing environment") do
38
- ENV['CI']
39
- end
40
36
  end
41
37
  end
42
38
 
@@ -1,8 +1,6 @@
1
1
  # :stopdoc:
2
2
  # This module extends the native Ruby Hash class to support deep merging
3
3
  # and comparing the difference between hashes.
4
- # This functionality mimics that found in ActiveSupport
5
- # @see https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/hash/deep_merge.rb
6
4
  #
7
5
  module Archetype::Functions::Hash
8
6
  #
@@ -13,10 +11,13 @@ module Archetype::Functions::Hash
13
11
  # *Returns*:
14
12
  # - {Hash} a new hash containing the contents of other_hash and the contents of hsh, deep merged
15
13
  #
16
- def rmerge(other_hash, &block)
17
- dup.rmerge!(other_hash, &block)
14
+ def rmerge(other_hash)
15
+ new_hash = {}
16
+ merge(other_hash) do |key, oldval, newval|
17
+ new_hash[key] = oldval.class == self.class ? oldval.rmerge(newval) : newval
18
+ end
18
19
  end
19
-
20
+
20
21
  #
21
22
  # adds the contents of other_hash to hsh, deep merged
22
23
  #
@@ -25,16 +26,10 @@ module Archetype::Functions::Hash
25
26
  # *Returns*:
26
27
  # - {Hash} the original hash with the addition of the contents of other_hash
27
28
  #
28
- def rmerge!(other_hash, &block)
29
- other_hash.each_pair do |k,v|
30
- tv = self[k]
31
- if tv.is_a?(Hash) && v.is_a?(Hash)
32
- self[k] = tv.rmerge(v, &block)
33
- else
34
- self[k] = block && tv ? block.call(k, tv, v) : v
35
- end
29
+ def rmerge!(other_hash)
30
+ merge!(other_hash) do |key, oldval, newval|
31
+ oldval.class == self.class ? oldval.rmerge!(newval) : newval
36
32
  end
37
- return self
38
33
  end
39
34
 
40
35
  #
@@ -46,7 +41,7 @@ module Archetype::Functions::Hash
46
41
  # - {Hash} a representation of the difference between the two hashes
47
42
  #
48
43
  def diff(other_hash)
49
- (self.keys + other_hash.keys).uniq.inject(Archetype::Hash.new) do |tmp, key|
44
+ (self.keys + other_hash.keys).uniq.inject({}) do |tmp, key|
50
45
  # special comparison for gradients
51
46
  are_gradients = self[key].is_a?(Compass::SassExtensions::Functions::GradientSupport::LinearGradient) and other_hash[key].is_a?(Compass::SassExtensions::Functions::GradientSupport::LinearGradient)
52
47
  eq_gradients = are_gradients ? (self[key].to_s == other_hash[key].to_s) : true
@@ -133,17 +128,6 @@ private
133
128
  end
134
129
  end
135
130
 
136
- # this shims the Hash functionality to ensure we have an ordered hash guarantee
137
- module Archetype
138
- if RUBY_VERSION < '1.9'
139
- require 'hashery/ordered_hash'
140
- class Hash < Hashery::OrderedHash
141
- include Archetype::Functions::Hash
142
- end
143
- else
144
- class Hash < ::Hash
145
- include Archetype::Functions::Hash
146
- end
147
- end
131
+ class Hash
132
+ include Archetype::Functions::Hash
148
133
  end
149
-
@@ -24,8 +24,7 @@ private
24
24
  def self.hash_to_list(hsh, depth = 0, separator = :comma)
25
25
  if hsh.is_a? Hash
26
26
  list = []
27
- hsh.each do |key, item|
28
- item = [key, item]
27
+ hsh.each do |item|
29
28
  # if its a hash, convert it to a List
30
29
  if item.is_a? Hash or item.is_a? Array
31
30
  tmp = []
@@ -55,66 +54,30 @@ private
55
54
  #
56
55
  def self.list_to_hash(list, depth = 0, nest = [], additives = [])
57
56
  list = list.to_a
58
- previous = nil
59
- hsh = Archetype::Hash.new
57
+ hsh = {}
60
58
  list.each do |item|
61
59
  item = item.to_a
62
-
63
- # if a 3rd item exists, we probably forgot a comma or parens somewhere
64
- if previous.nil? and not item[2].nil?
65
- msg = "you're likely missing a comma or parens in your data structure"
66
- begin
67
- logger.record(:warning, "#{msg}: #{item}")
68
- rescue
69
- logger.record(:warning, msg)
70
- end
71
- end
72
-
73
60
  # convert the key to a string and strip off quotes
74
- key = to_str(item[0], ' ' , :quotes)
75
- # capture the value
61
+ key = to_str(item[0]).gsub(/\A"|"\Z/, '')
76
62
  value = item[1]
77
-
78
63
  if key != 'nil'
79
- if is_value(value, :blank)
80
- if previous.nil?
81
- previous = key
82
- next
83
- else
84
- value = item[0]
85
- key = previous
86
- previous = nil
87
- end
88
- elsif not previous.nil?
89
- # if we got here, something is wrong with the structure
90
- list.shift if to_str(list[0]) == previous # remove the first item if it's the previous key, which is now the parent key
91
- list = list[0].to_a # now the remaining items were munged, so split them out
92
- hsh = Archetype::Hash.new
93
- hsh[previous] = list_to_hash(list, depth - 1, nest, additives)
94
- return hsh
95
- end
96
- end
97
-
98
- # update the hash if we have a valid key and hash
99
- if key != 'nil' and not is_value(value, :blank)
100
64
  # check if if it's a nesting hash
101
65
  nested = nest.include?(key)
102
66
  # if it's nested or we haven't reached out depth, recurse
103
67
  if nested or depth > 0
104
68
  value = list_to_hash(value, nested ? depth + 1 : depth - 1, nest, additives)
105
69
  end
106
-
107
- if additives.include?(key)
108
- hsh[key] ||= []
109
- hsh[key].push(value)
110
- else
111
- hsh[key] = value
70
+ # update the hash key
71
+ if not is_value(value, :blank)
72
+ if additives.include?(key)
73
+ hsh[key] ||= []
74
+ hsh[key].push(value)
75
+ else
76
+ hsh[key] = value
77
+ end
112
78
  end
113
79
  end
114
80
  end
115
-
116
- logger.record(:warning, "one of your data structures is ambiguous, please double check near `#{previous}`") if not previous.nil?
117
-
118
81
  return hsh
119
82
  end
120
83
 
@@ -127,12 +90,8 @@ private
127
90
  # *Returns*:
128
91
  # - {String} the converted String
129
92
  #
130
- def self.to_str(value, separator = ' ', strip = nil)
131
- if not value.is_a?(String)
132
- value = ((value.to_a).each{ |i| i.nil? ? 'nil' : (i.is_a?(String) ? i : i.value) }).join(separator || '')
133
- end
134
- strip = /\A"|"\Z/ if strip == :quotes
135
- return strip.nil? ? value : value.gsub(strip, '')
93
+ def self.to_str(value, separator = ' ')
94
+ return value.is_a?(String) ? value : ((value.to_a).each{ |i| i.is_a?(String) ? i : i.value }).join(separator || '')
136
95
  end
137
96
 
138
97
  #
@@ -150,13 +109,11 @@ private
150
109
  when :blank
151
110
  is_it = false
152
111
  value = value.value if value.is_a?(Sass::Script::String)
153
- is_it = value.nil?
154
112
  is_it = value.empty? if value.is_a?(String)
155
113
  is_it = value.to_a.empty? if value.is_a?(Sass::Script::List) or value.is_a?(Array)
156
114
  when :nil
157
115
  is_it = false
158
116
  value = value.value if value.is_a?(Sass::Script::String)
159
- is_it = value.nil?
160
117
  is_it = value == 'nil' if value.is_a?(String)
161
118
  is_it = to_str(value) == 'nil' if value.is_a?(Sass::Script::List) or value.is_a?(Array)
162
119
  end
@@ -50,7 +50,7 @@ private
50
50
  end
51
51
 
52
52
  #
53
- # invalidate the memoizer for the theme
53
+ # invalidate the entire memoizer for the theme
54
54
  #
55
55
  # *Parameters*:
56
56
  # - <tt>theme</tt> {String} the theme name
@@ -58,12 +58,4 @@ private
58
58
  def self.clear(theme)
59
59
  @components[theme] = {}
60
60
  end
61
-
62
-
63
- #
64
- # resets the entire memoizer
65
- #
66
- def self.reset!
67
- @components = {}
68
- end
69
61
  end
@@ -4,4 +4,3 @@ module Archetype::SassExtensions
4
4
  end
5
5
 
6
6
  require 'archetype/sass_extensions/functions'
7
- require 'archetype/sass_extensions/monkey_patches'
@@ -6,7 +6,7 @@ require 'archetype/functions/helpers'
6
6
  module Archetype::SassExtensions::Lists
7
7
  #
8
8
  # replace an index in a list
9
- #
9
+ #
10
10
  # *Parameters*:
11
11
  # - <tt>$list</tt> {List} the list to replace from
12
12
  # - <tt>$value</tt> {\*} the value to replace (if nil, it's a removal)
@@ -47,8 +47,8 @@ module Archetype::SassExtensions::Lists
47
47
  def list_remove(list, idx = false, separator = nil)
48
48
  return list_replace(list, idx, nil, separator)
49
49
  end
50
- Sass::Script::Functions.declare :list_remove, [:list, :idx]
51
- Sass::Script::Functions.declare :list_remove, [:list, :idx, :separator]
50
+ Sass::Script::Functions.declare :list_replace, [:list, :idx]
51
+ Sass::Script::Functions.declare :list_replace, [:list, :idx, :separator]
52
52
 
53
53
  #
54
54
  # insert an item into a list
@@ -67,9 +67,41 @@ module Archetype::SassExtensions::Lists
67
67
  return list if (not idx or idx == Sass::Script::Bool.new(false)) or value.nil?
68
68
  return list_replace(list, idx, value, separator, -1)
69
69
  end
70
- Sass::Script::Functions.declare :list_insert, [:list, :idx]
71
- Sass::Script::Functions.declare :list_insert, [:list, :idx, :value]
72
- Sass::Script::Functions.declare :list_insert, [:list, :idx, :value, :separator]
70
+ Sass::Script::Functions.declare :list_replace, [:list, :idx]
71
+ Sass::Script::Functions.declare :list_replace, [:list, :idx, :value]
72
+ Sass::Script::Functions.declare :list_replace, [:list, :idx, :value, :separator]
73
+
74
+ #
75
+ # sort a list
76
+ #
77
+ # *Parameters*:
78
+ # - <tt>$list</tt> {List} the list to sort
79
+ # - <tt>$reverse</tt> {Boolean} sort the list in reverse order
80
+ # *Returns*:
81
+ # - {List} the sorted list
82
+ #
83
+ # TODO - this is failing, fix this
84
+ #def list_sort(list, reverse = false)
85
+ # separator = list.separator if list.is_a?(Sass::Script::List)
86
+ # list = list.to_a.sort
87
+ # list = list.reverse if (reverse == Sass::Script::Bool.new(true))
88
+ # return Sass::Script::List.new(list, separator)
89
+ #end
90
+
91
+ #
92
+ # reverse order a list
93
+ #
94
+ # *Parameters*:
95
+ # - <tt>$list</tt> {List} the list to reverse
96
+ # *Returns*:
97
+ # - {List} the reversed list
98
+ #
99
+ # TODO - this is failing, fix this
100
+ #def list_reverse(list)
101
+ # separator = list.separator if list.is_a?(Sass::Script::List)
102
+ # list = list.to_a.reverse
103
+ # return Sass::Script::List.new(list, separator)
104
+ #end
73
105
 
74
106
  #
75
107
  # add values(s) to a list
@@ -185,7 +217,7 @@ module Archetype::SassExtensions::Lists
185
217
  def associative(list, key, strict = false)
186
218
  separator = list.separator if list.is_a?(Sass::Script::List)
187
219
  list = helpers.list_to_hash(list)
188
- item = list[helpers.to_str(key, ' ' , :quotes)]
220
+ item = list[helpers.to_str(key)]
189
221
  item ||= list.first[1] if not strict
190
222
  return Sass::Script::List.new([], separator) if item.nil?
191
223
  return helpers.hash_to_list(item, 0, separator) if item.is_a?(Array) or item.is_a?(Hash)
@@ -211,33 +243,7 @@ module Archetype::SassExtensions::Lists
211
243
  list = list.rmerge(extender)
212
244
  return helpers.hash_to_list(list, 0, separator)
213
245
  end
214
- Sass::Script::Functions.declare :associative_merge, [:list, :extender]
215
-
216
- #
217
- # given a string of styles, convert it into a key-value pair list
218
- #
219
- # *Parameters*:
220
- # - <tt>$string</tt> {String} the string to convert
221
- # *Returns*:
222
- # - <tt>$list</tt> {List} the converted list of styles
223
- #
224
- def _style_string_to_list(string = '')
225
- # convert to string and strip all comments
226
- string = helpers.to_str(string, ' ').gsub(/\/\*[^\*\/]*\*\//, '')
227
- # then split it on each rule
228
- tmp = string.split(';')
229
- styles = []
230
- # and for each rule break it into it's key-value pairs
231
- tmp.each do |rule|
232
- kvp = []
233
- rule.split(':').each do |str|
234
- kvp.push Sass::Script::String.new(str)
235
- end
236
- styles.push Sass::Script::List.new(kvp, :comma)
237
- end
238
- # the recompose the list
239
- return Sass::Script::List.new(styles, :comma)
240
- end
246
+ Sass::Script::Functions.declare :list_extend, [:list, :extender]
241
247
 
242
248
  private
243
249
  def helpers
@@ -3,36 +3,17 @@
3
3
  #
4
4
  module Archetype::SassExtensions::Locale
5
5
  #
6
- # get the current locale specified in config or test a list of locales against the current locale
6
+ # get the current locale specified in config
7
7
  #
8
- # *Parameters*:
9
- # - <tt>$locales</tt> {List} the list of locales to test
10
8
  # *Returns*:
11
- # - {String|Boolean} the current locale or whether or not the current locale is in the test set
9
+ # - {String} the current locale
12
10
  #
13
- def locale(locales = nil)
14
- locale = (Compass.configuration.locale || 'en_US').to_s
15
- # if the locales are nil, just return the current locale
16
- return Sass::Script::String.new(locale) if locales.nil?
17
- locales = locales.to_a.collect{|i| i.to_s}
18
- # add wild card support for language or territory
19
- match = locale.match(LOCALE_PATTERN)
20
- # language with wildcard territory
21
- language = match[1] + '_'
22
- # territory with wildcard language
23
- territory = '_' + match[2]
24
- # for each item, look it up in the alias list
25
- locales.each do |key|
26
- if a = locale_aliases[key]
27
- locales.delete(key)
28
- locales.concat(a)
29
- end
30
- end
31
- return Sass::Script::Bool.new(locales.include?(locale) || locales.include?(language) || locales.include?(territory))
11
+ def locale
12
+ return Sass::Script::String.new(Compass.configuration.locale || 'en_US')
32
13
  end
33
14
 
34
15
  #
35
- # test a list of locales against the current locale (this is now just an alias for locales(), for back-compat)
16
+ # test a list of locales against the current locale (supports an alias map)
36
17
  #
37
18
  # *Parameters*:
38
19
  # - <tt>$locales</tt> {List} the list of locales to test
@@ -40,9 +21,16 @@ module Archetype::SassExtensions::Locale
40
21
  # - {Boolean} is the current locale in the list or not
41
22
  #
42
23
  def lang(locales)
43
- return locale(locales)
24
+ locales = locales.to_a.collect{|i| i.to_s}
25
+ locales.each do |key|
26
+ if a = locale_aliases[key]
27
+ locales.delete(key)
28
+ locales.concat(a)
29
+ end
30
+ end
31
+ return Sass::Script::Bool.new(locales.include?(locale.to_s))
44
32
  end
45
-
33
+
46
34
  #
47
35
  # get the current reading direction
48
36
  #
@@ -55,9 +43,6 @@ module Archetype::SassExtensions::Locale
55
43
  end
56
44
 
57
45
  private
58
-
59
- LOCALE_PATTERN = /([a-z]{2})[-_]?([a-z]{2}?)/i
60
-
61
46
  #
62
47
  # provides an alias mapping for locale names
63
48
  #
@@ -67,9 +52,8 @@ private
67
52
  # TODO - make this easily extensible
68
53
  def locale_aliases
69
54
  if @locale_aliases.nil?
70
- a = {
71
- 'CJK' => ['ja_JP', 'ko_KR', 'zh_TW', 'zh_CN']
72
- }
55
+ a = {}
56
+ a['CJK'] = ['ja_JP', 'ko_KR', 'zh_TW', 'zh_CN']
73
57
  @locale_aliases = a
74
58
  end
75
59
  return @locale_aliases