stretcher 1.16.0 → 1.16.1

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: 40ad9ca446b66da2b1558340d83accb106dd80bc
4
- data.tar.gz: bc711b243bd448dbe5cb7079ad32353ef1244378
3
+ metadata.gz: 45e7f0125d5ba9baba24e71c12522d6150501edf
4
+ data.tar.gz: 6f5f9ec4b5e7fc75209c919e2d8e6abb2564a8ab
5
5
  SHA512:
6
- metadata.gz: 41acaea45c9f4ec37fcd736c4ba7dab2929ffcb39b06a4134c7db3a84b843e923c529113b08f29d5b98142a1d9e013a8c23238498cd3d6d7e5074702a8c071ae
7
- data.tar.gz: f00e4c5f5beaa2645680fdeff3182c4fd3b708981c15647ef2096ddad2a3ae84ea5ef959d0ccf3de8317e514806a756e5fc0dc5cc085098a09d3767f2d4e41a2
6
+ metadata.gz: f9287ac799f24dbe74738968c57e693f10ddceb3589226f6e235485af7bd3cd24482877b83f877eb65210235f7480133ba5b9a29209dcc2d10f62f837c44ef05
7
+ data.tar.gz: 4ed876dad2d9820b0f3a3959745bf66d5a6e7d75c28c247af9b5fb5d7213d2de8eae9490c9a7b1af818e5df8441c4413be660cc8853894e587b27525b759f81b
data/lib/stretcher.rb CHANGED
@@ -4,6 +4,7 @@ require 'hashie'
4
4
  require 'excon'
5
5
  require 'faraday'
6
6
  require 'faraday_middleware'
7
+ require 'faraday_middleware/multi_json'
7
8
  Faraday.load_autoloaded_constants
8
9
  require "stretcher/version"
9
10
  require 'stretcher/request_error'
@@ -50,8 +50,8 @@ module Stretcher
50
50
  index_meta[key] = d.delete(key) if system_fields.include?(key.to_s)
51
51
  end
52
52
 
53
- post_data << ({action => index_meta}.to_json + "\n")
54
- post_data << (d.to_json + "\n") unless action == :delete
53
+ post_data << (MultiJson.dump({action => index_meta}) + "\n")
54
+ post_data << (MultiJson.dump(d) + "\n") unless action == :delete
55
55
  post_data
56
56
  }
57
57
  @server.bulk body, options
@@ -7,9 +7,9 @@ module Stretcher
7
7
  def self.build_client(uri, options={})
8
8
  http = Faraday.new(:url => uri) do |builder|
9
9
  builder.response :mashify
10
- builder.response :json, :content_type => /\bjson$/
10
+ builder.response :multi_json, :content_type => /\bjson$/
11
11
 
12
- builder.request :json
12
+ builder.request :multi_json
13
13
 
14
14
  builder.options[:read_timeout] = options[:read_timeout] || 4
15
15
  builder.options[:open_timeout] = options[:open_timeout] || 2
@@ -125,7 +125,7 @@ module Stretcher
125
125
  # server.msearch(data)
126
126
  def msearch(body=[])
127
127
  raise ArgumentError, "msearch takes an array!" unless body.is_a?(Array)
128
- fmt_body = body.map(&:to_json).join("\n") + "\n"
128
+ fmt_body = body.map {|l| MultiJson.dump(l) }.join("\n") + "\n"
129
129
 
130
130
  res = request(:get, path_uri("/_msearch"), {}, fmt_body)
131
131
 
@@ -3,7 +3,7 @@ module Stretcher
3
3
 
4
4
  # cURL formats a Faraday req. Useful for logging
5
5
  def self.curl_format(req)
6
- body = "-d '#{req.body.is_a?(Hash) ? req.body.to_json : req.body}'" if req.body
6
+ body = "-d '#{req.body.is_a?(Hash) ? MultiJson.dump(req.body) : req.body}'" if req.body
7
7
  headers = req.headers.map {|name, value| "'-H #{name}: #{value}'" }.sort.join(' ')
8
8
  method = req.method.to_s.upcase
9
9
  url = Util.qurl(req.path,req.params)
@@ -1,3 +1,3 @@
1
1
  module Stretcher
2
- VERSION = "1.16.0"
2
+ VERSION = "1.16.1"
3
3
  end
@@ -58,7 +58,7 @@ describe Stretcher::Index do
58
58
  options = { :mappings => { :movie => { :properties => { :category => { :type => 'string' } } } } }
59
59
 
60
60
  server.logger.should_receive(:debug) do |&block|
61
- block.call.should == %{curl -XPUT http://localhost:9200/foo -d '#{options.to_json}' '-H Accept: application/json' '-H Content-Type: application/json' '-H User-Agent: Stretcher Ruby Gem #{Stretcher::VERSION}'}
61
+ block.call.should == %{curl -XPUT http://localhost:9200/foo -d '#{MultiJson.dump(options)}' '-H Accept: application/json' '-H Content-Type: application/json' '-H User-Agent: Stretcher Ruby Gem #{Stretcher::VERSION}'}
62
62
  end
63
63
 
64
64
  index.create(options)
data/stretcher.gemspec CHANGED
@@ -30,6 +30,8 @@ Gem::Specification.new do |gem|
30
30
  gem.add_dependency('faraday_middleware', '~> 0.9.0')
31
31
  gem.add_dependency('excon', '>= 0.16')
32
32
  gem.add_dependency('hashie', '>= 1.2.0')
33
+ gem.add_dependency('multi_json', '>= 1.0')
34
+ gem.add_dependency('faraday_middleware-multi_json', "~> 0.0.5")
33
35
 
34
36
  gem.add_development_dependency 'rspec', '>= 2.5.0'
35
37
  gem.add_development_dependency 'coveralls'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stretcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.0
4
+ version: 1.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Cholakian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-27 00:00:00.000000000 Z
11
+ date: 2013-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -66,6 +66,34 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.2.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: multi_json
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: faraday_middleware-multi_json
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 0.0.5
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 0.0.5
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: rspec
71
99
  requirement: !ruby/object:Gem::Requirement