lsolr 0.1.0 → 0.1.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/lsolr.rb +21 -22
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b3fd605f87e3c45d4869602a7d09c41b2340ca25b1770bf9b5883585155f2dc
4
- data.tar.gz: aae72dc1de31bbcf50db7d125788b3322315c6ce7382b470b78ad4c5539172f2
3
+ metadata.gz: 1e75a43fc67a6ff02216d1c5b0d9fa6daeeee15ff9e5bcff47262de740325370
4
+ data.tar.gz: 05dc3a9fca1cf448cafd9a72929eb5c9749b3a79484a77c50530fe705415b6d3
5
5
  SHA512:
6
- metadata.gz: eb1fc197db6a577e733ae7913c71b8f65f75f793e66fd39906a58ad0b42047730f9de781b5fe107999e459bb7d8cdc56782aab144ea43fcb8a38e4e32248057a
7
- data.tar.gz: 9b74944e2f4b42b71b669dd50d2000be44f0981f7c2a93a29c4b9728ab9c03cfeff86f09c0addd06d13f844e006e541a1814ce2b24d7996a59fed6b72670c36c
6
+ metadata.gz: 46405ec4cd25e20f6810b633a9a2526b1e2f58a733e46321b9560c917b552c3b2516da21cf1b8f03c483a761a5291646ea2eabe2ff7dfb1749fc6751f57bf20e
7
+ data.tar.gz: 1fce5e18a576157be0c77559633092a26adc601208b008078402072882318207d0852ce655f3bf13f9bdead3a4902f27c851cff8db40473c99b30e499c8ff6e0
data/lib/lsolr.rb CHANGED
@@ -229,12 +229,7 @@ class LSolr
229
229
  #
230
230
  # @return [LSolr] self instance
231
231
  def date_time_match(value)
232
- value = if value.is_a?(Date) || value.is_a?(Time)
233
- format_date(value)
234
- else
235
- clean(value, symbols: RESERVED_SYMBOLS - %w[- : . / +])
236
- end
237
-
232
+ value = stringify(value, symbols: RESERVED_SYMBOLS - %w[- : . / +])
238
233
  @value = %("#{value}")
239
234
  self
240
235
  end
@@ -289,8 +284,7 @@ class LSolr
289
284
  #
290
285
  # @return [LSolr] self instance
291
286
  def greater_than(value)
292
- value = format_date(value) if value.is_a?(Date) || value.is_a?(Time)
293
- @range_first = "#{GREATER_THAN}#{value}"
287
+ @range_first = "#{GREATER_THAN}#{stringify(value)}"
294
288
  self
295
289
  end
296
290
 
@@ -302,8 +296,7 @@ class LSolr
302
296
  #
303
297
  # @return [LSolr] self instance
304
298
  def less_than(value)
305
- value = format_date(value) if value.is_a?(Date) || value.is_a?(Time)
306
- @range_last = "#{value}#{LESS_THAN}"
299
+ @range_last = "#{stringify(value)}#{LESS_THAN}"
307
300
  self
308
301
  end
309
302
 
@@ -315,8 +308,7 @@ class LSolr
315
308
  #
316
309
  # @return [LSolr] self instance
317
310
  def greater_than_or_equal_to(value)
318
- value = format_date(value) if value.is_a?(Date) || value.is_a?(Time)
319
- @range_first = "#{GREATER_THAN_OR_EQUAL_TO}#{value}"
311
+ @range_first = "#{GREATER_THAN_OR_EQUAL_TO}#{stringify(value)}"
320
312
  self
321
313
  end
322
314
 
@@ -328,8 +320,7 @@ class LSolr
328
320
  #
329
321
  # @return [LSolr] self instance
330
322
  def less_than_or_equal_to(value)
331
- value = format_date(value) if value.is_a?(Date) || value.is_a?(Time)
332
- @range_last = "#{value}#{LESS_THAN_OR_EQUAL_TO}"
323
+ @range_last = "#{stringify(value)}#{LESS_THAN_OR_EQUAL_TO}"
333
324
  self
334
325
  end
335
326
 
@@ -384,14 +375,12 @@ class LSolr
384
375
  .gsub(RESERVED_WORDS) { |match| "\\#{match}" }
385
376
  end
386
377
 
387
- def link(another, operator)
388
- return self if another.nil? || another.blank?
389
-
390
- another = another.dup
391
- head = another.head
392
- head.prev = dup
393
- head.operator = operator
394
- another
378
+ def stringify(value, symbols: RESERVED_SYMBOLS - %w[- : . / + *])
379
+ if value.is_a?(Date) || value.is_a?(Time)
380
+ format_date(value)
381
+ else
382
+ clean(value, symbols: symbols)
383
+ end
395
384
  end
396
385
 
397
386
  def format_date(date)
@@ -405,4 +394,14 @@ class LSolr
405
394
 
406
395
  "#{date.strftime('%Y-%m-%dT%H:%M:%S')}.#{msec_str}Z"
407
396
  end
397
+
398
+ def link(another, operator)
399
+ return self if another.nil? || another.blank?
400
+
401
+ another = another.dup
402
+ head = another.head
403
+ head.prev = dup
404
+ head.operator = operator
405
+ another
406
+ end
408
407
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lsolr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taishi Kasuga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-26 00:00:00.000000000 Z
11
+ date: 2017-12-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: LSolr is a query builder of Apache Solr standard Lucene type query for
14
14
  Ruby.