model_set 1.1.2 → 1.1.3

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.2
1
+ 1.1.3
@@ -9,17 +9,17 @@ module Sphinx
9
9
 
10
10
  # Put int(s) to request.
11
11
  def put_int(*ints)
12
- ints.each { |i| @request << [i].pack('N') }
12
+ ints.each { |i| request << [i].pack('N') }
13
13
  end
14
14
 
15
15
  # Put 64-bit int(s) to request.
16
16
  def put_int64(*ints)
17
- ints.each { |i| @request << [i].pack('q').reverse }#[i >> 32, i & ((1 << 32) - 1)].pack('NN') }
17
+ ints.each { |i| request << [i].pack('q').reverse }#[i >> 32, i & ((1 << 32) - 1)].pack('NN') }
18
18
  end
19
19
 
20
20
  # Put string(s) to request (first length, then the string itself).
21
21
  def put_string(*strings)
22
- strings.each { |s| @request << [s.length].pack('N') + s }
22
+ strings.each { |s| request << [s.bytesize].pack('N') + convert_to_binary(s) }
23
23
  end
24
24
 
25
25
  # Put float(s) to request.
@@ -27,7 +27,7 @@ module Sphinx
27
27
  floats.each do |f|
28
28
  t1 = [f].pack('f') # machine order
29
29
  t2 = t1.unpack('L*').first # int in machine order
30
- @request << [t2].pack('N')
30
+ request << [t2].pack('N')
31
31
  end
32
32
  end
33
33
 
@@ -44,7 +44,26 @@ module Sphinx
44
44
 
45
45
  # Returns the entire message
46
46
  def to_s
47
- @request
47
+ request
48
48
  end
49
+
50
+ private
51
+
52
+ def request
53
+ if @request.respond_to?(:force_encodng)
54
+ @request.force_encoding('ASCII-8BIT')
55
+ else
56
+ @request
57
+ end
58
+ end
59
+
60
+ def convert_to_binary(s)
61
+ if s.respond_to?(:force_encoding)
62
+ s.dup.force_encoding('ASCII-8BIT')
63
+ else
64
+ s
65
+ end
66
+ end
67
+
49
68
  end
50
69
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: model_set
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 2
10
- version: 1.1.2
9
+ - 3
10
+ version: 1.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Justin Balthrop
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-07-22 00:00:00 -07:00
19
- default_executable:
18
+ date: 2013-11-27 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: shoulda
@@ -263,7 +262,6 @@ files:
263
262
  - vendor/sphinx_client/sphinx.yml.tpl
264
263
  - vendor/sphinx_client/tasks/sphinx.rake
265
264
  - vendor/sphinx_client/test.rb
266
- has_rdoc: true
267
265
  homepage: https://github.com/ninjudd/model_set
268
266
  licenses:
269
267
  - MIT
@@ -293,7 +291,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
293
291
  requirements: []
294
292
 
295
293
  rubyforge_project:
296
- rubygems_version: 1.5.2
294
+ rubygems_version: 1.8.15
297
295
  signing_key:
298
296
  specification_version: 3
299
297
  summary: Easy manipulation of sets of ActiveRecord models