picky 4.4.2 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,7 +26,7 @@ module Picky
26
26
  def [] key
27
27
  length, offset = mapping[key]
28
28
  return unless length
29
- result = Yajl::Parser.parse IO.read(cache_path, length, offset)
29
+ result = MultiJson.decode IO.read(cache_path, length, offset)
30
30
  result
31
31
  end
32
32
 
@@ -65,7 +65,7 @@ module Picky
65
65
  create_directory cache_path
66
66
  ::File.open(cache_path, 'w:utf-8') do |out_file|
67
67
  hash.each do |(key, object)|
68
- encoded = Yajl::Encoder.encode object
68
+ encoded = MultiJson.encode object
69
69
  length = encoded.size
70
70
  mapping[key] = [length, offset]
71
71
  offset += length
@@ -17,7 +17,7 @@ module Picky
17
17
  # Loads the index hash from json format.
18
18
  #
19
19
  def load
20
- Yajl::Parser.parse ::File.open(cache_path, 'r') # , symbolize_keys: true # TODO Symbols.
20
+ MultiJson.decode ::File.open(cache_path, 'r') # , symbolize_keys: true # TODO Symbols.
21
21
  end
22
22
 
23
23
  # Dumps the index internal backend in json format.
@@ -31,7 +31,7 @@ module Picky
31
31
  #
32
32
  def dump_json internal
33
33
  ::File.open(cache_path, 'w') do |out_file|
34
- Yajl::Encoder.encode internal, out_file
34
+ MultiJson.encode internal, out_file
35
35
  end
36
36
  end
37
37
 
@@ -19,7 +19,7 @@ module Picky
19
19
  unless array.empty?
20
20
  db.execute 'INSERT OR REPLACE INTO key_value (key,value) VALUES (?,?)',
21
21
  key.to_s,
22
- Yajl::Encoder.encode(array)
22
+ MultiJson.encode(array)
23
23
  end
24
24
 
25
25
  DirectlyManipulable.make self, array, key
@@ -30,7 +30,7 @@ module Picky
30
30
  res = db.execute "SELECT value FROM key_value WHERE key = ? LIMIT 1",
31
31
  key.to_s
32
32
 
33
- array = res.blank? ? [] : Yajl::Parser.parse(res.first.first)
33
+ array = res.blank? ? [] : MultiJson.decode(res.first.first)
34
34
  DirectlyManipulable.make self, array, key
35
35
  array
36
36
  end
@@ -52,7 +52,7 @@ module Picky
52
52
  # implement each.
53
53
  #
54
54
  internal.each do |key, value|
55
- encoded_value = Yajl::Encoder.encode value
55
+ encoded_value = MultiJson.encode value
56
56
  db.execute 'insert into key_value values (?,?)', key.to_s, encoded_value
57
57
  end
58
58
  end
@@ -13,7 +13,7 @@ module Picky
13
13
  def []= key, value
14
14
  db.execute 'INSERT OR REPLACE INTO key_value (key, value) VALUES (?,?)',
15
15
  key.to_s,
16
- Yajl::Encoder.encode(value)
16
+ MultiJson.encode(value)
17
17
 
18
18
  value
19
19
  end
@@ -22,7 +22,7 @@ module Picky
22
22
  res = db.execute "SELECT value FROM key_value WHERE key = ? LIMIT 1;", key.to_s
23
23
  return nil if res.empty?
24
24
 
25
- Yajl::Parser.parse res.first.first
25
+ MultiJson.decode res.first.first
26
26
  end
27
27
 
28
28
  def delete key
@@ -2,10 +2,10 @@
2
2
  #
3
3
  class Hash
4
4
 
5
- # Use yajl's encoding.
5
+ # Use multi_json's encoding.
6
6
  #
7
7
  def to_json options = {}
8
- Yajl::Encoder.encode self, options
8
+ MultiJson.encode self, options
9
9
  end
10
10
 
11
11
  end
@@ -115,7 +115,7 @@ module Picky
115
115
  # Note: Delegates to to_result.
116
116
  #
117
117
  def to_json options = {}
118
- Yajl::Encoder.encode to_result, options
118
+ MultiJson.encode to_result, options
119
119
  end
120
120
 
121
121
  #
data/lib/picky/results.rb CHANGED
@@ -78,7 +78,7 @@ module Picky
78
78
  # Convert to json format.
79
79
  #
80
80
  def to_json options = {}
81
- Yajl::Encoder.encode to_hash, options
81
+ MultiJson.encode to_hash, options
82
82
  end
83
83
 
84
84
  # For logging.
@@ -17,7 +17,7 @@ module Picky
17
17
  index = Picky::Indexes[index_name.to_sym]
18
18
  data = params['data']
19
19
  return 400 unless data
20
- data && index.replace_from(Yajl::Parser.parse data) && 200
20
+ data && index.replace_from(MultiJson.decode data) && 200
21
21
  rescue IdNotGivenException
22
22
  400
23
23
  rescue StandardError
@@ -36,7 +36,7 @@ module Picky
36
36
  index_name = params['index']
37
37
  begin
38
38
  index = Picky::Indexes[index_name.to_sym]
39
- data = Yajl::Parser.parse params['data']
39
+ data = MultiJson.decode params['data']
40
40
  id = data['id']
41
41
  id ? index.remove(id) && 200 : 400
42
42
  rescue StandardError
data/lib/picky.rb CHANGED
@@ -15,7 +15,7 @@ module Picky
15
15
  require 'active_support/core_ext/object/blank'
16
16
  require 'active_support/core_ext/enumerable'
17
17
  require 'active_support/multibyte'
18
- require 'yajl'
18
+ require 'multi_json'
19
19
  require 'procrastinate'
20
20
  require 'rack_fast_escape' if defined? Rack
21
21
  require 'fileutils'
@@ -1,4 +1,4 @@
1
- require 'yajl'
1
+ require 'multi_json'
2
2
  require 'sinatra'
3
3
  require_relative '../../../client/lib/picky-client'
4
4
  require_relative '../../../client/lib/picky-client/spec'
@@ -112,7 +112,7 @@ describe 'Sinatra Index Actions' do
112
112
  data: %Q{{ "id":"1", "name":"Florian", "surname":"Hanke" }}
113
113
  })
114
114
 
115
- results = Yajl::Parser.parse request.get('/people', params: { query: 'florian' }).body
115
+ results = MultiJson.decode request.get('/people', params: { query: 'florian' }).body
116
116
  results['total'].should == 1
117
117
 
118
118
  request.post('/', params: {
@@ -120,7 +120,7 @@ describe 'Sinatra Index Actions' do
120
120
  data: %Q{{ "id":"2", "name":"Florian", "surname":"Meier" }}
121
121
  })
122
122
 
123
- results = Yajl::Parser.parse request.get('/people', params: { query: 'florian' }).body
123
+ results = MultiJson.decode request.get('/people', params: { query: 'florian' }).body
124
124
  results['total'].should == 2
125
125
  end
126
126
  it 'updates the index correctly' do
@@ -129,10 +129,10 @@ describe 'Sinatra Index Actions' do
129
129
  data: %Q{{ "id":"1", "name":"Flarian", "surname":"Hanke" }}
130
130
  })
131
131
 
132
- results = Yajl::Parser.parse request.get('/people', params: { query: 'hanke' }).body
132
+ results = MultiJson.decode request.get('/people', params: { query: 'hanke' }).body
133
133
  results['total'].should == 1
134
134
 
135
- results = Yajl::Parser.parse request.get('/people', params: { query: 'florian' }).body
135
+ results = MultiJson.decode request.get('/people', params: { query: 'florian' }).body
136
136
  results['total'].should == 0
137
137
 
138
138
  # Whoops, typo. Let's fix it.
@@ -142,13 +142,13 @@ describe 'Sinatra Index Actions' do
142
142
  data: %Q{{ "id":"1", "name":"Florian", "surname":"Hanke" }}
143
143
  })
144
144
 
145
- results = Yajl::Parser.parse request.get('/people', params: { query: 'hanke' }).body
145
+ results = MultiJson.decode request.get('/people', params: { query: 'hanke' }).body
146
146
  results['total'].should == 1
147
147
 
148
- results = Yajl::Parser.parse request.get('/people', params: { query: 'flarian' }).body
148
+ results = MultiJson.decode request.get('/people', params: { query: 'flarian' }).body
149
149
  results['total'].should == 0
150
150
 
151
- results = Yajl::Parser.parse request.get('/people', params: { query: 'florian' }).body
151
+ results = MultiJson.decode request.get('/people', params: { query: 'florian' }).body
152
152
  results['total'].should == 1
153
153
  end
154
154
  it 'deletes entries from the index correctly' do
@@ -161,7 +161,7 @@ describe 'Sinatra Index Actions' do
161
161
  data: %Q{{ "id":"2", "name":"Florian", "surname":"Meier" }}
162
162
  })
163
163
 
164
- results = Yajl::Parser.parse request.get('/people', params: { query: 'florian' }).body
164
+ results = MultiJson.decode request.get('/people', params: { query: 'florian' }).body
165
165
  results['total'].should == 2
166
166
 
167
167
  request.delete('/', params: {
@@ -169,7 +169,7 @@ describe 'Sinatra Index Actions' do
169
169
  data: %Q{{ "id":"1" }}
170
170
  })
171
171
 
172
- results = Yajl::Parser.parse request.get('/people', params: { query: 'florian' }).body
172
+ results = MultiJson.decode request.get('/people', params: { query: 'florian' }).body
173
173
  results['total'].should == 1
174
174
  end
175
175
  it 'has no problem with a superfluous delete' do
@@ -178,7 +178,7 @@ describe 'Sinatra Index Actions' do
178
178
  data: %Q{{ "id":"1" }}
179
179
  })
180
180
 
181
- results = Yajl::Parser.parse request.get('/people', params: { query: 'florian' }).body
181
+ results = MultiJson.decode request.get('/people', params: { query: 'florian' }).body
182
182
  results['total'].should == 0
183
183
  end
184
184
  it 'works with the (test) client' do
@@ -117,7 +117,7 @@ describe Picky::Bundle do
117
117
  end
118
118
  describe "load_index" do
119
119
  it "uses the right file" do
120
- Yajl::Parser.stub! :parse
120
+ MultiJson.stub! :decode
121
121
 
122
122
  File.should_receive(:open).once.with 'spec/test_directory/index/test/some_index/some_category_some_name_inverted.memory.json', 'r'
123
123
 
@@ -126,7 +126,7 @@ describe Picky::Bundle do
126
126
  end
127
127
  describe "load_weights" do
128
128
  it "uses the right file" do
129
- Yajl::Parser.stub! :parse
129
+ MultiJson.stub! :decode
130
130
 
131
131
  File.should_receive(:open).once.with 'spec/test_directory/index/test/some_index/some_category_some_name_weights.memory.json', 'r'
132
132
 
@@ -144,7 +144,7 @@ describe Picky::Bundle do
144
144
  end
145
145
  describe "load_configuration" do
146
146
  it "uses the right file" do
147
- Yajl::Parser.stub! :parse
147
+ MultiJson.stub! :decode
148
148
 
149
149
  File.should_receive(:open).once.with 'spec/test_directory/index/test/some_index/some_category_some_name_configuration.memory.json', 'r'
150
150
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picky
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.2
4
+ version: 4.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-22 00:00:00.000000000 Z
12
+ date: 2012-07-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70255381661400 !ruby/object:Gem::Requirement
16
+ requirement: &70173482973460 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,21 +21,21 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70255381661400
24
+ version_requirements: *70173482973460
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: picky-client
27
- requirement: &70255381659920 !ruby/object:Gem::Requirement
27
+ requirement: &70173482988980 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 4.4.2
32
+ version: 4.5.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70255381659920
35
+ version_requirements: *70173482988980
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: text
38
- requirement: &70255381674980 !ruby/object:Gem::Requirement
38
+ requirement: &70173482988380 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70255381674980
46
+ version_requirements: *70173482988380
47
47
  - !ruby/object:Gem::Dependency
48
- name: yajl-ruby
49
- requirement: &70255381674320 !ruby/object:Gem::Requirement
48
+ name: multi_json
49
+ requirement: &70173482987800 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70255381674320
57
+ version_requirements: *70173482987800
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: activesupport
60
- requirement: &70255381673560 !ruby/object:Gem::Requirement
60
+ requirement: &70173482987160 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '3.0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70255381673560
68
+ version_requirements: *70173482987160
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: procrastinate
71
- requirement: &70255381672800 !ruby/object:Gem::Requirement
71
+ requirement: &70173482985880 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0.4'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70255381672800
79
+ version_requirements: *70173482985880
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rack_fast_escape
82
- requirement: &70255381672420 !ruby/object:Gem::Requirement
82
+ requirement: &70173482985400 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70255381672420
90
+ version_requirements: *70173482985400
91
91
  description: Fast Ruby semantic text search engine with comfortable single field interface.
92
92
  email: florian.hanke+picky@gmail.com
93
93
  executables: