sewell 0.1.3 → 0.1.4

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
  SHA1:
3
- metadata.gz: 4b931c0f4538f2a6fadce904291d4f78df0ef27d
4
- data.tar.gz: 88c22b0761e5ddff786522b257c45d706d0e804c
3
+ metadata.gz: 2cc476d2880d7559adf93942296f4d7f9d7876d7
4
+ data.tar.gz: 139437f77317f4aec2020db1362366d92cad36d4
5
5
  SHA512:
6
- metadata.gz: 3051047a33be3c1f45b4db5cd719c5de2c58420046575af21458b50727816267dee2f7c2add71b082187713545f0ddab2434219c65dd3f7ed89f1dc3992887ee
7
- data.tar.gz: 56c274b6a96305f82331a9045446d4a6ffca93d89674a82047ebe18a32aa9c0cc309645c299cc34756c8c32d3fefcc7b8c7135c91e90ee9615994ea621b9677e
6
+ metadata.gz: 10e5e4421b9735d41dccbd510e129129cd1d997b76064f2b78c0fe6cde4db6c58fc4171ed6a3ce8cb50fefef8ed615d0bd60c0d0d8185236e997ce8cade8c9ea
7
+ data.tar.gz: 6176fce7f2dd4401f816d6049b76623c626e88a59594a6c6a9232136d5ce24e5b5f7fc44ce56b0da2a7815c510d2b5632b6ed2d2b374a72d8fdd85ec61be4c56
@@ -1,3 +1,3 @@
1
1
  module Sewell
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/sewell.rb CHANGED
@@ -39,14 +39,20 @@ module Sewell
39
39
  }.join " #{sep} "
40
40
  end
41
41
 
42
+ def self.escape_groonga str
43
+ str.gsub(/(\"|\'|\(|\)|\\)/, "\\#{$1}")
44
+ end
45
+
42
46
  def self.from_str str, tables
43
- str.gsub!(/ /, ' ')
47
+ str.gsub!(/ |^:/, ' ')
48
+ str = escape_groonga(str)
44
49
  q = []
45
50
  str.split(' ').map{|x|
46
51
  q << x and next if x == 'OR' or x == 'AND'
47
52
  if x.scan(/:/).count == 1
48
53
  table = x.split(':').first
49
54
  word = x.split(':').last
55
+ next unless word
50
56
  if word.split('').first == '-'
51
57
  q << "( #{table}:!#{sanitize word, /#{table}\:/} )"
52
58
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sewell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ssig33
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-18 00:00:00.000000000 Z
11
+ date: 2013-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -62,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
62
  version: '0'
63
63
  requirements: []
64
64
  rubyforge_project:
65
- rubygems_version: 2.0.2
65
+ rubygems_version: 2.0.3
66
66
  signing_key:
67
67
  specification_version: 4
68
68
  summary: Generator for Groonga's query