-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4c5ba94
Showing
18 changed files
with
304 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/.bundle/ | ||
/.yardoc | ||
/Gemfile.lock | ||
/_yardoc/ | ||
/coverage/ | ||
/doc/ | ||
/pkg/ | ||
/spec/reports/ | ||
/tmp/ | ||
*.gem | ||
gemfiles/*.lock | ||
Gemfile.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
require: | ||
- rubocop-md | ||
|
||
AllCops: | ||
Include: | ||
- 'lib/**/*.rb' | ||
- 'lib/**/*.rake' | ||
- 'spec/**/*.rb' | ||
Exclude: | ||
- 'bin/**/*' | ||
- 'gemfiles/**/*' | ||
- 'spec/dummy/**/*' | ||
- 'vendor/**/*' | ||
- 'tmp/**/*' | ||
- 'Rakefile' | ||
- 'Gemfile' | ||
- '*.gemspec' | ||
DisplayCopNames: true | ||
StyleGuideCopsOnly: false | ||
TargetRubyVersion: 2.3 | ||
|
||
Rails: | ||
Enabled: false | ||
|
||
Style/SymbolArray: | ||
Enabled: false | ||
|
||
Style/Documentation: | ||
Exclude: | ||
- 'spec/**/*.rb' | ||
|
||
Style/StringLiterals: | ||
EnforcedStyle: double_quotes | ||
|
||
Style/RegexpLiteral: | ||
Enabled: false | ||
|
||
Style/BlockDelimiters: | ||
Exclude: | ||
- 'spec/**/*.rb' | ||
|
||
Layout/SpaceInsideStringInterpolation: | ||
EnforcedStyle: no_space | ||
|
||
Lint/AmbiguousRegexpLiteral: | ||
Enabled: false | ||
|
||
Metrics/LineLength: | ||
Max: 100 | ||
|
||
Metrics/BlockLength: | ||
Exclude: | ||
- 'spec/**/*.rb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
sudo: false | ||
language: ruby | ||
rvm: | ||
- 2.5.0 | ||
|
||
notifications: | ||
email: false | ||
|
||
matrix: | ||
fast_finish: true | ||
include: | ||
- rvm: ruby-head | ||
gemfile: gemfiles/railsmaster.gemfile | ||
- rvm: jruby-9.1.0.0 | ||
gemfile: gemfiles/jruby.gemfile | ||
- rvm: 2.5.0 | ||
gemfile: Gemfile | ||
- rvm: 2.4.3 | ||
gemfile: Gemfile | ||
- rvm: 2.3.1 | ||
gemfile: gemfiles/activerecord42.gemfile | ||
allow_failures: | ||
- rvm: ruby-head | ||
gemfile: gemfiles/railsmaster.gemfile | ||
- rvm: jruby-9.1.0.0 | ||
gemfile: gemfiles/jruby.gemfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Change log | ||
|
||
## master | ||
|
||
[@palkan]: https://github.com/palkan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
source "https://rubygems.org" | ||
|
||
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } | ||
|
||
# Specify your gem's dependencies in isolator.gemspec | ||
gemspec | ||
|
||
gem 'pry-byebug' | ||
gem 'sqlite3' | ||
gem 'activerecord', '>= 5.0' | ||
|
||
local_gemfile = 'Gemfile.local' | ||
|
||
if File.exist?(local_gemfile) | ||
eval(File.read(local_gemfile)) # rubocop:disable Security/Eval | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2018 Vladimir Dementyev | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
[](https://badge.fury.io/rb/isolator) | ||
[](https://travis-ci.org/palkan/isolator) | ||
|
||
# Isolator | ||
|
||
Detect non-atomic interactions within DB transactions. | ||
|
||
Examples: | ||
|
||
```ruby | ||
# HTTP calls within transaction | ||
User.transaction do | ||
user = User.new(user_params) | ||
user.save! | ||
# HTTP API call | ||
PaymentsService.charge!(user) | ||
end | ||
|
||
#=> raises Isolator::HTTPError | ||
|
||
# background job | ||
User.transaction do | ||
user.update!(confirmed_at: Time.now) | ||
UserMailer.successful_confirmation(user).deliver_later | ||
end | ||
|
||
#=> raises Isolator::BackgroundJobError | ||
``` | ||
|
||
## Installation | ||
|
||
Add this line to your application's Gemfile: | ||
|
||
```ruby | ||
group :development, :test do | ||
gem "isolator" | ||
end | ||
``` | ||
|
||
## Usage | ||
|
||
TBD | ||
|
||
## Contributing | ||
|
||
Bug reports and pull requests are welcome on GitHub at https://github.com/palkan/isolator. | ||
|
||
## License | ||
|
||
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require "bundler/gem_tasks" | ||
require "rspec/core/rake_task" | ||
require "rubocop/rake_task" | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
RuboCop::RakeTask.new | ||
|
||
task default: [:rubocop, :spec] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require "bundler/setup" | ||
require "isolator" | ||
|
||
require "pry" | ||
Pry.start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
set -vx | ||
|
||
bundle install | ||
|
||
# Do any other automated setup that you need to do here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'activerecord', '~> 4.2' | ||
gem 'sqlite3' | ||
|
||
gemspec path: '..' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'activerecord-jdbcsqlite3-adapter', '~> 50.0' | ||
gem 'jdbc-sqlite3' | ||
gem 'activerecord', '~> 5.0.0' | ||
|
||
gemspec path: '..' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'arel', github: 'rails/arel' | ||
gem 'rails', github: 'rails/rails' | ||
gem 'sqlite3' | ||
|
||
gemspec path: '..' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
lib = File.expand_path("../lib", __FILE__) | ||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | ||
require "isolator/version" | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "isolator" | ||
spec.version = Isolator::VERSION | ||
spec.authors = ["Vladimir Dementyev"] | ||
spec.email = ["[email protected]"] | ||
|
||
spec.summary = "Detect non-atomic interactions within DB transactions" | ||
spec.description = "Detect non-atomic interactions within DB transactions" | ||
spec.homepage = "https://github.com/palkan/isolator" | ||
spec.license = "MIT" | ||
|
||
spec.required_ruby_version = ">= 2.3.0" | ||
|
||
spec.files = `git ls-files -z`.split("\x0").reject do |f| | ||
f.match(%r{^(test|spec|features)/}) | ||
end | ||
spec.require_paths = ["lib"] | ||
|
||
spec.add_development_dependency "bundler", "~> 1.14" | ||
spec.add_development_dependency "rake", "~> 10.0" | ||
spec.add_development_dependency "rspec", "~> 3.0" | ||
spec.add_development_dependency "rubocop", "~> 0.51" | ||
spec.add_development_dependency "rubocop-md", "~> 0.2" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
require "isolator/version" | ||
|
||
module Isolator # :nodoc: | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module Isolator | ||
VERSION = "0.0.1" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
require "active_record" | ||
require "isolator" | ||
|
||
begin | ||
require "pry-byebug" | ||
rescue LoadError # rubocop:disable Lint/HandleExceptions | ||
end | ||
|
||
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } | ||
|
||
RSpec.configure do |config| | ||
config.example_status_persistence_file_path = ".rspec_status" | ||
config.filter_run focus: true | ||
config.run_all_when_everything_filtered = true | ||
|
||
config.order = :random | ||
|
||
config.expect_with :rspec do |c| | ||
c.syntax = :expect | ||
end | ||
|
||
config.mock_with :rspec do |mocks| | ||
mocks.verify_partial_doubles = true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
require "activerecord-jdbc-adapter" if defined? JRUBY_VERSION | ||
require "activerecord-jdbcsqlite3-adapter" if defined? JRUBY_VERSION | ||
|
||
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | ||
|
||
ActiveRecord::Schema.define do | ||
# Create schema here | ||
end | ||
|
||
ActiveRecord::Base.logger = Logger.new(STDOUT) if ENV["LOG"] |