parentry 1.0.0 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9ed402972198361a4692bb08c0e37de6c5ab2def
4
- data.tar.gz: db76e44d21d704adfdab3acb58db9eb695be6a96
2
+ SHA256:
3
+ metadata.gz: 66be4e773ca40d1773b87815cf33bd8d6f8cb4796718d64e4bec62ddeb53b3e5
4
+ data.tar.gz: 45039c18a5c69ebc0277cf38a48e46d3f17520be92e0409e6d1a4d5872f0b120
5
5
  SHA512:
6
- metadata.gz: f026004b8d0a07e24c7f104fb5a5f7368b5864af578089c20e0babda9540b716b027c13e9d0d671db27b433a9c8a1bc434e166f66a867e54fc951a91c66e55da
7
- data.tar.gz: 821a2c44e758aac123bd7f875abf1085ed18931a386ec533253ca365053cb9bb58cb3dd42d0fba2d6b31d81aaa395a2221fbbe9855d24f226e2aa8beeb148dac
6
+ metadata.gz: '000976a1fecf1bf1b004f44a1943d8f85e6d80b5835a3bb6a50efebd3735e6ee1cd116e8789759fce424130bab1b796a5992526112cf165f1556621c67c2b33f'
7
+ data.tar.gz: 136945945ecb766008a7545cadbd68b3d68a7d5bf151168991457831c0ddc1185dd87f89f1f5a78a1711afc046de60d08dd84452999eaec08acbbe30e5c53cb5
@@ -0,0 +1,72 @@
1
+ name: Ruby
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ strategy:
11
+ matrix:
12
+ ruby:
13
+ - 2.5.x
14
+ - 2.6.x
15
+ - 2.7.x
16
+ activerecord:
17
+ - 5.1.5
18
+ - 5.2.0
19
+ - 6.0.0
20
+ - 6.1.0
21
+ strategy:
22
+ - array
23
+ - ltree
24
+
25
+ env:
26
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/activerecord_${{ matrix.activerecord }}.gemfile
27
+
28
+ services:
29
+ postgres:
30
+ image: postgres:12.4
31
+ env:
32
+ POSTGRES_USER: postgres
33
+ POSTGRES_PASSWORD: postgres
34
+ POSTGRES_DB: parentry_test
35
+ ports:
36
+ - 5432:5432
37
+ # needed because the postgres container does not provide a healthcheck
38
+ options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
39
+
40
+ steps:
41
+ - uses: actions/checkout@v2
42
+
43
+ - name: Set up Ruby
44
+ uses: actions/setup-ruby@v1
45
+ with:
46
+ ruby-version: ${{ matrix.ruby }}
47
+
48
+ - uses: actions/cache@v1
49
+ with:
50
+ path: vendor/bundle
51
+ key: ${{ runner.os }}-gems-${{ hashFiles(format('gemfiles/activerecord_{0}.gemfile.lock', matrix.activerecord)) }}
52
+ restore-keys: |
53
+ ${{ runner.os }}-gems-
54
+
55
+ - name: Install PostgreSQL client
56
+ run: |
57
+ sudo apt-get -yqq install libpq-dev
58
+
59
+ - name: Configure Bundler
60
+ run: |
61
+ gem install bundler:2.1.4 --no-document
62
+ bundle config set path 'vendor/bundle'
63
+ bundle install --jobs 4 --retry 3
64
+
65
+ - name: Run tests with RSpec
66
+ uses: paambaati/codeclimate-action@v2.5.4
67
+ env:
68
+ CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
69
+ STRATEGY: ${{ matrix.strategy }}
70
+ with:
71
+ coverageCommand: bundle exec rspec
72
+ debug: false
data/.gitignore CHANGED
@@ -11,3 +11,4 @@
11
11
  .ruby-gemset
12
12
  .ruby-version
13
13
  /vendor/
14
+ /spec/internal/log/*
@@ -0,0 +1,38 @@
1
+ inherit_mode:
2
+ merge:
3
+ - Exclude
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.6
7
+ Exclude:
8
+ - gemfiles/**
9
+
10
+ Layout/LineLength:
11
+ Max: 120
12
+
13
+ Layout/MultilineMethodCallIndentation:
14
+ EnforcedStyle: indented_relative_to_receiver
15
+
16
+ Naming/PredicateName:
17
+ AllowedMethods:
18
+ - has_many
19
+
20
+ Style/Documentation:
21
+ Enabled: false
22
+
23
+ Style/EmptyMethod:
24
+ EnforcedStyle: expanded
25
+
26
+ Style/FormatStringToken:
27
+ EnforcedStyle: template
28
+
29
+ Style/FrozenStringLiteralComment:
30
+ Enabled: false
31
+
32
+ Style/PercentLiteralDelimiters:
33
+ PreferredDelimiters:
34
+ default: ()
35
+ '%w': '()'
36
+ '%W': '()'
37
+ '%i': '()'
38
+ '%I': '()'
@@ -0,0 +1 @@
1
+ ruby 2.7.2
data/Appraisals CHANGED
@@ -1,3 +1,15 @@
1
- appraise 'activerecord-5.1' do
2
- gem 'activerecord', '~> 5.1.0'
1
+ appraise 'activerecord-5.1.5' do
2
+ gem 'activerecord', '5.1.5'
3
+ end
4
+
5
+ appraise 'activerecord-5.2.0' do
6
+ gem 'activerecord', '5.2.0'
7
+ end
8
+
9
+ appraise 'activerecord-6.0.0' do
10
+ gem 'activerecord', '6.0.0'
11
+ end
12
+
13
+ appraise 'activerecord-6.1.0' do
14
+ gem 'activerecord', '6.0.0'
3
15
  end
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- [![Build Status](https://travis-ci.org/hasghari/parentry.svg?branch=master)](https://travis-ci.org/hasghari/parentry)
1
+ ![](https://github.com/hasghari/parentry/workflows/Ruby/badge.svg)
2
+ [![Maintainability](https://api.codeclimate.com/v1/badges/cc7180328fffcbdea2bb/maintainability)](https://codeclimate.com/github/hasghari/parentry/maintainability)
2
3
 
3
4
  # Parentry
4
5
 
@@ -24,11 +25,26 @@ Or install it yourself as:
24
25
 
25
26
  ## Usage
26
27
 
27
- This gem requires 2 columns for each table: `parentry` and `parent_id`. A sample migration would look like:
28
+ This gem requires 2 columns for each table: `parentry` and `parent_id`, and can leverage either the `ltree` postgresql extension, or else postgres `array` columns. A sample migration would look like:
28
29
 
29
30
  ```ruby
30
- add_column :my_table, :parentry, :ltree
31
+ enable_extension 'ltree' # ltree is not turned on by default; skip if you use the array strategy
32
+
31
33
  add_column :my_table, :parent_id, :integer
34
+
35
+ add_column :my_table, :parentry, :ltree
36
+ add_column :my_table, :parentry_depth, :integer, default: 0 # optional
37
+
38
+ add_index :my_table, :parentry, using: :gist
39
+ ```
40
+
41
+ ```ruby
42
+ class MyTable < ApplicationRecord
43
+ include Parentry
44
+ parentry cache_depth: true
45
+ # to change strategy to array, and avoid dependency on ltree
46
+ # parentry strategy: :array
47
+ end
32
48
  ```
33
49
 
34
50
  ## Contributing
data/Rakefile CHANGED
@@ -6,4 +6,4 @@ require 'rspec/core/rake_task'
6
6
 
7
7
  RSpec::Core::RakeTask.new(:spec)
8
8
 
9
- task :default => :spec
9
+ task default: :spec
@@ -3,6 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
- gem "activerecord", "~> 5.1.0"
6
+ gem "activerecord", "5.1.5"
7
7
 
8
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -0,0 +1,143 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ parentry (1.3.0)
5
+ activerecord (>= 5.1, < 6.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (5.1.5)
11
+ actionview (= 5.1.5)
12
+ activesupport (= 5.1.5)
13
+ rack (~> 2.0)
14
+ rack-test (>= 0.6.3)
15
+ rails-dom-testing (~> 2.0)
16
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
17
+ actionview (5.1.5)
18
+ activesupport (= 5.1.5)
19
+ builder (~> 3.1)
20
+ erubi (~> 1.4)
21
+ rails-dom-testing (~> 2.0)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
23
+ activemodel (5.1.5)
24
+ activesupport (= 5.1.5)
25
+ activerecord (5.1.5)
26
+ activemodel (= 5.1.5)
27
+ activesupport (= 5.1.5)
28
+ arel (~> 8.0)
29
+ activesupport (5.1.5)
30
+ concurrent-ruby (~> 1.0, >= 1.0.2)
31
+ i18n (~> 0.7)
32
+ minitest (~> 5.1)
33
+ tzinfo (~> 1.1)
34
+ appraisal (2.2.0)
35
+ bundler
36
+ rake
37
+ thor (>= 0.14.0)
38
+ arel (8.0.0)
39
+ ast (2.4.0)
40
+ builder (3.2.3)
41
+ coderay (1.1.2)
42
+ combustion (1.1.1)
43
+ activesupport (>= 3.0.0)
44
+ railties (>= 3.0.0)
45
+ thor (>= 0.14.6)
46
+ concurrent-ruby (1.0.5)
47
+ crass (1.0.3)
48
+ database_cleaner (1.6.2)
49
+ diff-lcs (1.3)
50
+ docile (1.3.0)
51
+ erubi (1.7.1)
52
+ i18n (0.9.5)
53
+ concurrent-ruby (~> 1.0)
54
+ jaro_winkler (1.5.4)
55
+ json (2.3.1)
56
+ loofah (2.2.2)
57
+ crass (~> 1.0.2)
58
+ nokogiri (>= 1.5.9)
59
+ method_source (0.9.0)
60
+ mini_portile2 (2.4.0)
61
+ minitest (5.11.3)
62
+ nokogiri (1.10.7)
63
+ mini_portile2 (~> 2.4.0)
64
+ parallel (1.19.1)
65
+ parser (2.7.0.2)
66
+ ast (~> 2.4.0)
67
+ pg (1.2.2)
68
+ pry (0.11.3)
69
+ coderay (~> 1.1.0)
70
+ method_source (~> 0.9.0)
71
+ rack (2.0.4)
72
+ rack-test (1.0.0)
73
+ rack (>= 1.0, < 3)
74
+ rails-dom-testing (2.0.3)
75
+ activesupport (>= 4.2.0)
76
+ nokogiri (>= 1.6)
77
+ rails-html-sanitizer (1.0.4)
78
+ loofah (~> 2.2, >= 2.2.2)
79
+ railties (5.1.5)
80
+ actionpack (= 5.1.5)
81
+ activesupport (= 5.1.5)
82
+ method_source
83
+ rake (>= 0.8.7)
84
+ thor (>= 0.18.1, < 2.0)
85
+ rainbow (3.0.0)
86
+ rake (12.3.3)
87
+ rspec-core (3.7.1)
88
+ rspec-support (~> 3.7.0)
89
+ rspec-expectations (3.7.0)
90
+ diff-lcs (>= 1.2.0, < 2.0)
91
+ rspec-support (~> 3.7.0)
92
+ rspec-mocks (3.7.0)
93
+ diff-lcs (>= 1.2.0, < 2.0)
94
+ rspec-support (~> 3.7.0)
95
+ rspec-rails (3.7.2)
96
+ actionpack (>= 3.0)
97
+ activesupport (>= 3.0)
98
+ railties (>= 3.0)
99
+ rspec-core (~> 3.7.0)
100
+ rspec-expectations (~> 3.7.0)
101
+ rspec-mocks (~> 3.7.0)
102
+ rspec-support (~> 3.7.0)
103
+ rspec-support (3.7.1)
104
+ rubocop (0.79.0)
105
+ jaro_winkler (~> 1.5.1)
106
+ parallel (~> 1.10)
107
+ parser (>= 2.7.0.1)
108
+ rainbow (>= 2.2.2, < 4.0)
109
+ ruby-progressbar (~> 1.7)
110
+ unicode-display_width (>= 1.4.0, < 1.7)
111
+ rubocop-rspec (1.37.1)
112
+ rubocop (>= 0.68.1)
113
+ ruby-progressbar (1.10.1)
114
+ simplecov (0.16.1)
115
+ docile (~> 1.1)
116
+ json (>= 1.8, < 3)
117
+ simplecov-html (~> 0.10.0)
118
+ simplecov-html (0.10.2)
119
+ thor (0.20.0)
120
+ thread_safe (0.3.6)
121
+ tzinfo (1.2.8)
122
+ thread_safe (~> 0.1)
123
+ unicode-display_width (1.6.1)
124
+
125
+ PLATFORMS
126
+ ruby
127
+
128
+ DEPENDENCIES
129
+ activerecord (= 5.1.5)
130
+ appraisal
131
+ bundler (~> 2.1)
132
+ combustion (~> 1.1)
133
+ database_cleaner (~> 1.6)
134
+ parentry!
135
+ pg (~> 1.2)
136
+ pry (~> 0.10)
137
+ rake (~> 12.3)
138
+ rspec-rails (~> 3.7)
139
+ rubocop-rspec (~> 1.37)
140
+ simplecov (~> 0.16)
141
+
142
+ BUNDLED WITH
143
+ 2.1.4
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "activerecord", "5.2.0"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,143 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ parentry (1.3.0)
5
+ activerecord (>= 5.1, < 6.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (5.2.0)
11
+ actionview (= 5.2.0)
12
+ activesupport (= 5.2.0)
13
+ rack (~> 2.0)
14
+ rack-test (>= 0.6.3)
15
+ rails-dom-testing (~> 2.0)
16
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
17
+ actionview (5.2.0)
18
+ activesupport (= 5.2.0)
19
+ builder (~> 3.1)
20
+ erubi (~> 1.4)
21
+ rails-dom-testing (~> 2.0)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
23
+ activemodel (5.2.0)
24
+ activesupport (= 5.2.0)
25
+ activerecord (5.2.0)
26
+ activemodel (= 5.2.0)
27
+ activesupport (= 5.2.0)
28
+ arel (>= 9.0)
29
+ activesupport (5.2.0)
30
+ concurrent-ruby (~> 1.0, >= 1.0.2)
31
+ i18n (>= 0.7, < 2)
32
+ minitest (~> 5.1)
33
+ tzinfo (~> 1.1)
34
+ appraisal (2.2.0)
35
+ bundler
36
+ rake
37
+ thor (>= 0.14.0)
38
+ arel (9.0.0)
39
+ ast (2.4.0)
40
+ builder (3.2.3)
41
+ coderay (1.1.2)
42
+ combustion (1.1.1)
43
+ activesupport (>= 3.0.0)
44
+ railties (>= 3.0.0)
45
+ thor (>= 0.14.6)
46
+ concurrent-ruby (1.0.5)
47
+ crass (1.0.4)
48
+ database_cleaner (1.6.2)
49
+ diff-lcs (1.3)
50
+ docile (1.3.0)
51
+ erubi (1.7.1)
52
+ i18n (1.0.0)
53
+ concurrent-ruby (~> 1.0)
54
+ jaro_winkler (1.5.4)
55
+ json (2.3.1)
56
+ loofah (2.2.2)
57
+ crass (~> 1.0.2)
58
+ nokogiri (>= 1.5.9)
59
+ method_source (0.9.0)
60
+ mini_portile2 (2.4.0)
61
+ minitest (5.11.3)
62
+ nokogiri (1.10.7)
63
+ mini_portile2 (~> 2.4.0)
64
+ parallel (1.19.1)
65
+ parser (2.7.0.2)
66
+ ast (~> 2.4.0)
67
+ pg (1.2.2)
68
+ pry (0.11.3)
69
+ coderay (~> 1.1.0)
70
+ method_source (~> 0.9.0)
71
+ rack (2.0.4)
72
+ rack-test (1.0.0)
73
+ rack (>= 1.0, < 3)
74
+ rails-dom-testing (2.0.3)
75
+ activesupport (>= 4.2.0)
76
+ nokogiri (>= 1.6)
77
+ rails-html-sanitizer (1.0.4)
78
+ loofah (~> 2.2, >= 2.2.2)
79
+ railties (5.2.0)
80
+ actionpack (= 5.2.0)
81
+ activesupport (= 5.2.0)
82
+ method_source
83
+ rake (>= 0.8.7)
84
+ thor (>= 0.18.1, < 2.0)
85
+ rainbow (3.0.0)
86
+ rake (12.3.3)
87
+ rspec-core (3.7.1)
88
+ rspec-support (~> 3.7.0)
89
+ rspec-expectations (3.7.0)
90
+ diff-lcs (>= 1.2.0, < 2.0)
91
+ rspec-support (~> 3.7.0)
92
+ rspec-mocks (3.7.0)
93
+ diff-lcs (>= 1.2.0, < 2.0)
94
+ rspec-support (~> 3.7.0)
95
+ rspec-rails (3.7.2)
96
+ actionpack (>= 3.0)
97
+ activesupport (>= 3.0)
98
+ railties (>= 3.0)
99
+ rspec-core (~> 3.7.0)
100
+ rspec-expectations (~> 3.7.0)
101
+ rspec-mocks (~> 3.7.0)
102
+ rspec-support (~> 3.7.0)
103
+ rspec-support (3.7.1)
104
+ rubocop (0.79.0)
105
+ jaro_winkler (~> 1.5.1)
106
+ parallel (~> 1.10)
107
+ parser (>= 2.7.0.1)
108
+ rainbow (>= 2.2.2, < 4.0)
109
+ ruby-progressbar (~> 1.7)
110
+ unicode-display_width (>= 1.4.0, < 1.7)
111
+ rubocop-rspec (1.37.1)
112
+ rubocop (>= 0.68.1)
113
+ ruby-progressbar (1.10.1)
114
+ simplecov (0.16.1)
115
+ docile (~> 1.1)
116
+ json (>= 1.8, < 3)
117
+ simplecov-html (~> 0.10.0)
118
+ simplecov-html (0.10.2)
119
+ thor (0.20.0)
120
+ thread_safe (0.3.6)
121
+ tzinfo (1.2.8)
122
+ thread_safe (~> 0.1)
123
+ unicode-display_width (1.6.1)
124
+
125
+ PLATFORMS
126
+ ruby
127
+
128
+ DEPENDENCIES
129
+ activerecord (= 5.2.0)
130
+ appraisal
131
+ bundler (~> 2.1)
132
+ combustion (~> 1.1)
133
+ database_cleaner (~> 1.6)
134
+ parentry!
135
+ pg (~> 1.2)
136
+ pry (~> 0.10)
137
+ rake (~> 12.3)
138
+ rspec-rails (~> 3.7)
139
+ rubocop-rspec (~> 1.37)
140
+ simplecov (~> 0.16)
141
+
142
+ BUNDLED WITH
143
+ 2.1.4