activerecord-vertica-adapter 0.1-java

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ Note that this license covers the code used to connect ActiveRecord to
2
+ the Vertica only, and not the Vertica-JDBC drivers or database itself, which
3
+ must be obtained from www.vertica.com.
4
+
5
+ The MIT License
6
+
7
+ Copyright (c) 2012 Paul Groudas
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in
17
+ all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,20 @@
1
+ activerecord-vertica-adapter
2
+ ===========================
3
+
4
+ This is an ActiveRecord adapter for Vertica extracted
5
+ from the activerecord-jdbc-adapter project.
6
+
7
+ This project is also an example of the activerecord-jdbc-adapter
8
+ adapter extension discovery mechanism, and how you might organize a
9
+ gem for your custom database. In particular, note:
10
+
11
+ - `lib/arjdbc/discover.rb`: This file gets loaded by
12
+ activerecord-jdbc-adapter, and where you register your extension.
13
+ Follow the conventions in that file to declare it.
14
+ - `lib/arjdbc/vertica*`: Organize the ::ArJdbc::Vertica code in here.
15
+ Typically you'll have a `connection_methods.rb` file which creates a
16
+ `vertica_connection` method on ActiveRecord::Base as well as an
17
+ `adapter.rb` file which contains most of the custom adapter code.
18
+ - `lib/active_record/connection_adapters/vertica_adapter.rb`: This
19
+ file is what allows ActiveRecord to load an adapter from its
20
+ `adapter: cachedb` line in database.yml.
data/Rakefile ADDED
@@ -0,0 +1,115 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'date'
4
+
5
+ #############################################################################
6
+ #
7
+ # Helper functions
8
+ #
9
+ #############################################################################
10
+
11
+ def name
12
+ @name ||= Dir['*.gemspec'].first.split('.').first
13
+ end
14
+
15
+ def version
16
+ line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
17
+ line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
18
+ end
19
+
20
+ def date
21
+ Date.today.to_s
22
+ end
23
+
24
+ def rubyforge_project
25
+ "jruby-extras"
26
+ end
27
+
28
+ def gemspec_file
29
+ "#{name}.gemspec"
30
+ end
31
+
32
+ def gem_file
33
+ "#{name}-#{version}*.gem"
34
+ end
35
+
36
+ def replace_header(head, header_name)
37
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
38
+ end
39
+
40
+ #############################################################################
41
+ #
42
+ # Standard tasks
43
+ #
44
+ #############################################################################
45
+
46
+ task :default => :test
47
+
48
+ require 'rake/testtask'
49
+ Rake::TestTask.new(:test) do |test|
50
+ test.libs << 'lib' << 'test'
51
+ ar_jdbc = ENV['AR_JDBC'] ||
52
+ (begin
53
+ gem 'activerecord-jdbc-adapter'
54
+ Gem.loaded_specs['activerecord-jdbc-adapter'].full_gem_path
55
+ rescue
56
+ raise "Please install activerecord-jdbc-adapter to run tests."
57
+ end)
58
+ test.libs << File.join(ar_jdbc, 'test')
59
+ test.pattern = 'test/**/*test*.rb'
60
+ test.verbose = true
61
+ end
62
+
63
+ require 'rake/rdoctask'
64
+ Rake::RDocTask.new do |rdoc|
65
+ rdoc.rdoc_dir = 'rdoc'
66
+ rdoc.title = "#{name} #{version}"
67
+ rdoc.rdoc_files.include('README*')
68
+ rdoc.rdoc_files.include('lib/**/*.rb')
69
+ end
70
+
71
+ task :release => :build do
72
+ unless `git branch` =~ /^\* master$/
73
+ puts "You must be on the master branch to release!"
74
+ exit!
75
+ end
76
+ sh "git commit --allow-empty -a -m 'Release #{version}'"
77
+ sh "git tag v#{version}"
78
+ sh "git push origin master"
79
+ sh "git push origin v#{version}"
80
+ sh "gem push pkg/#{name}-#{version}.gem"
81
+ end
82
+
83
+ task :build => :gemspec do
84
+ sh "mkdir -p pkg"
85
+ sh "gem build #{gemspec_file}"
86
+ sh "mv #{gem_file} pkg"
87
+ end
88
+
89
+ task :gemspec do
90
+ # read spec file and split out manifest section
91
+ spec = File.read(gemspec_file)
92
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
93
+
94
+ # replace name version and date
95
+ replace_header(head, :name)
96
+ replace_header(head, :version)
97
+ replace_header(head, :date)
98
+ #comment this out if your rubyforge_project has a different name
99
+ replace_header(head, :rubyforge_project)
100
+
101
+ # determine file list from git ls-files
102
+ files = `git ls-files`.
103
+ split("\n").
104
+ sort.
105
+ reject { |file| file =~ /^\./ }.
106
+ reject { |file| file =~ /^(rdoc|pkg)/ }.
107
+ map { |file| " #{file}" }.
108
+ join("\n")
109
+
110
+ # piece file back together and write
111
+ manifest = " s.files = %w[\n#{files}\n ]\n"
112
+ spec = [head, manifest, tail].join(" # = MANIFEST =\n")
113
+ File.open(gemspec_file, 'w') { |io| io.write(spec) }
114
+ puts "Updated #{gemspec_file}"
115
+ end
@@ -0,0 +1,48 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'activerecord-vertica-adapter'
5
+ s.version = '0.1'
6
+ s.date = '2012-03-05'
7
+
8
+ s.platform = Gem::Platform.new([nil, "java", nil])
9
+ s.rubyforge_project = %q{jruby-extras}
10
+
11
+ s.summary = "ActiveRecord adapter for Vertica."
12
+ s.description = "ActiveRecord adapter for Vertica. Only for use with JRuby. Requires separate Vertica JDBC driver."
13
+
14
+ s.authors = ["Paul Groudas"]
15
+ s.email = 'paul@intentmedia.com'
16
+ s.homepage = 'https://github.com/pgroudas/activerecord-vertica-adapter'
17
+ s.require_paths = %w[lib]
18
+ s.rdoc_options = ["--charset=UTF-8"]
19
+ s.extra_rdoc_files = %w[README.md LICENSE]
20
+
21
+ # = MANIFEST =
22
+ s.files = %w[
23
+ LICENSE
24
+ README.md
25
+ Rakefile
26
+ activerecord-vertica-adapter.gemspec
27
+ lib/active_record/connection_adapters/vertica_adapter.rb
28
+ lib/activerecord-vertica-adapter.rb
29
+ lib/arjdbc/vertica.rb
30
+ lib/arjdbc/vertica/adapter.rb
31
+ lib/arjdbc/vertica/connection_methods.rb
32
+ lib/arjdbc/discover.rb
33
+ test/vertica_simple_test.rb
34
+ test/db/vertica.rb
35
+ ]
36
+ # = MANIFEST =
37
+
38
+ s.test_files = s.files.select { |path| path =~ /^test\/.*test.*\.rb/ }
39
+
40
+ s.add_dependency(%q<activerecord-jdbc-adapter>, [">= 1.0.0"])
41
+
42
+ s.rubygems_version = %q{1.3.7}
43
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
44
+ if s.respond_to? :specification_version then
45
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
+ s.specification_version = 3
47
+ end
48
+ end
@@ -0,0 +1 @@
1
+ require 'arjdbc/vertica'
@@ -0,0 +1,5 @@
1
+ module ArJdbc
2
+ module Vertica
3
+ VERSION = "0.1"
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ # arjdbc/discover.rb: Declare ArJdbc.extension modules in this file
2
+ # that loads a custom module and adapter.
3
+
4
+ module ::ArJdbc
5
+ extension :Vertica do |name|
6
+ if name =~ /vertica/i
7
+ require 'arjdbc/vertica'
8
+ true
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ require 'arjdbc/jdbc'
2
+ require 'arjdbc/vertica/connection_methods'
3
+ require 'arjdbc/vertica/adapter'
@@ -0,0 +1,10 @@
1
+ module ActiveRecord
2
+ module ConnectionAdapters
3
+ AR_TO_JDBC_TYPES[:string] << lambda {|r| r['type_name'] =~ /varchar$/i} # For Vertica
4
+ end
5
+ end
6
+
7
+ module ::ArJdbc
8
+ module Vertica
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class ActiveRecord::Base
2
+ class << self
3
+ def vertica_connection( config )
4
+ config[:port] || 5433
5
+ config[:url] ||= "jdbc:vertica://#{config[:host]}:#{config[:port]}/#{ config[:database]}"
6
+ config[:driver] ||= "com.vertica.jdbc.Driver"
7
+ jdbc_connection(config)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ #config = {
2
+ #:username => '_SYSTEM',
3
+ #:password => 'SYS',
4
+ #:adapter => 'cachedb',
5
+ #:host => ENV[ "CACHE_HOST" ] || 'localhost',
6
+ #:database => ENV[ "CACHE_NAMESPACE" ] || 'weblog_development'
7
+ #}
8
+
9
+ #ActiveRecord::Base.establish_connection( config )
@@ -0,0 +1,6 @@
1
+ require 'jdbc_common'
2
+ require 'db/vertica'
3
+
4
+ class VerticaSimpleTest < Test::Unit::TestCase
5
+ #include SimpleTestMethods
6
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activerecord-vertica-adapter
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: "0.1"
6
+ platform: java
7
+ authors:
8
+ - Paul Groudas
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-03-05 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activerecord-jdbc-adapter
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.0.0
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ description: ActiveRecord adapter for Vertica. Only for use with JRuby. Requires separate Vertica JDBC driver.
27
+ email: paul@intentmedia.com
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files:
33
+ - README.md
34
+ - LICENSE
35
+ files:
36
+ - LICENSE
37
+ - README.md
38
+ - Rakefile
39
+ - activerecord-vertica-adapter.gemspec
40
+ - lib/active_record/connection_adapters/vertica_adapter.rb
41
+ - lib/activerecord-vertica-adapter.rb
42
+ - lib/arjdbc/vertica.rb
43
+ - lib/arjdbc/vertica/adapter.rb
44
+ - lib/arjdbc/vertica/connection_methods.rb
45
+ - lib/arjdbc/discover.rb
46
+ - test/vertica_simple_test.rb
47
+ - test/db/vertica.rb
48
+ homepage: https://github.com/pgroudas/activerecord-vertica-adapter
49
+ licenses: []
50
+
51
+ post_install_message:
52
+ rdoc_options:
53
+ - --charset=UTF-8
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">"
66
+ - !ruby/object:Gem::Version
67
+ version: 1.3.1
68
+ requirements: []
69
+
70
+ rubyforge_project: jruby-extras
71
+ rubygems_version: 1.8.9
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: ActiveRecord adapter for Vertica.
75
+ test_files:
76
+ - test/vertica_simple_test.rb