activerecord-exception-adapter 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a4122191d056e1386fc899bc15a308537b4a1963
4
+ data.tar.gz: 2f82d8cd040920288daaf9c1488baf460d4b039f
5
+ SHA512:
6
+ metadata.gz: 3a2b3682249a918bf156ce3c2a85c10020515e0b479f15e0d0440bcbd94b8c97e153d29f213a956a40b7f45702f18cce0532e2d82e3fc395214ed2090699686d
7
+ data.tar.gz: 6fd10c2f1b110c274f2cbc520a1ed6c3c283248d39f2181f72272a5031a0d6ac5731aa4821ee6e325e3c1a64c2d6da4ffd77657a8a0d83905da6703c4bb8f4f9
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ gemfiles/*.gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --warnings
3
+ --require spec_helper
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1
6
+ - ruby-head
7
+ gemfile:
8
+ - gemfiles/rails_3.2.gemfile
9
+ - gemfiles/rails_4.0.gemfile
10
+ - gemfiles/rails_4.1.gemfile
11
+ matrix:
12
+ allow_failures:
13
+ - rvm: ruby-head
@@ -0,0 +1,13 @@
1
+ appraise 'rails-3.2' do
2
+ gem 'activerecord', '~> 3.2'
3
+ end
4
+
5
+ appraise 'rails-4.0' do
6
+ gem 'activerecord', '~> 4.0'
7
+ end
8
+
9
+ appraise 'rails-4.1' do
10
+ gem 'activerecord', '~> 4.1'
11
+ end
12
+
13
+ # vim: set ft=ruby:
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in activerecord-exception-adapter.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Kohei Suzuki
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Activerecord::Exception::Adapter
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'activerecord-exception-adapter'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install activerecord-exception-adapter
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/eagletmt/activerecord-exception-adapter/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :default => :spec
4
+
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new(:spec)
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "activerecord-exception-adapter"
5
+ spec.version = '0.1.0'
6
+ spec.authors = ["Kohei Suzuki"]
7
+ spec.email = ["eagletmt@gmail.com"]
8
+ spec.summary = %q{ActiveRecord adapter that raises an exception when used}
9
+ spec.description = %q{ActiveRecord adapter that raises an exception when used}
10
+ spec.homepage = ""
11
+ spec.license = "MIT"
12
+
13
+ spec.files = `git ls-files -z`.split("\x0")
14
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_development_dependency "bundler"
19
+ spec.add_development_dependency "rake"
20
+ spec.add_development_dependency "rspec", ">= 3.0.0"
21
+ spec.add_development_dependency "appraisal", ">= 1.0.0"
22
+ spec.add_dependency "activerecord", ">= 3.2"
23
+ end
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 3.2"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 4.0"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 4.1"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,20 @@
1
+ require 'active_record'
2
+
3
+ module ActiveRecord
4
+ module ConnectionAdapters
5
+ class ExceptionAdapter
6
+ class Error < StandardError
7
+ attr_reader :config
8
+
9
+ def initialize(config)
10
+ super("Do NOT use me: #{config.inspect}")
11
+ @config = config
12
+ end
13
+ end
14
+
15
+ def initialize(config)
16
+ raise Error.new(config)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ require 'active_support/lazy_load_hooks'
2
+
3
+ module ActiveRecordExceptionAdapter
4
+ def exception_connection(config)
5
+ ActiveRecord::ConnectionAdapters::ExceptionAdapter.new(config)
6
+ end
7
+ end
8
+
9
+ ActiveSupport.on_load(:active_record) do
10
+ ActiveRecord::Base.extend ActiveRecordExceptionAdapter
11
+ end
@@ -0,0 +1,25 @@
1
+ require 'activerecord-exception-adapter'
2
+
3
+ RSpec.describe ActiveRecordExceptionAdapter do
4
+ before :all do
5
+ require 'active_record'
6
+ ActiveRecord::Base.configurations = {
7
+ 'main' => {
8
+ 'adapter' => 'exception',
9
+ },
10
+ }
11
+ end
12
+
13
+ describe '.establish_connection' do
14
+ it 'succeeds' do
15
+ expect(ActiveRecord::Base.establish_connection(:main)).to be_a(ActiveRecord::ConnectionAdapters::ConnectionPool)
16
+ end
17
+ end
18
+
19
+ describe '.connection' do
20
+ it 'raises an exception' do
21
+ ActiveRecord::Base.establish_connection(:main)
22
+ expect { ActiveRecord::Base.connection }.to raise_error(ActiveRecord::ConnectionAdapters::ExceptionAdapter::Error)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,9 @@
1
+ RSpec.configure do |config|
2
+ config.expose_dsl_globally = false
3
+
4
+ config.filter_run :focus
5
+ config.run_all_when_everything_filtered = true
6
+
7
+ config.order = :random
8
+ Kernel.srand config.seed
9
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activerecord-exception-adapter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kohei Suzuki
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 3.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: appraisal
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 1.0.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: activerecord
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '3.2'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '3.2'
83
+ description: ActiveRecord adapter that raises an exception when used
84
+ email:
85
+ - eagletmt@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Appraisals
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - activerecord-exception-adapter.gemspec
99
+ - gemfiles/rails_3.2.gemfile
100
+ - gemfiles/rails_4.0.gemfile
101
+ - gemfiles/rails_4.1.gemfile
102
+ - lib/active_record/connection_adapters/exception_adapter.rb
103
+ - lib/activerecord-exception-adapter.rb
104
+ - spec/exception_adapter_spec.rb
105
+ - spec/spec_helper.rb
106
+ homepage: ''
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.2.2
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: ActiveRecord adapter that raises an exception when used
130
+ test_files:
131
+ - spec/exception_adapter_spec.rb
132
+ - spec/spec_helper.rb