sparkql 1.1.3 → 1.1.4

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjU4ZTc2ZWNiYjIyODYxYjNmZTY1ZmZmOGExZTc2MmRkMGFjMGIwYg==
4
+ YTM5ZTA1MmJlMzc4M2IwMjEyMGIyOTI2MjdiNGFjOTRhZmFjMDJjNw==
5
5
  data.tar.gz: !binary |-
6
- MzBjYjdhY2E3MTNlMDZjMzU5MDI3NTYzZTVlMDE0NmZiMzQ0OTc4Yg==
6
+ ODdmZjYxZWNhMDBiMzlhMmMwODUzY2NmOGU0OTM3ODExOTc5OTNhZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZmQ5NjAxMTg4M2FlMTI1ZjJkMmZmNzQ5OGMwYTNiYWQxNTk0OWU2ZGI0ZDZm
10
- MTQwZDQ3ZDViY2U4NDIyNDU2ODg2NjlmZDgwZDEzZWY4ZGM4NTgyNWFlMzJh
11
- MjExZmUxZjA2MTI1OTBiMzgxMWEzNDljNzE3YTRhM2YyNmZjMTY=
9
+ ZmVkZTE3YTllMGNjNzA2YmJjZTAxMjJhNzE4YzFmOTlkMjNlMGIwNjI0YmU3
10
+ OTFjZjUyNGJmZmZhZjZkN2UyZmE1Njk3NmQ4MzY3YjgxM2M4ZGIyMjg1MmNl
11
+ OTQ5ZGU2YzhlOTI2Y2VjYzZiYzZlMGM1MTM3NGUzYmIwZDA0MzY=
12
12
  data.tar.gz: !binary |-
13
- OTFiNjcxN2I1NGUzYzg2ZWEyZjI1OWNiZDZmZWE1MGFmNmE5OWJiZjEwNTNh
14
- OTUwNDEwODI3Nzk2OWRkNzJjMzU5YzJhYjRjNzVjNDA0MTFjM2JiN2U1ZTVh
15
- NDU0NzU4ZmUxOTJlYzQ4OThjY2MxOTk2NzgxZjM0NzY3M2I4Njc=
13
+ NWUyODUxMzc1MDBmMGUwYWNkNTY4YjNlMDQzOGQzNmQ0MDFjOGQ4ZmE2MDY2
14
+ NWE5MzNlNWRlMjY3NjQ5ODNjYTkzYzMwYzhlZGNiMDIzMWVmYmZiMTE2OTdl
15
+ NDgyNTVmYzhhMjVkYWU0NzFmNmEwMzJmNDM0ZDllNjIyODA2YzA=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ v1.1.4, 2016-11-11 ([changes](https://github.com/sparkapi/sparkql/compare/v1.1.3...v1.1.4))
2
+ -------------------
3
+ * [IMPROVEMENT] New functions: contains(), startswith(), endswith()
4
+
1
5
  v1.1.3, 2016-11-10 ([changes](https://github.com/sparkapi/sparkql/compare/v1.1.2...v1.1.3))
2
6
  -------------------
3
7
  * [IMPROVEMENT] New functions: tolower() and toupper()
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.3
1
+ 1.1.4
@@ -44,6 +44,18 @@ class Sparkql::FunctionResolver
44
44
  :resolve_for_type => true,
45
45
  :return_type => :character
46
46
  },
47
+ :startswith => {
48
+ :args => [:character],
49
+ :return_type => :startswith
50
+ },
51
+ :endswith => {
52
+ :args => [:character],
53
+ :return_type => :endswith
54
+ },
55
+ :contains => {
56
+ :args => [:character],
57
+ :return_type => :contains
58
+ },
47
59
  :linestring => {
48
60
  :args => [:character],
49
61
  :return_type => :shape
@@ -257,6 +269,54 @@ class Sparkql::FunctionResolver
257
269
  }
258
270
  end
259
271
 
272
+ def startswith(string)
273
+ # Wrap this string in quotes, as we effectively translate
274
+ # City Eq startswith('far')
275
+ # ...to...
276
+ # City Eq 'far*'
277
+ #
278
+ # The string passed in will merely be "far", rather than
279
+ # the string literal "'far'".
280
+ new_value = "'#{string}*'"
281
+
282
+ {
283
+ :type => :character,
284
+ :value => new_value
285
+ }
286
+ end
287
+
288
+ def endswith(string)
289
+ # Wrap this string in quotes, as we effectively translate
290
+ # City Eq endswith('far')
291
+ # ...to...
292
+ # City Eq '*far'
293
+ #
294
+ # The string passed in will merely be "far", rather than
295
+ # the string literal "'far'".
296
+ new_value = "'*#{string}'"
297
+
298
+ {
299
+ :type => :character,
300
+ :value => new_value
301
+ }
302
+ end
303
+
304
+ def contains(string)
305
+ # Wrap this string in quotes, as we effectively translate
306
+ # City Eq contains('far')
307
+ # ...to...
308
+ # City Eq '*far*'
309
+ #
310
+ # The string passed in will merely be "far", rather than
311
+ # the string literal "'far'".
312
+ new_value = "'*#{string}*'"
313
+
314
+ {
315
+ :type => :character,
316
+ :value => new_value
317
+ }
318
+ end
319
+
260
320
  # Offset the current timestamp by a number of days
261
321
  def days(num)
262
322
  # date calculated as the offset from midnight tommorrow. Zero will provide values for all times
@@ -284,4 +284,20 @@ class FunctionResolverTest < Test::Unit::TestCase
284
284
  assert_equal 'date', value[:value]
285
285
  assert_equal "OriginalEntryTimestamp", value[:args].first
286
286
  end
287
+
288
+ test "startswith(), endswith() and contains()" do
289
+ [{'startswith' => "'far*'"},
290
+ {'endswith' => "'*far'"},
291
+ {'contains' => "'*far*'"}].each do |test_case|
292
+ function = test_case.keys.first
293
+ expected_value = test_case[function]
294
+
295
+ f = FunctionResolver.new(function, [{:type => :character, :value => "far"}])
296
+ f.validate
297
+ assert !f.errors?, "Errors #{f.errors.inspect}"
298
+ value = f.call
299
+ assert_equal :character, value[:type]
300
+ assert_equal expected_value, value[:value]
301
+ end
302
+ end
287
303
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sparkql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wade McEwen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-10 00:00:00.000000000 Z
11
+ date: 2016-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: georuby