gql 0.0.17 → 0.0.18

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 91c3e88c06f95f36b8f36526bce27d09799bec99
4
- data.tar.gz: fc749a590e76c66395a5f7d9bc8353368004053a
3
+ metadata.gz: dd01c67b3f0e68e96e94cccf2b52bdc7b0ef4683
4
+ data.tar.gz: e525e23f3345a58363e33af7c693cc5becc1570c
5
5
  SHA512:
6
- metadata.gz: 322528bd170fde6ab9d4ccfb70f4faa1619c4da64b9189b49f11899dc2a265db48ea08d6e95512e234d275845d13c733e70300ee7b039f434f8b1a956ab18e24
7
- data.tar.gz: b38aea1027e426fe732024b35ed37bf23bf41feb3cd31b63e62730f1f53be942452097d526a6569bd7b5c832b416bc1258363fe6f2bd40a7b684e42ccff9e078
6
+ metadata.gz: 5141e572b5eab687f99263e6195a146e0aff74a4ce8361abb1ef7eccacfcb6f785de58c9a9c5c908bc978701368382cf325d92a4024c0be4acdf42e4eb8521be
7
+ data.tar.gz: 633ae172c44ba70a937e0ab61ffb8fbff011f2b1ed6d172bb0f7ded9054c31203c33bc29fdad41aa4c95fcdfb603fb5c35811620a97a08d1aafd5b00edf66af9
data/lib/gql/array.rb CHANGED
@@ -1,34 +1,34 @@
1
1
  require 'active_support/core_ext/class/attribute'
2
2
 
3
3
  module GQL
4
- class Array < Node
5
- class_attribute :item_class, instance_accessor: false, instance_predicate: false
4
+ class Array < Field
5
+ class_attribute :item_field_class, instance_accessor: false, instance_predicate: false
6
6
 
7
7
  class << self
8
8
  def build_class(id, proc, options = {})
9
- item_class = options.delete(:item_class) || self.item_class
9
+ item_field_class = options.delete(:item_field_class) || self.item_field_class
10
10
 
11
- if item_class.is_a?(Hash)
12
- item_class.values.each do |klass|
13
- Node.validate_is_subclass! klass, 'item'
11
+ if item_field_class.is_a?(Hash)
12
+ item_field_class.values.each do |klass|
13
+ Field.validate_is_subclass! klass, 'item'
14
14
  end
15
15
  else
16
- Node.validate_is_subclass! item_class, 'item'
17
- item_class = Hash.new(item_class)
16
+ Field.validate_is_subclass! item_field_class, 'item'
17
+ item_field_class = Hash.new(item_field_class)
18
18
  end
19
19
 
20
20
  Class.new(self).tap do |field_class|
21
21
  field_class.id = id.to_s
22
22
  field_class.proc = proc
23
- field_class.item_class = item_class
23
+ field_class.item_field_class = item_field_class
24
24
  end
25
25
  end
26
26
  end
27
27
 
28
28
  def value
29
29
  target.map do |item|
30
- node = self.class.item_class[item.class].new(ast_node, item, variables, context)
31
- node.value
30
+ field = self.class.item_field_class[item.class].new(ast_node, item, variables, context)
31
+ field.value
32
32
  end
33
33
  end
34
34
  end
data/lib/gql/boolean.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module GQL
2
- class Boolean < Raw
2
+ class Boolean < Scalar
3
3
  end
4
4
  end
data/lib/gql/call.rb CHANGED
@@ -32,7 +32,7 @@ module GQL
32
32
  end
33
33
 
34
34
  def result_class_from_block(block)
35
- Class.new(Node).tap do |result_class|
35
+ Class.new(Field).tap do |result_class|
36
36
  result_class.field_proc = -> id { -> { target[id] } }
37
37
  result_class.class_eval(&block)
38
38
  end
data/lib/gql/config.rb CHANGED
@@ -2,16 +2,16 @@ require 'active_support/core_ext/class/subclasses'
2
2
 
3
3
  module GQL
4
4
  class Config
5
- def root_node_class
6
- @@root_node_class ||= nil
5
+ def root_field_class
6
+ @@root_field_class ||= nil
7
7
  end
8
8
 
9
- def root_node_class=(value)
10
- unless value.nil? || value <= Node
11
- raise Errors::InvalidNodeClass.new(value, Node)
9
+ def root_field_class=(value)
10
+ unless value.nil? || value <= Field
11
+ raise Errors::InvalidFieldClass.new(value, Field)
12
12
  end
13
13
 
14
- @@root_node_class = value
14
+ @@root_field_class = value
15
15
  end
16
16
 
17
17
  def root_target_proc
@@ -37,16 +37,16 @@ module GQL
37
37
  @@field_types = value
38
38
  end
39
39
 
40
- def default_list_class
41
- @@default_list_class ||= Node
40
+ def default_list_field_class
41
+ @@default_list_field_class ||= Field
42
42
  end
43
43
 
44
- def default_list_class=(value)
45
- unless value.nil? || value <= Node
46
- raise Errors::InvalidNodeClass.new(value, Node)
44
+ def default_list_field_class=(value)
45
+ unless value.nil? || value <= Field
46
+ raise Errors::InvalidFieldClass.new(value, Field)
47
47
  end
48
48
 
49
- @@default_list_class = value
49
+ @@default_list_field_class = value
50
50
  end
51
51
 
52
52
  def default_field_proc
@@ -96,31 +96,31 @@ module GQL
96
96
  end
97
97
 
98
98
  def switch_on_type_field
99
- return if Node.fields.has_key? :__type__
99
+ return if Field.has_field? :__type__
100
100
 
101
- type_field_class = Node.object :__type__, -> { field_class }, node_class: Schema::Field
101
+ type_field_class = Field.object :__type__, -> { field_class }, field_class: Schema::Field
102
102
 
103
- Node.descendants.each do |node_class|
104
- node_class.fields[:__type__] = type_field_class
103
+ Field.descendants.each do |field_class|
104
+ field_class.fields[:__type__] = type_field_class
105
105
  end
106
106
  end
107
107
 
108
108
  def switch_off_type_field
109
- return unless Node.fields.has_key? :__type__
109
+ return unless Field.has_field? :__type__
110
110
 
111
- [Node, *Node.descendants].each do |node_class|
112
- node_class.remove_field :__type__
111
+ [Field, *Field.descendants].each do |field_class|
112
+ field_class.remove_field :__type__
113
113
  end
114
114
  end
115
115
 
116
116
  def switch_on_execution_context
117
- Node.send :remove_const, :ExecutionContext if Node.const_defined?(:ExecutionContext)
118
- Node.const_set :ExecutionContext, Node::ExecutionContextDebug
117
+ Field.send :remove_const, :ExecutionContext if Field.const_defined?(:ExecutionContext)
118
+ Field.const_set :ExecutionContext, Field::ExecutionContextDebug
119
119
  end
120
120
 
121
121
  def switch_off_execution_context
122
- Node.send :remove_const, :ExecutionContext if Node.const_defined?(:ExecutionContext)
123
- Node.const_set :ExecutionContext, Node::ExecutionContextNoDebug
122
+ Field.send :remove_const, :ExecutionContext if Field.const_defined?(:ExecutionContext)
123
+ Field.const_set :ExecutionContext, Field::ExecutionContextNoDebug
124
124
  end
125
125
 
126
126
  end
@@ -1,16 +1,16 @@
1
1
  require 'active_support/core_ext/class/attribute'
2
2
 
3
3
  module GQL
4
- class Connection < Node
4
+ class Connection < Field
5
5
  class << self
6
6
  def build_class(id, proc, options = {})
7
- list_class = options.delete(:list_class) || GQL.default_list_class
8
- item_class = options.delete(:item_class)
7
+ list_field_class = options.delete(:list_field_class) || GQL.default_list_field_class
8
+ item_field_class = options.delete(:item_field_class)
9
9
 
10
- Node.validate_is_subclass! list_class, 'list'
10
+ Field.validate_is_subclass! list_field_class, 'list'
11
11
 
12
- list_class.build_class(id, proc, options).tap do |field_class|
13
- field_class.array :edges, -> { target }, item_class: item_class
12
+ list_field_class.build_class(id, proc, options).tap do |field_class|
13
+ field_class.array :edges, -> { target }, item_field_class: item_field_class
14
14
  end
15
15
  end
16
16
  end
data/lib/gql/errors.rb CHANGED
@@ -28,26 +28,26 @@ module GQL
28
28
  module Errors
29
29
  class NotFoundError < Error
30
30
  private
31
- def construct_message(node_class, id, name, method)
32
- items = node_class.send(method).keys.sort.map { |key| "`#{key}'" }
31
+ def construct_message(field_class, id, name, method)
32
+ items = field_class.send(method).keys.sort.map { |key| "`#{key}'" }
33
33
 
34
- msg = "#{node_class} has no #{name} named `#{id}'."
34
+ msg = "#{field_class} has no #{name} named `#{id}'."
35
35
  msg << " Available #{name.pluralize}: #{items.to_sentence}." if items.any?
36
36
  msg
37
37
  end
38
38
  end
39
39
 
40
40
  class CallNotFound < NotFoundError
41
- def initialize(id, node_class)
42
- msg = construct_message(node_class, id, 'call', :calls)
41
+ def initialize(id, field_class)
42
+ msg = construct_message(field_class, id, 'call', :calls)
43
43
 
44
44
  super(msg, 111, id)
45
45
  end
46
46
  end
47
47
 
48
48
  class FieldNotFound < NotFoundError
49
- def initialize(id, node_class)
50
- msg = construct_message(node_class, id, 'field', :fields)
49
+ def initialize(id, field_class)
50
+ msg = construct_message(field_class, id, 'field', :fields)
51
51
 
52
52
  super(msg, 112, id)
53
53
  end
@@ -61,37 +61,46 @@ module GQL
61
61
  end
62
62
  end
63
63
 
64
- class InvalidNodeClass < Error
64
+ class RootClassNotSet < Error
65
+ def initialize
66
+ msg = "GQL root field class is not set. "
67
+ msg << "Set it with `GQL.root_field_class = MyRootField'."
68
+
69
+ super(msg, 121)
70
+ end
71
+ end
72
+
73
+ class FieldClassNotSet < Error
74
+ def initialize(node_class, name)
75
+ msg = "#{node_class} must have a #{name} class set. "
76
+ msg << "Set it with `self.#{name}_class = My#{name.camelize}Class'."
77
+
78
+ super(msg, 122)
79
+ end
80
+ end
81
+
82
+ class InvalidFieldClass < Error
65
83
  def initialize(node_class, super_class)
66
84
  msg = "#{node_class} must be a (subclass of) #{super_class}."
67
85
 
68
- super(msg, 121)
86
+ super(msg, 123)
69
87
  end
70
88
  end
71
89
 
72
90
  class NoMethodError < Error
73
91
  attr_reader :cause
74
92
 
75
- def initialize(node_class, id, cause)
93
+ def initialize(field_class, id, cause)
76
94
  @cause = cause
77
95
 
78
- msg = "Undefined method `#{id}' for #{node_class}. "
96
+ msg = "Undefined method `#{id}' for #{field_class}. "
79
97
  msg << "Did you try to add a field of type `#{id}'? "
80
98
  msg << "If so, you have to register your field type first "
81
99
  msg << "like this: `GQL.field_types[:#{id}] = My#{id.to_s.camelize}'. "
82
100
  msg << "The following field types are currently registered: "
83
101
  msg << GQL.field_types.keys.sort.map { |key| "`#{key}'" }.to_sentence
84
102
 
85
- super(msg, 122)
86
- end
87
- end
88
-
89
- class RootClassNotSet < Error
90
- def initialize
91
- msg = "GQL root node class is not set. "
92
- msg << "Set it with `GQL.root_node_class = MyRootNode'."
93
-
94
- super(msg, 123)
103
+ super(msg, 124)
95
104
  end
96
105
  end
97
106
 
@@ -109,14 +118,5 @@ module GQL
109
118
  super(msg, 132, value)
110
119
  end
111
120
  end
112
-
113
- class UndefinedNodeClass < Error
114
- def initialize(node_class, name)
115
- msg = "#{node_class} must have a #{name} class set. "
116
- msg << "Set it with `self.#{name}_class = My#{name.camelize}Class'."
117
-
118
- super(msg, 124)
119
- end
120
- end
121
121
  end
122
122
  end
data/lib/gql/executor.rb CHANGED
@@ -8,16 +8,16 @@ module GQL
8
8
  end
9
9
 
10
10
  def execute(context = {}, vars = {})
11
- node_class = GQL.root_node_class
11
+ field_class = GQL.root_field_class
12
12
 
13
- raise Errors::RootClassNotSet if node_class.nil?
13
+ raise Errors::RootClassNotSet if field_class.nil?
14
14
 
15
15
  variables.update vars
16
16
 
17
17
  target = GQL.root_target_proc.call(context)
18
18
 
19
- node = node_class.new(ast_root, target, variables, context)
20
- node.value
19
+ field = field_class.new(ast_root, target, variables, context)
20
+ field.value
21
21
  end
22
22
  end
23
23
  end
@@ -4,7 +4,7 @@ require 'gql/has_calls'
4
4
  require 'gql/has_fields'
5
5
 
6
6
  module GQL
7
- class Node
7
+ class Field
8
8
  class_attribute :id, :proc, instance_accessor: false, instance_predicate: false
9
9
 
10
10
  class << self
@@ -17,11 +17,11 @@ module GQL
17
17
 
18
18
  def validate_is_subclass!(subclass, name)
19
19
  if subclass.nil?
20
- raise Errors::UndefinedNodeClass.new(self, name)
20
+ raise Errors::FieldClassNotSet.new(self, name)
21
21
  end
22
22
 
23
23
  unless subclass <= self
24
- raise Errors::InvalidNodeClass.new(subclass, self)
24
+ raise Errors::InvalidFieldClass.new(subclass, self)
25
25
  end
26
26
  end
27
27
  end
@@ -42,11 +42,11 @@ module GQL
42
42
  elsif ast_fields = ast_node.fields
43
43
  value_of_fields ast_fields
44
44
  else
45
- raw_value
45
+ scalar_value
46
46
  end
47
47
  end
48
48
 
49
- def raw_value
49
+ def scalar_value
50
50
  nil
51
51
  end
52
52
  end
data/lib/gql/has_calls.rb CHANGED
@@ -21,7 +21,7 @@ module GQL
21
21
  result_spec = options[:returns] || call_spec.try(:result_class)
22
22
  result_class = result_class_from_spec(result_spec)
23
23
 
24
- Node.validate_is_subclass! result_class, 'result' if result_class
24
+ Field.validate_is_subclass! result_class, 'result' if result_class
25
25
 
26
26
  call_class = call_class_from_spec(call_spec)
27
27
  call_class.id = id.to_s
@@ -65,12 +65,12 @@ module GQL
65
65
 
66
66
  def result_class_from_connection_spec(spec)
67
67
  if spec.size == 1
68
- spec.unshift GQL.default_list_class
68
+ spec.unshift GQL.default_list_field_class
69
69
  end
70
70
 
71
71
  options = {
72
- list_class: spec.first,
73
- item_class: spec.last
72
+ list_field_class: spec.first,
73
+ item_field_class: spec.last
74
74
  }
75
75
 
76
76
  Connection.build_class :result, nil, options
@@ -15,10 +15,10 @@ module GQL
15
15
  module ClassMethods
16
16
  def add_field(id, *args, &block)
17
17
  options = args.extract_options!
18
- type = options.delete(:type) || Node
18
+ type = options.delete(:type) || Field
19
19
  proc = args.shift || block || proc_for_field(id)
20
20
 
21
- Node.validate_is_subclass! type, 'type'
21
+ Field.validate_is_subclass! type, 'type'
22
22
 
23
23
  type.build_class(id, proc, options).tap do |field_class|
24
24
  const_name = const_name_for_field(id)
@@ -45,7 +45,7 @@ module GQL
45
45
  id = id_or_proc.is_a?(Proc) ? nil : id_or_proc
46
46
  proc = id ? -> { target.public_send(id) } : id_or_proc
47
47
 
48
- add_field :cursor, proc, type: Raw
48
+ add_field :cursor, proc, type: Scalar
49
49
  end
50
50
 
51
51
  def respond_to?(method, *args)
@@ -74,7 +74,7 @@ module GQL
74
74
  end
75
75
 
76
76
  def define_field_method(name, type)
77
- Node.define_singleton_method name do |*args, &block|
77
+ Field.define_singleton_method name do |*args, &block|
78
78
  options = args.extract_options!.merge(type: type)
79
79
  args = args.push(options)
80
80
 
data/lib/gql/number.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module GQL
2
- class Number < Raw
2
+ class Number < Scalar
3
3
  # This is just an example call. Monkeypatch class to add your own.
4
4
  call :is_zero, -> { target.zero? }, returns: Boolean
5
5
  end
data/lib/gql/object.rb CHANGED
@@ -1,14 +1,14 @@
1
1
  require 'active_support/core_ext/class/attribute'
2
2
 
3
3
  module GQL
4
- class Object < Node
4
+ class Object < Field
5
5
  class << self
6
6
  def build_class(id, proc, options = {})
7
- node_class = options.delete(:node_class)
7
+ field_class = options.delete(:field_class)
8
8
 
9
- Node.validate_is_subclass! node_class, 'node'
9
+ Field.validate_is_subclass! field_class, 'field'
10
10
 
11
- node_class.build_class id, proc, options
11
+ field_class.build_class id, proc, options
12
12
  end
13
13
  end
14
14
  end
data/lib/gql/parser.rb CHANGED
@@ -27,7 +27,7 @@ module_eval(<<'...end parser.racc/module_eval...', 'parser.racc', 136)
27
27
  end
28
28
  end
29
29
 
30
- class Node < Struct.new(:id, :alias_id, :call, :fields)
30
+ class Field < Struct.new(:id, :alias_id, :call, :fields)
31
31
  def as_json(*)
32
32
  {
33
33
  id: id,
@@ -301,14 +301,14 @@ module_eval(<<'.,.,', 'parser.racc', 4)
301
301
 
302
302
  module_eval(<<'.,.,', 'parser.racc', 8)
303
303
  def _reduce_2(val, _values, result)
304
- result = Node.new('[root]', nil, val[0], nil )
304
+ result = Field.new('[root]', nil, val[0], nil )
305
305
  result
306
306
  end
307
307
  .,.,
308
308
 
309
309
  module_eval(<<'.,.,', 'parser.racc', 9)
310
310
  def _reduce_3(val, _values, result)
311
- result = Node.new('[root]', nil, nil, val[1])
311
+ result = Field.new('[root]', nil, nil, val[1])
312
312
  result
313
313
  end
314
314
  .,.,
@@ -403,49 +403,49 @@ module_eval(<<'.,.,', 'parser.racc', 41)
403
403
 
404
404
  module_eval(<<'.,.,', 'parser.racc', 45)
405
405
  def _reduce_18(val, _values, result)
406
- result = Node.new(val[0], val[2], nil, val[1].presence)
406
+ result = Field.new(val[0], val[2], nil, val[1].presence)
407
407
  result
408
408
  end
409
409
  .,.,
410
410
 
411
411
  module_eval(<<'.,.,', 'parser.racc', 46)
412
412
  def _reduce_19(val, _values, result)
413
- result = Node.new(val[0], val[1], nil, val[2].presence)
413
+ result = Field.new(val[0], val[1], nil, val[2].presence)
414
414
  result
415
415
  end
416
416
  .,.,
417
417
 
418
418
  module_eval(<<'.,.,', 'parser.racc', 47)
419
419
  def _reduce_20(val, _values, result)
420
- result = Node.new(val[0], val[3], val[2], nil )
420
+ result = Field.new(val[0], val[3], val[2], nil )
421
421
  result
422
422
  end
423
423
  .,.,
424
424
 
425
425
  module_eval(<<'.,.,', 'parser.racc', 48)
426
426
  def _reduce_21(val, _values, result)
427
- result = Node.new(val[0], val[1], nil, nil )
427
+ result = Field.new(val[0], val[1], nil, nil )
428
428
  result
429
429
  end
430
430
  .,.,
431
431
 
432
432
  module_eval(<<'.,.,', 'parser.racc', 49)
433
433
  def _reduce_22(val, _values, result)
434
- result = Node.new(val[0], nil, nil, val[1].presence)
434
+ result = Field.new(val[0], nil, nil, val[1].presence)
435
435
  result
436
436
  end
437
437
  .,.,
438
438
 
439
439
  module_eval(<<'.,.,', 'parser.racc', 50)
440
440
  def _reduce_23(val, _values, result)
441
- result = Node.new(val[0], nil, val[2], nil )
441
+ result = Field.new(val[0], nil, val[2], nil )
442
442
  result
443
443
  end
444
444
  .,.,
445
445
 
446
446
  module_eval(<<'.,.,', 'parser.racc', 51)
447
447
  def _reduce_24(val, _values, result)
448
- result = Node.new(val[0], nil, nil, nil )
448
+ result = Field.new(val[0], nil, nil, nil )
449
449
  result
450
450
  end
451
451
  .,.,
data/lib/gql/scalar.rb ADDED
@@ -0,0 +1,7 @@
1
+ module GQL
2
+ class Scalar < Field
3
+ def scalar_value
4
+ target
5
+ end
6
+ end
7
+ end
@@ -1,14 +1,14 @@
1
1
  module GQL
2
2
  module Schema
3
- class Call < GQL::Node
3
+ class Call < GQL::Field
4
4
  cursor :id
5
5
 
6
6
  string :id
7
7
  string :name
8
- object :result_class, -> { target.result_class || CallerClass }, node_class: Field
9
- array :parameters, -> { (target.proc || target.instance_method(:execute)).parameters }, item_class: Parameter
8
+ object :result_class, -> { target.result_class || CallerClass }, field_class: Field
9
+ array :parameters, -> { (target.proc || target.instance_method(:execute)).parameters }, item_field_class: Parameter
10
10
 
11
- def raw_value
11
+ def scalar_value
12
12
  target.name
13
13
  end
14
14
  end
@@ -1,6 +1,6 @@
1
1
  module GQL
2
2
  module Schema
3
- class CallerClass < GQL::Node
3
+ class CallerClass < GQL::Field
4
4
  end
5
5
  end
6
6
  end
@@ -1,14 +1,14 @@
1
1
  module GQL
2
2
  module Schema
3
- class Field < GQL::Node
3
+ class Field < GQL::Field
4
4
  cursor :id
5
5
 
6
6
  string :id
7
7
  string :name
8
- connection :calls, -> { target.calls.values }, list_class: List, item_class: Call
9
- connection :fields, -> { target.fields.values }, list_class: List, item_class: Field
8
+ connection :calls, -> { target.calls.values }, list_field_class: List, item_field_class: Call
9
+ connection :fields, -> { target.fields.values }, list_field_class: List, item_field_class: Field
10
10
 
11
- def raw_value
11
+ def scalar_value
12
12
  target.name
13
13
  end
14
14
  end
@@ -1,6 +1,6 @@
1
1
  module GQL
2
2
  module Schema
3
- class List < GQL::Node
3
+ class List < GQL::Field
4
4
  call :count, returns: GQL::Number
5
5
  number :count
6
6
 
@@ -1,6 +1,6 @@
1
1
  module GQL
2
2
  module Schema
3
- class Parameter < GQL::Node
3
+ class Parameter < GQL::Field
4
4
  TYPES = {
5
5
  req: 'required',
6
6
  opt: 'optional',
@@ -16,7 +16,7 @@ module GQL
16
16
  string :id, -> { target[1].to_s }
17
17
  string :type, -> { TYPES[target[0]] || target[0].to_s }
18
18
 
19
- def raw_value
19
+ def scalar_value
20
20
  "#{target[1]} (#{TYPES[target[0]] || target[0]})"
21
21
  end
22
22
  end
data/lib/gql/string.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module GQL
2
- class String < Raw
2
+ class String < Scalar
3
3
  # These are just example calls. Monkeypatch class to add your own.
4
4
  call :upcase
5
5
  call :downcase
data/lib/gql/tokenizer.rb CHANGED
@@ -69,22 +69,25 @@ class GQL::Tokenizer < Racc::Parser
69
69
  when (text = @ss.scan(/-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/))
70
70
  action { [:NUMBER, text] }
71
71
 
72
- when (text = @ss.scan(/true/))
72
+ when (text = @ss.scan(/true\b/))
73
73
  action { [:TRUE, text] }
74
74
 
75
- when (text = @ss.scan(/false/))
75
+ when (text = @ss.scan(/false\b/))
76
76
  action { [:FALSE, text] }
77
77
 
78
- when (text = @ss.scan(/null/))
78
+ when (text = @ss.scan(/null\b/))
79
79
  action { [:NULL, text] }
80
80
 
81
- when (text = @ss.scan(/[aA][sS]/))
81
+ when (text = @ss.scan(/[aA][sS]\b/))
82
82
  action { [:AS, text] }
83
83
 
84
84
  when (text = @ss.scan(/[a-zA-Z_][a-zA-Z0-9_]*/))
85
85
  action { [:IDENT, text] }
86
86
 
87
- when (text = @ss.scan(/\s+/))
87
+ when (text = @ss.scan(/(?:[[:blank:]]|\f)+/))
88
+ ;
89
+
90
+ when (text = @ss.scan(/\r?\n/))
88
91
  ;
89
92
 
90
93
  when (text = @ss.scan(/./))
data/lib/gql/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module GQL
2
- VERSION = '0.0.17'
2
+ VERSION = '0.0.18'
3
3
  end
data/lib/gql.rb CHANGED
@@ -11,11 +11,11 @@ module GQL
11
11
  autoload :Connection
12
12
  autoload :Error, 'gql/errors'
13
13
  autoload :Executor
14
- autoload :Node
14
+ autoload :Field
15
15
  autoload :Number
16
16
  autoload :Object
17
17
  autoload :Parser
18
- autoload :Raw
18
+ autoload :Scalar
19
19
  autoload :String
20
20
  autoload :TestCase
21
21
  autoload :Tokenizer
@@ -25,13 +25,13 @@ module GQL
25
25
 
26
26
  autoload_at 'gql/errors' do
27
27
  autoload :CallNotFound
28
+ autoload :FieldClassNotSet
28
29
  autoload :FieldNotFound
29
- autoload :InvalidNodeClass
30
+ autoload :InvalidFieldClass
30
31
  autoload :NoMethodError
31
32
  autoload :RootClassNotSet
32
33
  autoload :ScanError
33
34
  autoload :SyntaxError
34
- autoload :UndefinedNodeClass
35
35
  autoload :VariableNotFound
36
36
  end
37
37
  end
@@ -55,8 +55,8 @@ module GQL
55
55
  Thread.current[:gql_config] = value
56
56
  end
57
57
 
58
- %w(root_node_class root_target_proc field_types
59
- default_list_class default_field_proc
58
+ %w(root_field_class root_target_proc field_types
59
+ default_list_field_class default_field_proc
60
60
  default_call_proc debug).each do |method|
61
61
  module_eval <<-DELEGATORS, __FILE__, __LINE__ + 1
62
62
  def #{method}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Andert
@@ -111,13 +111,13 @@ files:
111
111
  - lib/gql/connection.rb
112
112
  - lib/gql/errors.rb
113
113
  - lib/gql/executor.rb
114
+ - lib/gql/field.rb
114
115
  - lib/gql/has_calls.rb
115
116
  - lib/gql/has_fields.rb
116
- - lib/gql/node.rb
117
117
  - lib/gql/number.rb
118
118
  - lib/gql/object.rb
119
119
  - lib/gql/parser.rb
120
- - lib/gql/raw.rb
120
+ - lib/gql/scalar.rb
121
121
  - lib/gql/schema/call.rb
122
122
  - lib/gql/schema/caller_class.rb
123
123
  - lib/gql/schema/field.rb
data/lib/gql/raw.rb DELETED
@@ -1,7 +0,0 @@
1
- module GQL
2
- class Raw < Node
3
- def raw_value
4
- target
5
- end
6
- end
7
- end