archetype 0.0.1.pre.3.811928f → 0.0.1.pre.4

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.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +24 -1
  3. data/LICENSE +1 -1
  4. data/README.md +1 -1
  5. data/VERSION.yml +1 -1
  6. data/bin/archetype +3 -0
  7. data/lib/archetype.rb +4 -0
  8. data/lib/archetype/actions/help.rb +16 -0
  9. data/lib/archetype/actions/theme.rb +73 -0
  10. data/lib/archetype/executor.rb +27 -0
  11. data/lib/archetype/functions/hash.rb +28 -12
  12. data/lib/archetype/functions/helpers.rb +46 -13
  13. data/lib/archetype/functions/styleguide_memoizer.rb +9 -1
  14. data/lib/archetype/sass_extensions.rb +1 -0
  15. data/lib/archetype/sass_extensions/functions/lists.rb +34 -40
  16. data/lib/archetype/sass_extensions/functions/locale.rb +32 -16
  17. data/lib/archetype/sass_extensions/functions/styleguide.rb +115 -37
  18. data/lib/archetype/sass_extensions/functions/ui.rb +3 -2
  19. data/lib/archetype/sass_extensions/functions/version.rb +11 -6
  20. data/lib/archetype/sass_extensions/monkey_patches.rb +3 -0
  21. data/lib/archetype/sass_extensions/monkey_patches/handle_include_loop.rb +13 -0
  22. data/lib/archetype/version.rb +19 -12
  23. data/stylesheets/archetype/_base.scss +3 -0
  24. data/stylesheets/archetype/_config.scss +31 -7
  25. data/stylesheets/archetype/_hacks.scss +17 -5
  26. data/stylesheets/archetype/_ui.scss +64 -23
  27. data/stylesheets/archetype/styleguide/components/_buttons.scss +6 -6
  28. data/stylesheets/archetype/styleguide/components/_headlines.scss +1 -0
  29. data/stylesheets/archetype/styleguide/components/_links.scss +2 -0
  30. data/stylesheets/archetype/util/_styles.scss +59 -14
  31. data/stylesheets/archetype/util/_targeting.scss +1 -1
  32. data/templates/_theme/_components.scss +3 -0
  33. data/templates/_theme/_config.scss +1 -0
  34. data/templates/_theme/_core.scss +13 -0
  35. data/templates/_theme/_helpers.scss +1 -0
  36. data/templates/_theme/_primitives.scss +3 -0
  37. data/templates/_theme/components/README +1 -0
  38. data/templates/_theme/primitives/README +1 -0
  39. data/test/fixtures/stylesheets/archetype/config.rb +2 -0
  40. data/test/fixtures/stylesheets/archetype/expected/base.css +349 -0
  41. data/test/fixtures/stylesheets/archetype/expected/hacks/ie_pseudo.css +3 -3
  42. data/test/fixtures/stylesheets/archetype/expected/hacks/transparent_focusable.css +4 -0
  43. data/test/fixtures/stylesheets/archetype/expected/locale.css +23 -0
  44. data/test/fixtures/stylesheets/archetype/expected/styleguide/alerts.css +675 -0
  45. data/test/fixtures/stylesheets/archetype/expected/styleguide/buttons.css +110 -18
  46. data/test/fixtures/stylesheets/archetype/expected/styleguide/drop.css +63 -0
  47. data/test/fixtures/stylesheets/archetype/expected/styleguide/extend.css +7 -0
  48. data/test/fixtures/stylesheets/archetype/expected/styleguide/invalid_structures.css +21 -0
  49. data/test/fixtures/stylesheets/archetype/expected/styleguide/multi_value.css +13 -0
  50. data/test/fixtures/stylesheets/archetype/expected/styleguide/selective_state.css +3 -0
  51. data/test/fixtures/stylesheets/archetype/expected/ui/glyph_icon.css +116 -2
  52. data/test/fixtures/stylesheets/archetype/expected/utilities/associative.css +9 -0
  53. data/test/fixtures/stylesheets/archetype/expected/utilities/custom_output_styler.css +8 -0
  54. data/test/fixtures/stylesheets/archetype/expected/utilities/targeting/target-browser.css +5 -0
  55. data/test/fixtures/stylesheets/archetype/source/base.scss +3 -0
  56. data/test/fixtures/stylesheets/archetype/source/hacks/transparent_focusable.scss +5 -0
  57. data/test/fixtures/stylesheets/archetype/source/locale.scss +43 -0
  58. data/test/fixtures/stylesheets/archetype/source/styleguide/alerts.scss +21 -0
  59. data/test/fixtures/stylesheets/archetype/source/styleguide/buttons.scss +5 -1
  60. data/test/fixtures/stylesheets/archetype/source/styleguide/drop.scss +101 -0
  61. data/test/fixtures/stylesheets/archetype/source/styleguide/extend.scss +23 -0
  62. data/test/fixtures/stylesheets/archetype/source/styleguide/fallback_styles.scss +1 -1
  63. data/test/fixtures/stylesheets/archetype/source/styleguide/invalid_structures.scss +85 -0
  64. data/test/fixtures/stylesheets/archetype/source/styleguide/multi_value.scss +18 -0
  65. data/test/fixtures/stylesheets/archetype/source/styleguide/nested_styleguides.scss +1 -1
  66. data/test/fixtures/stylesheets/archetype/source/styleguide/selective_state.scss +1 -1
  67. data/test/fixtures/stylesheets/archetype/source/ui/glyph_icon.scss +30 -0
  68. data/test/fixtures/stylesheets/archetype/source/utilities/associative.scss +24 -0
  69. data/test/fixtures/stylesheets/archetype/source/utilities/custom_output_styler.scss +21 -0
  70. data/test/fixtures/stylesheets/archetype/source/utilities/targeting/target-browser.scss +8 -1
  71. data/test/helpers/test_case.rb +2 -2
  72. data/test/integrations/archetype_test.rb +3 -1
  73. data/test/units/sass_extensions_test.rb +18 -25
  74. metadata +108 -36
  75. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders-s7889ccc8c1.png +0 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 10b8c76537375cc63d59a51cd980ff057de481ae
4
+ data.tar.gz: cb746cde2c62f0b0c1165d80c0f8e79436ed4f44
5
+ SHA512:
6
+ metadata.gz: 6758bc5a310d1a0c10e97285e3aeace27781a8f3e3516da5867fb741d1b48b83926189792e855dbedebf767c07898e299b30027045b270f68e51e8dd6bc9ba2b
7
+ data.tar.gz: 8aef25fe89a313843d68471fe7dacc28c7da625f054c6ef42801680da48a42a9ba1d32e94fa86cc83c99f4d037058ab5cfdd0f3a0bc2facd94093db1a54f804b
data/CHANGELOG.md CHANGED
@@ -4,13 +4,36 @@
4
4
 
5
5
  - initial public release
6
6
 
7
- ## 0.0.1.pre.3 (unreleased)
7
+ ## 0.0.1.pre.3 (pre-released)
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
+
13
34
  - added test case for fallback CSS properties
35
+ - added test case for generating loading spinner keyframe animations
36
+ - updated test cases for minor changes
14
37
 
15
38
  ## 0.0.1.pre.2 (unreleased)
16
39
 
data/LICENSE CHANGED
@@ -1,5 +1,5 @@
1
1
  Archetype
2
- Copyright (c) 2012 LinkedIn
2
+ Copyright (c) 2013 LinkedIn Corp. All rights reserved.
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/eoneill/archetype.png)](https://travis-ci.org/eoneill/archetype)
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)
4
4
 
5
5
  Archetype is a UI pattern and component library for quickly iterating on and maintaining scalable web interfaces.
6
6
 
data/VERSION.yml CHANGED
@@ -3,4 +3,4 @@
3
3
  :minor: 0
4
4
  :build: 1
5
5
  :state: pre
6
- :iteration: 3
6
+ :iteration: 4
data/bin/archetype ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.join(File.dirname(__FILE__), '..', 'lib/archetype/executor')
data/lib/archetype.rb CHANGED
@@ -33,6 +33,10 @@ 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
36
40
  end
37
41
  end
38
42
 
@@ -0,0 +1,16 @@
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
@@ -0,0 +1,73 @@
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
@@ -0,0 +1,27 @@
1
+ require 'optparse'
2
+
3
+ @actions_path = File.join(File.dirname(__FILE__), 'actions')
4
+
5
+ if not ARGV[0].nil? and not ARGV[0].empty?
6
+ action_name = ARGV[0]
7
+ action = File.join(@actions_path, action_name)
8
+ begin
9
+ require action
10
+ rescue
11
+ puts "unknown action: #{action_name}"
12
+ end
13
+ end
14
+
15
+ # if we got here, there was either no action, or the action was invalid
16
+ OptionParser.new do |opts|
17
+ opts.banner = "Archetype command line actions\n\n"
18
+ opts.define_head "Usage: archetype <action> [options]"
19
+ opts.separator ""
20
+ opts.separator "Available Actions:"
21
+ Dir.glob("#{@actions_path}/*.rb") do |action|
22
+ @description = true
23
+ load action
24
+ opts.separator " * #{File.basename(action, '.rb')}\t- #{@description}"
25
+ end
26
+ puts opts
27
+ end.parse!
@@ -1,6 +1,8 @@
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
4
6
  #
5
7
  module Archetype::Functions::Hash
6
8
  #
@@ -11,13 +13,10 @@ module Archetype::Functions::Hash
11
13
  # *Returns*:
12
14
  # - {Hash} a new hash containing the contents of other_hash and the contents of hsh, deep merged
13
15
  #
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
16
+ def rmerge(other_hash, &block)
17
+ dup.rmerge!(other_hash, &block)
19
18
  end
20
-
19
+
21
20
  #
22
21
  # adds the contents of other_hash to hsh, deep merged
23
22
  #
@@ -26,10 +25,16 @@ module Archetype::Functions::Hash
26
25
  # *Returns*:
27
26
  # - {Hash} the original hash with the addition of the contents of other_hash
28
27
  #
29
- def rmerge!(other_hash)
30
- merge!(other_hash) do |key, oldval, newval|
31
- oldval.class == self.class ? oldval.rmerge!(newval) : newval
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
32
36
  end
37
+ return self
33
38
  end
34
39
 
35
40
  #
@@ -41,7 +46,7 @@ module Archetype::Functions::Hash
41
46
  # - {Hash} a representation of the difference between the two hashes
42
47
  #
43
48
  def diff(other_hash)
44
- (self.keys + other_hash.keys).uniq.inject({}) do |tmp, key|
49
+ (self.keys + other_hash.keys).uniq.inject(Archetype::Hash.new) do |tmp, key|
45
50
  # special comparison for gradients
46
51
  are_gradients = self[key].is_a?(Compass::SassExtensions::Functions::GradientSupport::LinearGradient) and other_hash[key].is_a?(Compass::SassExtensions::Functions::GradientSupport::LinearGradient)
47
52
  eq_gradients = are_gradients ? (self[key].to_s == other_hash[key].to_s) : true
@@ -128,6 +133,17 @@ private
128
133
  end
129
134
  end
130
135
 
131
- class Hash
132
- include Archetype::Functions::Hash
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
133
148
  end
149
+
@@ -24,7 +24,8 @@ 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 |item|
27
+ hsh.each do |key, item|
28
+ item = [key, item]
28
29
  # if its a hash, convert it to a List
29
30
  if item.is_a? Hash or item.is_a? Array
30
31
  tmp = []
@@ -54,30 +55,56 @@ private
54
55
  #
55
56
  def self.list_to_hash(list, depth = 0, nest = [], additives = [])
56
57
  list = list.to_a
57
- hsh = {}
58
+ previous = nil
59
+ hsh = Archetype::Hash.new
58
60
  list.each do |item|
59
61
  item = item.to_a
62
+
60
63
  # convert the key to a string and strip off quotes
61
- key = to_str(item[0]).gsub(/\A"|"\Z/, '')
64
+ key = to_str(item[0], ' ' , :quotes)
65
+ # capture the value
62
66
  value = item[1]
67
+
63
68
  if key != 'nil'
69
+ if is_value(value, :blank)
70
+ if previous.nil?
71
+ previous = key
72
+ next
73
+ else
74
+ value = item[0]
75
+ key = previous
76
+ previous = nil
77
+ end
78
+ elsif not previous.nil?
79
+ # if we got here, something is wrong with the structure
80
+ list.shift if to_str(list[0]) == previous # remove the first item if it's the previous key, which is now the parent key
81
+ list = list[0].to_a # now the remaining items were munged, so split them out
82
+ hsh = Archetype::Hash.new
83
+ hsh[previous] = list_to_hash(list, depth - 1, nest, additives)
84
+ return hsh
85
+ end
86
+ end
87
+
88
+ # update the hash if we have a valid key and hash
89
+ if key != 'nil' and not is_value(value, :blank)
64
90
  # check if if it's a nesting hash
65
91
  nested = nest.include?(key)
66
92
  # if it's nested or we haven't reached out depth, recurse
67
93
  if nested or depth > 0
68
94
  value = list_to_hash(value, nested ? depth + 1 : depth - 1, nest, additives)
69
95
  end
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
96
+
97
+ if additives.include?(key)
98
+ hsh[key] ||= []
99
+ hsh[key].push(value)
100
+ else
101
+ hsh[key] = value
78
102
  end
79
103
  end
80
104
  end
105
+
106
+ logger.record(:warning, "one of your data structures is ambiguous, please double check near `#{previous}`") if not previous.nil?
107
+
81
108
  return hsh
82
109
  end
83
110
 
@@ -90,8 +117,12 @@ private
90
117
  # *Returns*:
91
118
  # - {String} the converted String
92
119
  #
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 || '')
120
+ def self.to_str(value, separator = ' ', strip = nil)
121
+ if not value.is_a?(String)
122
+ value = ((value.to_a).each{ |i| i.nil? ? 'nil' : (i.is_a?(String) ? i : i.value) }).join(separator || '')
123
+ end
124
+ strip = /\A"|"\Z/ if strip == :quotes
125
+ return strip.nil? ? value : value.gsub(strip, '')
95
126
  end
96
127
 
97
128
  #
@@ -109,11 +140,13 @@ private
109
140
  when :blank
110
141
  is_it = false
111
142
  value = value.value if value.is_a?(Sass::Script::String)
143
+ is_it = value.nil?
112
144
  is_it = value.empty? if value.is_a?(String)
113
145
  is_it = value.to_a.empty? if value.is_a?(Sass::Script::List) or value.is_a?(Array)
114
146
  when :nil
115
147
  is_it = false
116
148
  value = value.value if value.is_a?(Sass::Script::String)
149
+ is_it = value.nil?
117
150
  is_it = value == 'nil' if value.is_a?(String)
118
151
  is_it = to_str(value) == 'nil' if value.is_a?(Sass::Script::List) or value.is_a?(Array)
119
152
  end
@@ -50,7 +50,7 @@ private
50
50
  end
51
51
 
52
52
  #
53
- # invalidate the entire memoizer for the theme
53
+ # invalidate the memoizer for the theme
54
54
  #
55
55
  # *Parameters*:
56
56
  # - <tt>theme</tt> {String} the theme name
@@ -58,4 +58,12 @@ 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
61
69
  end
@@ -4,3 +4,4 @@ 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_replace, [:list, :idx]
51
- Sass::Script::Functions.declare :list_replace, [:list, :idx, :separator]
50
+ Sass::Script::Functions.declare :list_remove, [:list, :idx]
51
+ Sass::Script::Functions.declare :list_remove, [:list, :idx, :separator]
52
52
 
53
53
  #
54
54
  # insert an item into a list
@@ -67,41 +67,9 @@ 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_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
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]
105
73
 
106
74
  #
107
75
  # add values(s) to a list
@@ -217,7 +185,7 @@ module Archetype::SassExtensions::Lists
217
185
  def associative(list, key, strict = false)
218
186
  separator = list.separator if list.is_a?(Sass::Script::List)
219
187
  list = helpers.list_to_hash(list)
220
- item = list[helpers.to_str(key)]
188
+ item = list[helpers.to_str(key, ' ' , :quotes)]
221
189
  item ||= list.first[1] if not strict
222
190
  return Sass::Script::List.new([], separator) if item.nil?
223
191
  return helpers.hash_to_list(item, 0, separator) if item.is_a?(Array) or item.is_a?(Hash)
@@ -243,7 +211,33 @@ module Archetype::SassExtensions::Lists
243
211
  list = list.rmerge(extender)
244
212
  return helpers.hash_to_list(list, 0, separator)
245
213
  end
246
- Sass::Script::Functions.declare :list_extend, [:list, :extender]
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
247
241
 
248
242
  private
249
243
  def helpers