oort 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.bin/bundle +109 -0
- data/.bin/htmldiff +27 -0
- data/.bin/ldiff +27 -0
- data/.bin/racc +27 -0
- data/.bin/rake +27 -0
- data/.bin/rspec +27 -0
- data/.bin/rubocop +27 -0
- data/.bin/ruby-parse +27 -0
- data/.bin/ruby-rewrite +27 -0
- data/.rubocop.yml +19 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +82 -0
- data/LICENSE.txt +21 -0
- data/README.md +28 -0
- data/Rakefile +16 -0
- data/lib/oort/callbacks.rb +61 -0
- data/lib/oort/configuration.rb +12 -0
- data/lib/oort/inserts.rb +42 -0
- data/lib/oort/ordered.rb +34 -0
- data/lib/oort/removes.rb +45 -0
- data/lib/oort/scopes.rb +30 -0
- data/lib/oort/version.rb +5 -0
- data/lib/oort.rb +22 -0
- data/sig/oort.rbs +4 -0
- metadata +68 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2482601efe735a7063d6d22932bc2026ee1cdd456e29d6adf1e875d52845b3ed
|
4
|
+
data.tar.gz: 3020190a7db7c6eae9088046952e42dac96dbacc48eb7ffe64990191f3802182
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 215ba707002ebe3b5732f071eabd62e093f2480814736d10ae59f79f9b6b7c8fc20cb3a46efd2858fcc855fffa1c400e1fdf75c82c40e3e7351106d53aa4faa6
|
7
|
+
data.tar.gz: 73df1b6f0e2ec22d2b6fc66d1158e47bd863af85ef3b344ef2bd1a12955a5ea365555bf63afd2ee731c86618cbc3827e5e8987a6e80d0a4eeae90ce4d9eddf73
|
data/.bin/bundle
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
|
13
|
+
m = Module.new do
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def invoked_as_script?
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV["BUNDLER_VERSION"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def cli_arg_version
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
+
bundler_version = nil
|
28
|
+
update_index = nil
|
29
|
+
ARGV.each_with_index do |a, i|
|
30
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
31
|
+
bundler_version = a
|
32
|
+
end
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
+
bundler_version = $1
|
35
|
+
update_index = i
|
36
|
+
end
|
37
|
+
bundler_version
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
43
|
+
|
44
|
+
File.expand_path("../Gemfile", __dir__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
lockfile =
|
49
|
+
case File.basename(gemfile)
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
|
51
|
+
else "#{gemfile}.lock"
|
52
|
+
end
|
53
|
+
File.expand_path(lockfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lockfile_version
|
57
|
+
return unless File.file?(lockfile)
|
58
|
+
lockfile_contents = File.read(lockfile)
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
+
Regexp.last_match(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundler_requirement
|
64
|
+
@bundler_requirement ||=
|
65
|
+
env_var_version ||
|
66
|
+
cli_arg_version ||
|
67
|
+
bundler_requirement_for(lockfile_version)
|
68
|
+
end
|
69
|
+
|
70
|
+
def bundler_requirement_for(version)
|
71
|
+
return "#{Gem::Requirement.default}.a" unless version
|
72
|
+
|
73
|
+
bundler_gem_version = Gem::Version.new(version)
|
74
|
+
|
75
|
+
bundler_gem_version.approximate_recommendation
|
76
|
+
end
|
77
|
+
|
78
|
+
def load_bundler!
|
79
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
80
|
+
|
81
|
+
activate_bundler
|
82
|
+
end
|
83
|
+
|
84
|
+
def activate_bundler
|
85
|
+
gem_error = activation_error_handling do
|
86
|
+
gem "bundler", bundler_requirement
|
87
|
+
end
|
88
|
+
return if gem_error.nil?
|
89
|
+
require_error = activation_error_handling do
|
90
|
+
require "bundler/version"
|
91
|
+
end
|
92
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
93
|
+
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
|
94
|
+
exit 42
|
95
|
+
end
|
96
|
+
|
97
|
+
def activation_error_handling
|
98
|
+
yield
|
99
|
+
nil
|
100
|
+
rescue StandardError, LoadError => e
|
101
|
+
e
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
m.load_bundler!
|
106
|
+
|
107
|
+
if m.invoked_as_script?
|
108
|
+
load Gem.bin_path("bundler", "bundle")
|
109
|
+
end
|
data/.bin/htmldiff
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'htmldiff' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("diff-lcs", "htmldiff")
|
data/.bin/ldiff
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'ldiff' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("diff-lcs", "ldiff")
|
data/.bin/racc
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'racc' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("racc", "racc")
|
data/.bin/rake
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("rake", "rake")
|
data/.bin/rspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/.bin/rubocop
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rubocop' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("rubocop", "rubocop")
|
data/.bin/ruby-parse
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'ruby-parse' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("parser", "ruby-parse")
|
data/.bin/ruby-rewrite
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'ruby-rewrite' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("parser", "ruby-rewrite")
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 3.2.0
|
3
|
+
|
4
|
+
Style/StringLiterals:
|
5
|
+
Enabled: true
|
6
|
+
EnforcedStyle: double_quotes
|
7
|
+
|
8
|
+
Style/StringLiteralsInInterpolation:
|
9
|
+
Enabled: true
|
10
|
+
EnforcedStyle: double_quotes
|
11
|
+
|
12
|
+
Layout/LineLength:
|
13
|
+
Max: 120
|
14
|
+
|
15
|
+
Style/Documentation:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Metrics/MethodLength:
|
19
|
+
Max: 30
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gemspec
|
6
|
+
|
7
|
+
gem "minitest"
|
8
|
+
gem "rake"
|
9
|
+
gem "rubocop", require: false
|
10
|
+
|
11
|
+
group :development, :test do
|
12
|
+
gem "activerecord", "~> 7.0", ">= 7.0.1"
|
13
|
+
gem "pg"
|
14
|
+
gem "zeitwerk", "~> 2.5"
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
oort (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (7.1.3)
|
10
|
+
activesupport (= 7.1.3)
|
11
|
+
activerecord (7.1.3)
|
12
|
+
activemodel (= 7.1.3)
|
13
|
+
activesupport (= 7.1.3)
|
14
|
+
timeout (>= 0.4.0)
|
15
|
+
activesupport (7.1.3)
|
16
|
+
base64
|
17
|
+
bigdecimal
|
18
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
|
+
connection_pool (>= 2.2.5)
|
20
|
+
drb
|
21
|
+
i18n (>= 1.6, < 2)
|
22
|
+
minitest (>= 5.1)
|
23
|
+
mutex_m
|
24
|
+
tzinfo (~> 2.0)
|
25
|
+
ast (2.4.2)
|
26
|
+
base64 (0.2.0)
|
27
|
+
bigdecimal (3.1.6)
|
28
|
+
concurrent-ruby (1.2.3)
|
29
|
+
connection_pool (2.4.1)
|
30
|
+
drb (2.2.0)
|
31
|
+
ruby2_keywords
|
32
|
+
i18n (1.14.1)
|
33
|
+
concurrent-ruby (~> 1.0)
|
34
|
+
json (2.7.1)
|
35
|
+
language_server-protocol (3.17.0.3)
|
36
|
+
minitest (5.21.2)
|
37
|
+
mutex_m (0.2.0)
|
38
|
+
parallel (1.24.0)
|
39
|
+
parser (3.3.0.5)
|
40
|
+
ast (~> 2.4.1)
|
41
|
+
racc
|
42
|
+
pg (1.5.4)
|
43
|
+
racc (1.7.3)
|
44
|
+
rainbow (3.1.1)
|
45
|
+
rake (13.1.0)
|
46
|
+
regexp_parser (2.9.0)
|
47
|
+
rexml (3.2.6)
|
48
|
+
rubocop (1.60.2)
|
49
|
+
json (~> 2.3)
|
50
|
+
language_server-protocol (>= 3.17.0)
|
51
|
+
parallel (~> 1.10)
|
52
|
+
parser (>= 3.3.0.2)
|
53
|
+
rainbow (>= 2.2.2, < 4.0)
|
54
|
+
regexp_parser (>= 1.8, < 3.0)
|
55
|
+
rexml (>= 3.2.5, < 4.0)
|
56
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
57
|
+
ruby-progressbar (~> 1.7)
|
58
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
59
|
+
rubocop-ast (1.30.0)
|
60
|
+
parser (>= 3.2.1.0)
|
61
|
+
ruby-progressbar (1.13.0)
|
62
|
+
ruby2_keywords (0.0.5)
|
63
|
+
timeout (0.4.1)
|
64
|
+
tzinfo (2.0.6)
|
65
|
+
concurrent-ruby (~> 1.0)
|
66
|
+
unicode-display_width (2.5.0)
|
67
|
+
zeitwerk (2.6.12)
|
68
|
+
|
69
|
+
PLATFORMS
|
70
|
+
x86_64-darwin-20
|
71
|
+
|
72
|
+
DEPENDENCIES
|
73
|
+
activerecord (~> 7.0, >= 7.0.1)
|
74
|
+
minitest
|
75
|
+
oort!
|
76
|
+
pg
|
77
|
+
rake
|
78
|
+
rubocop
|
79
|
+
zeitwerk (~> 2.5)
|
80
|
+
|
81
|
+
BUNDLED WITH
|
82
|
+
2.4.10
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Toby
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Oort
|
2
|
+
|
3
|
+
Ordering your collections without deadlocks.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install the gem and add to the application's Gemfile by executing:
|
8
|
+
|
9
|
+
$ bundle add oort
|
10
|
+
|
11
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
12
|
+
|
13
|
+
$ gem install oort
|
14
|
+
|
15
|
+
|
16
|
+
## Development
|
17
|
+
|
18
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
19
|
+
|
20
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
21
|
+
|
22
|
+
## Contributing
|
23
|
+
|
24
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tobyond/oort.
|
25
|
+
|
26
|
+
## License
|
27
|
+
|
28
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
10
|
+
end
|
11
|
+
|
12
|
+
require "rubocop/rake_task"
|
13
|
+
|
14
|
+
RuboCop::RakeTask.new
|
15
|
+
|
16
|
+
task default: %i[test rubocop]
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Oort
|
4
|
+
class Callbacks
|
5
|
+
def self.call(association_class:, remove_from_method_name:, insert_method_name:, instance_name:)
|
6
|
+
new(
|
7
|
+
association_class: association_class,
|
8
|
+
remove_from_method_name: remove_from_method_name,
|
9
|
+
insert_method_name: insert_method_name,
|
10
|
+
instance_name: instance_name
|
11
|
+
).call
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :association_class, :remove_from_method_name, :insert_method_name, :instance_name
|
15
|
+
|
16
|
+
def initialize(association_class:, remove_from_method_name:, insert_method_name:, instance_name:)
|
17
|
+
@association_class = association_class
|
18
|
+
@remove_from_method_name = remove_from_method_name
|
19
|
+
@insert_method_name = insert_method_name
|
20
|
+
@instance_name = instance_name
|
21
|
+
end
|
22
|
+
|
23
|
+
def call
|
24
|
+
add_callbacks
|
25
|
+
add_methods
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def add_callbacks
|
31
|
+
association_class.class_eval do
|
32
|
+
after_create_commit :insert_at
|
33
|
+
after_destroy :remove_from_reorderable
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_methods
|
38
|
+
association_class.class_eval(
|
39
|
+
# def insert_at(position = 0)
|
40
|
+
# public_send(:user)
|
41
|
+
# .public_send(:update_posts_ordering, insert: id, at: position)
|
42
|
+
# end
|
43
|
+
|
44
|
+
# def remove_from_reorderable
|
45
|
+
# public_send(:user).public_send(:remove_from_posts_ordering, id)
|
46
|
+
# end
|
47
|
+
<<-RUBY, __FILE__, __LINE__ + 1
|
48
|
+
def insert_at(position = 0)
|
49
|
+
public_send(#{instance_name.inspect})
|
50
|
+
.public_send(#{insert_method_name.inspect}, insert: id, at: position)
|
51
|
+
end
|
52
|
+
|
53
|
+
def remove_from_reorderable
|
54
|
+
public_send(#{instance_name.inspect})
|
55
|
+
.public_send(#{remove_from_method_name.inspect}, id)
|
56
|
+
end
|
57
|
+
RUBY
|
58
|
+
)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/oort/inserts.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Oort
|
4
|
+
class Inserts
|
5
|
+
def self.call(stored_in:, insert_method_name:, class_name:)
|
6
|
+
new(stored_in: stored_in, insert_method_name: insert_method_name, class_name: class_name).call
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :stored_in, :insert_method_name, :class_name
|
10
|
+
|
11
|
+
def initialize(stored_in:, insert_method_name:, class_name:)
|
12
|
+
@stored_in = stored_in
|
13
|
+
@insert_method_name = insert_method_name
|
14
|
+
@class_name = class_name
|
15
|
+
end
|
16
|
+
|
17
|
+
def call
|
18
|
+
class_name.class_eval(
|
19
|
+
# def update_posts_ordering(insert:, at: 0)
|
20
|
+
# with_lock do
|
21
|
+
# current_values = public_send(stored_in.inspect)
|
22
|
+
# current_index = current_values.find_index(insert)
|
23
|
+
# insertable = current_index.blank? ? insert : current_values.delete_at(current_index)
|
24
|
+
# current_values.insert(at, insertable)
|
25
|
+
# update(stored_in.inspect => current_values)
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
<<-RUBY, __FILE__, __LINE__ + 1
|
29
|
+
def #{insert_method_name}(insert:, at: 0)
|
30
|
+
with_lock do
|
31
|
+
current_values = public_send(#{stored_in.inspect})
|
32
|
+
current_index = current_values.find_index(insert)
|
33
|
+
insertable = current_index.blank? ? insert : current_values.delete_at(current_index)
|
34
|
+
current_values.insert(at, insertable)
|
35
|
+
update(#{stored_in.inspect} => current_values)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
RUBY
|
39
|
+
)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/oort/ordered.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Oort
|
4
|
+
# Oort.configure do |config|
|
5
|
+
# config.option = 'this'
|
6
|
+
# end
|
7
|
+
module Ordered
|
8
|
+
def self.included(base)
|
9
|
+
base.extend ClassMethods
|
10
|
+
# base.include InstanceMethods
|
11
|
+
|
12
|
+
base.class_eval do
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module ClassMethods
|
17
|
+
def handles_ordering_of(association)
|
18
|
+
args = {
|
19
|
+
stored_in: :"#{association}_ordering",
|
20
|
+
insert_method_name: :"update_#{association}_ordering",
|
21
|
+
remove_from_method_name: :"remove_from_#{association}_ordering",
|
22
|
+
association_class: association.to_s.classify.constantize,
|
23
|
+
instance_name: :"#{name.downcase}",
|
24
|
+
class_name: name.classify.constantize
|
25
|
+
}
|
26
|
+
|
27
|
+
Inserts.call(**args.slice(:stored_in, :insert_method_name, :class_name))
|
28
|
+
Removes.call(**args.slice(:stored_in, :remove_from_method_name, :class_name))
|
29
|
+
Scopes.call(**args.slice(:association_class))
|
30
|
+
Callbacks.call(**args.slice(:association_class, :remove_from_method_name, :insert_method_name, :instance_name))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/oort/removes.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Oort
|
4
|
+
# Oort.configure do |config|
|
5
|
+
# config.option = 'this'
|
6
|
+
# end
|
7
|
+
class Removes
|
8
|
+
def self.call(stored_in:, remove_from_method_name:, class_name:)
|
9
|
+
new(stored_in: stored_in, remove_from_method_name: remove_from_method_name, class_name: class_name).call
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :stored_in, :remove_from_method_name, :class_name
|
13
|
+
|
14
|
+
def initialize(stored_in:, remove_from_method_name:, class_name:)
|
15
|
+
@stored_in = stored_in
|
16
|
+
@remove_from_method_name = remove_from_method_name
|
17
|
+
@class_name = class_name
|
18
|
+
end
|
19
|
+
|
20
|
+
def call
|
21
|
+
class_name.class_eval(
|
22
|
+
# def remove_from_posts_ordering(id)
|
23
|
+
# with_lock do
|
24
|
+
# current_values = public_send(stored_in.inspect)
|
25
|
+
# current_index = current_values.find_index(id)
|
26
|
+
# current_values.delete_at(current_index)
|
27
|
+
# update(stored_in.inspect => current_values)
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
<<-RUBY, __FILE__, __LINE__ + 1
|
31
|
+
def #{remove_from_method_name}(id)
|
32
|
+
with_lock do
|
33
|
+
current_values = public_send(#{stored_in.inspect})
|
34
|
+
current_index = current_values.find_index(id)
|
35
|
+
return if current_index.blank?
|
36
|
+
|
37
|
+
current_values.delete_at(current_index)
|
38
|
+
update(#{stored_in.inspect} => current_values)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
RUBY
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/oort/scopes.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Oort
|
4
|
+
class Scopes
|
5
|
+
def self.call(association_class:)
|
6
|
+
new(association_class: association_class).call
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(association_class:)
|
10
|
+
@association_class = association_class
|
11
|
+
end
|
12
|
+
|
13
|
+
def call
|
14
|
+
# user = User.find(909)
|
15
|
+
# user.posts.ordered_with(user.posts_ordered)
|
16
|
+
# by default this will use posts.id::INTEGER
|
17
|
+
# but you can pass in something else if you have joins and items
|
18
|
+
# stored in another table
|
19
|
+
@association_class.class_eval do
|
20
|
+
scope :ordered_with, lambda { |ids, type = "#{table_name}.id::INTEGER"|
|
21
|
+
if ids.blank?
|
22
|
+
order(:id)
|
23
|
+
else
|
24
|
+
order(Arel.sql("array_position(ARRAY[#{ids.join(", ")}], #{type})"))
|
25
|
+
end
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/oort/version.rb
ADDED
data/lib/oort.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "oort/version"
|
4
|
+
|
5
|
+
module Oort
|
6
|
+
class << self
|
7
|
+
def configuration
|
8
|
+
@configuration ||= Oort::Configuration.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def configure
|
12
|
+
yield configuration
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
require "zeitwerk"
|
18
|
+
|
19
|
+
loader = Zeitwerk::Loader.for_gem
|
20
|
+
loader.ignore("#{__dir__}/kamal/sshkit_with_ext.rb")
|
21
|
+
loader.setup
|
22
|
+
loader.eager_load # We need all commands loaded.
|
data/sig/oort.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: oort
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- tobyond
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-01-26 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Oort to sort, order
|
14
|
+
email:
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- ".bin/bundle"
|
20
|
+
- ".bin/htmldiff"
|
21
|
+
- ".bin/ldiff"
|
22
|
+
- ".bin/racc"
|
23
|
+
- ".bin/rake"
|
24
|
+
- ".bin/rspec"
|
25
|
+
- ".bin/rubocop"
|
26
|
+
- ".bin/ruby-parse"
|
27
|
+
- ".bin/ruby-rewrite"
|
28
|
+
- ".rubocop.yml"
|
29
|
+
- CHANGELOG.md
|
30
|
+
- Gemfile
|
31
|
+
- Gemfile.lock
|
32
|
+
- LICENSE.txt
|
33
|
+
- README.md
|
34
|
+
- Rakefile
|
35
|
+
- lib/oort.rb
|
36
|
+
- lib/oort/callbacks.rb
|
37
|
+
- lib/oort/configuration.rb
|
38
|
+
- lib/oort/inserts.rb
|
39
|
+
- lib/oort/ordered.rb
|
40
|
+
- lib/oort/removes.rb
|
41
|
+
- lib/oort/scopes.rb
|
42
|
+
- lib/oort/version.rb
|
43
|
+
- sig/oort.rbs
|
44
|
+
homepage:
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
metadata:
|
48
|
+
source_code_uri: https://github.com/tobyond/oort
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 3.2.0
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubygems_version: 3.4.10
|
65
|
+
signing_key:
|
66
|
+
specification_version: 4
|
67
|
+
summary: Oort to sort, order
|
68
|
+
test_files: []
|