must 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,9 +17,9 @@ module Must
17
17
  def compact(obj)
18
18
  case obj
19
19
  when Hash
20
- Hash[*(obj.first || []).map{|i| compact(i)}]
20
+ obj.empty? ? Hash : Hash[*obj.first.map{|i| compact(i)}]
21
21
  when Array
22
- obj.empty? ? [] : [compact(obj.first)]
22
+ obj.empty? ? Array : [compact(obj.first)]
23
23
  else
24
24
  classify(obj)
25
25
  end
data/lib/must/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Must
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
@@ -29,7 +29,9 @@ class StructInfoTest < Test::Unit::TestCase
29
29
 
30
30
  def test_compact
31
31
  assert_equal(Fixnum, Must::StructInfo.new(1).compact)
32
- assert_equal({}, Must::StructInfo.new({}).compact)
32
+ assert_equal(Hash, Must::StructInfo.new({}).compact)
33
+ assert_equal(Array, Must::StructInfo.new([]).compact)
34
+ assert_equal([Fixnum], Must::StructInfo.new([1]).compact)
33
35
  assert_equal({String=>Fixnum}, Must::StructInfo.new({"a"=>1}).compact)
34
36
  assert_equal([{String=>Float}], Must::StructInfo.new([{"1"=>0.25}]).compact)
35
37
  assert_equal({String=>{String=>[{Symbol=>Fixnum}]}}, Must::StructInfo.new({"1.1" => {"jp"=>[{:a=>0},{:b=>2}]}}).compact)
@@ -45,7 +47,9 @@ class StructInfoTest < Test::Unit::TestCase
45
47
 
46
48
  def test_inspect
47
49
  assert_equal "Fixnum", Must::StructInfo.new(1).inspect
48
- assert_equal "{}", Must::StructInfo.new({}).inspect
50
+ assert_equal "Hash", Must::StructInfo.new({}).inspect
51
+ assert_equal "Array", Must::StructInfo.new([]).inspect
52
+ assert_equal "[Fixnum]", Must::StructInfo.new([1]).inspect
49
53
  assert_equal "{String=>Fixnum}", Must::StructInfo.new({"a"=>1}).inspect
50
54
  assert_equal "[{String=>Float}]", Must::StructInfo.new([{"1"=>0.25}]).inspect
51
55
  assert_equal "{String=>{String=>[{Symbol=>Fixnum}]}}", Must::StructInfo.new({"1.1" => {"jp"=>[{:a=>0},{:b=>2}]}}).inspect
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: must
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 5
10
- version: 0.2.5
9
+ - 6
10
+ version: 0.2.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - maiha
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-09 00:00:00 +09:00
18
+ date: 2012-02-13 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies: []
21
21