sparsam 0.2.7 → 0.2.8

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
- SHA1:
3
- metadata.gz: 418d5b778804d87629bffaa38ae70420ce0c1d54
4
- data.tar.gz: 97e472841bbf213dfad5e161228bdea9ec2e2baa
2
+ SHA256:
3
+ metadata.gz: 8d2c1375a7b3b2819de7f3ee0ad85fa964fc86345ab6ae109e18a033be94178c
4
+ data.tar.gz: f47b19af1fc8810c9e06864a11c6bbfd6b78635c430c9ba2e10d578d4f3f01c4
5
5
  SHA512:
6
- metadata.gz: 823b230987338ee70f778a1c1dd92818acf6d1719175ae0f365b3514eb0ebcdb203993442b9688b1e3e63fc81ddc809d6ce51747b23f46d3c5b62818e2a0ef86
7
- data.tar.gz: f11c539cedebcad0ac100fa27a0cd267f2b50b97d652800537413ba13009d4bf723c872874c6c43f0d77fcdf609ac8ec340caf091c0855735f76fd1f0fb8a6b8
6
+ metadata.gz: 978c4060ced319ba2d1a24462d1c3bc917bd42f049ea591f67023631895467df7c1917734b461b9ec7c2f210f014cce5b9cd95a820a74e9d432492c80ec133fa
7
+ data.tar.gz: 948ae683123165a6e4c85537b252f882fd10e1c6f481b3641799d0635067804aaf47743aecfaca267a764bd2a4ca4ec3495a5a294871e65ab7c953efd8d6d2cb
@@ -16,6 +16,8 @@ module Sparsam
16
16
  reader = name_to_accessors(info[:name]).reader
17
17
  return false unless send(reader) == other.send(reader)
18
18
  end
19
+
20
+ true
19
21
  end
20
22
  alias_method :eql?, :==
21
23
  end
@@ -13,6 +13,7 @@ module Magic
13
13
  Blue = 3
14
14
  Green = 4
15
15
  VALUE_MAP = {0 => "Black", 1 => "White", 2 => "Red", 3 => "Blue", 4 => "Green"}
16
+ INVERTED_VALUE_MAP = {"Black" => 0, "White" => 1, "Red" => 2, "Blue" => 3, "Green" => 4}
16
17
  VALID_VALUES = Set.new([Black, White, Red, Blue, Green]).freeze
17
18
  end
18
19
 
@@ -546,4 +546,76 @@ describe 'Sparsam' do
546
546
  end
547
547
  end
548
548
  end
549
+
550
+ describe 'generated enum types' do
551
+ let(:enum_module) { Magic }
552
+
553
+ it 'includes thrift constants as top level module constants' do
554
+ enum_module.const_defined?(:Black).should == true
555
+ enum_module.const_defined?(:White).should == true
556
+ enum_module.const_defined?(:Red).should == true
557
+ enum_module.const_defined?(:Blue).should == true
558
+ enum_module.const_defined?(:Green).should == true
559
+
560
+ enum_module.const_get(:Black).should == 0
561
+ enum_module.const_get(:White).should == 1
562
+ enum_module.const_get(:Red).should == 2
563
+ enum_module.const_get(:Blue).should == 3
564
+ enum_module.const_get(:Green).should == 4
565
+ end
566
+
567
+ it 'contains a VALUE_MAP constant that maps from int value to string' do
568
+ enum_module.const_defined?(:VALUE_MAP).should == true
569
+
570
+ value_map = enum_module.const_get(:VALUE_MAP)
571
+
572
+ value_map.should eql({
573
+ 0 => 'Black',
574
+ 1 => 'White',
575
+ 2 => 'Red',
576
+ 3 => 'Blue',
577
+ 4 => 'Green',
578
+ })
579
+
580
+ value_map[enum_module.const_get(:Black)].should == 'Black'
581
+ value_map[enum_module.const_get(:White)].should == 'White'
582
+ value_map[enum_module.const_get(:Red)].should == 'Red'
583
+ value_map[enum_module.const_get(:Blue)].should == 'Blue'
584
+ value_map[enum_module.const_get(:Green)].should == 'Green'
585
+ end
586
+
587
+ it 'contains an INVERTED_VALUE_MAP constant that maps from name to int value' do
588
+ enum_module.const_defined?(:INVERTED_VALUE_MAP).should == true
589
+
590
+ inverted_value_map = enum_module.const_get(:INVERTED_VALUE_MAP)
591
+
592
+ inverted_value_map.should eql({
593
+ 'Black' => 0,
594
+ 'White' => 1,
595
+ 'Red' => 2,
596
+ 'Blue' => 3,
597
+ 'Green' => 4,
598
+ })
599
+
600
+ inverted_value_map['Black'].should == enum_module.const_get(:Black)
601
+ inverted_value_map['White'].should == enum_module.const_get(:White)
602
+ inverted_value_map['Red'].should == enum_module.const_get(:Red)
603
+ inverted_value_map['Blue'].should == enum_module.const_get(:Blue)
604
+ inverted_value_map['Green'].should == enum_module.const_get(:Green)
605
+ end
606
+
607
+ it 'contains a VALID_VALUES constant that is a set of all enum values' do
608
+ enum_module.const_defined?(:VALID_VALUES).should == true
609
+
610
+ valid_values = enum_module.const_get(:VALID_VALUES)
611
+
612
+ valid_values.should be_a(Set)
613
+ valid_values.should include(enum_module.const_get(:Black))
614
+ valid_values.should include(enum_module.const_get(:White))
615
+ valid_values.should include(enum_module.const_get(:Red))
616
+ valid_values.should include(enum_module.const_get(:Blue))
617
+ valid_values.should include(enum_module.const_get(:Green))
618
+ valid_values.length.should == 5
619
+ end
620
+ end
549
621
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sparsam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airbnb Thrift Developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-08 00:00:00.000000000 Z
11
+ date: 2021-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -164,8 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  - !ruby/object:Gem::Version
165
165
  version: '0'
166
166
  requirements: []
167
- rubyforge_project: thrift
168
- rubygems_version: 2.5.1
167
+ rubygems_version: 3.0.3
169
168
  signing_key:
170
169
  specification_version: 4
171
170
  summary: Ruby bindings for Apache Thrift