forest_liana 1.0.0.pre.beta.3 → 1.0.0.pre.beta.4

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: c441f632d727c3c652579b7046bb0f61b26ac11b
4
- data.tar.gz: 7954a066e87c9436bdb25ffea3a2fddb1defed3b
3
+ metadata.gz: 1440f829c84d9e72e9cd2d28414d644ea9000296
4
+ data.tar.gz: 29c6a921350fe9a254c2722493e28381e4351887
5
5
  SHA512:
6
- metadata.gz: feb8c12be5289fbf48d9f126cab69d32f605568d0442b5aa19cd95a209119ec88396aa0e5c648c2010057a1d3a2f24e42dc29c47236102e85abd102567481f1a
7
- data.tar.gz: 2147c19557e09e9ae30f0f33f7582109bc9b89fd075c63845f5d24c06a1ab0a2a025850433ab71b0b3149a96874509f731717fdde84f7a95009911d95db32d17
6
+ metadata.gz: ed6c960a600df1b8e890367d3b5b18411ba81a51ec994cf1cdb41270615d94d7cdbfbf90de301eeb9e316f17de57461c8a8f41e52e0bbab983c2d67478a7b228
7
+ data.tar.gz: 6644dac11fc2a615ab9c85c19a85c44ecf89e7a254e076f2b45e8a51a1bbcb380d0e888b09a5b63e166269a897e09f53559f15773b8f34e045f8b187a3adae60
@@ -22,7 +22,7 @@ module ForestLiana
22
22
  end
23
23
 
24
24
  def authenticate_user_from_jwt
25
- JWT.decode request.headers[:Authorization].split[1],
25
+ JWT.decode request.headers['Authorization'].split[1],
26
26
  ForestLiana.jwt_signing_key
27
27
  end
28
28
 
@@ -21,7 +21,7 @@ module ForestLiana
21
21
  private
22
22
 
23
23
  def search_query
24
- SearchQueryBuilder.new(@resource.joins(includes), @params).perform
24
+ SearchQueryBuilder.new(@resource.includes(includes), @params).perform
25
25
  end
26
26
 
27
27
  def sort_query
@@ -68,10 +68,8 @@ module ForestLiana
68
68
  end
69
69
 
70
70
  def includes
71
- # avoid .joins on polymorphic associations
72
71
  @resource
73
72
  .reflect_on_all_associations
74
- .select {|a| a.options[:polymorphic].blank?}
75
73
  .map {|a| a.name }
76
74
  end
77
75
 
@@ -20,15 +20,14 @@ module ForestLiana
20
20
 
21
21
  @resource.columns.each_with_index do |column, index|
22
22
  if column.name == 'id'
23
- conditions << @resource.where(id: @params[:search])
23
+ conditions << "id = #{@params[:search].to_i}"
24
24
  elsif column.type == :string || column.type == :text
25
- conditions << @resource.where(
26
- @resource.arel_table[column.name].matches(
27
- "%#{@params[:search].downcase}%"))
25
+ conditions <<
26
+ "#{column.name} LIKE '%#{@params[:search].downcase}%'"
28
27
  end
29
28
  end
30
29
 
31
- @resource = @resource.where.or(*conditions)
30
+ @resource = @resource.where(conditions.join(' OR '))
32
31
  end
33
32
  end
34
33
 
@@ -0,0 +1 @@
1
+ require_dependency ForestLiana::Engine.root.join("lib/patches/add_patch_method").to_s
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "1.0.0-beta.3"
2
+ VERSION = "1.0.0-beta.4"
3
3
  end
@@ -0,0 +1,124 @@
1
+ # Rails 3.2 support for HTTP PATCH.
2
+ if Rails::VERSION::MAJOR < 4
3
+ # see http://weblog.rubyonrails.org/2012/2/26/edge-rails-patch-is-the-new-primary-http-method-for-updates/
4
+ # https://github.com/rails/rails/pull/505
5
+
6
+ ActionDispatch::Routing::Mapper::HttpHelpers.module_eval do
7
+ # Define a route that only recognizes HTTP PATCH.
8
+ # For supported arguments, see <tt>Base#match</tt>.
9
+ #
10
+ # Example:
11
+ #
12
+ # patch 'bacon', :to => 'food#bacon'
13
+ def patch(*args, &block)
14
+ map_method(:patch, *args, &block)
15
+ end
16
+
17
+ def put(*args, &block)
18
+ map_method(:put, *args, &block)
19
+ map_method(:patch, *args, &block)
20
+ end
21
+ end
22
+
23
+ # Be very conservative not to monkey-patch any methods until
24
+ # the relevant files are loaded.
25
+ ActiveSupport.on_load(:action_controller) do
26
+ ActionDispatch::Request.module_eval do
27
+ # Is this a PATCH request?
28
+ # Equivalent to <tt>request.request_method == :patch</tt>.
29
+ def patch?
30
+ HTTP_METHOD_LOOKUP[request_method] == :patch
31
+ end
32
+ end
33
+ module ActionDispatch::Routing
34
+ HTTP_METHODS << :patch unless HTTP_METHODS.include?(:patch)
35
+ end
36
+ ActionDispatch::Integration::RequestHelpers.module_eval do
37
+ # Performs a PATCH request with the given parameters. See +#get+ for more
38
+ # details.
39
+ def patch(path, parameters = nil, headers = nil)
40
+ process :patch, path, parameters, headers
41
+ end
42
+
43
+ # Performs a PATCH request, following any subsequent redirect.
44
+ # See +request_via_redirect+ for more information.
45
+ def patch_via_redirect(path, parameters = nil, headers = nil)
46
+ request_via_redirect(:patch, path, parameters, headers)
47
+ end
48
+ end
49
+ ActionDispatch::Integration::Runner.class_eval do
50
+ %w(patch).each do |method|
51
+ define_method(method) do |*args|
52
+ reset! unless integration_session
53
+ # reset the html_document variable, but only for new get/post calls
54
+ @html_document = nil unless method.in?(["cookies", "assigns"])
55
+ integration_session.__send__(method, *args).tap do
56
+ copy_session_variables!
57
+ end
58
+ end
59
+ end
60
+ end
61
+ module ActionController::TestCase::Behavior
62
+ def patch(action, parameters = nil, session = nil, flash = nil)
63
+ process(action, parameters, session, flash, "PATCH")
64
+ end
65
+ end
66
+ class ActionController::Responder
67
+ ACTIONS_FOR_VERBS.update(:patch => :edit)
68
+ delegate :patch?, :to => :request
69
+ end
70
+ ActionView::Helpers::FormHelper.module_eval do
71
+ # = Action View Form Helpers
72
+ def apply_form_for_options!(record, object, options) #:nodoc:
73
+ object = convert_to_model(object)
74
+
75
+ as = options[:as]
76
+ action, method = object.respond_to?(:persisted?) && object.persisted? ? [:edit, :patch] : [:new, :post]
77
+ options[:html].reverse_merge!(
78
+ :class => as ? "#{action}_#{as}" : dom_class(object, action),
79
+ :id => as ? "#{action}_#{as}" : [options[:namespace], dom_id(object, action)].compact.join("_").presence,
80
+ :method => method
81
+ )
82
+
83
+ options[:url] ||= polymorphic_path(record, :format => options.delete(:format))
84
+ end
85
+ private :apply_form_for_options!
86
+ end
87
+ module ActionDispatch::Routing::Mapper::Resources
88
+ class SingletonResource
89
+ def resource(*resources, &block)
90
+ options = resources.extract_options!.dup
91
+
92
+ if apply_common_behavior_for(:resource, resources, options, &block)
93
+ return self
94
+ end
95
+
96
+ resource_scope(:resource, SingletonResource.new(resources.pop, options)) do
97
+ yield if block_given?
98
+
99
+ collection do
100
+ post :create
101
+ end if parent_resource.actions.include?(:create)
102
+
103
+ new do
104
+ get :new
105
+ end if parent_resource.actions.include?(:new)
106
+
107
+ member do
108
+ get :edit if parent_resource.actions.include?(:edit)
109
+ get :show if parent_resource.actions.include?(:show)
110
+ if parent_resource.actions.include?(:update)
111
+ # all that for this PATCH
112
+ patch :update
113
+ put :update
114
+ end
115
+ delete :destroy if parent_resource.actions.include?(:destroy)
116
+ end
117
+ end
118
+
119
+ self
120
+ end
121
+ end
122
+ end
123
+ end
124
+ end
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_liana
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.beta.3
4
+ version: 1.0.0.pre.beta.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Munda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-03 00:00:00.000000000 Z
11
+ date: 2015-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: jsonapi-serializers
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.2.6
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.2.6
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: jwt
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.5'
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '1.5'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rack-cors
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 0.4.0
61
+ version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 0.4.0
68
+ version: '0'
69
69
  description: Forest Rails Liana
70
70
  email:
71
71
  - sandro@munda.me
@@ -92,13 +92,14 @@ files:
92
92
  - app/services/forest_liana/schema_adapter.rb
93
93
  - app/services/forest_liana/search_query_builder.rb
94
94
  - app/views/layouts/forest_liana/application.html.erb
95
- - config/initializers/active_record_or.rb
96
95
  - config/initializers/mimetype.rb
96
+ - config/initializers/rails32_http_patch_support_initializer.rb
97
97
  - config/routes.rb
98
98
  - lib/forest_liana.rb
99
99
  - lib/forest_liana/engine.rb
100
100
  - lib/forest_liana/version.rb
101
101
  - lib/generators/forest_liana/install_generator.rb
102
+ - lib/patches/add_patch_method.rb
102
103
  - lib/tasks/forest_tasks.rake
103
104
  - test/dummy/README.rdoc
104
105
  - test/dummy/Rakefile
@@ -1,21 +0,0 @@
1
- ActiveRecord::QueryMethods::WhereChain.class_eval do
2
- def or(*scopes)
3
- scopes_where_values = []
4
- scopes_bind_values = []
5
- scopes.each do |scope|
6
- case scope
7
- when ActiveRecord::Relation
8
- scopes_where_values += scope.where_values
9
- scopes_bind_values += scope.bind_values
10
- when Hash
11
- temp_scope = @scope.model.where(scope)
12
- scopes_where_values += temp_scope.where_values
13
- scopes_bind_values += temp_scope.bind_values
14
- end
15
- end
16
- scopes_where_values = scopes_where_values.inject(:or)
17
- @scope.where_values += [scopes_where_values]
18
- @scope.bind_values += scopes_bind_values
19
- @scope
20
- end
21
- end