proto_factory 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/proto_factory/builder.rb +18 -7
- metadata +29 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 381990fb82cc8476993a9ebfd2dadf0c9c71e1d6
|
4
|
+
data.tar.gz: fb54426ccded9f59de8425c6a7ab2cf43eb7b94f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60295eed7c4d602353cf8eef65d9f5ed50118f272649385f7e63689dfccd903e903acc140061135d242702aa674cbbe653c76df64add63906432ba1f4aab529e
|
7
|
+
data.tar.gz: c9c42f8c4a70d3e0180573831aae7232b2625a23300793a59c05c7199b597e285e498aaa48e2fbf4f6a7081e5093b60b24d916b3454b311366029c1225954525
|
@@ -1,9 +1,11 @@
|
|
1
|
+
require 'faker'
|
2
|
+
|
1
3
|
module ProtoFactory
|
2
4
|
class Builder
|
3
5
|
class << self
|
4
6
|
|
5
|
-
def build(factory_name
|
6
|
-
factory_class ||= Object.const_get(
|
7
|
+
def build(factory_name)
|
8
|
+
factory_class ||= Object.const_get(find(factory_name))
|
7
9
|
proto_object = factory_class.new
|
8
10
|
metadata = generate_types(factory_class)
|
9
11
|
set_data(proto_object, metadata, factory_class)
|
@@ -17,11 +19,11 @@ module ProtoFactory
|
|
17
19
|
when :enum
|
18
20
|
set_random_enum(proto_object, factory_class, name)
|
19
21
|
when :int32, :int64
|
20
|
-
proto_object["#{name}"] = Faker::Number.number(4).to_i
|
22
|
+
proto_object["#{name}"] = ::Faker::Number.number(4).to_i
|
21
23
|
when :string
|
22
|
-
proto_object["#{name}"] = Faker::Hacker.verb
|
24
|
+
proto_object["#{name}"] = ::Faker::Hacker.verb
|
23
25
|
when :bool
|
24
|
-
proto_object["#{name}"] = Faker::Boolean.boolean(0.5)
|
26
|
+
proto_object["#{name}"] = ::Faker::Boolean.boolean(0.5)
|
25
27
|
else
|
26
28
|
proto_object["#{name}"] = "Found a weird #{data_type} data type, yo."
|
27
29
|
end
|
@@ -30,13 +32,22 @@ module ProtoFactory
|
|
30
32
|
end
|
31
33
|
|
32
34
|
def submsg_to_class(submsg_name)
|
33
|
-
|
35
|
+
array_of_words = submsg_name.split('.')
|
36
|
+
class_string = array_of_words.map do |word|
|
37
|
+
if word.match?(/[A-Z]/)
|
38
|
+
word
|
39
|
+
else
|
40
|
+
word.split('_').collect(&:capitalize).join
|
41
|
+
end
|
42
|
+
end.join('::') # thanks I hate it
|
43
|
+
Object.const_get(class_string)
|
34
44
|
end
|
35
45
|
|
36
46
|
def set_all_messages(proto_object, factory_class, name)
|
37
47
|
message_class = submsg_to_class(factory_class.descriptor.lookup("#{name}").submsg_name)
|
38
48
|
nested_collection = generate_types(message_class)
|
39
|
-
|
49
|
+
nested_proto_object = message_class.new
|
50
|
+
proto_object["#{name}"] = set_data(nested_proto_object, nested_collection, message_class)
|
40
51
|
end
|
41
52
|
|
42
53
|
def set_random_enum(proto_object, factory_class, name)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proto_factory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Moore, Terese Lichty, Marshall Houston
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-remote
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry-nav
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
55
83
|
description: A simple hello world gem
|
56
84
|
email: lucas.moore@ibotta.com
|
57
85
|
executables: []
|