diff --git a/.travis.yml b/.travis.yml index 1e07dc4..ef78d11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: ruby rvm: - 2.1 + - jruby notifications: email: false diff --git a/Gemfile b/Gemfile index fd58460..933ada0 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source 'https://rubygems.org' gem 'rails', '~> 3.2.19' gem 'pg', platforms: :ruby -#gem 'activerecord-jdbcpostgresql-adapter', platforms: :jruby +gem 'activerecord-jdbcpostgresql-adapter', platforms: :jruby gem 'cancan' # Authorization gem 'default_value_for' # Default values @@ -24,7 +24,7 @@ gem 'yaml_db' # Database dump group :assets do gem 'coffee-rails' gem 'therubyracer', platforms: :ruby -# gem 'therubyrhino', platforms: :jruby + gem 'therubyrhino', platforms: :jruby gem 'uglifier' gem 'sass-rails' @@ -39,7 +39,7 @@ group :development do gem 'capistrano-rbenv', github: 'capistrano/rbenv' # More beautiful exception pages - gem 'better_errors' + gem 'better_errors', platforms: :ruby gem 'binding_of_caller', platforms: :ruby gem 'rails-erd' # Entity/relationship diagram of model @@ -52,10 +52,10 @@ group :development, :test do gem 'mysql2' end -# platforms :jruby do -# gem 'activerecord-jdbcsqlite3-adapter' -# gem 'activerecord-jdbcmysql-adapter' -# end + platforms :jruby do + gem 'activerecord-jdbcsqlite3-adapter' + gem 'activerecord-jdbcmysql-adapter' + end end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index d7ef0a9..7899cea 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -30,6 +30,17 @@ GEM activesupport (= 3.2.21) arel (~> 3.0.2) tzinfo (~> 0.3.29) + activerecord-jdbc-adapter (1.3.13) + activerecord (>= 2.2) + activerecord-jdbcmysql-adapter (1.3.13) + activerecord-jdbc-adapter (~> 1.3.13) + jdbc-mysql (>= 5.1.22) + activerecord-jdbcpostgresql-adapter (1.3.13) + activerecord-jdbc-adapter (~> 1.3.13) + jdbc-postgres (>= 9.1) + activerecord-jdbcsqlite3-adapter (1.3.13) + activerecord-jdbc-adapter (~> 1.3.13) + jdbc-sqlite3 (>= 3.7.2, < 3.9) activeresource (3.2.21) activemodel (= 3.2.21) activesupport (= 3.2.21) @@ -119,9 +130,9 @@ GEM faraday (0.9.0) multipart-post (>= 1.2, < 3) fastercsv (1.5.5) - foreigner (1.6.1) + foreigner (1.7.1) activerecord (>= 3.0.0) - haml (4.0.5) + haml (4.0.6) tilt has_scope (0.6.0.rc) actionpack (>= 3.2, < 5) @@ -133,6 +144,9 @@ GEM inherited_resources (1.4.1) has_scope (~> 0.6.0.rc) responders (~> 1.0.0.rc) + jdbc-mysql (5.1.33) + jdbc-postgres (9.3.1102) + jdbc-sqlite3 (3.8.7) journey (1.0.4) jquery-rails (3.1.2) railties (>= 3.0, < 5.0) @@ -153,7 +167,7 @@ GEM net-scp (1.2.1) net-ssh (>= 2.6.5) net-ssh (2.9.1) - netrc (0.8.0) + netrc (0.9.0) orm_adapter (0.5.0) paper_trail (2.7.2) activerecord (~> 3.0) @@ -189,7 +203,7 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) - rake (10.4.0) + rake (10.4.2) rdoc (3.12.2) json (~> 1.4) ref (1.0.5) @@ -248,6 +262,9 @@ GEM therubyracer (0.12.1) libv8 (~> 3.16.14.0) ref + therubyrhino (2.0.4) + therubyrhino_jar (>= 1.7.3) + therubyrhino_jar (1.7.4) thor (0.19.1) thread_safe (0.3.4) thread_safe (0.3.4-java) @@ -257,7 +274,7 @@ GEM polyglot polyglot (>= 0.3.1) tzinfo (0.3.42) - uglifier (2.5.3) + uglifier (2.6.0) execjs (>= 0.3.0) json (>= 1.8.0) warden (1.2.3) @@ -271,6 +288,9 @@ PLATFORMS ruby DEPENDENCIES + activerecord-jdbcmysql-adapter + activerecord-jdbcpostgresql-adapter + activerecord-jdbcsqlite3-adapter better_errors binding_of_caller bootstrap-sass (~> 3.1.1.1) @@ -306,5 +326,6 @@ DEPENDENCIES simple_form sqlite3 therubyracer + therubyrhino uglifier yaml_db diff --git a/lib/search.rb b/lib/search.rb index b85dbd4..0dde325 100644 --- a/lib/search.rb +++ b/lib/search.rb @@ -1,7 +1,9 @@ # Search for resources. module Search # Results for query. - def self.for(mailbox, query, sql: !Settings.elasticsearch) + def self.for(mailbox, query, options = {}) + sql = options[:sql] || !Settings.elasticsearch + haystack = ::Domain.managable(mailbox) haystack_ids = haystack.pluck(:id) diff --git a/lib/search/address.rb b/lib/search/address.rb index da76d52..e9fdf36 100644 --- a/lib/search/address.rb +++ b/lib/search/address.rb @@ -3,7 +3,9 @@ module Search::Address @model = nil # Search either via SQL or indexed (depending on settings or argument). - def self.search(haystack, needle, sql: !Settings.elasticsearch) + def self.search(haystack, needle, options = {}) + sql = options[:sql] || !Settings.elasticsearch + @model = Object.const_get haystack.model_name if sql diff --git a/lib/search/domain.rb b/lib/search/domain.rb index 3fae410..1e629a5 100644 --- a/lib/search/domain.rb +++ b/lib/search/domain.rb @@ -1,7 +1,9 @@ # Search for domains. module Search::Domain # Search either via SQL or indexed (depending on settings or argument). - def self.search(haystack, needle, sql: !Settings.elasticsearch) + def self.search(haystack, needle, options = {}) + sql = options[:sql] || !Settings.elasticsearch + if sql sql_search(haystack, needle) else