Skip to content
This repository was archived by the owner on Jul 17, 2022. It is now read-only.

Commit

Permalink
use multi_json gem for yajl detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Sonnek committed Oct 18, 2011
1 parent 2548b7a commit a694445
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 20 deletions.
5 changes: 1 addition & 4 deletions .rvmrc
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
rvm use ree-1.8.7-2011.03@rails3

# use rails2 gemset for testing as well
#ree-1.8.7-2011.03@rails2
rvm use ree-1.8.7-2011.03@elastic_searchable --create
10 changes: 6 additions & 4 deletions elastic_searchable.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ Gem::Specification.new do |s|

s.rubyforge_project = "elastic_searchable"

s.add_runtime_dependency(%q<activerecord>, [">= 3.0.5"])
s.add_runtime_dependency(%q<will_paginate>, [">= 3.0.pre2"])
s.add_runtime_dependency(%q<activerecord>, ["~> 3.0.5"])
s.add_runtime_dependency(%q<will_paginate>, ["~> 3.0.0"])
s.add_runtime_dependency(%q<httparty>, ["~> 0.6.0"])
s.add_runtime_dependency(%q<backgrounded>, ["~> 0.7.0"])
s.add_runtime_dependency(%q<multi_json>, ["~> 1.0.0"])
s.add_development_dependency(%q<rake>, ["0.9.2"])
s.add_development_dependency(%q<sqlite3-ruby>, ["~> 1.3.2"])
s.add_development_dependency(%q<pry>, ["0.9.6.2"])
s.add_development_dependency(%q<shoulda>, [">= 0"])
s.add_development_dependency(%q<mocha>, [">= 0"])
s.add_development_dependency(%q<sqlite3-ruby>, ["~> 1.3.2"])
# s.add_development_dependency(%q<ruby-debug>, [">= 0"])

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
Expand Down
3 changes: 2 additions & 1 deletion lib/elastic_searchable.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'httparty'
require 'multi_json'
require 'logger'
require 'elastic_searchable/active_record_extensions'

Expand All @@ -25,7 +26,7 @@ def offline?
# encapsulate encoding hash into json string
# support Yajl encoder if installed
def encode_json(options = {})
defined?(Yajl) ? Yajl::Encoder.encode(options) : ActiveSupport::JSON.encode(options)
MultiJson.encode options
end
# perform a request to the elasticsearch server
# configuration:
Expand Down
2 changes: 1 addition & 1 deletion test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
require 'test/unit'
require 'shoulda'
require 'mocha'
# require 'ruby-debug'
require 'pry'

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
Expand Down
10 changes: 2 additions & 8 deletions test/setup_database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,5 @@
end
end

if WillPaginate.respond_to?(:enable_activerecord)
puts 'configuring will_paginate v2.x'
WillPaginate.enable_activerecord
else
puts 'configuring will_paginate v3.x'
require 'will_paginate/finders/active_record'
WillPaginate::Finders::ActiveRecord.enable!
end
puts 'configuring will_paginate v3.x'
require 'will_paginate/active_record'
4 changes: 2 additions & 2 deletions test/test_elastic_searchable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class TestElasticSearchable < Test::Unit::TestCase
def setup
delete_index
end
ElasticSearchable.debug_output
# ElasticSearchable.debug_output
SINGLE_NODE_CLUSTER_CONFIG = {'number_of_replicas' => 0, 'number_of_shards' => 1}

context 'non elastic activerecord class' do
Expand Down Expand Up @@ -294,7 +294,7 @@ class User < ActiveRecord::Base
'number_of_shards' => 1,
"analysis.analyzer.default.tokenizer" => 'standard',
"analysis.analyzer.default.filter" => ["standard", "lowercase", 'porterStem']},
:mapping => {:properties => {:name => {:type => :string, :index => :not_analyzed}}}
:mapping => {:properties => {:name => {:type => 'string', :index => 'not_analyzed'}}}
end
context 'activerecord class with :index_options and :mapping' do
context 'creating index' do
Expand Down

0 comments on commit a694445

Please sign in to comment.