stark 0.6.1 → 0.7.0
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.
- data/History.txt +10 -0
- data/Manifest.txt +3 -0
- data/README.txt +5 -1
- data/Rakefile +0 -2
- data/bin/stark +12 -6
- data/lib/stark/converters.rb +151 -0
- data/lib/stark/parser.rb +28 -0
- data/lib/stark/raw_parser.rb +7 -2
- data/lib/stark/ruby.rb +82 -91
- data/lib/stark/struct.rb +17 -0
- data/lib/stark/thrift.kpeg +1 -1
- data/lib/stark.rb +6 -9
- data/test/blah.thrift +5 -0
- data/test/gen-rb/profile_types.rb +67 -0
- data/test/gen-rb/user_storage.rb +315 -0
- data/test/include_blah.thrift +1 -0
- data/test/legacy_profile/profile_types.rb +67 -0
- data/test/legacy_profile/user_storage.rb +315 -0
- data/test/profile.thrift +30 -1
- data/test/test_client.rb +131 -1
- data/test/test_parser.rb +64 -0
- data/test/test_ruby.rb +27 -0
- data/test/test_server.rb +105 -1
- metadata +6 -2
@@ -5,6 +5,16 @@
|
|
5
5
|
#
|
6
6
|
|
7
7
|
|
8
|
+
module MaritalStatus
|
9
|
+
SINGLE = 0
|
10
|
+
MARRIED = 1
|
11
|
+
DIVORCED = 2
|
12
|
+
UPSIDEDOWN = 3
|
13
|
+
ITS_COMPLICATED = 4
|
14
|
+
VALUE_MAP = {0 => "SINGLE", 1 => "MARRIED", 2 => "DIVORCED", 3 => "UPSIDEDOWN", 4 => "ITS_COMPLICATED"}
|
15
|
+
VALID_VALUES = Set.new([SINGLE, MARRIED, DIVORCED, UPSIDEDOWN, ITS_COMPLICATED]).freeze
|
16
|
+
end
|
17
|
+
|
8
18
|
module Status
|
9
19
|
ON = 0
|
10
20
|
OFF = 1
|
@@ -34,6 +44,63 @@ class UserProfile
|
|
34
44
|
::Thrift::Struct.generate_accessors self
|
35
45
|
end
|
36
46
|
|
47
|
+
class UserStatus
|
48
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
49
|
+
PROFILE = 1
|
50
|
+
ACTIVE = 2
|
51
|
+
|
52
|
+
FIELDS = {
|
53
|
+
PROFILE => {:type => ::Thrift::Types::STRUCT, :name => 'profile', :class => UserProfile},
|
54
|
+
ACTIVE => {:type => ::Thrift::Types::BOOL, :name => 'active'}
|
55
|
+
}
|
56
|
+
|
57
|
+
def struct_fields; FIELDS; end
|
58
|
+
|
59
|
+
def validate
|
60
|
+
end
|
61
|
+
|
62
|
+
::Thrift::Struct.generate_accessors self
|
63
|
+
end
|
64
|
+
|
65
|
+
class UserRelationship
|
66
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
67
|
+
USER = 1
|
68
|
+
STATUS = 2
|
69
|
+
|
70
|
+
FIELDS = {
|
71
|
+
USER => {:type => ::Thrift::Types::I32, :name => 'user'},
|
72
|
+
STATUS => {:type => ::Thrift::Types::I32, :name => 'status', :enum_class => MaritalStatus}
|
73
|
+
}
|
74
|
+
|
75
|
+
def struct_fields; FIELDS; end
|
76
|
+
|
77
|
+
def validate
|
78
|
+
unless @status.nil? || MaritalStatus::VALID_VALUES.include?(@status)
|
79
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field status!')
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
::Thrift::Struct.generate_accessors self
|
84
|
+
end
|
85
|
+
|
86
|
+
class UserFriends
|
87
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
88
|
+
USER = 1
|
89
|
+
FRIENDS = 2
|
90
|
+
|
91
|
+
FIELDS = {
|
92
|
+
USER => {:type => ::Thrift::Types::I32, :name => 'user'},
|
93
|
+
FRIENDS => {:type => ::Thrift::Types::LIST, :name => 'friends', :element => {:type => ::Thrift::Types::I32}}
|
94
|
+
}
|
95
|
+
|
96
|
+
def struct_fields; FIELDS; end
|
97
|
+
|
98
|
+
def validate
|
99
|
+
end
|
100
|
+
|
101
|
+
::Thrift::Struct.generate_accessors self
|
102
|
+
end
|
103
|
+
|
37
104
|
class RockTooHard < ::Thrift::Exception
|
38
105
|
include ::Thrift::Struct, ::Thrift::Struct_Union
|
39
106
|
VOLUME = 1
|
data/test/gen-rb/user_storage.rb
CHANGED
@@ -165,6 +165,93 @@ module UserStorage
|
|
165
165
|
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'add failed: unknown result')
|
166
166
|
end
|
167
167
|
|
168
|
+
def user_status()
|
169
|
+
send_user_status()
|
170
|
+
return recv_user_status()
|
171
|
+
end
|
172
|
+
|
173
|
+
def send_user_status()
|
174
|
+
send_message('user_status', User_status_args)
|
175
|
+
end
|
176
|
+
|
177
|
+
def recv_user_status()
|
178
|
+
result = receive_message(User_status_result)
|
179
|
+
return result.success unless result.success.nil?
|
180
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'user_status failed: unknown result')
|
181
|
+
end
|
182
|
+
|
183
|
+
def set_user_status(stat)
|
184
|
+
send_set_user_status(stat)
|
185
|
+
recv_set_user_status()
|
186
|
+
end
|
187
|
+
|
188
|
+
def send_set_user_status(stat)
|
189
|
+
send_message('set_user_status', Set_user_status_args, :stat => stat)
|
190
|
+
end
|
191
|
+
|
192
|
+
def recv_set_user_status()
|
193
|
+
result = receive_message(Set_user_status_result)
|
194
|
+
return
|
195
|
+
end
|
196
|
+
|
197
|
+
def user_relationship()
|
198
|
+
send_user_relationship()
|
199
|
+
return recv_user_relationship()
|
200
|
+
end
|
201
|
+
|
202
|
+
def send_user_relationship()
|
203
|
+
send_message('user_relationship', User_relationship_args)
|
204
|
+
end
|
205
|
+
|
206
|
+
def recv_user_relationship()
|
207
|
+
result = receive_message(User_relationship_result)
|
208
|
+
return result.success unless result.success.nil?
|
209
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'user_relationship failed: unknown result')
|
210
|
+
end
|
211
|
+
|
212
|
+
def set_user_relationship(rel)
|
213
|
+
send_set_user_relationship(rel)
|
214
|
+
recv_set_user_relationship()
|
215
|
+
end
|
216
|
+
|
217
|
+
def send_set_user_relationship(rel)
|
218
|
+
send_message('set_user_relationship', Set_user_relationship_args, :rel => rel)
|
219
|
+
end
|
220
|
+
|
221
|
+
def recv_set_user_relationship()
|
222
|
+
result = receive_message(Set_user_relationship_result)
|
223
|
+
return
|
224
|
+
end
|
225
|
+
|
226
|
+
def user_friends()
|
227
|
+
send_user_friends()
|
228
|
+
return recv_user_friends()
|
229
|
+
end
|
230
|
+
|
231
|
+
def send_user_friends()
|
232
|
+
send_message('user_friends', User_friends_args)
|
233
|
+
end
|
234
|
+
|
235
|
+
def recv_user_friends()
|
236
|
+
result = receive_message(User_friends_result)
|
237
|
+
return result.success unless result.success.nil?
|
238
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'user_friends failed: unknown result')
|
239
|
+
end
|
240
|
+
|
241
|
+
def set_user_friends(fr)
|
242
|
+
send_set_user_friends(fr)
|
243
|
+
recv_set_user_friends()
|
244
|
+
end
|
245
|
+
|
246
|
+
def send_set_user_friends(fr)
|
247
|
+
send_message('set_user_friends', Set_user_friends_args, :fr => fr)
|
248
|
+
end
|
249
|
+
|
250
|
+
def recv_set_user_friends()
|
251
|
+
result = receive_message(Set_user_friends_result)
|
252
|
+
return
|
253
|
+
end
|
254
|
+
|
168
255
|
end
|
169
256
|
|
170
257
|
class Processor
|
@@ -250,6 +337,48 @@ module UserStorage
|
|
250
337
|
write_result(result, oprot, 'add', seqid)
|
251
338
|
end
|
252
339
|
|
340
|
+
def process_user_status(seqid, iprot, oprot)
|
341
|
+
args = read_args(iprot, User_status_args)
|
342
|
+
result = User_status_result.new()
|
343
|
+
result.success = @handler.user_status()
|
344
|
+
write_result(result, oprot, 'user_status', seqid)
|
345
|
+
end
|
346
|
+
|
347
|
+
def process_set_user_status(seqid, iprot, oprot)
|
348
|
+
args = read_args(iprot, Set_user_status_args)
|
349
|
+
result = Set_user_status_result.new()
|
350
|
+
@handler.set_user_status(args.stat)
|
351
|
+
write_result(result, oprot, 'set_user_status', seqid)
|
352
|
+
end
|
353
|
+
|
354
|
+
def process_user_relationship(seqid, iprot, oprot)
|
355
|
+
args = read_args(iprot, User_relationship_args)
|
356
|
+
result = User_relationship_result.new()
|
357
|
+
result.success = @handler.user_relationship()
|
358
|
+
write_result(result, oprot, 'user_relationship', seqid)
|
359
|
+
end
|
360
|
+
|
361
|
+
def process_set_user_relationship(seqid, iprot, oprot)
|
362
|
+
args = read_args(iprot, Set_user_relationship_args)
|
363
|
+
result = Set_user_relationship_result.new()
|
364
|
+
@handler.set_user_relationship(args.rel)
|
365
|
+
write_result(result, oprot, 'set_user_relationship', seqid)
|
366
|
+
end
|
367
|
+
|
368
|
+
def process_user_friends(seqid, iprot, oprot)
|
369
|
+
args = read_args(iprot, User_friends_args)
|
370
|
+
result = User_friends_result.new()
|
371
|
+
result.success = @handler.user_friends()
|
372
|
+
write_result(result, oprot, 'user_friends', seqid)
|
373
|
+
end
|
374
|
+
|
375
|
+
def process_set_user_friends(seqid, iprot, oprot)
|
376
|
+
args = read_args(iprot, Set_user_friends_args)
|
377
|
+
result = Set_user_friends_result.new()
|
378
|
+
@handler.set_user_friends(args.fr)
|
379
|
+
write_result(result, oprot, 'set_user_friends', seqid)
|
380
|
+
end
|
381
|
+
|
253
382
|
end
|
254
383
|
|
255
384
|
# HELPER FUNCTIONS AND STRUCTURES
|
@@ -606,5 +735,191 @@ module UserStorage
|
|
606
735
|
::Thrift::Struct.generate_accessors self
|
607
736
|
end
|
608
737
|
|
738
|
+
class User_status_args
|
739
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
740
|
+
|
741
|
+
FIELDS = {
|
742
|
+
|
743
|
+
}
|
744
|
+
|
745
|
+
def struct_fields; FIELDS; end
|
746
|
+
|
747
|
+
def validate
|
748
|
+
end
|
749
|
+
|
750
|
+
::Thrift::Struct.generate_accessors self
|
751
|
+
end
|
752
|
+
|
753
|
+
class User_status_result
|
754
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
755
|
+
SUCCESS = 0
|
756
|
+
|
757
|
+
FIELDS = {
|
758
|
+
SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => UserStatus}
|
759
|
+
}
|
760
|
+
|
761
|
+
def struct_fields; FIELDS; end
|
762
|
+
|
763
|
+
def validate
|
764
|
+
end
|
765
|
+
|
766
|
+
::Thrift::Struct.generate_accessors self
|
767
|
+
end
|
768
|
+
|
769
|
+
class Set_user_status_args
|
770
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
771
|
+
STAT = 1
|
772
|
+
|
773
|
+
FIELDS = {
|
774
|
+
STAT => {:type => ::Thrift::Types::STRUCT, :name => 'stat', :class => UserStatus}
|
775
|
+
}
|
776
|
+
|
777
|
+
def struct_fields; FIELDS; end
|
778
|
+
|
779
|
+
def validate
|
780
|
+
end
|
781
|
+
|
782
|
+
::Thrift::Struct.generate_accessors self
|
783
|
+
end
|
784
|
+
|
785
|
+
class Set_user_status_result
|
786
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
787
|
+
|
788
|
+
FIELDS = {
|
789
|
+
|
790
|
+
}
|
791
|
+
|
792
|
+
def struct_fields; FIELDS; end
|
793
|
+
|
794
|
+
def validate
|
795
|
+
end
|
796
|
+
|
797
|
+
::Thrift::Struct.generate_accessors self
|
798
|
+
end
|
799
|
+
|
800
|
+
class User_relationship_args
|
801
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
802
|
+
|
803
|
+
FIELDS = {
|
804
|
+
|
805
|
+
}
|
806
|
+
|
807
|
+
def struct_fields; FIELDS; end
|
808
|
+
|
809
|
+
def validate
|
810
|
+
end
|
811
|
+
|
812
|
+
::Thrift::Struct.generate_accessors self
|
813
|
+
end
|
814
|
+
|
815
|
+
class User_relationship_result
|
816
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
817
|
+
SUCCESS = 0
|
818
|
+
|
819
|
+
FIELDS = {
|
820
|
+
SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => UserRelationship}
|
821
|
+
}
|
822
|
+
|
823
|
+
def struct_fields; FIELDS; end
|
824
|
+
|
825
|
+
def validate
|
826
|
+
end
|
827
|
+
|
828
|
+
::Thrift::Struct.generate_accessors self
|
829
|
+
end
|
830
|
+
|
831
|
+
class Set_user_relationship_args
|
832
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
833
|
+
REL = 1
|
834
|
+
|
835
|
+
FIELDS = {
|
836
|
+
REL => {:type => ::Thrift::Types::STRUCT, :name => 'rel', :class => UserRelationship}
|
837
|
+
}
|
838
|
+
|
839
|
+
def struct_fields; FIELDS; end
|
840
|
+
|
841
|
+
def validate
|
842
|
+
end
|
843
|
+
|
844
|
+
::Thrift::Struct.generate_accessors self
|
845
|
+
end
|
846
|
+
|
847
|
+
class Set_user_relationship_result
|
848
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
849
|
+
|
850
|
+
FIELDS = {
|
851
|
+
|
852
|
+
}
|
853
|
+
|
854
|
+
def struct_fields; FIELDS; end
|
855
|
+
|
856
|
+
def validate
|
857
|
+
end
|
858
|
+
|
859
|
+
::Thrift::Struct.generate_accessors self
|
860
|
+
end
|
861
|
+
|
862
|
+
class User_friends_args
|
863
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
864
|
+
|
865
|
+
FIELDS = {
|
866
|
+
|
867
|
+
}
|
868
|
+
|
869
|
+
def struct_fields; FIELDS; end
|
870
|
+
|
871
|
+
def validate
|
872
|
+
end
|
873
|
+
|
874
|
+
::Thrift::Struct.generate_accessors self
|
875
|
+
end
|
876
|
+
|
877
|
+
class User_friends_result
|
878
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
879
|
+
SUCCESS = 0
|
880
|
+
|
881
|
+
FIELDS = {
|
882
|
+
SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => UserFriends}
|
883
|
+
}
|
884
|
+
|
885
|
+
def struct_fields; FIELDS; end
|
886
|
+
|
887
|
+
def validate
|
888
|
+
end
|
889
|
+
|
890
|
+
::Thrift::Struct.generate_accessors self
|
891
|
+
end
|
892
|
+
|
893
|
+
class Set_user_friends_args
|
894
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
895
|
+
FR = 1
|
896
|
+
|
897
|
+
FIELDS = {
|
898
|
+
FR => {:type => ::Thrift::Types::STRUCT, :name => 'fr', :class => UserFriends}
|
899
|
+
}
|
900
|
+
|
901
|
+
def struct_fields; FIELDS; end
|
902
|
+
|
903
|
+
def validate
|
904
|
+
end
|
905
|
+
|
906
|
+
::Thrift::Struct.generate_accessors self
|
907
|
+
end
|
908
|
+
|
909
|
+
class Set_user_friends_result
|
910
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
911
|
+
|
912
|
+
FIELDS = {
|
913
|
+
|
914
|
+
}
|
915
|
+
|
916
|
+
def struct_fields; FIELDS; end
|
917
|
+
|
918
|
+
def validate
|
919
|
+
end
|
920
|
+
|
921
|
+
::Thrift::Struct.generate_accessors self
|
922
|
+
end
|
923
|
+
|
609
924
|
end
|
610
925
|
|
@@ -0,0 +1 @@
|
|
1
|
+
include "test/blah.thrift"
|
@@ -5,6 +5,16 @@
|
|
5
5
|
#
|
6
6
|
|
7
7
|
|
8
|
+
module MaritalStatus
|
9
|
+
SINGLE = 0
|
10
|
+
MARRIED = 1
|
11
|
+
DIVORCED = 2
|
12
|
+
UPSIDEDOWN = 3
|
13
|
+
ITS_COMPLICATED = 4
|
14
|
+
VALUE_MAP = {0 => "SINGLE", 1 => "MARRIED", 2 => "DIVORCED", 3 => "UPSIDEDOWN", 4 => "ITS_COMPLICATED"}
|
15
|
+
VALID_VALUES = Set.new([SINGLE, MARRIED, DIVORCED, UPSIDEDOWN, ITS_COMPLICATED]).freeze
|
16
|
+
end
|
17
|
+
|
8
18
|
module Status
|
9
19
|
ON = 0
|
10
20
|
OFF = 1
|
@@ -34,6 +44,63 @@ class UserProfile
|
|
34
44
|
::Thrift::Struct.generate_accessors self
|
35
45
|
end
|
36
46
|
|
47
|
+
class UserStatus
|
48
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
49
|
+
PROFILE = 1
|
50
|
+
ACTIVE = 2
|
51
|
+
|
52
|
+
FIELDS = {
|
53
|
+
PROFILE => {:type => ::Thrift::Types::STRUCT, :name => 'profile', :class => UserProfile},
|
54
|
+
ACTIVE => {:type => ::Thrift::Types::BOOL, :name => 'active'}
|
55
|
+
}
|
56
|
+
|
57
|
+
def struct_fields; FIELDS; end
|
58
|
+
|
59
|
+
def validate
|
60
|
+
end
|
61
|
+
|
62
|
+
::Thrift::Struct.generate_accessors self
|
63
|
+
end
|
64
|
+
|
65
|
+
class UserRelationship
|
66
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
67
|
+
USER = 1
|
68
|
+
STATUS = 2
|
69
|
+
|
70
|
+
FIELDS = {
|
71
|
+
USER => {:type => ::Thrift::Types::I32, :name => 'user'},
|
72
|
+
STATUS => {:type => ::Thrift::Types::I32, :name => 'status', :enum_class => MaritalStatus}
|
73
|
+
}
|
74
|
+
|
75
|
+
def struct_fields; FIELDS; end
|
76
|
+
|
77
|
+
def validate
|
78
|
+
unless @status.nil? || MaritalStatus::VALID_VALUES.include?(@status)
|
79
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field status!')
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
::Thrift::Struct.generate_accessors self
|
84
|
+
end
|
85
|
+
|
86
|
+
class UserFriends
|
87
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
88
|
+
USER = 1
|
89
|
+
FRIENDS = 2
|
90
|
+
|
91
|
+
FIELDS = {
|
92
|
+
USER => {:type => ::Thrift::Types::I32, :name => 'user'},
|
93
|
+
FRIENDS => {:type => ::Thrift::Types::LIST, :name => 'friends', :element => {:type => ::Thrift::Types::I32}}
|
94
|
+
}
|
95
|
+
|
96
|
+
def struct_fields; FIELDS; end
|
97
|
+
|
98
|
+
def validate
|
99
|
+
end
|
100
|
+
|
101
|
+
::Thrift::Struct.generate_accessors self
|
102
|
+
end
|
103
|
+
|
37
104
|
class RockTooHard < ::Thrift::Exception
|
38
105
|
include ::Thrift::Struct, ::Thrift::Struct_Union
|
39
106
|
VOLUME = 1
|