apiql 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/apiql.gemspec +1 -1
  3. data/lib/apiql.rb +10 -8
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b31f3704ac2a7144b1d492f13cddc83b3c722cd5db52ecee24efa8889cdc4fc7
4
- data.tar.gz: f2c5ebc7381cd7b2fd2f9cb886e674f8c68fc193071ba98a1edeb4c19b570a20
3
+ metadata.gz: 63b4f97269f59d36c635c7b748139aaa028ee54d39693d6f0f44e047448fbf50
4
+ data.tar.gz: 2b349ebef9fc19be13bff57f40a3b35dbb9b87fd749087da5b57f2d853442c83
5
5
  SHA512:
6
- metadata.gz: 92e64b9e2d197e22cb01eb14a97448551d49e89c03af894646d993abed04b8fd08c558216f82a2f7a00cd2e19bced08bac1cf3642e3b9fc7fb792ab6ed8186dc
7
- data.tar.gz: 16460fa4e99dbd0ab42ca676f7f95a758b9d5ef83f63e07a8fe4483a5dc818145b8e873a6f2a9ecbdc10abf182ba9e7b9d64e0a0250290ed5cd98cdb828909a1
6
+ metadata.gz: ca5733013a1f7346c3ec80f9baab183694d8a2681a1f91d926c7827ae2d52014389a050d6ff5b3aefbec9da46e0bb28a5b89fc0d68cf318d62fa6f7e8baf03ea
7
+ data.tar.gz: e6b7644edb288b4cf7f4b729706b292e4ca0aad43e251bf4862cb7024ccf15e12b60306616a0b9075ed3648209b6ff18ac41084dd7bb9968b1de680becb9b1e6
data/apiql.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'apiql'
7
- spec.version = '0.3.5'
7
+ spec.version = '0.3.6'
8
8
  spec.authors = ['Dmitry Silchenko']
9
9
  spec.email = ['dmitry@desofto.com']
10
10
 
data/lib/apiql.rb CHANGED
@@ -101,15 +101,15 @@ class APIQL
101
101
  end
102
102
 
103
103
  ptr.push(key)
104
- elsif reg = schema.match(/\A\s*(?<name>[\w\.]+)(\((?<params>((\w+)(\s*\,\s*\w+)*))?\))?\s*\{(?<rest>.*)\z/m)
104
+ elsif reg = schema.match(/\A\s*((?<alias>[\w\.]+):\s*)?(?<name>[\w\.]+)(\((?<params>((\w+)(\s*\,\s*\w+)*))?\))?\s*\{(?<rest>.*)\z/m)
105
105
  schema = reg[:rest]
106
106
 
107
107
  pool.push(ptr)
108
- ptr.push("#{reg[:name]}(#{reg[:params]})" => (ptr = []))
109
- elsif reg = schema.match(/\A\s*(?<name>[\w\.]+)(\((?<params>((\w+)(\s*\,\s*\w+)*))?\))?\s*\n?(?<rest>.*)\z/m)
108
+ ptr.push("#{reg[:alias] || reg[:name]}: #{reg[:name]}(#{reg[:params]})" => (ptr = []))
109
+ elsif reg = schema.match(/\A\s*((?<alias>[\w\.]+):\s*)?(?<name>[\w\.]+)(\((?<params>((\w+)(\s*\,\s*\w+)*))?\))?\s*\n?(?<rest>.*)\z/m)
110
110
  schema = reg[:rest]
111
111
 
112
- ptr.push("#{reg[:name]}(#{reg[:params]})")
112
+ ptr.push("#{reg[:alias] || reg[:name]}: #{reg[:name]}(#{reg[:params]})")
113
113
  else
114
114
  raise Error, schema
115
115
  end
@@ -138,9 +138,10 @@ class APIQL
138
138
  schema.map do |call|
139
139
  if call.is_a? ::Hash
140
140
  call.each do |function, sub_schema|
141
- reg = function.match(/\A(?<name>[\w\.]+)(\((?<params>.*?)\))?\z/)
141
+ reg = function.match(/\A((?<alias>[\w\.]+):\s*)?(?<name>[\w\.]+)(\((?<params>.*?)\))?\z/)
142
142
  raise Error, function unless reg.present?
143
143
 
144
+ name = reg[:alias] || reg[:name]
144
145
  function = reg[:name]
145
146
  params = @context.parse_params(reg[:params].presence)
146
147
 
@@ -154,12 +155,13 @@ class APIQL
154
155
  end
155
156
  end
156
157
 
157
- result[function] = @context.render_value(data, sub_schema)
158
+ result[name] = @context.render_value(data, sub_schema)
158
159
  end
159
160
  else
160
- reg = call.match(/\A(?<name>[\w\.]+)(\((?<params>.*?)\))?\z/)
161
+ reg = call.match(/\A((?<alias>[\w\.]+):\s*)?(?<name>[\w\.]+)(\((?<params>.*?)\))?\z/)
161
162
  raise Error, call unless reg.present?
162
163
 
164
+ name = reg[:alias] || reg[:name]
163
165
  function = reg[:name]
164
166
  params = @context.parse_params(reg[:params].presence)
165
167
 
@@ -173,7 +175,7 @@ class APIQL
173
175
  data = nil
174
176
  end
175
177
 
176
- result[function] = data
178
+ result[name] = data
177
179
  end
178
180
  end
179
181
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apiql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Silchenko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-25 00:00:00.000000000 Z
11
+ date: 2018-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler