neo4j-will_paginate 0.1.2-java
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.
- data/.gitignore +7 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/README.md +39 -0
- data/Rakefile +7 -0
- data/lib/neo4j-will_paginate.rb +53 -0
- data/lib/neo4j-will_paginate/version.rb +5 -0
- data/neo4j-will_paginate.gemspec +27 -0
- data/spec/neo4j-will_paginate_spec.rb +67 -0
- data/spec/spec_helper.rb +39 -0
- metadata +117 -0
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            Integration for Neo4j.rb and will_paginate
         | 
| 2 | 
            +
            ============================================
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            This gem is just a simple integration of will_paginate and neo4j.
         | 
| 5 | 
            +
            [](http://travis-ci.org/dnagir/neo4j-will_paginate)
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Installation
         | 
| 8 | 
            +
            ==================
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            1. Add `neo4j-will_paginate` to your `Gemfile`.
         | 
| 11 | 
            +
            2. `require 'neo4j-will_paginate'` somewhere from your code.
         | 
| 12 | 
            +
             | 
| 13 | 
            +
             | 
| 14 | 
            +
             | 
| 15 | 
            +
            Using
         | 
| 16 | 
            +
            ==================
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            Please see the [will_paginate](https://github.com/mislav/will_paginate)
         | 
| 19 | 
            +
            and [neo4j.rb](https://github.com/andreasronge/neo4j) for details.
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            But here is simple example:
         | 
| 22 | 
            +
             | 
| 23 | 
            +
             | 
| 24 | 
            +
            ```ruby
         | 
| 25 | 
            +
            # Probably in the Rails controller:
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            def index
         | 
| 28 | 
            +
              @people = Person.all.paginate(:page => 2, :per_page => 20) # :per_page is optional
         | 
| 29 | 
            +
            end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            # Then in the view:
         | 
| 32 | 
            +
            paginate @people
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            ```
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            License
         | 
| 37 | 
            +
            =====================
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            MIT by Dmytrii Nagirniak and Andreas Ronge
         | 
    
        data/Rakefile
    ADDED
    
    
| @@ -0,0 +1,53 @@ | |
| 1 | 
            +
            require "neo4j-will_paginate/version"
         | 
| 2 | 
            +
            require 'will_paginate/collection'
         | 
| 3 | 
            +
            require 'neo4j'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
             | 
| 6 | 
            +
            module Neo4j
         | 
| 7 | 
            +
              module WillPaginate
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                # The module provides the common interface for the pagination on any Enumerable class.
         | 
| 10 | 
            +
                # By including the module, {Neo4j::WillPaginate::Pagination#paginate} method will be available.
         | 
| 11 | 
            +
                module Pagination
         | 
| 12 | 
            +
                  include ::WillPaginate::CollectionMethods
         | 
| 13 | 
            +
             | 
| 14 | 
            +
             | 
| 15 | 
            +
                  # Paginates the {Enumerable} and returns {::WillPaginate::Collection} instance.
         | 
| 16 | 
            +
                  #
         | 
| 17 | 
            +
                  # @param [Hash] options a hash of options for the pagination.
         | 
| 18 | 
            +
                  # @option options [Symbol] :page current page for the pagination (defualts to 1).
         | 
| 19 | 
            +
                  # @option options [Symbol] :per_page numer of items per page (defaults to {::WillPaginate.per_page}).
         | 
| 20 | 
            +
                  #                           Aliases are `:per`, `:limit`.
         | 
| 21 | 
            +
                  #
         | 
| 22 | 
            +
                  # @example Paginate on a relationship:
         | 
| 23 | 
            +
                  #   person.friends.paginate(:page => 5, :per_page => 10)
         | 
| 24 | 
            +
                  #
         | 
| 25 | 
            +
                  # @example Paginate the search results:
         | 
| 26 | 
            +
                  #   Person.all(:conditions => "name: Dmytrii*").paginate(:page => 5, :per_page => 10)
         | 
| 27 | 
            +
                  def paginate(options={})
         | 
| 28 | 
            +
                    page      = (options[:page] || 1).to_i
         | 
| 29 | 
            +
                    per_page  = (options[:per] || options[:per_page] || options[:limit] || WillPaginate.per_page).to_i
         | 
| 30 | 
            +
                    ::WillPaginate::Collection.create(page, per_page) do |pager|
         | 
| 31 | 
            +
                      res = ::Neo4j::Paginated.create_from(self, page, per_page)
         | 
| 32 | 
            +
                      pager.replace res.to_a
         | 
| 33 | 
            +
                      pager.total_entries = res.total unless pager.total_entries
         | 
| 34 | 
            +
                    end
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            [
         | 
| 44 | 
            +
              Neo4j::Core::Traversal::Traverser,
         | 
| 45 | 
            +
              Neo4j::Core::Index::LuceneQuery,
         | 
| 46 | 
            +
              Neo4j::Core::Cypher::ResultWrapper,
         | 
| 47 | 
            +
              Neo4j::Core::Traversal::CypherQuery,
         | 
| 48 | 
            +
              Neo4j::Wrapper::HasN::Nodes,
         | 
| 49 | 
            +
              Neo4j::Rails::Relationships::NodesDSL,
         | 
| 50 | 
            +
              Neo4j::Rails::Relationships::RelsDSL
         | 
| 51 | 
            +
            ].each do |m|
         | 
| 52 | 
            +
              m.send :include, Neo4j::WillPaginate::Pagination
         | 
| 53 | 
            +
            end
         | 
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
            $:.push File.expand_path("../lib", __FILE__)
         | 
| 3 | 
            +
            require "neo4j-will_paginate/version"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Gem::Specification.new do |s|
         | 
| 6 | 
            +
              s.name        = "neo4j-will_paginate"
         | 
| 7 | 
            +
              s.version     = Neo4j::WillPaginate::VERSION
         | 
| 8 | 
            +
              s.authors     = ["Dmytrii Nagirniak", "Andreas Ronge"]
         | 
| 9 | 
            +
              s.email       = ["dnagir@gmail.com", "andreas.ronge@gmail.com"]
         | 
| 10 | 
            +
              s.homepage    = "https://github.com/dnagir/neo4j-will_paginate"
         | 
| 11 | 
            +
              s.summary     = %q{Integration between neo4j.rb and will_paginate.}
         | 
| 12 | 
            +
              s.description = s.summary
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              s.rubyforge_project = "neo4j-will_paginate"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              s.files         = `git ls-files`.split("\n")
         | 
| 17 | 
            +
              s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
         | 
| 18 | 
            +
              s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         | 
| 19 | 
            +
              s.require_paths = ["lib"]
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              s.platform = 'java'
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              s.add_development_dependency "rspec"
         | 
| 24 | 
            +
              s.add_runtime_dependency "activesupport", "~> 3.0"
         | 
| 25 | 
            +
              s.add_runtime_dependency "will_paginate", "~> 3.0"
         | 
| 26 | 
            +
              s.add_runtime_dependency "neo4j", ">= 2.0.0.alpha.4"
         | 
| 27 | 
            +
            end
         | 
| @@ -0,0 +1,67 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Specs
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              class Person < ::Neo4j::Rails::Model
         | 
| 6 | 
            +
                property :name, :default => 'x'
         | 
| 7 | 
            +
                index :name
         | 
| 8 | 
            +
                has_n :friends
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              describe Neo4j::WillPaginate::Pagination do
         | 
| 12 | 
            +
                subject { source.paginate(:page => 2, :per_page => 3) }
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                def self.should_be_paginated
         | 
| 15 | 
            +
                  its(:size)          { should == 3 }
         | 
| 16 | 
            +
                  its(:current_page)  { should == 2 }
         | 
| 17 | 
            +
                  its(:per_page)      { should == 3 }
         | 
| 18 | 
            +
                  its(:total_entries) { should == 10 }
         | 
| 19 | 
            +
                  its(:offset)        { should == 3 }
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                context ::Neo4j::Core::Traversal::Traverser do
         | 
| 23 | 
            +
                  let(:source)  { Person.all }
         | 
| 24 | 
            +
                  before        { 10.times { Person.create } }
         | 
| 25 | 
            +
                  should_be_paginated
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                context ::Neo4j::Core::Cypher::ResultWrapper do
         | 
| 29 | 
            +
                  let(:source)  { Neo4j._query(Person.all.query.to_s) }
         | 
| 30 | 
            +
                  before        { 10.times { Person.create(:name => 'x') } }
         | 
| 31 | 
            +
                  it do
         | 
| 32 | 
            +
                    pending "does not work yet"
         | 
| 33 | 
            +
                    should_be_paginated
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                context ::Neo4j::Core::Traversal::CypherQuery do
         | 
| 38 | 
            +
                  let(:source)  { Person.all.query }
         | 
| 39 | 
            +
                  before        { 10.times { Person.create(:name => 'x') } }
         | 
| 40 | 
            +
                  should_be_paginated
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                context ::Neo4j::Core::Index::LuceneQuery do
         | 
| 44 | 
            +
                  let(:source)  { Person.all(:conditions => 'name: *') }
         | 
| 45 | 
            +
                  before        { 10.times { Person.create(:name => 'x') } }
         | 
| 46 | 
            +
                  should_be_paginated
         | 
| 47 | 
            +
                end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                describe "models & rels" do
         | 
| 50 | 
            +
                  let(:source)  { he.friends }
         | 
| 51 | 
            +
                  let(:he)      { Person.create }
         | 
| 52 | 
            +
                  before        { 10.times { he.friends << Person.create }; he.save! }
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                  context ::Neo4j::Rails::Relationships::NodesDSL do
         | 
| 55 | 
            +
                    should_be_paginated
         | 
| 56 | 
            +
                  end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                  context ::Neo4j::Rails::Relationships::RelsDSL do
         | 
| 59 | 
            +
                    subject { source.paginate(:page => "2", :per => "3") } # Just a bit different set of options
         | 
| 60 | 
            +
                    let(:source)        { he.rels(:outgoing, :friends) }
         | 
| 61 | 
            +
                    should_be_paginated
         | 
| 62 | 
            +
                  end
         | 
| 63 | 
            +
                end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
              end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            # This file was generated by the `rspec --init` command. Conventionally, all
         | 
| 2 | 
            +
            # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
         | 
| 3 | 
            +
            # Require this file using `require "spec_helper.rb"` to ensure that it is only
         | 
| 4 | 
            +
            # loaded once.
         | 
| 5 | 
            +
            #
         | 
| 6 | 
            +
            # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
         | 
| 7 | 
            +
            RSpec.configure do |config|
         | 
| 8 | 
            +
              config.treat_symbols_as_metadata_keys_with_true_values = true
         | 
| 9 | 
            +
              config.run_all_when_everything_filtered = true
         | 
| 10 | 
            +
              config.filter_run :focus
         | 
| 11 | 
            +
            end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
             | 
| 14 | 
            +
            require 'neo4j-will_paginate'
         | 
| 15 | 
            +
             | 
| 16 | 
            +
             | 
| 17 | 
            +
            # neo4j Specs clean-up
         | 
| 18 | 
            +
            require 'fileutils'
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            def rm_db_storage!
         | 
| 21 | 
            +
              FileUtils.rm_rf Neo4j::Config[:storage_path]
         | 
| 22 | 
            +
              raise "Can't delete db" if File.exist?(Neo4j::Config[:storage_path])
         | 
| 23 | 
            +
            end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            RSpec.configure do |config|
         | 
| 26 | 
            +
              $spec_counter = 0
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              config.before(:all) do
         | 
| 29 | 
            +
                rm_db_storage! unless Neo4j.running?
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              config.after(:each) do
         | 
| 33 | 
            +
                Neo4j::Rails::Model.close_lucene_connections
         | 
| 34 | 
            +
                Neo4j::Transaction.run do
         | 
| 35 | 
            +
                  Neo4j.threadlocal_ref_node = Neo4j::Node.new :name => "ref_#{$spec_counter}"
         | 
| 36 | 
            +
                  $spec_counter += 1
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,117 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification 
         | 
| 2 | 
            +
            name: neo4j-will_paginate
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            +
              prerelease: 
         | 
| 5 | 
            +
              version: 0.1.2
         | 
| 6 | 
            +
            platform: java
         | 
| 7 | 
            +
            authors: 
         | 
| 8 | 
            +
              - Dmytrii Nagirniak
         | 
| 9 | 
            +
              - Andreas Ronge
         | 
| 10 | 
            +
            autorequire: 
         | 
| 11 | 
            +
            bindir: bin
         | 
| 12 | 
            +
            cert_chain: []
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            date: 2012-08-21 00:00:00 Z
         | 
| 15 | 
            +
            dependencies: 
         | 
| 16 | 
            +
              - !ruby/object:Gem::Dependency 
         | 
| 17 | 
            +
                name: rspec
         | 
| 18 | 
            +
                version_requirements: &id001 !ruby/object:Gem::Requirement 
         | 
| 19 | 
            +
                  none: false
         | 
| 20 | 
            +
                  requirements: 
         | 
| 21 | 
            +
                    - - ">="
         | 
| 22 | 
            +
                      - !ruby/object:Gem::Version 
         | 
| 23 | 
            +
                        version: "0"
         | 
| 24 | 
            +
                requirement: *id001
         | 
| 25 | 
            +
                prerelease: false
         | 
| 26 | 
            +
                type: :development
         | 
| 27 | 
            +
              - !ruby/object:Gem::Dependency 
         | 
| 28 | 
            +
                name: activesupport
         | 
| 29 | 
            +
                version_requirements: &id002 !ruby/object:Gem::Requirement 
         | 
| 30 | 
            +
                  none: false
         | 
| 31 | 
            +
                  requirements: 
         | 
| 32 | 
            +
                    - - ~>
         | 
| 33 | 
            +
                      - !ruby/object:Gem::Version 
         | 
| 34 | 
            +
                        version: "3.0"
         | 
| 35 | 
            +
                requirement: *id002
         | 
| 36 | 
            +
                prerelease: false
         | 
| 37 | 
            +
                type: :runtime
         | 
| 38 | 
            +
              - !ruby/object:Gem::Dependency 
         | 
| 39 | 
            +
                name: will_paginate
         | 
| 40 | 
            +
                version_requirements: &id003 !ruby/object:Gem::Requirement 
         | 
| 41 | 
            +
                  none: false
         | 
| 42 | 
            +
                  requirements: 
         | 
| 43 | 
            +
                    - - ~>
         | 
| 44 | 
            +
                      - !ruby/object:Gem::Version 
         | 
| 45 | 
            +
                        version: "3.0"
         | 
| 46 | 
            +
                requirement: *id003
         | 
| 47 | 
            +
                prerelease: false
         | 
| 48 | 
            +
                type: :runtime
         | 
| 49 | 
            +
              - !ruby/object:Gem::Dependency 
         | 
| 50 | 
            +
                name: neo4j
         | 
| 51 | 
            +
                version_requirements: &id004 !ruby/object:Gem::Requirement 
         | 
| 52 | 
            +
                  none: false
         | 
| 53 | 
            +
                  requirements: 
         | 
| 54 | 
            +
                    - - ">="
         | 
| 55 | 
            +
                      - !ruby/object:Gem::Version 
         | 
| 56 | 
            +
                        version: 2.0.0.alpha.4
         | 
| 57 | 
            +
                requirement: *id004
         | 
| 58 | 
            +
                prerelease: false
         | 
| 59 | 
            +
                type: :runtime
         | 
| 60 | 
            +
            description: Integration between neo4j.rb and will_paginate.
         | 
| 61 | 
            +
            email: 
         | 
| 62 | 
            +
              - dnagir@gmail.com
         | 
| 63 | 
            +
              - andreas.ronge@gmail.com
         | 
| 64 | 
            +
            executables: []
         | 
| 65 | 
            +
             | 
| 66 | 
            +
            extensions: []
         | 
| 67 | 
            +
             | 
| 68 | 
            +
            extra_rdoc_files: []
         | 
| 69 | 
            +
             | 
| 70 | 
            +
            files: 
         | 
| 71 | 
            +
              - .gitignore
         | 
| 72 | 
            +
              - .rspec
         | 
| 73 | 
            +
              - .travis.yml
         | 
| 74 | 
            +
              - Gemfile
         | 
| 75 | 
            +
              - README.md
         | 
| 76 | 
            +
              - Rakefile
         | 
| 77 | 
            +
              - lib/neo4j-will_paginate.rb
         | 
| 78 | 
            +
              - lib/neo4j-will_paginate/version.rb
         | 
| 79 | 
            +
              - neo4j-will_paginate.gemspec
         | 
| 80 | 
            +
              - spec/neo4j-will_paginate_spec.rb
         | 
| 81 | 
            +
              - spec/spec_helper.rb
         | 
| 82 | 
            +
            homepage: https://github.com/dnagir/neo4j-will_paginate
         | 
| 83 | 
            +
            licenses: []
         | 
| 84 | 
            +
             | 
| 85 | 
            +
            post_install_message: 
         | 
| 86 | 
            +
            rdoc_options: []
         | 
| 87 | 
            +
             | 
| 88 | 
            +
            require_paths: 
         | 
| 89 | 
            +
              - lib
         | 
| 90 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 91 | 
            +
              none: false
         | 
| 92 | 
            +
              requirements: 
         | 
| 93 | 
            +
                - - ">="
         | 
| 94 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 95 | 
            +
                    hash: 2
         | 
| 96 | 
            +
                    segments: 
         | 
| 97 | 
            +
                      - 0
         | 
| 98 | 
            +
                    version: "0"
         | 
| 99 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 100 | 
            +
              none: false
         | 
| 101 | 
            +
              requirements: 
         | 
| 102 | 
            +
                - - ">="
         | 
| 103 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 104 | 
            +
                    hash: 2
         | 
| 105 | 
            +
                    segments: 
         | 
| 106 | 
            +
                      - 0
         | 
| 107 | 
            +
                    version: "0"
         | 
| 108 | 
            +
            requirements: []
         | 
| 109 | 
            +
             | 
| 110 | 
            +
            rubyforge_project: neo4j-will_paginate
         | 
| 111 | 
            +
            rubygems_version: 1.8.15
         | 
| 112 | 
            +
            signing_key: 
         | 
| 113 | 
            +
            specification_version: 3
         | 
| 114 | 
            +
            summary: Integration between neo4j.rb and will_paginate.
         | 
| 115 | 
            +
            test_files: 
         | 
| 116 | 
            +
              - spec/neo4j-will_paginate_spec.rb
         | 
| 117 | 
            +
              - spec/spec_helper.rb
         |