sparsam 0.2.7 → 0.2.8
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.
- checksums.yaml +5 -5
- data/lib/sparsam/struct.rb +2 -0
- data/spec/gen-ruby/user_types.rb +1 -0
- data/spec/sparsam_spec.rb +72 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8d2c1375a7b3b2819de7f3ee0ad85fa964fc86345ab6ae109e18a033be94178c
|
4
|
+
data.tar.gz: f47b19af1fc8810c9e06864a11c6bbfd6b78635c430c9ba2e10d578d4f3f01c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 978c4060ced319ba2d1a24462d1c3bc917bd42f049ea591f67023631895467df7c1917734b461b9ec7c2f210f014cce5b9cd95a820a74e9d432492c80ec133fa
|
7
|
+
data.tar.gz: 948ae683123165a6e4c85537b252f882fd10e1c6f481b3641799d0635067804aaf47743aecfaca267a764bd2a4ca4ec3495a5a294871e65ab7c953efd8d6d2cb
|
data/lib/sparsam/struct.rb
CHANGED
data/spec/gen-ruby/user_types.rb
CHANGED
@@ -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
|
|
data/spec/sparsam_spec.rb
CHANGED
@@ -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.
|
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:
|
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
|
-
|
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
|