metova 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODNjYWI1M2Y1YjlkYTY1N2E1MTBiN2IxNTE4MjA4NmQwY2MzY2JmNA==
4
+ NTAzNDQ4ODgwZWY4ODcyYWMyNzk2OGNjYmI2M2YxZTgyYTE2NzYxOA==
5
5
  data.tar.gz: !binary |-
6
- YzRiMTZjNjA0ZDI5YjdmNmE5NmIwN2UyZjdlN2NkZmNmY2NmNzVhOQ==
6
+ Y2IzM2I1MTI1MDE0YzFhZGEwNGNhMzU2MTllOTI0YTMwZmE2OWQ3Nw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTk2ZmNlNTBlMDBmMmEzZTcyNTQ4MTM0MGQ4ZDQwZmM5MTg0MDEwNjkzNTcy
10
- Mzk2MjdhZGFlN2VmOTAxZDAyZjVhMDQ1M2VlMGQyODIyN2ZkMTAxYzBjYThj
11
- YjdiZmE0NDA4M2ZiZDAwMWU5NWM5OWVmYTdhOTcxODEwMmNlYzA=
9
+ ODE0NGM5ZTQ0NjE4NjcyZDJlYWY5ZDU2NGIzZTBjMzUzODA3NjY4YjViMWJj
10
+ NDI4YzBmYmY1N2YzNmQ4ZmY0ZDBiMzQwZjE4MmU5NzFhNDZlNTNhYWJkMjhm
11
+ NTMxNjEzNjAzYjU5NmRmYWYzMGIyNDUzY2U4NzU2MzJiZDA2ODc=
12
12
  data.tar.gz: !binary |-
13
- ZWI1ZDc3Mzk5ZWE4NGNkNmMwMGI2MDU5YmE3NzMyNzk0YTQ1YzdhMzFhMjBj
14
- YzBiZjRkZmEzZmVhODI2MzhhZjFiM2Q2ZmVjOTg3ZjJiZjE1NmRmZmI3OGNi
15
- MjBjOWZjYmUyYTBhOTI2OTU5N2RlYzA2OTRhYmQzMjZiYzc5NGU=
13
+ MzMwNjY5Yzc4M2IzMjdhNzQ3YjQ0MDJlZjBlNTczZmZjOGY2NDY1ZDYyZWJh
14
+ NWQ2NTA2NzRkNTdlNzVjZTI5YzdkNTg2NGJkNDcyZTBkZmJmZTU5Mzk0ZTE1
15
+ NTc5YjgzYmJjYTMwYTU3OWJlM2YzMGM1NTIxY2FjYjQ5ZWMzYTE=
@@ -5,12 +5,12 @@ module Metova
5
5
 
6
6
  included do
7
7
  respond_to :json
8
- before_action :accept_user_param_root!
9
8
  self.responder = Metova::Responder
10
9
  end
11
10
 
12
- def accept_user_param_root!
13
- params[:api_user] = params[:user] if params[:user] && !params[:api_user]
11
+ def devise_mapping
12
+ _super = super
13
+ @_devise_mapping ||= ::Devise.mappings[_super.singular.to_s.gsub('api_', '').intern] || _super
14
14
  end
15
15
 
16
16
  end
@@ -4,6 +4,7 @@ module Metova
4
4
 
5
5
  initializer "metova.mandrill" do |app|
6
6
  if ENV['MANDRILL_DOMAIN']
7
+
7
8
  app.config.action_mailer.default_url_options = { host: (ENV['MANDRILL_DEFAULT_HOST'] || ENV['MANDRILL_DOMAIN']) }
8
9
  app.config.action_mailer.delivery_method = :smtp
9
10
  app.config.action_mailer.smtp_settings = {
@@ -17,6 +18,7 @@ module Metova
17
18
  }
18
19
 
19
20
  app.routes.default_url_options = app.config.action_mailer.default_url_options
21
+
20
22
  end
21
23
  end
22
24
 
@@ -0,0 +1,44 @@
1
+ module Metova
2
+ module Responders
3
+ module SearchResponder
4
+
5
+ def initialize(*)
6
+ super
7
+ @resource = search(@resource, query) if searching?
8
+ end
9
+
10
+ private
11
+
12
+ def search(resource, query = {})
13
+ if fuzzy?
14
+ resource.fuzzy_search query, exclusive?
15
+ else
16
+ resource.basic_search query, exclusive?
17
+ end
18
+ end
19
+
20
+ def searching?
21
+ controller.params.include?(:search) && controller.params[:search].is_a?(Hash)
22
+ end
23
+
24
+ def query
25
+ controller.params[:search][:query]
26
+ end
27
+
28
+ def fuzzy?
29
+ controller.params[:search][:_fuzzy] == '1'
30
+ end
31
+
32
+ def exclusive?
33
+ if controller.params[:search][:_operator] =~ /OR/i
34
+ false
35
+ else
36
+ true
37
+ end
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+
44
+ Metova::Responder.send :prepend, Metova::Responders::SearchResponder
@@ -0,0 +1,8 @@
1
+ require 'metova'
2
+ require 'metova/responders/search_responder'
3
+
4
+ begin
5
+ require 'textacular'
6
+ rescue LoadError
7
+ raise "You've required metova/search but don't have textacular! Install textacular first (gem 'textacular')"
8
+ end
@@ -1,3 +1,3 @@
1
1
  module Metova
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metova
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Logan Serman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-16 00:00:00.000000000 Z
11
+ date: 2015-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -108,6 +108,34 @@ dependencies:
108
108
  - - ! '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: textacular
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pg
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
111
139
  description: Metova libraries for Ruby on Rails
112
140
  email:
113
141
  - loganserman@gmail.com
@@ -136,7 +164,9 @@ files:
136
164
  - lib/metova/responder.rb
137
165
  - lib/metova/responders/ids_filter_responder.rb
138
166
  - lib/metova/responders/pagination_responder.rb
167
+ - lib/metova/responders/search_responder.rb
139
168
  - lib/metova/responders/sort_responder.rb
169
+ - lib/metova/search.rb
140
170
  - lib/metova/version.rb
141
171
  - lib/metova/versioning/constraints.rb
142
172
  - lib/metova/versioning/railtie.rb