sassy_hash 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2bba186a79b04ecf17896b7ddf1af2c9137de539
4
- data.tar.gz: df05deb4a69e41ab3687d36c761b6780e7404a10
3
+ metadata.gz: 0bc1f81c885e612d2d539b7ca3dfb70f7b9425ce
4
+ data.tar.gz: 58514540992b22b0b1cf15fb98d83767f2ec7dc5
5
5
  SHA512:
6
- metadata.gz: b4085398c11db340d45c48d7e68ae852b9f75c85999df40a44fd3d0bbf9830ed494a17962982c2436e782c4a4c3a81b6d129cbc40a2e28051078e6f35aff6fc9
7
- data.tar.gz: 5b89a3b3394e8556a8e6ae47e54e287a61ab62fef372cc35db5d0a3fbda6c03a9cf93c45adafdbe3b6f1da3198ea329b69b3d0514f8fa4c00426cccbd6a35013
6
+ metadata.gz: 6c3d1a1b6f1b0f9ab40aa8813ccac97c09c2e1cfb414fe2a5be2d87601da3e3e74619f64a43e3841edac8014769bed7610da694792cdc2642caa7b68530f21ff
7
+ data.tar.gz: 381c192c08d250924e27911124a310ec36f0e720496c7fb48df7e193242836b3d158a751539fa42d2de81054a18cbf9ccf61bcef69c40a975f7a86fe24e272b4
data/README.md CHANGED
@@ -10,7 +10,7 @@ SassHash takes a normal ruby hash and maps is keys and values into Sass Values f
10
10
 
11
11
  ```ruby
12
12
  some_hash = {:foo => :bar}
13
- ::Sass::Script::Value::Map.new(SassyHash[some_hash)
13
+ ::Sass::Script::Value::Map.new(SassyHash[some_hash])
14
14
  ```
15
15
  ## Installation
16
16
 
data/lib/sassy_hash.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  require 'sass'
2
2
  class SassyHashException < Exception; end
3
3
  class SassyHash < Hash
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
+ VALID_UNIT = %r{(?<unit>#{::Sass::SCSS::RX::NMSTART}#{::Sass::SCSS::RX::NMCHAR}|%*)}
6
+ VALID_NUMBER = %r{(?<number>#{::Sass::SCSS::RX::NUM})#{VALID_UNIT}}
5
7
 
6
8
  def self.[](hash_values)
7
9
  super(hash_values).tap do |hash|
@@ -36,9 +38,12 @@ class SassyHash < Hash
36
38
  when Symbol
37
39
  return ::Sass::Script::Value::String.new(value.to_s)
38
40
  when String
41
+ if matches = value.match(VALID_NUMBER)
42
+ return ::Sass::Script::Value::Number.new(matches[:number], matches[:unit])
43
+ end
39
44
  return ::Sass::Script::Value::String.new(value)
40
45
  when Array
41
- return ::Sass::Script::Value::List.new(value, ',')
46
+ return ::Sass::Script::Value::List.new(array_to_list(value), :sapce)
42
47
  when Hash
43
48
  return ::Sass::Script::Value::Map.new(self[value])
44
49
  when TrueClass, FalseClass
@@ -50,4 +55,11 @@ class SassyHash < Hash
50
55
  end
51
56
  end
52
57
 
58
+ def self.array_to_list(array)
59
+ array.map do |value|
60
+ sass_convert_value(value)
61
+ end
62
+ end
53
63
  end
64
+
65
+
@@ -39,11 +39,27 @@ describe SassyHash do
39
39
  SassyHash.sass_convert_value(array).class.should eq(::Sass::Script::Value::List)
40
40
  end
41
41
 
42
+ it "should create nested arrays" do
43
+ array =[1,2,[3,4, [5,6]]]
44
+ hash = {:foo => array}
45
+ sassy_hash = SassyHash[hash]
46
+ sassy_hash[sass_value(:foo)].value[2].class.should eq(::Sass::Script::Value::List)
47
+ end
48
+
49
+ it "should create nested arrays with maps" do
50
+ array =[1,2,[3, 4, {:map => :foo}]]
51
+ hash = {:foo => array}
52
+ sassy_hash = SassyHash[hash]
53
+ sassy_hash[sass_value(:foo)].value[2].class.should eq(::Sass::Script::Value::List)
54
+ sassy_hash[sass_value(:foo)].value[2].value[2].class.should eq(::Sass::Script::Value::Map)
55
+ end
42
56
 
43
57
  {
44
58
  'foo' => ::Sass::Script::Value::String,
45
59
  0 => ::Sass::Script::Value::Number,
46
60
  1.0 => ::Sass::Script::Value::Number,
61
+ "1.0px" => ::Sass::Script::Value::Number,
62
+ '1px' => ::Sass::Script::Value::Number,
47
63
  :foo => ::Sass::Script::Value::String,
48
64
  true => ::Sass::Script::Value::Bool,
49
65
  false => ::Sass::Script::Value::Bool
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sassy_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Davis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-31 00:00:00.000000000 Z
11
+ date: 2014-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  requirements: []
91
91
  rubyforge_project:
92
- rubygems_version: 2.2.0.rc.1
92
+ rubygems_version: 2.2.1
93
93
  signing_key:
94
94
  specification_version: 4
95
95
  summary: Hash vonverter for Sass::Script::Value::Map