atomically 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << 'test'
6
- t.libs << 'lib'
7
- t.test_files = FileList['test/**/*_test.rb']
8
- end
9
-
10
- task default: :test
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task default: :test
data/bin/console CHANGED
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'atomically'
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
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'atomically'
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
data/bin/setup CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install --gemfile=gemfiles/4.2.gemfile
7
-
8
- # Do any other automated setup that you need to do here
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install --gemfile=gemfiles/4.2.gemfile
7
+
8
+ # Do any other automated setup that you need to do here
data/gemfiles/3.2.gemfile CHANGED
@@ -1,16 +1,16 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'activerecord', '~> 3.2.0'
4
-
5
- group :test do
6
- gem 'mysql2', '0.3.21' if %w[mysql makara_mysql].include?(ENV['DB'])
7
- gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB'])
8
- gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB'])
9
- gem 'simplecov'
10
- gem 'i18n', '< 1.6'
11
- gem 'pluck_all', '>= 2.0.3'
12
- gem 'timecop', '~> 0.9.1'
13
- gem 'update_all_scope', '~> 0.1.0'
14
- end
15
-
16
- gemspec path: '../'
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'activerecord', '~> 3.2.0'
4
+
5
+ group :test do
6
+ gem 'mysql2', '0.3.21' if %w[mysql makara_mysql].include?(ENV['DB'])
7
+ gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB'])
8
+ gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB'])
9
+ gem 'simplecov', '< 0.18'
10
+ gem 'i18n', '< 1.6'
11
+ gem 'pluck_all', '>= 2.0.3'
12
+ gem 'timecop', '~> 0.9.1'
13
+ gem 'update_all_scope', '~> 0.1.0'
14
+ end
15
+
16
+ gemspec path: '../'
data/gemfiles/4.2.gemfile CHANGED
@@ -1,16 +1,16 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'activerecord', '~> 4.2.0'
4
-
5
- group :test do
6
- gem 'mysql2', '0.3.21' if %w[mysql makara_mysql].include?(ENV['DB'])
7
- gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB'])
8
- gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB'])
9
- gem 'simplecov'
10
- gem 'i18n', '< 1.6'
11
- gem 'pluck_all', '>= 2.0.3'
12
- gem 'timecop', '~> 0.9.1'
13
- gem 'update_all_scope', '~> 0.1.0'
14
- end
15
-
16
- gemspec path: '../'
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'activerecord', '~> 4.2.0'
4
+
5
+ group :test do
6
+ gem 'mysql2', '0.4.10' if %w[mysql makara_mysql].include?(ENV['DB'])
7
+ gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB'])
8
+ gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB'])
9
+ gem 'simplecov', '< 0.18'
10
+ gem 'i18n', '< 1.6'
11
+ gem 'pluck_all', '>= 2.0.3'
12
+ gem 'timecop', '~> 0.9.1'
13
+ gem 'update_all_scope', '~> 0.1.0'
14
+ end
15
+
16
+ gemspec path: '../'
data/gemfiles/5.0.gemfile CHANGED
@@ -1,16 +1,16 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'activerecord', '~> 5.0.0'
4
-
5
- group :test do
6
- gem 'mysql2', '0.3.21' if %w[mysql makara_mysql].include?(ENV['DB'])
7
- gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB'])
8
- gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB'])
9
- gem 'simplecov'
10
- gem 'i18n', '< 1.6'
11
- gem 'pluck_all', '>= 2.0.3'
12
- gem 'timecop', '~> 0.9.1'
13
- gem 'update_all_scope', '~> 0.1.0'
14
- end
15
-
16
- gemspec path: '../'
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'activerecord', '~> 5.0.0'
4
+
5
+ group :test do
6
+ gem 'mysql2', '0.4.10' if %w[mysql makara_mysql].include?(ENV['DB'])
7
+ gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB'])
8
+ gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB'])
9
+ gem 'simplecov', '< 0.18'
10
+ gem 'i18n', '< 1.6'
11
+ gem 'pluck_all', '>= 2.0.3'
12
+ gem 'timecop', '~> 0.9.1'
13
+ gem 'update_all_scope', '~> 0.1.0'
14
+ end
15
+
16
+ gemspec path: '../'
data/gemfiles/5.1.gemfile CHANGED
@@ -1,16 +1,16 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'activerecord', '~> 5.1.0'
4
-
5
- group :test do
6
- gem 'mysql2', '0.3.21' if %w[mysql makara_mysql].include?(ENV['DB'])
7
- gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB'])
8
- gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB'])
9
- gem 'simplecov'
10
- gem 'i18n', '< 1.6'
11
- gem 'pluck_all', '>= 2.0.3'
12
- gem 'timecop', '~> 0.9.1'
13
- gem 'update_all_scope', '~> 0.1.0'
14
- end
15
-
16
- gemspec path: '../'
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'activerecord', '~> 5.1.0'
4
+
5
+ group :test do
6
+ gem 'mysql2', '0.4.10' if %w[mysql makara_mysql].include?(ENV['DB'])
7
+ gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB'])
8
+ gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB'])
9
+ gem 'simplecov', '< 0.18'
10
+ gem 'i18n', '< 1.6'
11
+ gem 'pluck_all', '>= 2.0.3'
12
+ gem 'timecop', '~> 0.9.1'
13
+ gem 'update_all_scope', '~> 0.1.0'
14
+ end
15
+
16
+ gemspec path: '../'
data/gemfiles/5.2.gemfile CHANGED
@@ -1,16 +1,16 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'activerecord', '~> 5.2.0'
4
-
5
- group :test do
6
- gem 'mysql2', '0.5.1' if %w[mysql makara_mysql].include?(ENV['DB'])
7
- gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB'])
8
- gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB'])
9
- gem 'simplecov'
10
- gem 'i18n', '< 1.6'
11
- gem 'pluck_all', '>= 2.0.3'
12
- gem 'timecop', '~> 0.9.1'
13
- gem 'update_all_scope', '~> 0.1.0'
14
- end
15
-
16
- gemspec path: '../'
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'activerecord', '~> 5.2.0'
4
+
5
+ group :test do
6
+ gem 'mysql2', '0.5.1' if %w[mysql makara_mysql].include?(ENV['DB'])
7
+ gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB'])
8
+ gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB'])
9
+ gem 'simplecov', '< 0.18'
10
+ gem 'i18n', '< 1.6'
11
+ gem 'pluck_all', '>= 2.0.3'
12
+ gem 'timecop', '~> 0.9.1'
13
+ gem 'update_all_scope', '~> 0.1.0'
14
+ end
15
+
16
+ gemspec path: '../'
data/gemfiles/6.0.gemfile CHANGED
@@ -1,15 +1,15 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'activerecord', '~> 6.0.0'
4
-
5
- group :test do
6
- gem 'mysql2', '0.5.1' if %w[mysql makara_mysql].include?(ENV['DB'])
7
- gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB'])
8
- gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB'])
9
- gem 'simplecov'
10
- gem 'pluck_all', '>= 2.0.4'
11
- gem 'timecop', '~> 0.9.1'
12
- gem 'update_all_scope', '~> 0.1.0'
13
- end
14
-
15
- gemspec path: '../'
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'activerecord', '~> 6.0.0'
4
+
5
+ group :test do
6
+ gem 'mysql2', '0.5.1' if %w[mysql makara_mysql].include?(ENV['DB'])
7
+ gem 'pg', '~> 1.4.6' if %w[pg makara_pg].include?(ENV['DB'])
8
+ gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB'])
9
+ gem 'simplecov', '< 0.18'
10
+ gem 'pluck_all', '>= 2.0.4'
11
+ gem 'timecop', '~> 0.9.1'
12
+ gem 'update_all_scope', '~> 0.1.0'
13
+ end
14
+
15
+ gemspec path: '../'
@@ -1,20 +1,20 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_record'
4
- require 'atomically/query_service'
5
-
6
- class ActiveRecord::Relation
7
- def atomically
8
- Atomically::QueryService.new(klass, relation: self)
9
- end
10
- end
11
-
12
- class ActiveRecord::Base
13
- def self.atomically
14
- Atomically::QueryService.new(self)
15
- end
16
-
17
- def atomically
18
- Atomically::QueryService.new(self.class, model: self)
19
- end
20
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_record'
4
+ require 'atomically/query_service'
5
+
6
+ class ActiveRecord::Relation
7
+ def atomically
8
+ Atomically::QueryService.new(klass, relation: self)
9
+ end
10
+ end
11
+
12
+ class ActiveRecord::Base
13
+ def self.atomically
14
+ Atomically::QueryService.new(self)
15
+ end
16
+
17
+ def atomically
18
+ Atomically::QueryService.new(self.class, model: self)
19
+ end
20
+ end
@@ -1,30 +1,30 @@
1
-
2
- class Atomically::AdapterCheckService
3
- def initialize(klass)
4
- @klass = klass
5
- end
6
-
7
- def pg?
8
- possible_pg_klasses.any?{|s| @klass.connection.is_a?(s) }
9
- end
10
-
11
- def mysql?
12
- possible_mysql_klasses.any?{|s| @klass.connection.is_a?(s) }
13
- end
14
-
15
- private
16
-
17
- def possible_pg_klasses
18
- @possible_pg_klasses ||= [].tap do |result|
19
- result << ActiveRecord::ConnectionAdapters::PostgreSQLAdapter if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
20
- result << ActiveRecord::ConnectionAdapters::MakaraPostgreSQLAdapter if defined?(ActiveRecord::ConnectionAdapters::MakaraPostgreSQLAdapter)
21
- end
22
- end
23
-
24
- def possible_mysql_klasses
25
- @possible_mysql_klasses ||= [].tap do |result|
26
- result << ActiveRecord::ConnectionAdapters::Mysql2Adapter if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
27
- result << ActiveRecord::ConnectionAdapters::MakaraMysql2Adapter if defined?(ActiveRecord::ConnectionAdapters::MakaraMysql2Adapter)
28
- end
29
- end
30
- end
1
+
2
+ class Atomically::AdapterCheckService
3
+ def initialize(klass)
4
+ @klass = klass
5
+ end
6
+
7
+ def pg?
8
+ possible_pg_klasses.any?{|s| @klass.connection.is_a?(s) }
9
+ end
10
+
11
+ def mysql?
12
+ possible_mysql_klasses.any?{|s| @klass.connection.is_a?(s) }
13
+ end
14
+
15
+ private
16
+
17
+ def possible_pg_klasses
18
+ @possible_pg_klasses ||= [].tap do |result|
19
+ result << ActiveRecord::ConnectionAdapters::PostgreSQLAdapter if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
20
+ result << ActiveRecord::ConnectionAdapters::MakaraPostgreSQLAdapter if defined?(ActiveRecord::ConnectionAdapters::MakaraPostgreSQLAdapter)
21
+ end
22
+ end
23
+
24
+ def possible_mysql_klasses
25
+ @possible_mysql_klasses ||= [].tap do |result|
26
+ result << ActiveRecord::ConnectionAdapters::Mysql2Adapter if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
27
+ result << ActiveRecord::ConnectionAdapters::MakaraMysql2Adapter if defined?(ActiveRecord::ConnectionAdapters::MakaraMysql2Adapter)
28
+ end
29
+ end
30
+ end
@@ -1,28 +1,28 @@
1
- # frozen_string_literal: true
2
-
3
- class Atomically::OnDuplicateSqlService
4
- def initialize(klass, columns)
5
- @klass = klass
6
- @columns = columns
7
- end
8
-
9
- def mysql_quote_columns_for_plus
10
- return @columns.map do |column|
11
- quoted_column = quote_column(column)
12
- next "#{quoted_column} = #{quoted_column} + VALUES(#{quoted_column})"
13
- end
14
- end
15
-
16
- def pg_quote_columns_for_plus
17
- return @columns.map do |column|
18
- quoted_column = quote_column(column)
19
- next "#{quoted_column} = #{@klass.quoted_table_name}.#{quoted_column} + excluded.#{quoted_column}"
20
- end
21
- end
22
-
23
- private
24
-
25
- def quote_column(column)
26
- @klass.connection.quote_column_name(column)
27
- end
28
- end
1
+ # frozen_string_literal: true
2
+
3
+ class Atomically::OnDuplicateSqlService
4
+ def initialize(klass, columns)
5
+ @klass = klass
6
+ @columns = columns
7
+ end
8
+
9
+ def mysql_quote_columns_for_plus
10
+ return @columns.map do |column|
11
+ quoted_column = quote_column(column)
12
+ next "#{quoted_column} = #{quoted_column} + VALUES(#{quoted_column})"
13
+ end
14
+ end
15
+
16
+ def pg_quote_columns_for_plus
17
+ return @columns.map do |column|
18
+ quoted_column = quote_column(column)
19
+ next "#{quoted_column} = #{@klass.quoted_table_name}.#{quoted_column} + excluded.#{quoted_column}"
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def quote_column(column)
26
+ @klass.connection.quote_column_name(column)
27
+ end
28
+ end
@@ -1,17 +1,17 @@
1
- module ActiveModel
2
- module Dirty
3
- private
4
-
5
- alias attributes_changed_by_setter changed_attributes # :nodoc:
6
-
7
- # Force an attribute to have a particular "before" value
8
- def set_attribute_was(attr, old_value)
9
- attributes_changed_by_setter[attr] = old_value
10
- end
11
-
12
- # Remove changes information for the provided attributes.
13
- def clear_attribute_changes(attributes) # :doc:
14
- attributes_changed_by_setter.except!(*attributes)
15
- end
16
- end
17
- end
1
+ module ActiveModel
2
+ module Dirty
3
+ private
4
+
5
+ alias attributes_changed_by_setter changed_attributes # :nodoc:
6
+
7
+ # Force an attribute to have a particular "before" value
8
+ def set_attribute_was(attr, old_value)
9
+ attributes_changed_by_setter[attr] = old_value
10
+ end
11
+
12
+ # Remove changes information for the provided attributes.
13
+ def clear_attribute_changes(attributes) # :doc:
14
+ attributes_changed_by_setter.except!(*attributes)
15
+ end
16
+ end
17
+ end
@@ -1,10 +1,10 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_record'
4
-
5
- class << ActiveRecord::Base
6
- def from(value) # For Rails 3
7
- value = "(#{value.to_sql}) subquery" if value.is_a?(ActiveRecord::Relation)
8
- return super
9
- end
10
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_record'
4
+
5
+ class << ActiveRecord::Base
6
+ def from(value) # For Rails 3
7
+ value = "(#{value.to_sql}) subquery" if value.is_a?(ActiveRecord::Relation)
8
+ return super
9
+ end
10
+ end
@@ -1,9 +1,9 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_record'
4
-
5
- class << ActiveRecord::Base
6
- def none # For Rails 3
7
- where('1=0')
8
- end
9
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_record'
4
+
5
+ class << ActiveRecord::Base
6
+ def none # For Rails 3
7
+ where('1=0')
8
+ end
9
+ end