query_police 0.1.3.beta → 0.1.4.beta

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27f13db4425088a65a440e6f5bc0092898f45b3bda80e20a8f02c810153eca9b
4
- data.tar.gz: 7a75948db5efee3b2a21b4b2f1479f0640c1f270b8b95cebe2d04079d43f9eb9
3
+ metadata.gz: 8be9c9ecaea3622ddb4c569a289fba9ba8f6fde860bb5a987d1176cba557d4bf
4
+ data.tar.gz: 8bdf19f5812a8bc990835d808f5bbc17c17764ed7cd853f11dfd9ae8d4d32984
5
5
  SHA512:
6
- metadata.gz: 37bf74b29105ed8a838019bda964395daadfe9241f4b14f91dee9ac306d5374c6b8faf08fb090df9fdcc7f52394c47d5973079c2f31a9ff4fc20434f9bff33df
7
- data.tar.gz: b02df2bee3c473856e8a2edd0956cf39670d58d20b7f8f66f6b63d7e749e2fa01de82bd0f898b08ff223992ebb1936599765c3dc090423c7e974776e895e10de
6
+ metadata.gz: 877344423887126e3b8d19ede4755e3d73c07172376340227119975835ab474b2dad60779afe284f9a93551b3bf63aff47e8d76b38bf42e384de0937fced0f64
7
+ data.tar.gz: fedcc1df590836fc6e55e7e41bb1527300f05ce0c3b12faf5b32cffcecd607b0f36dd0739b787a64fcddf45e6da78a693b6706d86bc8e9707e9c073ff52679b7
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "analysis/dynamic_message"
4
+ require_relative "helper"
4
5
 
5
6
  module QueryPolice
6
7
  # This class is used to store analysis of a query and provide methods over them
@@ -190,8 +191,8 @@ module QueryPolice
190
191
  suggestion = dynamic_message(opts.merge({ "type" => "suggestion" }))
191
192
  tag_message << ["impact", impact(opts.merge({ "colours" => true }))]
192
193
  tag_message << ["tag_score", score(opts.merge({ "colours" => true }))]
193
- tag_message << ["message", message]
194
- tag_message << ["suggestion", suggestion] if suggestion.present?
194
+ tag_message << ["message", Helper.word_wrap(message)]
195
+ tag_message << ["suggestion", Helper.word_wrap(suggestion)] if suggestion.present?
195
196
 
196
197
  tag_message
197
198
  end
@@ -34,7 +34,20 @@ module QueryPolice
34
34
  JSON.parse(File.read(rules_path))
35
35
  end
36
36
 
37
- module_function :flatten_hash, :logger, :load_config
37
+ def word_wrap(string, width = 100)
38
+ words = string.split
39
+ wrapped_string = " "
40
+
41
+ words.each do |word|
42
+ last_line_size = (wrapped_string.split("\n")[-1]&.size || 0)
43
+ wrapped_string = wrapped_string.strip + "\n" if (last_line_size + word.size) > width
44
+ wrapped_string += "#{word} "
45
+ end
46
+
47
+ wrapped_string.strip
48
+ end
49
+
50
+ module_function :flatten_hash, :logger, :load_config, :word_wrap
38
51
  end
39
52
 
40
53
  private_constant :Helper
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module QueryPolice
4
- VERSION = "0.1.3.beta"
4
+ VERSION = "0.1.4.beta"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: query_police
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3.beta
4
+ version: 0.1.4.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - strikeraryu