├── Rakefile ├── lib ├── redshift_cursor │ ├── version.rb │ └── active_record │ │ └── connection_adapters │ │ └── redshift_type_map.rb └── redshift_cursor.rb ├── Gemfile ├── .gitignore ├── bin ├── setup └── console ├── LICENSE.txt ├── redshift_cursor.gemspec └── README.md /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | task :default => :spec 3 | -------------------------------------------------------------------------------- /lib/redshift_cursor/version.rb: -------------------------------------------------------------------------------- 1 | module RedshiftCursor 2 | VERSION = "1.2.0" 3 | end 4 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in redshift_cursor.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /Gemfile.lock 4 | /_yardoc/ 5 | /coverage/ 6 | /doc/ 7 | /pkg/ 8 | /spec/reports/ 9 | /tmp/ 10 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | set -vx 5 | 6 | bundle install 7 | 8 | # Do any other automated setup that you need to do here 9 | -------------------------------------------------------------------------------- /bin/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require "bundler/setup" 4 | require "redshift_cursor" 5 | 6 | # You can add fixtures and/or initialization code here to make experimenting 7 | # with your gem easier. You can also use a different console, if you like. 8 | 9 | # (If you use this, don't forget to add pry to your Gemfile!) 10 | # require "pry" 11 | # Pry.start 12 | 13 | require "irb" 14 | IRB.start 15 | -------------------------------------------------------------------------------- /lib/redshift_cursor.rb: -------------------------------------------------------------------------------- 1 | require 'redshift_cursor/version' 2 | 3 | require 'active_support' 4 | 5 | ActiveSupport.on_load :active_record do 6 | require 'redshift_cursor/active_record/connection_adapters/redshift_type_map' 7 | 8 | require 'postgresql_cursor' 9 | 10 | require 'active_record/connection_adapters/redshift_adapter' 11 | ActiveRecord::ConnectionAdapters::RedshiftAdapter.send(:include, RedshiftCursor::ActiveRecord::ConnectionAdapters::RedshiftTypeMap) 12 | end 13 | -------------------------------------------------------------------------------- /lib/redshift_cursor/active_record/connection_adapters/redshift_type_map.rb: -------------------------------------------------------------------------------- 1 | module RedshiftCursor 2 | module ActiveRecord 3 | module ConnectionAdapters 4 | module RedshiftTypeMap 5 | def get_type_map 6 | if ::ActiveRecord::VERSION::MAJOR == 4 && ::ActiveRecord::VERSION::MINOR == 0 7 | ::ActiveRecord::ConnectionAdapters::RedshiftAdapter::OID::TYPE_MAP 8 | else 9 | type_map 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Hiroyuki Inoue 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 13 | all 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /redshift_cursor.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'redshift_cursor/version' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = "redshift_cursor" 8 | spec.version = RedshiftCursor::VERSION 9 | spec.authors = ["Hiroyuki Inoue"] 10 | spec.email = ["mammymax@gmail.com"] 11 | 12 | spec.summary = "Enable cursor to Redshift on ActiveRecord" 13 | spec.description = "Enable cursor to Redshift on ActiveRecord" 14 | spec.homepage = "https://github.com/inohiro/redshift_cursor" 15 | spec.license = "MIT" 16 | 17 | spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } 18 | spec.bindir = "exe" 19 | spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } 20 | spec.require_paths = ["lib"] 21 | 22 | spec.add_dependency 'pg' 23 | spec.add_dependency 'postgresql_cursor' 24 | spec.add_dependency 'activerecord-redshift' 25 | 26 | spec.add_development_dependency "bundler", "~> 1.11" 27 | spec.add_development_dependency "rake", "~> 10.0" 28 | end 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RedshiftCursor 2 | 3 | [![Gem Version](https://badge.fury.io/rb/redshift_cursor.svg)](https://badge.fury.io/rb/redshift_cursor) 4 | 5 | Enable cursor to Redshift on ActiveRecord. 6 | 7 | This gem bridges 8 | [activerecord-redshift](https://github.com/bricolages/activerecord-redshift) 9 | and [PostgreSQLCursor](https://github.com/afair/postgresql_cursor). 10 | 11 | Supporting ActiveRecord version: >= 4.0 12 | 13 | ## Installation 14 | 15 | Add this line to your application's Gemfile: 16 | 17 | ```ruby 18 | gem 'redshift_cursor' 19 | ``` 20 | 21 | And then execute: 22 | 23 | $ bundle 24 | 25 | Or install it yourself as: 26 | 27 | $ gem install redshift_cursor 28 | 29 | ## Usage 30 | 31 | See PostgreSQLCursor one: https://github.com/afair/postgresql_cursor/blob/master/README.md 32 | 33 | ## Development 34 | 35 | After checking out the repo, run `bin/setup` to install 36 | dependencies. You can also run `bin/console` for an interactive prompt 37 | that will allow you to experiment. 38 | 39 | To install this gem onto your local machine, run `bundle exec rake 40 | install`. To release a new version, update the version number in 41 | `version.rb`, and then run `bundle exec rake release`, which will 42 | create a git tag for the version, push git commits and tags, and push 43 | the `.gem` file to [rubygems.org](https://rubygems.org). 44 | 45 | ## Contributing 46 | 47 | Bug reports and pull requests are welcome on GitHub at 48 | https://github.com/bricolages/redshift_cursor. 49 | 50 | 51 | ## License 52 | 53 | The gem is available as open source under the terms of the 54 | [MIT License](http://opensource.org/licenses/MIT). 55 | --------------------------------------------------------------------------------