upnxt_ransack 1.6.6.patch1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b9eea3c3a0fdb88250e6e58f5deb8ff69cc6868e
4
+ data.tar.gz: 0594da0f013cf3092c603b33d921222d9e59f0e8
5
+ SHA512:
6
+ metadata.gz: befd8fc4143c823acf3137d4b57e1c6ab71784baa9f8ec84eef71e454fc2a568473728f5464b793c16bdcf194a169d4624700d5dd97d879f3b43261c58cf299f
7
+ data.tar.gz: 46754d606fe8bd0d654be19fc693aee48a6257d0e86a224fb91a67cbb3679daceb06f7df7bd0932a88e0a9764cd52694b37020db48c4f14d5c90836419e48d9f
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,9 @@
1
+ = UpnxtRansack
2
+
3
+ Wrapper for Ransack to provide early releases of Ransack to Upnxt.
4
+
5
+ Currently addressed issues:
6
+
7
+ * {Searching across multiple associations that reference the same model/table joining on the wrong association}[https://github.com/activerecord-hackery/ransack/issues/374]
8
+
9
+ {<img src="https://badge.fury.io/rb/upnxt_ransack.svg" alt="Gem Version" />}[http://badge.fury.io/rb/upnxt_ransack]
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'UpnxtRansack'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
@@ -0,0 +1,41 @@
1
+ module Ransack
2
+ class Search
3
+ alias :old_initializer :initialize
4
+
5
+ def initialize(object, params = {}, options = {})
6
+ params ||= {}
7
+ params.each do |str, _|
8
+ str = str.is_a?(String) ? str.dup : str.to_s
9
+ Predicate.detect_and_strip_from_string!(str)
10
+ assoc = convert_to_associations_tree(object, str)
11
+ if assoc
12
+ macro = :has_one
13
+ last = assoc.pop
14
+ attr_name = last[1]
15
+ prev_assoc_sym = nil
16
+ assoc.reverse.each do |klass, str, reflection|
17
+ assoc_sym = str.sub(/_#{attr_name}\z/, '').to_sym
18
+ macro = reflection.macro if reflection.macro == :has_many
19
+ klass.send(macro, assoc_sym, through: reflection.name.to_sym, source: prev_assoc_sym) unless klass.reflections.keys.include?(assoc_sym)
20
+ prev_assoc_sym = assoc_sym
21
+ end
22
+ end
23
+ end
24
+ old_initializer(object, params, options)
25
+ end
26
+
27
+ private
28
+ def convert_to_associations_tree(klass, str)
29
+ #sort backwards to favor longer names
30
+ byebug unless klass
31
+ Hash[klass.reflections.sort { |a, b| b<=>a }].each do |name, reflection|
32
+ if str.start_with? name.to_s
33
+ next_source = reflection.options[:class] || reflection.class_name.constantize
34
+ result = convert_to_associations_tree(next_source, str.sub(/\A#{name.to_s}_/, ''))
35
+ return [[klass, str, reflection]].concat(result) if result
36
+ end
37
+ end
38
+ return [[klass, str, :none]] if klass.attribute_names.include?(str)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,4 @@
1
+ module UpnxtRansack
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module UpnxtRansack
2
+ VERSION = "1.6.6.patch1"
3
+ end
@@ -0,0 +1,4 @@
1
+ require "upnxt_ransack/engine"
2
+
3
+ module UpnxtRansack
4
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: upnxt_ransack
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.6.6.patch1
5
+ platform: ruby
6
+ authors:
7
+ - bert bruynooghe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ransack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.6.6
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.6.6
27
+ description: Ransack patch wrapper for Upnxt.
28
+ email:
29
+ - bert.bruynooghe@up-nxt.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - MIT-LICENSE
35
+ - README.rdoc
36
+ - Rakefile
37
+ - config/initializers/ransack.rb
38
+ - lib/upnxt_ransack.rb
39
+ - lib/upnxt_ransack/engine.rb
40
+ - lib/upnxt_ransack/version.rb
41
+ homepage: https://github.com/UP-nxt/upnxt_ransack
42
+ licenses:
43
+ - MIT
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">"
57
+ - !ruby/object:Gem::Version
58
+ version: 1.3.1
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 2.2.0
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: Ransack patch wrapper for Upnxt.
65
+ test_files: []