orthoses-ancestry 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0b6f9c531cfd0effbe0c2459edc1274b868828ab960e07a19eef72e799f8454d
4
+ data.tar.gz: db5475f36c7872143ccc085713c73ebd3bac2338c8b171b943a5202c9739156e
5
+ SHA512:
6
+ metadata.gz: fbfe81b9a44a47df43749f01e720f5f714915488c08134b5647eb299b628677f84b696468a57afd25da1ae3aee1f7b3332962691084ae358d8b29e8c34636932
7
+ data.tar.gz: 4a1318131e2dffbce915b9a77de21a020c8ddf5c1ee4acab35837bba6b6f0185391f86ccf44c7c5325a44495b6e788ac1d1b4ff81c3df76290d103e4ed088c22
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2026-01-15
4
+
5
+ - Initial release
@@ -0,0 +1,10 @@
1
+ # Code of Conduct
2
+
3
+ "orthoses-ancestry" follows [The Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct) in all "collaborative space", which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.):
4
+
5
+ * Participants will be tolerant of opposing views.
6
+ * Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
7
+ * When interpreting the words and actions of others, participants should always assume good intentions.
8
+ * Behaviour which can be reasonably considered harassment will not be tolerated.
9
+
10
+ If you have any concerns about behaviour within this project, please contact us at ["yakiyaki_ikayaki@yahoo.co.jp"](mailto:"yakiyaki_ikayaki@yahoo.co.jp").
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 masatoshi_moritsuka
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,49 @@
1
+ # Orthoses::Ancestry
2
+
3
+ [Orthoses](https://github.com/ksss/orthoses) extension for [Ancestry](https://github.com/stefankroes/ancestry).
4
+ Orthoses::Ancestry automatically generates RBS for methods added by Ancestry.
5
+
6
+ ```rb
7
+ Node.first!.children #=> Node::ActiveRecord_Relation
8
+ ```
9
+
10
+ ## Installation
11
+
12
+ Install the gem and add to the application's Gemfile by executing:
13
+
14
+ ```bash
15
+ bundle add orthoses-ancestry
16
+ ```
17
+
18
+ If bundler is not being used to manage dependencies, install the gem by executing:
19
+
20
+ ```bash
21
+ gem install orthoses-ancestry
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ancestry depends on rails.
27
+ orthoses-ancestry is strongly recommended to use with [orthoses-rails](https://github.com/ksss/orthoses-rails).
28
+
29
+ ```rb
30
+ use Orthoses::Ancestry
31
+ ```
32
+
33
+ ## Development
34
+
35
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
36
+
37
+ 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).
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sanfrecce-osaka/orthoses-ancestry. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/sanfrecce-osaka/orthoses-ancestry/blob/main/CODE_OF_CONDUCT.md).
42
+
43
+ ## License
44
+
45
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
46
+
47
+ ## Code of Conduct
48
+
49
+ Everyone interacting in the Orthoses::Ancestry project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/sanfrecce-osaka/orthoses-ancestry/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Orthoses
4
+ class Ancestry
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'ancestry/version'
4
+
5
+ module Orthoses
6
+ class Ancestry
7
+ def initialize(loader)
8
+ @loader = loader
9
+ end
10
+
11
+ def call
12
+ tracer = CallTracer::Lazy.new
13
+ store = tracer.trace('Ancestry::HasAncestry#has_ancestry') do
14
+ @loader.call
15
+ end
16
+
17
+ tracer.captures.each do |capture|
18
+ base_name = Utils.module_name(capture.method.receiver) or next
19
+ rel = "#{base_name}::ActiveRecord_Relation"
20
+
21
+ options = capture.argument[:options] || {}
22
+ ancestry_format = options[:ancestry_format] || ::Ancestry.default_ancestry_format
23
+
24
+ has_ancestry_sig = 'extend Ancestry::HasAncestry'
25
+ unless store['ActiveRecord::Base'].body.include?(has_ancestry_sig)
26
+ store['ActiveRecord::Base'] << has_ancestry_sig
27
+ end
28
+
29
+ store[base_name] << "include Ancestry::InstanceMethods[#{base_name}, #{rel}, Integer]"
30
+ store[base_name] << "extend Ancestry::ClassMethods[#{base_name}, #{rel}, Integer]"
31
+
32
+ if ancestry_format == :materialized_path2
33
+ store[base_name] << "extend Ancestry::MaterializedPath2[#{base_name}, #{rel}, Integer]"
34
+ store[base_name] << 'include Ancestry::MaterializedPathPg'
35
+ store[base_name] << "include Ancestry::MaterializedPath::InstanceMethods[#{base_name}, Integer]"
36
+ store[base_name] << 'include Ancestry::MaterializedPath2::InstanceMethods[Integer]'
37
+
38
+ store[rel] << "include Ancestry::ClassMethods[#{base_name}, #{rel}, Integer]"
39
+ store[rel] << "include Ancestry::MaterializedPath2[#{base_name}, #{rel}, Integer]"
40
+ else
41
+ store[base_name] << "extend Ancestry::MaterializedPath[#{base_name}, #{rel}, Integer]"
42
+ store[base_name] << 'include Ancestry::MaterializedPathPg'
43
+ store[base_name] << "include Ancestry::MaterializedPath::InstanceMethods[#{base_name}, Integer]"
44
+
45
+ store[rel] << "include Ancestry::ClassMethods[#{base_name}, #{rel}, Integer]"
46
+ store[rel] << "include Ancestry::MaterializedPath[#{base_name}, #{rel}, Integer]"
47
+ end
48
+
49
+ store[base_name] << 'def self.ancestry_column: () -> Symbol'
50
+ store[base_name] << 'def self.ancestry_delimiter: () -> String'
51
+ store[base_name] << "def self.ancestry_base_class: () -> singleton(#{base_name})"
52
+
53
+ store[base_name] << 'def self.touch_ancestors: () -> bool'
54
+ store[base_name] << 'def touch_ancestors: () -> bool'
55
+ store[base_name] << 'def self.touch_ancestors=: (bool val) -> bool'
56
+ store[base_name] << 'def touch_ancestors=: (bool val) -> bool'
57
+
58
+ if options[:cache_depth] && options[:cache_depth] != :virtual
59
+ store[base_name] << 'def self.depth_cache_column: () -> String'
60
+ store[base_name] << 'def depth_cache_column: () -> String'
61
+ store[base_name] << 'def self.depth_cache_column=: (String val) -> String'
62
+ store[base_name] << 'def depth_cache_column=: (String val) -> String'
63
+ end
64
+
65
+ if options[:counter_cache]
66
+ store[base_name] << 'def self.counter_cache_column: () -> String'
67
+ store[base_name] << 'def counter_cache_column: () -> String'
68
+ store[base_name] << 'def self.counter_cache_column=: (String val) -> String'
69
+ store[base_name] << 'def counter_cache_column=: (String val) -> String'
70
+ end
71
+
72
+ orphan_strategy = options[:orphan_strategy] || :destroy
73
+ unless orphan_strategy.to_s == 'none'
74
+ store[base_name] << "alias apply_orphan_strategy apply_orphan_strategy_#{orphan_strategy}"
75
+ end
76
+ end
77
+
78
+ store
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,14 @@
1
+ module Orthoses
2
+ class Ancestry
3
+ interface _Loader
4
+ def call: () -> Store
5
+ end
6
+
7
+ VERSION: String
8
+
9
+ @loader: _Loader
10
+
11
+ def initialize: (_Loader loader) -> void
12
+ def call: () -> Store
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: orthoses-ancestry
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - masatoshi_moritsuka
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: ancestry
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: orthoses
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ description: Orthoses middleware ancestry
41
+ email:
42
+ - yakiyaki_ikayaki@yahoo.co.jp
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - CHANGELOG.md
48
+ - CODE_OF_CONDUCT.md
49
+ - LICENSE.txt
50
+ - README.md
51
+ - Rakefile
52
+ - lib/orthoses/ancestry.rb
53
+ - lib/orthoses/ancestry/version.rb
54
+ - sig/orthoses/ancestry.rbs
55
+ homepage: https://github.com/sanfrecce-osaka/ancestry
56
+ licenses:
57
+ - MIT
58
+ metadata:
59
+ homepage_uri: https://github.com/sanfrecce-osaka/ancestry
60
+ source_code_uri: https://github.com/sanfrecce-osaka/ancestry
61
+ changelog_uri: https://github.com/sanfrecce-osaka/ancestry
62
+ rubygems_mfa_required: 'true'
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 3.2.0
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubygems_version: 4.0.3
78
+ specification_version: 4
79
+ summary: Orthoses middleware for ancestry
80
+ test_files: []