graphql-idl-parser 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 140e46859bc93230d1d6ab77585ac60add046620
4
+ data.tar.gz: 3763416e5e5495e9c002c31b2d7250d989074f5a
5
+ SHA512:
6
+ metadata.gz: e564993dbc210343566966090c19e225fcaf3d1dbed9a231d207d2ed533a904bf2289b2fb39fefb9504b9bd871f7a22427a27a66d621f95a917c38aafbb41d1f
7
+ data.tar.gz: c9bf8c3221a7604a08292c42045aa6c9377579b024674f19dfc00e36dec500762c3b6c3d78818be6a6950d6023b97664886eb15a423107d4d22ff31d54f84193
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ _yardoc
2
+ .yardoc
3
+ .DS_Store
4
+ .config
5
+ *.bundle
6
+ *.gif
7
+ *.rbc
8
+ *.so
9
+ .byebug_history
10
+ /vendor/cache/ruby/
11
+ /vendor/gems/
12
+ /vendor/ruby
13
+ bin/
14
+ tmp/
15
+ /Gemfile.lock
16
+
17
+ .byebug_history
data/.gitmodules ADDED
@@ -0,0 +1,4 @@
1
+ [submodule "ext/graphql-idl-parser/graphql-idl-parser"]
2
+ path = ext/graphql-idl-parser/graphql-idl-parser
3
+ url = git@github.com:gjtorikian/graphql-idl-parser.git
4
+ ignore = dirty
data/.travis.yml ADDED
@@ -0,0 +1,28 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ cache:
6
+ directories:
7
+ - $HOME/.rvm/gems
8
+ - $HOME/.cargo
9
+ - $HOME/.multirust
10
+
11
+ env:
12
+ global:
13
+ - RUST_VERSION=stable
14
+
15
+ git:
16
+ depth: 10
17
+ submodules: false
18
+
19
+ before_install:
20
+ - sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules
21
+ - git submodule update --init --recursive
22
+ # Install Rust
23
+ - if [ ! -e "$HOME/.cargo/bin" ]; then curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain $RUST_VERSION -y; fi
24
+ - export PATH="$HOME/.cargo/bin:$PATH"
25
+ - rustup default $RUST_VERSION
26
+
27
+ script:
28
+ - script/cibuild
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in graphql-idl-parser.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Garen Torikian
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # GraphQL-IDL-Parser
2
+
3
+ This gem will accept a GraphQL IDL file and parse it. It uses [gjtorikian/graphql-idl-parser](https://github.com/gjtorikian/graphql-idl-parser) as the mechanism
4
+ for this, which is written in Rust, making this blazing fast.
5
+
6
+ [![Build Status](https://travis-ci.org/gjtorikian/graphql-idl-parser-ruby.svg?branch=master)](https://travis-ci.org/gjtorikian/graphql-idl-parser-ruby)
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'graphql-idl-parser'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install graphql-idl-parser
23
+
24
+ ## Usage
25
+
26
+ ``` ruby
27
+ # feed it a file
28
+ parser = GraphQL::IDLParser.new(filename: contents)
29
+
30
+ # or feed it a string
31
+ parser = GraphQL::IDLParser.new(schema: contents)
32
+
33
+ # execute!
34
+ results = parser.process
35
+ ```
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+ require 'rake/clean'
4
+ require 'rake/extensiontask'
5
+
6
+ task default: :test
7
+
8
+ Rake::TestTask.new(:test) do |t|
9
+ t.libs << 'test'
10
+ t.libs << 'lib'
11
+ t.test_files = FileList['test/**/*_test.rb']
12
+ end
13
+
14
+ # Gem Spec
15
+ gem_spec = Gem::Specification.load('graphql-idl-parser.gemspec')
16
+
17
+ Rake::ExtensionTask.new('graphql-idl-parser', gem_spec) do |ext|
18
+ ext.name = 'graphqlidlparser'
19
+ ext.lib_dir = File.join('lib', 'graphql-idl-parser')
20
+ end
21
+
22
+ desc 'Pretty format C code'
23
+ task :format do
24
+ puts `astyle --indent=spaces=2 --style=1tbs --keep-one-line-blocks \
25
+ $(ack -n -f --type=cpp --type=cc ext/graphql-idl-parser/)`
26
+ end
27
+
28
+ desc 'Benchmark loading an IDL file'
29
+ task :benchmark do
30
+ require 'benchmark'
31
+ require 'graphql'
32
+ require 'graphql-idl-parser'
33
+
34
+ schema = File.read(File.join('ext', 'graphql-idl-parser', 'graphql-idl-parser', 'test', 'github.graphql'))
35
+
36
+ Benchmark.bm(10) do |x|
37
+ x.report('this-gem: ') { parser = GraphQL::IDLParser.new(schema: schema); parser.process }
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ require 'fileutils'
2
+ require 'mkmf'
3
+ require 'rbconfig'
4
+ include FileUtils
5
+
6
+ LIBDIR = RbConfig::CONFIG['libdir']
7
+ INCLUDEDIR = RbConfig::CONFIG['includedir']
8
+ EXT_DIR = File.expand_path(File.join(File.dirname(__FILE__), 'graphql-idl-parser'))
9
+ FFI_DIR = File.expand_path(File.join(EXT_DIR, 'graphql-idl-parser-ffi'))
10
+ HEADER_DIR = File.expand_path(File.join(EXT_DIR, 'graphql-idl-parser-ffi', 'includes'))
11
+
12
+ if ENV['TRAVIS']
13
+ type = 'debug'
14
+ target = ''
15
+ flag = '-O0'
16
+ else
17
+ type = 'release'
18
+ target = '--release'
19
+ flag = '-O2'
20
+ end
21
+
22
+ RELEASE_DIR = File.join(FFI_DIR, 'target', type)
23
+
24
+ if !system('cargo --version') || !system('rustc --version')
25
+ raise '\n\n\n[ERROR]: You have to install Rust with Cargo (https://www.rust-lang.org/)'
26
+ end
27
+
28
+ `cargo build #{target} --manifest-path #{File.join(FFI_DIR, 'Cargo.toml')}`
29
+
30
+ $LIBS << ' -lgraphqlidlparser'
31
+
32
+ HEADER_DIRS = [INCLUDEDIR, HEADER_DIR]
33
+ LIB_DIRS = [LIBDIR, RELEASE_DIR]
34
+
35
+ dir_config('graphql-idl-parser', HEADER_DIRS, LIB_DIRS)
36
+
37
+ $CFLAGS << " #{flag} -std=c11 -Wall -pedantic -Werror -Wfatal-errors -Wstrict-aliasing"
38
+
39
+ create_makefile('graphql-idl-parser/graphqlidlparser')
@@ -0,0 +1,227 @@
1
+ #include "graphql-idl-parser.h"
2
+
3
+ static VALUE rb_mGraphQL;
4
+ static VALUE rb_cGraphQLIDLParser;
5
+
6
+ VALUE convert_string(const char* c_string) {
7
+ VALUE rb_string;
8
+ int enc;
9
+
10
+ if (c_string == NULL) {
11
+ return Qnil;
12
+ }
13
+
14
+ rb_string = rb_str_new2(c_string);
15
+ enc = rb_enc_find_index("UTF-8");
16
+ rb_enc_associate_index(rb_string, enc);
17
+
18
+ return rb_string;
19
+ }
20
+
21
+ VALUE convert_type_info(struct FieldType c_field_type) {
22
+ VALUE rb_hash = rb_hash_new();
23
+
24
+ rb_hash_aset(rb_hash, CSTR2SYM("name"), convert_string(c_field_type.name));
25
+ rb_hash_aset(rb_hash, CSTR2SYM("info"), convert_string(c_field_type.info));
26
+
27
+ return rb_hash;
28
+ }
29
+
30
+ VALUE convert_array_of_strings(struct array_of_strings c_array_of_strings) {
31
+ VALUE rb_array = rb_ary_new();
32
+ size_t i;
33
+
34
+ if (c_array_of_strings.length == 0) {
35
+ return rb_array;
36
+ }
37
+
38
+ for (i = 0; i < c_array_of_strings.length; i++) {
39
+ rb_ary_push(rb_array, convert_string(c_array_of_strings.data[i]));
40
+ }
41
+
42
+ return rb_array;
43
+ }
44
+
45
+ VALUE convert_array_of_arguments(struct array_of_arguments c_array_of_arguments) {
46
+ VALUE rb_array = rb_ary_new();
47
+ VALUE rb_hash;
48
+ size_t i;
49
+
50
+ if (c_array_of_arguments.length == 0) {
51
+ return rb_array;
52
+ }
53
+
54
+ for (i = 0; i < c_array_of_arguments.length; i++) {
55
+ rb_hash = rb_hash_new();
56
+
57
+ rb_hash_aset(rb_hash, CSTR2SYM("name"), convert_string(c_array_of_arguments.data[i].name));
58
+ rb_hash_aset(rb_hash, CSTR2SYM("description"), convert_string(c_array_of_arguments.data[i].description));
59
+ rb_hash_aset(rb_hash, CSTR2SYM("type_info"), convert_type_info(c_array_of_arguments.data[i].type_info));
60
+ rb_hash_aset(rb_hash, CSTR2SYM("default_value"), convert_string(c_array_of_arguments.data[i].default_value));
61
+ rb_hash_aset(rb_hash, CSTR2SYM("directives"), convert_array_of_directives(c_array_of_arguments.data[i].directives));
62
+
63
+ rb_ary_push(rb_array, rb_hash);
64
+ }
65
+
66
+ return rb_array;
67
+ }
68
+
69
+ VALUE convert_array_of_fields(struct array_of_fields c_array_of_fields) {
70
+ VALUE rb_array = rb_ary_new();
71
+ VALUE rb_hash;
72
+ size_t i;
73
+
74
+ if (c_array_of_fields.length == 0) {
75
+ return rb_array;
76
+ }
77
+
78
+ for (i = 0; i < c_array_of_fields.length; i++) {
79
+ rb_hash = rb_hash_new();
80
+
81
+ rb_hash_aset(rb_hash, CSTR2SYM("name"), convert_string(c_array_of_fields.data[i].name));
82
+ rb_hash_aset(rb_hash, CSTR2SYM("description"), convert_string(c_array_of_fields.data[i].description));
83
+ rb_hash_aset(rb_hash, CSTR2SYM("type_info"), convert_type_info(c_array_of_fields.data[i].type_info));
84
+ rb_hash_aset(rb_hash, CSTR2SYM("arguments"), convert_array_of_arguments(c_array_of_fields.data[i].arguments));
85
+ rb_hash_aset(rb_hash, CSTR2SYM("directives"), convert_array_of_directives(c_array_of_fields.data[i].directives));
86
+
87
+ rb_ary_push(rb_array, rb_hash);
88
+ }
89
+
90
+ return rb_array;
91
+ }
92
+
93
+ VALUE convert_array_of_values(struct array_of_values c_array_of_values) {
94
+ VALUE rb_array = rb_ary_new();
95
+ VALUE rb_hash;
96
+ size_t i;
97
+
98
+ if (c_array_of_values.length == 0) {
99
+ return rb_array;
100
+ }
101
+
102
+ for (i = 0; i < c_array_of_values.length; i++) {
103
+ rb_hash = rb_hash_new();
104
+ rb_hash_aset(rb_hash, CSTR2SYM("name"), convert_string(c_array_of_values.data[i].name));
105
+ rb_hash_aset(rb_hash, CSTR2SYM("description"), convert_string(c_array_of_values.data[i].description));
106
+ rb_hash_aset(rb_hash, CSTR2SYM("directives"), convert_array_of_directives(c_array_of_values.data[i].directives));
107
+
108
+ rb_ary_push(rb_array, rb_hash);
109
+ }
110
+
111
+ return rb_array;
112
+ }
113
+
114
+ VALUE convert_array_of_directives(struct array_of_directives c_array_of_directives) {
115
+ VALUE rb_array = rb_ary_new();
116
+ VALUE rb_hash;
117
+ VALUE rb_arguments_array;
118
+ VALUE rb_arguments_hash;
119
+
120
+ size_t i, j;
121
+
122
+ if (c_array_of_directives.length == 0) {
123
+ return rb_array;
124
+ }
125
+
126
+ for (i = 0; i < c_array_of_directives.length; i++) {
127
+ rb_hash = rb_hash_new();
128
+ rb_arguments_array = rb_ary_new();
129
+
130
+ rb_hash_aset(rb_hash, CSTR2SYM("name"), convert_string(c_array_of_directives.data[i].name));
131
+ rb_hash_aset(rb_hash, CSTR2SYM("arguments"), rb_arguments_array);
132
+
133
+ for (j = 0; j < c_array_of_directives.data[i].arguments.length; j++) {
134
+ rb_arguments_hash = rb_hash_new();
135
+ rb_hash_aset(rb_arguments_hash, CSTR2SYM("name"), convert_string(c_array_of_directives.data[i].arguments.data[j].name));
136
+ rb_hash_aset(rb_arguments_hash, CSTR2SYM("value"), convert_string(c_array_of_directives.data[i].arguments.data[j].value));
137
+
138
+ rb_ary_push(rb_arguments_array, rb_arguments_hash);
139
+ }
140
+
141
+ rb_ary_push(rb_array, rb_hash);
142
+ }
143
+
144
+ return rb_array;
145
+ }
146
+
147
+ static VALUE GRAPHQLIDLPARSERPROCESS_process(VALUE self)
148
+ {
149
+ VALUE rb_schema = rb_iv_get(self, "@schema");
150
+ VALUE rb_definitions;
151
+ VALUE rb_hash;
152
+ GraphQLTypes* types = NULL;
153
+ size_t types_len = 0;
154
+ uint8_t err;
155
+ const char *schema = StringValueCStr(rb_schema);
156
+
157
+ err = gqlidl_parse_schema(schema, &types, &types_len);
158
+
159
+ if (err > 0) {
160
+ printf("Error: Return code %d", err);
161
+ exit(err);
162
+ }
163
+
164
+ rb_definitions = rb_ary_new();
165
+
166
+ for (size_t i = 0; i < types_len; i++) {
167
+ rb_hash = rb_hash_new();
168
+
169
+ if (strcmp(types[i].typename, "scalar") == 0) {
170
+ rb_hash_aset(rb_hash, CSTR2SYM("typename"), convert_string(types[i].typename));
171
+ rb_hash_aset(rb_hash, CSTR2SYM("name"), convert_string(types[i].scalar_type.name));
172
+ rb_hash_aset(rb_hash, CSTR2SYM("description"), convert_string(types[i].scalar_type.description));
173
+ }
174
+ else if (strcmp(types[i].typename, "object") == 0) {
175
+ rb_hash_aset(rb_hash, CSTR2SYM("typename"), convert_string(types[i].typename));
176
+ rb_hash_aset(rb_hash, CSTR2SYM("description"), convert_string(types[i].object_type.description));
177
+ rb_hash_aset(rb_hash, CSTR2SYM("name"), convert_string(types[i].object_type.name));
178
+ rb_hash_aset(rb_hash, CSTR2SYM("implements"), convert_array_of_strings(types[i].object_type.implements));
179
+ rb_hash_aset(rb_hash, CSTR2SYM("directives"), convert_array_of_directives(types[i].object_type.directives));
180
+ 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) {
183
+ rb_hash_aset(rb_hash, CSTR2SYM("typename"), convert_string(types[i].typename));
184
+ rb_hash_aset(rb_hash, CSTR2SYM("description"), convert_string(types[i].enum_type.description));
185
+ rb_hash_aset(rb_hash, CSTR2SYM("name"), convert_string(types[i].enum_type.name));
186
+ rb_hash_aset(rb_hash, CSTR2SYM("directives"), convert_array_of_directives(types[i].enum_type.directives));
187
+ 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) {
190
+ rb_hash_aset(rb_hash, CSTR2SYM("typename"), convert_string(types[i].typename));
191
+ rb_hash_aset(rb_hash, CSTR2SYM("description"), convert_string(types[i].interface_type.description));
192
+ rb_hash_aset(rb_hash, CSTR2SYM("name"), convert_string(types[i].interface_type.name));
193
+ rb_hash_aset(rb_hash, CSTR2SYM("directives"), convert_array_of_directives(types[i].interface_type.directives));
194
+ 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) {
197
+ rb_hash_aset(rb_hash, CSTR2SYM("typename"), convert_string(types[i].typename));
198
+ rb_hash_aset(rb_hash, CSTR2SYM("description"), convert_string(types[i].union_type.description));
199
+ rb_hash_aset(rb_hash, CSTR2SYM("name"), convert_string(types[i].union_type.name));
200
+ rb_hash_aset(rb_hash, CSTR2SYM("directives"), convert_array_of_directives(types[i].union_type.directives));
201
+ 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) {
204
+ rb_hash_aset(rb_hash, CSTR2SYM("typename"), convert_string(types[i].typename));
205
+ rb_hash_aset(rb_hash, CSTR2SYM("description"), convert_string(types[i].input_object_type.description));
206
+ rb_hash_aset(rb_hash, CSTR2SYM("name"), convert_string(types[i].input_object_type.name));
207
+ rb_hash_aset(rb_hash, CSTR2SYM("directives"), convert_array_of_directives(types[i].input_object_type.directives));
208
+ rb_hash_aset(rb_hash, CSTR2SYM("fields"), convert_array_of_fields(types[i].input_object_type.fields));
209
+ }
210
+ else {
211
+ printf("\nError: Unknown type %s\n", types[i].typename);
212
+ exit(1);
213
+ }
214
+
215
+ rb_ary_push(rb_definitions, rb_hash);
216
+ }
217
+
218
+ return rb_definitions;
219
+ }
220
+
221
+ void Init_graphqlidlparser()
222
+ {
223
+ rb_mGraphQL = rb_define_module("GraphQL");
224
+ rb_cGraphQLIDLParser = rb_define_class_under(rb_mGraphQL, "IDLParser", rb_cObject);
225
+
226
+ rb_define_method(rb_cGraphQLIDLParser, "process", GRAPHQLIDLPARSERPROCESS_process, 0);
227
+ }
@@ -0,0 +1,27 @@
1
+ #ifndef GRAPHQLIDLPARSER_H
2
+ #define GRAPHQLIDLPARSER_H
3
+
4
+ #ifndef __MSXML_LIBRARY_DEFINED__
5
+ #define __MSXML_LIBRARY_DEFINED__
6
+ #endif
7
+
8
+ #define CSTR2SYM(s) (ID2SYM(rb_intern((s))))
9
+
10
+ #include "ruby.h"
11
+ #include <ruby/encoding.h>
12
+ #include "gql-idl-parser.h"
13
+
14
+ #include "graphql-idl-parser.h"
15
+
16
+ static VALUE rb_mGraphQL;
17
+ static VALUE rb_cGraphQLIDLParser;
18
+
19
+ VALUE convert_string(const char* c_string);
20
+ VALUE convert_type_info(struct FieldType c_field_type);
21
+ VALUE convert_array_of_strings(struct array_of_strings c_array_of_strings);
22
+ VALUE convert_array_of_arguments(struct array_of_arguments c_array_of_arguments);
23
+ VALUE convert_array_of_fields(struct array_of_fields c_array_of_fields);
24
+ VALUE convert_array_of_values(struct array_of_values c_array_of_values);
25
+ VALUE convert_array_of_directives(struct array_of_directives c_array_of_directives);
26
+
27
+ #endif
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'graphql-idl-parser/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'graphql-idl-parser'
8
+ spec.version = GraphQLIDLParser::VERSION
9
+ spec.authors = ['Garen J. Torikian']
10
+ spec.email = ['gjtorikian@gmail.com']
11
+
12
+ spec.summary = 'A parser for the GraphQL IDL format.'
13
+ spec.homepage = 'https://www.github.com/gjtorikian/graphql-idl-parser-ruby'
14
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
15
+ f.match(%r{^(test|spec|features)/})
16
+ end
17
+ spec.bindir = 'exe'
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+ spec.extensions = ['ext/graphql-idl-parser/extconf.rb']
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.14'
23
+ spec.add_development_dependency 'graphql', '~> 1.6'
24
+ spec.add_development_dependency 'minitest', '~> 5.0'
25
+ spec.add_development_dependency 'pry-byebug'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'rake-compiler', '~> 0.9'
28
+ end
@@ -0,0 +1,34 @@
1
+ require 'graphql-idl-parser/graphqlidlparser'
2
+ require 'graphql-idl-parser/version'
3
+
4
+ module GraphQL
5
+ class IDLParser
6
+ def initialize(filename: nil, schema: nil)
7
+ if !filename.nil? && !schema.nil?
8
+ raise ArgumentError, 'Pass in `filename` or `schema`, but not both!'
9
+ end
10
+
11
+ if filename.nil? && schema.nil?
12
+ raise ArgumentError, 'Pass in either `filename` or `schema`'
13
+ end
14
+
15
+ if filename
16
+ unless filename.is_a?(String)
17
+ raise TypeError, "Expected `String`, got `#{filename.class}`"
18
+ end
19
+
20
+ unless File.exist?(filename)
21
+ raise ArgumentError, "#{filename} does not exist!"
22
+ end
23
+
24
+ @schema = File.read(filename)
25
+ else
26
+ unless schema.is_a?(String)
27
+ raise TypeError, "Expected `String`, got `#{schema.class}`"
28
+ end
29
+
30
+ @schema = schema
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ class GraphQLIDLParser
2
+ VERSION = '0.0.1'.freeze
3
+ end
data/script/bootstrap ADDED
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ echo "==> Initing Git submodules"
6
+
7
+ git submodule update --init --recursive
8
+
9
+ echo "==> Installing gem dependencies…"
10
+
11
+ bundle install --path vendor/gems --local --standalone --clean "$@"
data/script/cibuild ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+
3
+ bundle exec rake compile
4
+
5
+ bundle exec rake test
@@ -0,0 +1,21 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ if [ -z "$1" ]; then
6
+ BRANCH="master"
7
+ else
8
+ BRANCH=$1
9
+ fi
10
+
11
+ echo "Using $BRANCH..."
12
+
13
+ echo "Checking out graphql-idl-parser"
14
+ echo "---------------------"
15
+ cd ext/graphql-idl-parser/graphql-idl-parser
16
+ git fetch origin
17
+ git checkout $BRANCH && git pull
18
+ sha=`git rev-parse HEAD`
19
+ cd ../../..
20
+ git add ext/graphql-idl-parser/graphql-idl-parser
21
+ git commit -m "Update graphql-idl-parser to $(git config submodule.ext/graphql-idl-parser/graphql-idl-parser.url | sed s_.git\$__)/commit/${sha}"
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: graphql-idl-parser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Garen J. Torikian
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-08-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: graphql
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-byebug
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: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake-compiler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.9'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.9'
97
+ description:
98
+ email:
99
+ - gjtorikian@gmail.com
100
+ executables: []
101
+ extensions:
102
+ - ext/graphql-idl-parser/extconf.rb
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".gitmodules"
107
+ - ".travis.yml"
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - ext/graphql-idl-parser/extconf.rb
113
+ - ext/graphql-idl-parser/graphql-idl-parser.c
114
+ - ext/graphql-idl-parser/graphql-idl-parser.h
115
+ - graphql-idl-parser.gemspec
116
+ - lib/graphql-idl-parser.rb
117
+ - lib/graphql-idl-parser/version.rb
118
+ - script/bootstrap
119
+ - script/cibuild
120
+ - script/update_submodules
121
+ homepage: https://www.github.com/gjtorikian/graphql-idl-parser-ruby
122
+ licenses: []
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 2.6.12
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: A parser for the GraphQL IDL format.
144
+ test_files: []