thrift-validator 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/Makefile +9 -0
- data/README.md +84 -0
- data/Rakefile +8 -0
- data/lib/thrift/validator/version.rb +5 -0
- data/lib/thrift/validator.rb +36 -0
- data/lib/thrift-validator.rb +1 -0
- data/test/acceptance_test.rb +122 -0
- data/test/test_helper.rb +12 -0
- data/test.thrift +29 -0
- data/thrift-validator.gemspec +25 -0
- data/vendor/gen-rb/test_constants.rb +9 -0
- data/vendor/gen-rb/test_types.rb +122 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d1e1282790eab6d2034f8f05da9d4512102c59be
|
4
|
+
data.tar.gz: 50535756f602fcf6c60b4f2ef47222fc28e75e6d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f59768669a591b41eeb0c1802252ba2256f53800c18242cf21196496c9dc13b08535a52098ed7b9302a2499f97971dddd93e9a2146bf5380e6aa78c73a28c124
|
7
|
+
data.tar.gz: 96421ce8b108eb57fee36cfa5e1e18b0dd318c2081573110c796320438b0c3612054fd7a38d2066caa4236cb1c7deb66e9588731d5fedc45507c7724d68a91dc
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 ahawkins
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Makefile
ADDED
data/README.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Thrift::Validator
|
2
|
+
|
3
|
+
Recursive [thrift][] struct validator. The thrift library out of the
|
4
|
+
box does not validated nested structs, this library fixes that
|
5
|
+
problem. It does not monkey-patch the Thrift code. Instead this
|
6
|
+
library includes a class to recursively validate objects.
|
7
|
+
|
8
|
+
Here's an example from this libraries test. Take a look at this
|
9
|
+
protocol:
|
10
|
+
|
11
|
+
```thrift
|
12
|
+
struct SimpleStruct {
|
13
|
+
1: required string required_string
|
14
|
+
2: optional string optional_string
|
15
|
+
}
|
16
|
+
|
17
|
+
struct NestedExample {
|
18
|
+
1: required SimpleStruct required_struct
|
19
|
+
2: optional SimpleStruct optional_struct
|
20
|
+
}
|
21
|
+
```
|
22
|
+
|
23
|
+
Then ran some ruby:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
struct = SimpleStruct.new
|
27
|
+
nested = NestedStruct.new required_struct: struct
|
28
|
+
|
29
|
+
# Method defined by the thrift library
|
30
|
+
struct.validate # => Thrift::ProtocolException
|
31
|
+
|
32
|
+
# Thrift only validate fields set as required on this instance.
|
33
|
+
# so since required_struct is non-nil validation succeeds.
|
34
|
+
# Also note that thrift does not validate the semantics of
|
35
|
+
# the assigned objects, so also assigning and invalid struct will
|
36
|
+
# pass its validation method.
|
37
|
+
nested.validate # => true
|
38
|
+
|
39
|
+
# With the validator
|
40
|
+
validator = Thrift::Validator.new
|
41
|
+
validator.validate nested # => Thrift::ProtocolException
|
42
|
+
```
|
43
|
+
|
44
|
+
## Semantics
|
45
|
+
|
46
|
+
* Original thrift validation smenatics enforces
|
47
|
+
* `optional` or `required` `struct` types pass validation
|
48
|
+
* `optional` or `required` `list<struct>` items pass validation
|
49
|
+
* `optional` or `required` `set<struct>` items pass validation
|
50
|
+
* `optional` or `required` `map` type using a `struct` for key or
|
51
|
+
value pass validation
|
52
|
+
|
53
|
+
|
54
|
+
## Installation
|
55
|
+
|
56
|
+
Add this line to your application's Gemfile:
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
gem 'thrift-validator'
|
60
|
+
```
|
61
|
+
|
62
|
+
And then execute:
|
63
|
+
|
64
|
+
$ bundle
|
65
|
+
|
66
|
+
Or install it yourself as:
|
67
|
+
|
68
|
+
$ gem install thrift-validator
|
69
|
+
|
70
|
+
## Testing
|
71
|
+
|
72
|
+
First install `thrift` compilier on your platform.
|
73
|
+
|
74
|
+
$ make test
|
75
|
+
|
76
|
+
## Contributing
|
77
|
+
|
78
|
+
1. Fork it ( https://github.com/saltside/thrift-validator/fork )
|
79
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
80
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
81
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
82
|
+
5. Create a new Pull Request
|
83
|
+
|
84
|
+
[thrift]: https://thrift.apache.org
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'thrift/validator/version'
|
2
|
+
require 'thrift'
|
3
|
+
|
4
|
+
module Thrift
|
5
|
+
class Validator
|
6
|
+
def validate(source)
|
7
|
+
source.validate
|
8
|
+
|
9
|
+
source.struct_fields.each_pair do |_, field|
|
10
|
+
type, name = field.fetch(:type), field.fetch(:name)
|
11
|
+
case type
|
12
|
+
when Types::STRUCT
|
13
|
+
validate source.send(name)
|
14
|
+
when Types::LIST, Types::SET
|
15
|
+
Array(source.send(name)).each do |item|
|
16
|
+
validate item
|
17
|
+
end
|
18
|
+
when Types::MAP
|
19
|
+
key_field = field.fetch(:key)
|
20
|
+
if key_field[:class] && key_field[:class] < ::Thrift::Struct
|
21
|
+
Hash(source.send(name)).each_key do |key_value|
|
22
|
+
validate key_value
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
value_field = field.fetch(:value)
|
27
|
+
if value_field[:class] && value_field[:class] < ::Thrift::Struct
|
28
|
+
Hash(source.send(name)).each_value do |value_value|
|
29
|
+
validate value_value
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'thrift/validator'
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
class AcceptanceTest < MiniTest::Unit::TestCase
|
4
|
+
def test_follows_thrift_semantics
|
5
|
+
struct = SimpleStruct.new required_string: nil, optional_string: nil
|
6
|
+
refute_valid struct
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_fails_if_a_required_nested_struct_is_invalid
|
10
|
+
struct = NestedExample.new
|
11
|
+
struct.required_struct = SimpleStruct.new
|
12
|
+
refute_valid struct
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_fails_if_an_optional_nested_struct_is_valid
|
16
|
+
struct = NestedExample.new
|
17
|
+
struct.required_struct = SimpleStruct.new required_string: 'foo'
|
18
|
+
struct.optional_struct = SimpleStruct.new
|
19
|
+
refute_valid struct
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_passes_if_nested_structs_are_valid
|
23
|
+
struct = NestedExample.new
|
24
|
+
struct.required_struct = SimpleStruct.new required_string: 'foo'
|
25
|
+
struct.optional_struct = SimpleStruct.new required_string: 'bar'
|
26
|
+
assert_valid struct
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_fails_if_a_nested_list_item_is_invalid
|
30
|
+
struct = ListExample.new
|
31
|
+
struct.required_list = [ SimpleStruct.new ]
|
32
|
+
refute_valid struct
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_fails_if_a_nested_list_item_is_invalid
|
36
|
+
struct = ListExample.new
|
37
|
+
struct.required_list = [ SimpleStruct.new({ required_string: 'foo' }) ]
|
38
|
+
struct.optional_list = [ SimpleStruct.new ]
|
39
|
+
refute_valid struct
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_passes_if_given_valid_list_items
|
43
|
+
struct = ListExample.new
|
44
|
+
struct.required_list = [ SimpleStruct.new({ required_string: 'foo' }) ]
|
45
|
+
struct.optional_list = [ SimpleStruct.new({ required_string: 'bar' }) ]
|
46
|
+
assert_valid struct
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_fails_if_a_nested_set_item_is_invalid
|
50
|
+
struct = SetExample.new
|
51
|
+
struct.required_set = Set.new([ SimpleStruct.new ])
|
52
|
+
refute_valid struct
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_fails_if_a_nested_set_item_is_invalid
|
56
|
+
struct = SetExample.new
|
57
|
+
struct.required_set = Set.new([ SimpleStruct.new({ required_string: 'foo' }) ])
|
58
|
+
struct.optional_set = Set.new([ SimpleStruct.new ])
|
59
|
+
refute_valid struct
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_passes_if_given_valid_set_items
|
63
|
+
struct = SetExample.new
|
64
|
+
struct.required_set = Set.new([ SimpleStruct.new({ required_string: 'foo' }) ])
|
65
|
+
struct.optional_set = Set.new([ SimpleStruct.new({ required_string: 'bar' }) ])
|
66
|
+
assert_valid struct
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_fails_if_nested_map_key_is_invalid
|
70
|
+
struct = MapKeyExample.new
|
71
|
+
struct.required_map = { SimpleStruct.new => 'foo' }
|
72
|
+
refute_valid struct
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_fails_if_nested_map_key_is_invalid
|
76
|
+
struct = MapKeyExample.new
|
77
|
+
struct.required_map = { SimpleStruct.new({ required_string: 'foo' }) => 'foo' }
|
78
|
+
struct.optional_map = { SimpleStruct.new => 'foo' }
|
79
|
+
refute_valid struct
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_passess_when_valid_map_keys_are_given
|
83
|
+
struct = MapKeyExample.new
|
84
|
+
struct.required_map = { SimpleStruct.new({ required_string: 'foo' }) => 'foo' }
|
85
|
+
struct.optional_map = { SimpleStruct.new({ required_string: 'bar' }) => 'bar' }
|
86
|
+
assert_valid struct
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_fails_if_nested_map_value_is_invalid
|
90
|
+
struct = MapValueExample.new
|
91
|
+
struct.required_map = { 'foo' => SimpleStruct.new }
|
92
|
+
refute_valid struct
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_fails_if_optional_nested_map_value_is_invalid
|
96
|
+
struct = MapValueExample.new
|
97
|
+
struct.required_map = { 'foo' => SimpleStruct.new({ required_string: 'foo' }) }
|
98
|
+
struct.required_map = { 'foo' => SimpleStruct.new }
|
99
|
+
refute_valid struct
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_passes_if_optional_and_required_valid_map_values_are_given
|
103
|
+
struct = MapValueExample.new
|
104
|
+
struct.required_map = { 'foo' => SimpleStruct.new({ required_string: 'foo' }) }
|
105
|
+
struct.optional_map = { 'foo' => SimpleStruct.new({ required_string: 'bar' }) }
|
106
|
+
assert_valid struct
|
107
|
+
end
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
def refute_valid(struct)
|
112
|
+
assert_raises Thrift::ProtocolException, 'Incorrect validation' do
|
113
|
+
Thrift::Validator.new.validate(struct)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def assert_valid(struct)
|
118
|
+
Thrift::Validator.new.validate(struct)
|
119
|
+
rescue Thrift::ProtocolException => ex
|
120
|
+
flunk ex
|
121
|
+
end
|
122
|
+
end
|
data/test/test_helper.rb
ADDED
data/test.thrift
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
struct SimpleStruct {
|
2
|
+
1: required string required_string
|
3
|
+
2: optional string optional_string
|
4
|
+
}
|
5
|
+
|
6
|
+
struct NestedExample {
|
7
|
+
1: required SimpleStruct required_struct
|
8
|
+
2: optional SimpleStruct optional_struct
|
9
|
+
}
|
10
|
+
|
11
|
+
struct ListExample {
|
12
|
+
1: required list<SimpleStruct> required_list
|
13
|
+
2: optional list<SimpleStruct> optional_list
|
14
|
+
}
|
15
|
+
|
16
|
+
struct SetExample {
|
17
|
+
1: required set<SimpleStruct> required_set
|
18
|
+
2: optional set<SimpleStruct> optional_set
|
19
|
+
}
|
20
|
+
|
21
|
+
struct MapKeyExample {
|
22
|
+
1: required map<SimpleStruct, string> required_map
|
23
|
+
2: optional map<SimpleStruct, string> optional_map
|
24
|
+
}
|
25
|
+
|
26
|
+
struct MapValueExample {
|
27
|
+
1: required map<string, SimpleStruct> required_map
|
28
|
+
2: optional map<string, SimpleStruct> optional_map
|
29
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'thrift/validator/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "thrift-validator"
|
8
|
+
spec.version = Thrift::Validator::VERSION
|
9
|
+
spec.authors = ["ahawkins"]
|
10
|
+
spec.email = ["adam@hawkins.io"]
|
11
|
+
spec.summary = %q{Recursive thrift struct validator}
|
12
|
+
spec.description = %q{}
|
13
|
+
spec.homepage = "https://github.com/saltside/thrift-validator-ruby"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "thrift"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
#
|
2
|
+
# Autogenerated by Thrift Compiler (0.9.2)
|
3
|
+
#
|
4
|
+
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'thrift'
|
8
|
+
|
9
|
+
class SimpleStruct
|
10
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
11
|
+
REQUIRED_STRING = 1
|
12
|
+
OPTIONAL_STRING = 2
|
13
|
+
|
14
|
+
FIELDS = {
|
15
|
+
REQUIRED_STRING => {:type => ::Thrift::Types::STRING, :name => 'required_string'},
|
16
|
+
OPTIONAL_STRING => {:type => ::Thrift::Types::STRING, :name => 'optional_string', :optional => true}
|
17
|
+
}
|
18
|
+
|
19
|
+
def struct_fields; FIELDS; end
|
20
|
+
|
21
|
+
def validate
|
22
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field required_string is unset!') unless @required_string
|
23
|
+
end
|
24
|
+
|
25
|
+
::Thrift::Struct.generate_accessors self
|
26
|
+
end
|
27
|
+
|
28
|
+
class NestedExample
|
29
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
30
|
+
REQUIRED_STRUCT = 1
|
31
|
+
OPTIONAL_STRUCT = 2
|
32
|
+
|
33
|
+
FIELDS = {
|
34
|
+
REQUIRED_STRUCT => {:type => ::Thrift::Types::STRUCT, :name => 'required_struct', :class => ::SimpleStruct},
|
35
|
+
OPTIONAL_STRUCT => {:type => ::Thrift::Types::STRUCT, :name => 'optional_struct', :class => ::SimpleStruct, :optional => true}
|
36
|
+
}
|
37
|
+
|
38
|
+
def struct_fields; FIELDS; end
|
39
|
+
|
40
|
+
def validate
|
41
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field required_struct is unset!') unless @required_struct
|
42
|
+
end
|
43
|
+
|
44
|
+
::Thrift::Struct.generate_accessors self
|
45
|
+
end
|
46
|
+
|
47
|
+
class ListExample
|
48
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
49
|
+
REQUIRED_LIST = 1
|
50
|
+
OPTIONAL_LIST = 2
|
51
|
+
|
52
|
+
FIELDS = {
|
53
|
+
REQUIRED_LIST => {:type => ::Thrift::Types::LIST, :name => 'required_list', :element => {:type => ::Thrift::Types::STRUCT, :class => ::SimpleStruct}},
|
54
|
+
OPTIONAL_LIST => {:type => ::Thrift::Types::LIST, :name => 'optional_list', :element => {:type => ::Thrift::Types::STRUCT, :class => ::SimpleStruct}, :optional => true}
|
55
|
+
}
|
56
|
+
|
57
|
+
def struct_fields; FIELDS; end
|
58
|
+
|
59
|
+
def validate
|
60
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field required_list is unset!') unless @required_list
|
61
|
+
end
|
62
|
+
|
63
|
+
::Thrift::Struct.generate_accessors self
|
64
|
+
end
|
65
|
+
|
66
|
+
class SetExample
|
67
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
68
|
+
REQUIRED_SET = 1
|
69
|
+
OPTIONAL_SET = 2
|
70
|
+
|
71
|
+
FIELDS = {
|
72
|
+
REQUIRED_SET => {:type => ::Thrift::Types::SET, :name => 'required_set', :element => {:type => ::Thrift::Types::STRUCT, :class => ::SimpleStruct}},
|
73
|
+
OPTIONAL_SET => {:type => ::Thrift::Types::SET, :name => 'optional_set', :element => {:type => ::Thrift::Types::STRUCT, :class => ::SimpleStruct}, :optional => true}
|
74
|
+
}
|
75
|
+
|
76
|
+
def struct_fields; FIELDS; end
|
77
|
+
|
78
|
+
def validate
|
79
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field required_set is unset!') unless @required_set
|
80
|
+
end
|
81
|
+
|
82
|
+
::Thrift::Struct.generate_accessors self
|
83
|
+
end
|
84
|
+
|
85
|
+
class MapKeyExample
|
86
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
87
|
+
REQUIRED_MAP = 1
|
88
|
+
OPTIONAL_MAP = 2
|
89
|
+
|
90
|
+
FIELDS = {
|
91
|
+
REQUIRED_MAP => {:type => ::Thrift::Types::MAP, :name => 'required_map', :key => {:type => ::Thrift::Types::STRUCT, :class => ::SimpleStruct}, :value => {:type => ::Thrift::Types::STRING}},
|
92
|
+
OPTIONAL_MAP => {:type => ::Thrift::Types::MAP, :name => 'optional_map', :key => {:type => ::Thrift::Types::STRUCT, :class => ::SimpleStruct}, :value => {:type => ::Thrift::Types::STRING}, :optional => true}
|
93
|
+
}
|
94
|
+
|
95
|
+
def struct_fields; FIELDS; end
|
96
|
+
|
97
|
+
def validate
|
98
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field required_map is unset!') unless @required_map
|
99
|
+
end
|
100
|
+
|
101
|
+
::Thrift::Struct.generate_accessors self
|
102
|
+
end
|
103
|
+
|
104
|
+
class MapValueExample
|
105
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
106
|
+
REQUIRED_MAP = 1
|
107
|
+
OPTIONAL_MAP = 2
|
108
|
+
|
109
|
+
FIELDS = {
|
110
|
+
REQUIRED_MAP => {:type => ::Thrift::Types::MAP, :name => 'required_map', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRUCT, :class => ::SimpleStruct}},
|
111
|
+
OPTIONAL_MAP => {:type => ::Thrift::Types::MAP, :name => 'optional_map', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRUCT, :class => ::SimpleStruct}, :optional => true}
|
112
|
+
}
|
113
|
+
|
114
|
+
def struct_fields; FIELDS; end
|
115
|
+
|
116
|
+
def validate
|
117
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field required_map is unset!') unless @required_map
|
118
|
+
end
|
119
|
+
|
120
|
+
::Thrift::Struct.generate_accessors self
|
121
|
+
end
|
122
|
+
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: thrift-validator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ahawkins
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thrift
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: ''
|
56
|
+
email:
|
57
|
+
- adam@hawkins.io
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- Makefile
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/thrift-validator.rb
|
69
|
+
- lib/thrift/validator.rb
|
70
|
+
- lib/thrift/validator/version.rb
|
71
|
+
- test.thrift
|
72
|
+
- test/acceptance_test.rb
|
73
|
+
- test/test_helper.rb
|
74
|
+
- thrift-validator.gemspec
|
75
|
+
- vendor/gen-rb/test_constants.rb
|
76
|
+
- vendor/gen-rb/test_types.rb
|
77
|
+
homepage: https://github.com/saltside/thrift-validator-ruby
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.2.2
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: Recursive thrift struct validator
|
101
|
+
test_files:
|
102
|
+
- test/acceptance_test.rb
|
103
|
+
- test/test_helper.rb
|