kaminari-neo4j 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f3757da254f5e7f7dff521f7e505482f2ee93eda
4
+ data.tar.gz: 51e11d1bb43661d5b5f8934daacac8bf15136c99
5
+ SHA512:
6
+ metadata.gz: e468ea5032281e4f69be0e9f1882162157548f1bbedc79696e97577e3a4435a5cb4e5c1167daee25fdc7455778345743608c7157f006c2b96ba9229205ae036f
7
+ data.tar.gz: ea7bc1becc8167b52b4b02a8dc0123f2cc726949e399c98d1f0ee1451f6954d0b1a972b1fc7eea039272d66c6b1514c14dec7e2fe1bb3186ef83e5689bf51c82
@@ -0,0 +1 @@
1
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'bundler', '~> 1.7'
6
+ gem 'rake', '~> 10.0'
@@ -0,0 +1,102 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ kaminari-neo4j (0.0.1)
5
+ activesupport (>= 3.0)
6
+ kaminari (>= 0.16.3)
7
+ neo4j (>= 4.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actionpack (4.2.1)
13
+ actionview (= 4.2.1)
14
+ activesupport (= 4.2.1)
15
+ rack (~> 1.6)
16
+ rack-test (~> 0.6.2)
17
+ rails-dom-testing (~> 1.0, >= 1.0.5)
18
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
19
+ actionview (4.2.1)
20
+ activesupport (= 4.2.1)
21
+ builder (~> 3.1)
22
+ erubis (~> 2.7.0)
23
+ rails-dom-testing (~> 1.0, >= 1.0.5)
24
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
25
+ active_attr (0.8.5)
26
+ activemodel (>= 3.0.2, < 5.0)
27
+ activesupport (>= 3.0.2, < 5.0)
28
+ activemodel (4.2.1)
29
+ activesupport (= 4.2.1)
30
+ builder (~> 3.1)
31
+ activesupport (4.2.1)
32
+ i18n (~> 0.7)
33
+ json (~> 1.7, >= 1.7.7)
34
+ minitest (~> 5.1)
35
+ thread_safe (~> 0.3, >= 0.3.4)
36
+ tzinfo (~> 1.1)
37
+ builder (3.2.2)
38
+ erubis (2.7.0)
39
+ faraday (0.9.1)
40
+ multipart-post (>= 1.2, < 3)
41
+ faraday_middleware (0.9.1)
42
+ faraday (>= 0.7.4, < 0.10)
43
+ httparty (0.13.3)
44
+ json (~> 1.8)
45
+ multi_xml (>= 0.5.2)
46
+ httpclient (2.6.0.1)
47
+ i18n (0.7.0)
48
+ json (1.8.2)
49
+ kaminari (0.16.3)
50
+ actionpack (>= 3.0.0)
51
+ activesupport (>= 3.0.0)
52
+ loofah (2.0.1)
53
+ nokogiri (>= 1.5.9)
54
+ mini_portile (0.6.2)
55
+ minitest (5.6.1)
56
+ multi_xml (0.5.5)
57
+ multipart-post (2.0.0)
58
+ neo4j (4.1.5)
59
+ active_attr (~> 0.8)
60
+ activemodel (~> 4)
61
+ activesupport (~> 4)
62
+ neo4j-core (~> 4.0.0)
63
+ orm_adapter (~> 0.5.0)
64
+ neo4j-core (4.0.7)
65
+ activesupport
66
+ faraday (~> 0.9.0)
67
+ faraday_middleware (~> 0.9.1)
68
+ httparty
69
+ httpclient
70
+ json
71
+ net-http-persistent
72
+ os
73
+ zip
74
+ net-http-persistent (2.9.4)
75
+ nokogiri (1.6.6.2)
76
+ mini_portile (~> 0.6.0)
77
+ orm_adapter (0.5.0)
78
+ os (0.9.6)
79
+ rack (1.6.0)
80
+ rack-test (0.6.3)
81
+ rack (>= 1.0)
82
+ rails-deprecated_sanitizer (1.0.3)
83
+ activesupport (>= 4.2.0.alpha)
84
+ rails-dom-testing (1.0.6)
85
+ activesupport (>= 4.2.0.beta, < 5.0)
86
+ nokogiri (~> 1.6.0)
87
+ rails-deprecated_sanitizer (>= 1.0.1)
88
+ rails-html-sanitizer (1.0.2)
89
+ loofah (~> 2.0)
90
+ rake (10.4.2)
91
+ thread_safe (0.3.5)
92
+ tzinfo (1.2.2)
93
+ thread_safe (~> 0.1)
94
+ zip (2.0.2)
95
+
96
+ PLATFORMS
97
+ ruby
98
+
99
+ DEPENDENCIES
100
+ bundler (~> 1.7)
101
+ kaminari-neo4j!
102
+ rake (~> 10.0)
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 megorei Software
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,33 @@
1
+ # Kaminari::Neo4j
2
+
3
+ Adds [neo4j](https://github.com/neo4jrb/neo4j) support to [kaminari](https://github.com/amatsuda/kaminari).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'kaminari-neo4j'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install kaminari-neo4j
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ MyModel.page(4).per(10)
25
+ ```
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it ( https://github.com/[my-github-username]/kaminari-neo4j/fork )
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require 'bundler/gem_tasks'
2
+
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kaminari/neo4j/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'kaminari-neo4j'
8
+ spec.version = Kaminari::Neo4j::VERSION
9
+ spec.authors = ['Dieter Pisarewski']
10
+ spec.email = ['dieter.pisarewski@gmail.com']
11
+ spec.summary = 'Neo4j support for kaminari'
12
+ spec.description = 'Adds Neo4j support to kaminari'
13
+ spec.homepage = 'https://github.com/megorei/kaminari-neo4j'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'activesupport', '>= 3.0'
22
+ spec.add_dependency 'neo4j', '>= 4.0'
23
+ spec.add_dependency 'kaminari', '>= 0.16.3'
24
+ end
@@ -0,0 +1,10 @@
1
+ require 'kaminari/neo4j/version'
2
+ require 'active_support'
3
+ require 'neo4j'
4
+ require 'kaminari'
5
+ require 'kaminari/models/configuration_methods'
6
+ require 'kaminari/neo4j/criteria_methods'
7
+ require 'kaminari/neo4j/paginated'
8
+ require 'kaminari/neo4j/extension'
9
+ require 'kaminari/neo4j/hooks'
10
+ Kaminari::Neo4j::Hooks.init
@@ -0,0 +1,25 @@
1
+ module Kaminari
2
+ module Neo4j
3
+ module CriteriaMethods
4
+ include Kaminari::PageScopeMethods
5
+
6
+ delegate :default_per_page, :max_per_page, :max_pages, :to => :model
7
+
8
+ def entry_name
9
+ model.model_name.human.downcase
10
+ end
11
+
12
+ def limit_value
13
+ per_page
14
+ end
15
+
16
+ def offset_value
17
+ (current_page - 1) * per_page
18
+ end
19
+
20
+ def total_count
21
+ total
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,29 @@
1
+ module Kaminari
2
+ module Neo4j
3
+ module Extension
4
+ module QueryMethods
5
+ eval <<-RUBY
6
+ def #{Kaminari.config.page_method_name}(num = nil)
7
+ Kaminari::Neo4j::Paginated.new(self, num)
8
+ end
9
+ RUBY
10
+ end
11
+
12
+ module InstanceMethods
13
+ extend ActiveSupport::Concern
14
+
15
+ included do
16
+ include QueryMethods
17
+ end
18
+ end
19
+
20
+ module ClassMethods
21
+ extend ActiveSupport::Concern
22
+
23
+ included do
24
+ extend QueryMethods
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,13 @@
1
+ module Kaminari
2
+ module Neo4j
3
+ class Hooks
4
+ def self.init
5
+ ActiveSupport.on_load(:active_node) do
6
+ ::Neo4j::Core::Query.send :include, Kaminari::Neo4j::Extension::InstanceMethods
7
+ ::Neo4j::ActiveNode::Query::QueryProxy.send :include, Kaminari::Neo4j::Extension::InstanceMethods
8
+ ::Neo4j::ActiveNode.send :include, Kaminari::Neo4j::Extension::ClassMethods
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,61 @@
1
+ module Kaminari
2
+ module Neo4j
3
+ class Paginated
4
+ include Enumerable
5
+ include Kaminari::Neo4j::CriteriaMethods
6
+ include Kaminari::ConfigurationMethods::ClassMethods
7
+
8
+ attr_accessor :source, :total, :current_page, :per_page
9
+
10
+ delegate :each, to: :items
11
+ delegate :pluck, to: :items
12
+ delegate :[], to: :items
13
+ delegate :size, to: :to_a
14
+
15
+ def initialize(source, current_page, per_page = nil)
16
+ self.source = source
17
+ self.current_page = (current_page || 1).to_i
18
+ self.per_page = (per_page || default_per_page).to_i
19
+ end
20
+
21
+ def total
22
+ target = target(source)
23
+ if source.instance_of?(::Neo4j::Core::Query)
24
+ source.reorder.with("#{target} as #{target}").pluck("COUNT(#{target})").first
25
+ else
26
+ source.count
27
+ end
28
+ end
29
+
30
+ def items
31
+ @items || source.skip((current_page - 1) * per_page).limit(per_page)
32
+ end
33
+
34
+ def self.create_from(source, page, per_page = 0)
35
+ new(source, page, per_page)
36
+ end
37
+
38
+ def target(source)
39
+ source.instance_of?(::Neo4j::Core::Query) ? return_var : source.identity
40
+ end
41
+
42
+ def per(num)
43
+ self.class.create_from(source, current_page, num)
44
+ end
45
+
46
+ def pluck(*args)
47
+ @items = source.pluck(*args)
48
+ self
49
+ end
50
+
51
+ def return_var
52
+ clause = source.instance_variable_get('@clauses').find { |c| c.is_a?(::Neo4j::Core::QueryClauses::ReturnClause) }
53
+ clause.instance_variable_get('@arg')
54
+ end
55
+
56
+ def to_ary
57
+ items.to_a
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,5 @@
1
+ module Kaminari
2
+ module Neo4j
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kaminari-neo4j
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dieter Pisarewski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: neo4j
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: kaminari
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.16.3
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.16.3
55
+ description: Adds Neo4j support to kaminari
56
+ email:
57
+ - dieter.pisarewski@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - LICENSE
66
+ - README.md
67
+ - Rakefile
68
+ - kaminari-neo4j.gemspec
69
+ - lib/kaminari/neo4j.rb
70
+ - lib/kaminari/neo4j/criteria_methods.rb
71
+ - lib/kaminari/neo4j/extension.rb
72
+ - lib/kaminari/neo4j/hooks.rb
73
+ - lib/kaminari/neo4j/paginated.rb
74
+ - lib/kaminari/neo4j/version.rb
75
+ homepage: https://github.com/megorei/kaminari-neo4j
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.2.2
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Neo4j support for kaminari
99
+ test_files: []
100
+ has_rdoc: