graphql-idl-parser 0.0.1 → 0.1.0

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
2
  SHA1:
3
- metadata.gz: 140e46859bc93230d1d6ab77585ac60add046620
4
- data.tar.gz: 3763416e5e5495e9c002c31b2d7250d989074f5a
3
+ metadata.gz: 7ae6e5ecf5f40c76b7721b68e49b9f5e8cb7f49f
4
+ data.tar.gz: d44b6476cb80dade38866fc7e123b4c459e43127
5
5
  SHA512:
6
- metadata.gz: e564993dbc210343566966090c19e225fcaf3d1dbed9a231d207d2ed533a904bf2289b2fb39fefb9504b9bd871f7a22427a27a66d621f95a917c38aafbb41d1f
7
- data.tar.gz: c9bf8c3221a7604a08292c42045aa6c9377579b024674f19dfc00e36dec500762c3b6c3d78818be6a6950d6023b97664886eb15a423107d4d22ff31d54f84193
6
+ metadata.gz: 5a4514479740020381613658aa8df606dbdfcb959529676634dc92c3c5631a31d5da75a7da5ad5a7998dbad83db797baf2bcb1f12ad25fa6d9fe6a1594751715
7
+ data.tar.gz: 921df12743e9510f5567836b83417eacc88bb326548be831918dc50dab2c39570abc162b53ba88d0232e4f918e39b3c2bf27299ec1ebec30507c85df57a5699a
data/.gitignore CHANGED
@@ -12,6 +12,7 @@ _yardoc
12
12
  /vendor/ruby
13
13
  bin/
14
14
  tmp/
15
+ pkg/
15
16
  /Gemfile.lock
16
17
 
17
18
  .byebug_history
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ inherit_gem:
2
+ rubocop-github:
3
+ - config/default.yml
4
+
5
+ Style/StringLiterals:
6
+ Enabled: true
7
+ EnforcedStyle: single_quotes
8
+
9
+ RequireParentheses:
10
+ Enabled: true
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ end
21
21
 
22
22
  desc 'Pretty format C code'
23
23
  task :format do
24
- puts `astyle --indent=spaces=2 --style=1tbs --keep-one-line-blocks \
24
+ puts `astyle --indent=spaces=2 --style=1tbs --keep-one-line-blocks -n \
25
25
  $(ack -n -f --type=cpp --type=cc ext/graphql-idl-parser/)`
26
26
  end
27
27
 
@@ -2,8 +2,10 @@
2
2
 
3
3
  static VALUE rb_mGraphQL;
4
4
  static VALUE rb_cGraphQLIDLParser;
5
+ static VALUE rb_cResult;
5
6
 
6
- VALUE convert_string(const char* c_string) {
7
+ VALUE convert_string(const char* c_string)
8
+ {
7
9
  VALUE rb_string;
8
10
  int enc;
9
11
 
@@ -18,7 +20,8 @@ VALUE convert_string(const char* c_string) {
18
20
  return rb_string;
19
21
  }
20
22
 
21
- VALUE convert_type_info(struct FieldType c_field_type) {
23
+ VALUE convert_type_info(struct FieldType c_field_type)
24
+ {
22
25
  VALUE rb_hash = rb_hash_new();
23
26
 
24
27
  rb_hash_aset(rb_hash, CSTR2SYM("name"), convert_string(c_field_type.name));
@@ -27,7 +30,8 @@ VALUE convert_type_info(struct FieldType c_field_type) {
27
30
  return rb_hash;
28
31
  }
29
32
 
30
- VALUE convert_array_of_strings(struct array_of_strings c_array_of_strings) {
33
+ VALUE convert_array_of_strings(struct array_of_strings c_array_of_strings)
34
+ {
31
35
  VALUE rb_array = rb_ary_new();
32
36
  size_t i;
33
37
 
@@ -42,7 +46,8 @@ VALUE convert_array_of_strings(struct array_of_strings c_array_of_strings) {
42
46
  return rb_array;
43
47
  }
44
48
 
45
- VALUE convert_array_of_arguments(struct array_of_arguments c_array_of_arguments) {
49
+ VALUE convert_array_of_arguments(struct array_of_arguments c_array_of_arguments)
50
+ {
46
51
  VALUE rb_array = rb_ary_new();
47
52
  VALUE rb_hash;
48
53
  size_t i;
@@ -66,7 +71,8 @@ VALUE convert_array_of_arguments(struct array_of_arguments c_array_of_arguments)
66
71
  return rb_array;
67
72
  }
68
73
 
69
- VALUE convert_array_of_fields(struct array_of_fields c_array_of_fields) {
74
+ VALUE convert_array_of_fields(struct array_of_fields c_array_of_fields)
75
+ {
70
76
  VALUE rb_array = rb_ary_new();
71
77
  VALUE rb_hash;
72
78
  size_t i;
@@ -90,7 +96,8 @@ VALUE convert_array_of_fields(struct array_of_fields c_array_of_fields) {
90
96
  return rb_array;
91
97
  }
92
98
 
93
- VALUE convert_array_of_values(struct array_of_values c_array_of_values) {
99
+ VALUE convert_array_of_values(struct array_of_values c_array_of_values)
100
+ {
94
101
  VALUE rb_array = rb_ary_new();
95
102
  VALUE rb_hash;
96
103
  size_t i;
@@ -111,7 +118,8 @@ VALUE convert_array_of_values(struct array_of_values c_array_of_values) {
111
118
  return rb_array;
112
119
  }
113
120
 
114
- VALUE convert_array_of_directives(struct array_of_directives c_array_of_directives) {
121
+ VALUE convert_array_of_directives(struct array_of_directives c_array_of_directives)
122
+ {
115
123
  VALUE rb_array = rb_ary_new();
116
124
  VALUE rb_hash;
117
125
  VALUE rb_arguments_array;
@@ -147,7 +155,8 @@ VALUE convert_array_of_directives(struct array_of_directives c_array_of_directiv
147
155
  static VALUE GRAPHQLIDLPARSERPROCESS_process(VALUE self)
148
156
  {
149
157
  VALUE rb_schema = rb_iv_get(self, "@schema");
150
- VALUE rb_definitions;
158
+ VALUE rb_result = rb_obj_alloc(rb_cResult);
159
+ VALUE rb_types;
151
160
  VALUE rb_hash;
152
161
  GraphQLTypes* types = NULL;
153
162
  size_t types_len = 0;
@@ -161,7 +170,10 @@ static VALUE GRAPHQLIDLPARSERPROCESS_process(VALUE self)
161
170
  exit(err);
162
171
  }
163
172
 
164
- rb_definitions = rb_ary_new();
173
+ rb_types = rb_ary_new();
174
+
175
+ /* attr_reader :types */
176
+ rb_define_attr(rb_cResult, "types", 1, 0);
165
177
 
166
178
  for (size_t i = 0; i < types_len; i++) {
167
179
  rb_hash = rb_hash_new();
@@ -170,52 +182,47 @@ static VALUE GRAPHQLIDLPARSERPROCESS_process(VALUE self)
170
182
  rb_hash_aset(rb_hash, CSTR2SYM("typename"), convert_string(types[i].typename));
171
183
  rb_hash_aset(rb_hash, CSTR2SYM("name"), convert_string(types[i].scalar_type.name));
172
184
  rb_hash_aset(rb_hash, CSTR2SYM("description"), convert_string(types[i].scalar_type.description));
173
- }
174
- else if (strcmp(types[i].typename, "object") == 0) {
185
+ } else if (strcmp(types[i].typename, "object") == 0) {
175
186
  rb_hash_aset(rb_hash, CSTR2SYM("typename"), convert_string(types[i].typename));
176
187
  rb_hash_aset(rb_hash, CSTR2SYM("description"), convert_string(types[i].object_type.description));
177
188
  rb_hash_aset(rb_hash, CSTR2SYM("name"), convert_string(types[i].object_type.name));
178
189
  rb_hash_aset(rb_hash, CSTR2SYM("implements"), convert_array_of_strings(types[i].object_type.implements));
179
190
  rb_hash_aset(rb_hash, CSTR2SYM("directives"), convert_array_of_directives(types[i].object_type.directives));
180
191
  rb_hash_aset(rb_hash, CSTR2SYM("fields"), convert_array_of_fields(types[i].object_type.fields));
181
- }
182
- else if (strcmp(types[i].typename, "enum") == 0) {
192
+ } else if (strcmp(types[i].typename, "enum") == 0) {
183
193
  rb_hash_aset(rb_hash, CSTR2SYM("typename"), convert_string(types[i].typename));
184
194
  rb_hash_aset(rb_hash, CSTR2SYM("description"), convert_string(types[i].enum_type.description));
185
195
  rb_hash_aset(rb_hash, CSTR2SYM("name"), convert_string(types[i].enum_type.name));
186
196
  rb_hash_aset(rb_hash, CSTR2SYM("directives"), convert_array_of_directives(types[i].enum_type.directives));
187
197
  rb_hash_aset(rb_hash, CSTR2SYM("values"), convert_array_of_values(types[i].enum_type.values));
188
- }
189
- else if (strcmp(types[i].typename, "interface") == 0) {
198
+ } else if (strcmp(types[i].typename, "interface") == 0) {
190
199
  rb_hash_aset(rb_hash, CSTR2SYM("typename"), convert_string(types[i].typename));
191
200
  rb_hash_aset(rb_hash, CSTR2SYM("description"), convert_string(types[i].interface_type.description));
192
201
  rb_hash_aset(rb_hash, CSTR2SYM("name"), convert_string(types[i].interface_type.name));
193
202
  rb_hash_aset(rb_hash, CSTR2SYM("directives"), convert_array_of_directives(types[i].interface_type.directives));
194
203
  rb_hash_aset(rb_hash, CSTR2SYM("fields"), convert_array_of_fields(types[i].interface_type.fields));
195
- }
196
- else if (strcmp(types[i].typename, "union") == 0) {
204
+ } else if (strcmp(types[i].typename, "union") == 0) {
197
205
  rb_hash_aset(rb_hash, CSTR2SYM("typename"), convert_string(types[i].typename));
198
206
  rb_hash_aset(rb_hash, CSTR2SYM("description"), convert_string(types[i].union_type.description));
199
207
  rb_hash_aset(rb_hash, CSTR2SYM("name"), convert_string(types[i].union_type.name));
200
208
  rb_hash_aset(rb_hash, CSTR2SYM("directives"), convert_array_of_directives(types[i].union_type.directives));
201
209
  rb_hash_aset(rb_hash, CSTR2SYM("values"), convert_array_of_strings(types[i].union_type.values));
202
- }
203
- else if (strcmp(types[i].typename, "input_object") == 0) {
210
+ } else if (strcmp(types[i].typename, "input_object") == 0) {
204
211
  rb_hash_aset(rb_hash, CSTR2SYM("typename"), convert_string(types[i].typename));
205
212
  rb_hash_aset(rb_hash, CSTR2SYM("description"), convert_string(types[i].input_object_type.description));
206
213
  rb_hash_aset(rb_hash, CSTR2SYM("name"), convert_string(types[i].input_object_type.name));
207
214
  rb_hash_aset(rb_hash, CSTR2SYM("directives"), convert_array_of_directives(types[i].input_object_type.directives));
208
215
  rb_hash_aset(rb_hash, CSTR2SYM("fields"), convert_array_of_fields(types[i].input_object_type.fields));
209
- }
210
- else {
216
+ } else {
211
217
  printf("\nError: Unknown type %s\n", types[i].typename);
212
218
  exit(1);
213
219
  }
214
220
 
215
- rb_ary_push(rb_definitions, rb_hash);
221
+ rb_ary_push(rb_types, rb_hash);
216
222
  }
217
223
 
218
- return rb_definitions;
224
+ rb_iv_set(rb_result, "@types", rb_types);
225
+ return rb_result;
219
226
  }
220
227
 
221
228
  void Init_graphqlidlparser()
@@ -224,4 +231,6 @@ void Init_graphqlidlparser()
224
231
  rb_cGraphQLIDLParser = rb_define_class_under(rb_mGraphQL, "IDLParser", rb_cObject);
225
232
 
226
233
  rb_define_method(rb_cGraphQLIDLParser, "process", GRAPHQLIDLPARSERPROCESS_process, 0);
234
+
235
+ rb_cResult = rb_define_class_under(rb_cGraphQLIDLParser, "Result", rb_cObject);
227
236
  }
@@ -25,4 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency 'pry-byebug'
26
26
  spec.add_development_dependency 'rake', '~> 10.0'
27
27
  spec.add_development_dependency 'rake-compiler', '~> 0.9'
28
+ spec.add_development_dependency 'rubocop'
29
+ spec.add_development_dependency 'rubocop-github'
28
30
  end
@@ -1,3 +1,3 @@
1
1
  class GraphQLIDLParser
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-idl-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen J. Torikian
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-14 00:00:00.000000000 Z
11
+ date: 2017-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,34 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.9'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-github
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  description:
98
126
  email:
99
127
  - gjtorikian@gmail.com
@@ -104,6 +132,7 @@ extra_rdoc_files: []
104
132
  files:
105
133
  - ".gitignore"
106
134
  - ".gitmodules"
135
+ - ".rubocop.yml"
107
136
  - ".travis.yml"
108
137
  - Gemfile
109
138
  - LICENSE.txt