table_saw 2.4.3 → 2.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67ef82a827e7b74d82d18a1ca59c5cea9d4d8fb4bc7f518c2dbc81ddd8880c11
4
- data.tar.gz: 46291dd57476c4a73635921ebb6587aef1d58ba17656b1a11289543da9b90ed0
3
+ metadata.gz: 47ac846bd63f95c2ab738a6de5bb6011f85a201bdbf5e2011435771504caf68f
4
+ data.tar.gz: d2626da1b76f1b2ade2dee2d008d99765dccdac332f33b95336a231bea794782
5
5
  SHA512:
6
- metadata.gz: 7ba5ee90c773bb5bf2e9631e87d4a7e7448a3506e94743cbc52eefb16e41cd25b309201249475b0a490262025259974086125dec00786306fa8c688fd82bea21
7
- data.tar.gz: 8b5073d3e40c6b64e92618ba911368f8cc5b938bac6704c63e77dce90667776981146920bc0c6d9dd7b2662ae667b82d408056e20e667057d1021dad9191ba2b
6
+ metadata.gz: c7f3242fd4617ca2e0d4a7f498fcfa59efcf62368e2c0691d82e9d6f9b75e9907ca7312d2a171f3559227e2738c1d2c45074fd272d52227780848201cb862655
7
+ data.tar.gz: ccebba52760f172c53186766586267e52050650e117d0509a91416fee74b2096d90a85b60bb240673c1738437575174e337d43d34d19b6ee54c358fac8a768de
@@ -0,0 +1,65 @@
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.6.x
14
+ - 2.7.x
15
+ activerecord:
16
+ - 6.0.0
17
+ - 6.1.0
18
+
19
+ env:
20
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/activerecord_${{ matrix.activerecord }}.gemfile
21
+
22
+ services:
23
+ postgres:
24
+ image: postgres:12.4
25
+ env:
26
+ POSTGRES_USER: postgres
27
+ POSTGRES_PASSWORD: postgres
28
+ POSTGRES_DB: table_saw_test
29
+ ports:
30
+ - 5432:5432
31
+ # needed because the postgres container does not provide a healthcheck
32
+ options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
33
+
34
+ steps:
35
+ - uses: actions/checkout@v2
36
+
37
+ - name: Set up Ruby
38
+ uses: actions/setup-ruby@v1
39
+ with:
40
+ ruby-version: ${{ matrix.ruby }}
41
+
42
+ - uses: actions/cache@v1
43
+ with:
44
+ path: vendor/bundle
45
+ key: ${{ runner.os }}-gems-${{ hashFiles(format('gemfiles/activerecord_{0}.gemfile.lock', matrix.activerecord)) }}
46
+ restore-keys: |
47
+ ${{ runner.os }}-gems-
48
+
49
+ - name: Install PostgreSQL client
50
+ run: |
51
+ sudo apt-get -yqq install libpq-dev
52
+
53
+ - name: Configure Bundler
54
+ run: |
55
+ gem install bundler -v 2.1.4 --no-document
56
+ bundle config set path 'vendor/bundle'
57
+ bundle install --jobs 4 --retry 3
58
+
59
+ - name: Run tests with RSpec
60
+ uses: paambaati/codeclimate-action@v2.5.4
61
+ env:
62
+ CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
63
+ with:
64
+ coverageCommand: bundle exec rspec
65
+ debug: false
@@ -3,14 +3,23 @@ require: rubocop-rspec
3
3
  AllCops:
4
4
  TargetRubyVersion: 2.6
5
5
 
6
+ Layout/LineLength:
7
+ Max: 120
8
+
6
9
  Layout/MultilineMethodCallIndentation:
7
10
  EnforcedStyle: indented_relative_to_receiver
8
11
 
9
- Metrics/LineLength:
10
- Max: 120
12
+ Layout/SpaceAroundMethodCallOperator:
13
+ Enabled: true
14
+
15
+ Lint/RaiseException:
16
+ Enabled: true
17
+
18
+ Lint/StructNewOverride:
19
+ Enabled: true
11
20
 
12
21
  Naming/PredicateName:
13
- NameWhitelist:
22
+ AllowedMethods:
14
23
  - has_many
15
24
 
16
25
  Style/Documentation:
@@ -19,9 +28,21 @@ Style/Documentation:
19
28
  Style/EmptyMethod:
20
29
  EnforcedStyle: expanded
21
30
 
31
+ Style/ExponentialNotation:
32
+ Enabled: true
33
+
22
34
  Style/FormatStringToken:
23
35
  EnforcedStyle: template
24
36
 
37
+ Style/HashEachMethods:
38
+ Enabled: true
39
+
40
+ Style/HashTransformKeys:
41
+ Enabled: true
42
+
43
+ Style/HashTransformValues:
44
+ Enabled: true
45
+
25
46
  Style/PercentLiteralDelimiters:
26
47
  PreferredDelimiters:
27
48
  default: ()
@@ -1 +1 @@
1
- 2.6.5
1
+ 2.6.6
@@ -0,0 +1 @@
1
+ ruby 2.7.2
@@ -0,0 +1,7 @@
1
+ appraise 'activerecord-6.0.0' do
2
+ gem 'activerecord', '6.0.0'
3
+ end
4
+
5
+ appraise 'activerecord-6.1.0' do
6
+ gem 'activerecord', '6.1.0'
7
+ end
data/Gemfile CHANGED
@@ -4,3 +4,5 @@ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in table_saw.gemspec
6
6
  gemspec
7
+
8
+ gem 'appraisal'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- table_saw (2.4.3)
4
+ table_saw (2.8.1)
5
5
  activerecord (>= 5.2)
6
6
  pg
7
7
  thor
@@ -9,63 +9,67 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- actionpack (6.0.2.1)
13
- actionview (= 6.0.2.1)
14
- activesupport (= 6.0.2.1)
15
- rack (~> 2.0, >= 2.0.8)
12
+ actionpack (6.1.0)
13
+ actionview (= 6.1.0)
14
+ activesupport (= 6.1.0)
15
+ rack (~> 2.0, >= 2.0.9)
16
16
  rack-test (>= 0.6.3)
17
17
  rails-dom-testing (~> 2.0)
18
18
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
19
- actionview (6.0.2.1)
20
- activesupport (= 6.0.2.1)
19
+ actionview (6.1.0)
20
+ activesupport (= 6.1.0)
21
21
  builder (~> 3.1)
22
22
  erubi (~> 1.4)
23
23
  rails-dom-testing (~> 2.0)
24
24
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
25
- activemodel (6.0.2.1)
26
- activesupport (= 6.0.2.1)
27
- activerecord (6.0.2.1)
28
- activemodel (= 6.0.2.1)
29
- activesupport (= 6.0.2.1)
30
- activesupport (6.0.2.1)
25
+ activemodel (6.1.0)
26
+ activesupport (= 6.1.0)
27
+ activerecord (6.1.0)
28
+ activemodel (= 6.1.0)
29
+ activesupport (= 6.1.0)
30
+ activesupport (6.1.0)
31
31
  concurrent-ruby (~> 1.0, >= 1.0.2)
32
- i18n (>= 0.7, < 2)
33
- minitest (~> 5.1)
34
- tzinfo (~> 1.1)
35
- zeitwerk (~> 2.2)
32
+ i18n (>= 1.6, < 2)
33
+ minitest (>= 5.1)
34
+ tzinfo (~> 2.0)
35
+ zeitwerk (~> 2.3)
36
+ appraisal (2.3.0)
37
+ bundler
38
+ rake
39
+ thor (>= 0.14.0)
36
40
  ast (2.4.0)
37
41
  builder (3.2.4)
38
42
  coderay (1.1.2)
39
- combustion (1.1.2)
43
+ combustion (1.3.1)
40
44
  activesupport (>= 3.0.0)
41
45
  railties (>= 3.0.0)
42
46
  thor (>= 0.14.6)
43
- concurrent-ruby (1.1.5)
47
+ concurrent-ruby (1.1.7)
44
48
  crass (1.0.6)
45
49
  database_cleaner (1.7.0)
46
50
  diff-lcs (1.3)
47
51
  docile (1.3.1)
48
- erubi (1.9.0)
49
- i18n (1.8.2)
52
+ erubi (1.10.0)
53
+ i18n (1.8.5)
50
54
  concurrent-ruby (~> 1.0)
51
- jaro_winkler (1.5.2)
52
- json (2.2.0)
53
- loofah (2.4.0)
55
+ jaro_winkler (1.5.4)
56
+ json (2.3.1)
57
+ loofah (2.8.0)
54
58
  crass (~> 1.0.2)
55
59
  nokogiri (>= 1.5.9)
56
60
  method_source (0.9.2)
57
61
  mini_portile2 (2.4.0)
58
- minitest (5.14.0)
59
- nokogiri (1.10.7)
62
+ minitest (5.14.2)
63
+ nokogiri (1.10.10)
60
64
  mini_portile2 (~> 2.4.0)
61
- parallel (1.17.0)
62
- parser (2.6.3.0)
65
+ parallel (1.19.1)
66
+ parser (2.7.1.2)
63
67
  ast (~> 2.4.0)
64
- pg (1.2.2)
68
+ pg (1.2.3)
65
69
  pry (0.12.2)
66
70
  coderay (~> 1.1.0)
67
71
  method_source (~> 0.9.0)
68
- rack (2.1.1)
72
+ rack (2.2.3)
69
73
  rack-test (1.1.0)
70
74
  rack (>= 1.0, < 3)
71
75
  rails-dom-testing (2.0.3)
@@ -73,38 +77,40 @@ GEM
73
77
  nokogiri (>= 1.6)
74
78
  rails-html-sanitizer (1.3.0)
75
79
  loofah (~> 2.3)
76
- railties (6.0.2.1)
77
- actionpack (= 6.0.2.1)
78
- activesupport (= 6.0.2.1)
80
+ railties (6.1.0)
81
+ actionpack (= 6.1.0)
82
+ activesupport (= 6.1.0)
79
83
  method_source
80
84
  rake (>= 0.8.7)
81
- thor (>= 0.20.3, < 2.0)
85
+ thor (~> 1.0)
82
86
  rainbow (3.0.0)
83
- rake (10.5.0)
84
- rspec (3.8.0)
85
- rspec-core (~> 3.8.0)
86
- rspec-expectations (~> 3.8.0)
87
- rspec-mocks (~> 3.8.0)
88
- rspec-core (3.8.0)
89
- rspec-support (~> 3.8.0)
90
- rspec-expectations (3.8.3)
87
+ rake (13.0.1)
88
+ rexml (3.2.4)
89
+ rspec (3.9.0)
90
+ rspec-core (~> 3.9.0)
91
+ rspec-expectations (~> 3.9.0)
92
+ rspec-mocks (~> 3.9.0)
93
+ rspec-core (3.9.1)
94
+ rspec-support (~> 3.9.1)
95
+ rspec-expectations (3.9.0)
91
96
  diff-lcs (>= 1.2.0, < 2.0)
92
- rspec-support (~> 3.8.0)
93
- rspec-mocks (3.8.0)
97
+ rspec-support (~> 3.9.0)
98
+ rspec-mocks (3.9.1)
94
99
  diff-lcs (>= 1.2.0, < 2.0)
95
- rspec-support (~> 3.8.0)
96
- rspec-support (3.8.0)
97
- rubocop (0.71.0)
100
+ rspec-support (~> 3.9.0)
101
+ rspec-support (3.9.2)
102
+ rubocop (0.82.0)
98
103
  jaro_winkler (~> 1.5.1)
99
104
  parallel (~> 1.10)
100
- parser (>= 2.6)
105
+ parser (>= 2.7.0.1)
101
106
  rainbow (>= 2.2.2, < 4.0)
107
+ rexml
102
108
  ruby-progressbar (~> 1.7)
103
- unicode-display_width (>= 1.4.0, < 1.7)
109
+ unicode-display_width (>= 1.4.0, < 2.0)
104
110
  rubocop-rspec (1.33.0)
105
111
  rubocop (>= 0.60.0)
106
112
  ruby-progressbar (1.10.1)
107
- scenic (1.5.1)
113
+ scenic (1.5.4)
108
114
  activerecord (>= 4.0.0)
109
115
  railties (>= 4.0.0)
110
116
  simplecov (0.16.1)
@@ -113,21 +119,21 @@ GEM
113
119
  simplecov-html (~> 0.10.0)
114
120
  simplecov-html (0.10.2)
115
121
  thor (1.0.1)
116
- thread_safe (0.3.6)
117
- tzinfo (1.2.6)
118
- thread_safe (~> 0.1)
119
- unicode-display_width (1.6.0)
120
- zeitwerk (2.2.2)
122
+ tzinfo (2.0.3)
123
+ concurrent-ruby (~> 1.0)
124
+ unicode-display_width (1.7.0)
125
+ zeitwerk (2.4.2)
121
126
 
122
127
  PLATFORMS
123
128
  ruby
124
129
 
125
130
  DEPENDENCIES
131
+ appraisal
126
132
  bundler (~> 2.0)
127
- combustion (~> 1.1)
133
+ combustion (~> 1.3)
128
134
  database_cleaner (~> 1.7)
129
135
  pry
130
- rake (~> 10.0)
136
+ rake (~> 13.0)
131
137
  rspec (~> 3.0)
132
138
  rubocop-rspec (~> 1.33)
133
139
  scenic (~> 1.5)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/hasghari/table_saw.svg?branch=master)](https://travis-ci.org/hasghari/table_saw)
1
+ ![](https://github.com/hasghari/table_saw/workflows/Ruby/badge.svg)
2
2
  [![Maintainability](https://api.codeclimate.com/v1/badges/abd5b5451c764d3249f1/maintainability)](https://codeclimate.com/github/hasghari/table_saw/maintainability)
3
3
  [![Test Coverage](https://api.codeclimate.com/v1/badges/abd5b5451c764d3249f1/test_coverage)](https://codeclimate.com/github/hasghari/table_saw/test_coverage)
4
4
 
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_RETRY: "1"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "activerecord", "6.0.0"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,148 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ table_saw (2.7.0)
5
+ activerecord (>= 5.2)
6
+ pg
7
+ thor
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actionpack (6.0.0)
13
+ actionview (= 6.0.0)
14
+ activesupport (= 6.0.0)
15
+ rack (~> 2.0)
16
+ rack-test (>= 0.6.3)
17
+ rails-dom-testing (~> 2.0)
18
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
19
+ actionview (6.0.0)
20
+ activesupport (= 6.0.0)
21
+ builder (~> 3.1)
22
+ erubi (~> 1.4)
23
+ rails-dom-testing (~> 2.0)
24
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
25
+ activemodel (6.0.0)
26
+ activesupport (= 6.0.0)
27
+ activerecord (6.0.0)
28
+ activemodel (= 6.0.0)
29
+ activesupport (= 6.0.0)
30
+ activesupport (6.0.0)
31
+ concurrent-ruby (~> 1.0, >= 1.0.2)
32
+ i18n (>= 0.7, < 2)
33
+ minitest (~> 5.1)
34
+ tzinfo (~> 1.1)
35
+ zeitwerk (~> 2.1, >= 2.1.8)
36
+ appraisal (2.3.0)
37
+ bundler
38
+ rake
39
+ thor (>= 0.14.0)
40
+ ast (2.4.1)
41
+ builder (3.2.4)
42
+ coderay (1.1.3)
43
+ combustion (1.3.1)
44
+ activesupport (>= 3.0.0)
45
+ railties (>= 3.0.0)
46
+ thor (>= 0.14.6)
47
+ concurrent-ruby (1.1.7)
48
+ crass (1.0.6)
49
+ database_cleaner (1.8.5)
50
+ diff-lcs (1.4.4)
51
+ docile (1.3.2)
52
+ erubi (1.10.0)
53
+ i18n (1.8.5)
54
+ concurrent-ruby (~> 1.0)
55
+ loofah (2.8.0)
56
+ crass (~> 1.0.2)
57
+ nokogiri (>= 1.5.9)
58
+ method_source (1.0.0)
59
+ mini_portile2 (2.4.0)
60
+ minitest (5.14.2)
61
+ nokogiri (1.10.10)
62
+ mini_portile2 (~> 2.4.0)
63
+ parallel (1.20.1)
64
+ parser (2.7.2.0)
65
+ ast (~> 2.4.1)
66
+ pg (1.2.3)
67
+ pry (0.13.1)
68
+ coderay (~> 1.1)
69
+ method_source (~> 1.0)
70
+ rack (2.2.3)
71
+ rack-test (1.1.0)
72
+ rack (>= 1.0, < 3)
73
+ rails-dom-testing (2.0.3)
74
+ activesupport (>= 4.2.0)
75
+ nokogiri (>= 1.6)
76
+ rails-html-sanitizer (1.3.0)
77
+ loofah (~> 2.3)
78
+ railties (6.0.0)
79
+ actionpack (= 6.0.0)
80
+ activesupport (= 6.0.0)
81
+ method_source
82
+ rake (>= 0.8.7)
83
+ thor (>= 0.20.3, < 2.0)
84
+ rainbow (3.0.0)
85
+ rake (13.0.1)
86
+ regexp_parser (2.0.0)
87
+ rexml (3.2.4)
88
+ rspec (3.9.0)
89
+ rspec-core (~> 3.9.0)
90
+ rspec-expectations (~> 3.9.0)
91
+ rspec-mocks (~> 3.9.0)
92
+ rspec-core (3.9.3)
93
+ rspec-support (~> 3.9.3)
94
+ rspec-expectations (3.9.4)
95
+ diff-lcs (>= 1.2.0, < 2.0)
96
+ rspec-support (~> 3.9.0)
97
+ rspec-mocks (3.9.1)
98
+ diff-lcs (>= 1.2.0, < 2.0)
99
+ rspec-support (~> 3.9.0)
100
+ rspec-support (3.9.4)
101
+ rubocop (0.93.1)
102
+ parallel (~> 1.10)
103
+ parser (>= 2.7.1.5)
104
+ rainbow (>= 2.2.2, < 4.0)
105
+ regexp_parser (>= 1.8)
106
+ rexml
107
+ rubocop-ast (>= 0.6.0)
108
+ ruby-progressbar (~> 1.7)
109
+ unicode-display_width (>= 1.4.0, < 2.0)
110
+ rubocop-ast (1.3.0)
111
+ parser (>= 2.7.1.5)
112
+ rubocop-rspec (1.44.1)
113
+ rubocop (~> 0.87)
114
+ rubocop-ast (>= 0.7.1)
115
+ ruby-progressbar (1.10.1)
116
+ scenic (1.5.2)
117
+ activerecord (>= 4.0.0)
118
+ railties (>= 4.0.0)
119
+ simplecov (0.19.1)
120
+ docile (~> 1.1)
121
+ simplecov-html (~> 0.11)
122
+ simplecov-html (0.12.3)
123
+ thor (1.0.1)
124
+ thread_safe (0.3.6)
125
+ tzinfo (1.2.8)
126
+ thread_safe (~> 0.1)
127
+ unicode-display_width (1.7.0)
128
+ zeitwerk (2.4.2)
129
+
130
+ PLATFORMS
131
+ ruby
132
+
133
+ DEPENDENCIES
134
+ activerecord (= 6.0.0)
135
+ appraisal
136
+ bundler (~> 2.0)
137
+ combustion (~> 1.3)
138
+ database_cleaner (~> 1.7)
139
+ pry
140
+ rake (~> 13.0)
141
+ rspec (~> 3.0)
142
+ rubocop-rspec (~> 1.33)
143
+ scenic (~> 1.5)
144
+ simplecov (~> 0.16)
145
+ table_saw!
146
+
147
+ BUNDLED WITH
148
+ 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", "6.1.0"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,147 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ table_saw (2.7.0)
5
+ activerecord (>= 5.2)
6
+ pg
7
+ thor
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actionpack (6.1.0)
13
+ actionview (= 6.1.0)
14
+ activesupport (= 6.1.0)
15
+ rack (~> 2.0, >= 2.0.9)
16
+ rack-test (>= 0.6.3)
17
+ rails-dom-testing (~> 2.0)
18
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
19
+ actionview (6.1.0)
20
+ activesupport (= 6.1.0)
21
+ builder (~> 3.1)
22
+ erubi (~> 1.4)
23
+ rails-dom-testing (~> 2.0)
24
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
25
+ activemodel (6.1.0)
26
+ activesupport (= 6.1.0)
27
+ activerecord (6.1.0)
28
+ activemodel (= 6.1.0)
29
+ activesupport (= 6.1.0)
30
+ activesupport (6.1.0)
31
+ concurrent-ruby (~> 1.0, >= 1.0.2)
32
+ i18n (>= 1.6, < 2)
33
+ minitest (>= 5.1)
34
+ tzinfo (~> 2.0)
35
+ zeitwerk (~> 2.3)
36
+ appraisal (2.3.0)
37
+ bundler
38
+ rake
39
+ thor (>= 0.14.0)
40
+ ast (2.4.1)
41
+ builder (3.2.4)
42
+ coderay (1.1.3)
43
+ combustion (1.3.1)
44
+ activesupport (>= 3.0.0)
45
+ railties (>= 3.0.0)
46
+ thor (>= 0.14.6)
47
+ concurrent-ruby (1.1.7)
48
+ crass (1.0.6)
49
+ database_cleaner (1.8.5)
50
+ diff-lcs (1.4.4)
51
+ docile (1.3.2)
52
+ erubi (1.10.0)
53
+ i18n (1.8.5)
54
+ concurrent-ruby (~> 1.0)
55
+ loofah (2.8.0)
56
+ crass (~> 1.0.2)
57
+ nokogiri (>= 1.5.9)
58
+ method_source (1.0.0)
59
+ mini_portile2 (2.4.0)
60
+ minitest (5.14.2)
61
+ nokogiri (1.10.10)
62
+ mini_portile2 (~> 2.4.0)
63
+ parallel (1.20.1)
64
+ parser (2.7.2.0)
65
+ ast (~> 2.4.1)
66
+ pg (1.2.3)
67
+ pry (0.13.1)
68
+ coderay (~> 1.1)
69
+ method_source (~> 1.0)
70
+ rack (2.2.3)
71
+ rack-test (1.1.0)
72
+ rack (>= 1.0, < 3)
73
+ rails-dom-testing (2.0.3)
74
+ activesupport (>= 4.2.0)
75
+ nokogiri (>= 1.6)
76
+ rails-html-sanitizer (1.3.0)
77
+ loofah (~> 2.3)
78
+ railties (6.1.0)
79
+ actionpack (= 6.1.0)
80
+ activesupport (= 6.1.0)
81
+ method_source
82
+ rake (>= 0.8.7)
83
+ thor (~> 1.0)
84
+ rainbow (3.0.0)
85
+ rake (13.0.1)
86
+ regexp_parser (2.0.0)
87
+ rexml (3.2.4)
88
+ rspec (3.9.0)
89
+ rspec-core (~> 3.9.0)
90
+ rspec-expectations (~> 3.9.0)
91
+ rspec-mocks (~> 3.9.0)
92
+ rspec-core (3.9.3)
93
+ rspec-support (~> 3.9.3)
94
+ rspec-expectations (3.9.4)
95
+ diff-lcs (>= 1.2.0, < 2.0)
96
+ rspec-support (~> 3.9.0)
97
+ rspec-mocks (3.9.1)
98
+ diff-lcs (>= 1.2.0, < 2.0)
99
+ rspec-support (~> 3.9.0)
100
+ rspec-support (3.9.4)
101
+ rubocop (0.93.1)
102
+ parallel (~> 1.10)
103
+ parser (>= 2.7.1.5)
104
+ rainbow (>= 2.2.2, < 4.0)
105
+ regexp_parser (>= 1.8)
106
+ rexml
107
+ rubocop-ast (>= 0.6.0)
108
+ ruby-progressbar (~> 1.7)
109
+ unicode-display_width (>= 1.4.0, < 2.0)
110
+ rubocop-ast (1.3.0)
111
+ parser (>= 2.7.1.5)
112
+ rubocop-rspec (1.44.1)
113
+ rubocop (~> 0.87)
114
+ rubocop-ast (>= 0.7.1)
115
+ ruby-progressbar (1.10.1)
116
+ scenic (1.5.2)
117
+ activerecord (>= 4.0.0)
118
+ railties (>= 4.0.0)
119
+ simplecov (0.19.1)
120
+ docile (~> 1.1)
121
+ simplecov-html (~> 0.11)
122
+ simplecov-html (0.12.3)
123
+ thor (1.0.1)
124
+ tzinfo (2.0.3)
125
+ concurrent-ruby (~> 1.0)
126
+ unicode-display_width (1.7.0)
127
+ zeitwerk (2.4.2)
128
+
129
+ PLATFORMS
130
+ ruby
131
+
132
+ DEPENDENCIES
133
+ activerecord (= 6.1.0)
134
+ appraisal
135
+ bundler (~> 2.0)
136
+ combustion (~> 1.3)
137
+ database_cleaner (~> 1.7)
138
+ pry
139
+ rake (~> 13.0)
140
+ rspec (~> 3.0)
141
+ rubocop-rspec (~> 1.33)
142
+ scenic (~> 1.5)
143
+ simplecov (~> 0.16)
144
+ table_saw!
145
+
146
+ BUNDLED WITH
147
+ 2.1.4
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TableSaw
4
+ class Associations
5
+ attr_reader :manifest
6
+
7
+ def initialize(manifest)
8
+ @manifest = manifest
9
+ end
10
+
11
+ def belongs_to
12
+ @belongs_to ||= foreign_keys.each_with_object(Hash.new { |h, k| h[k] = Set.new }) do |fk, memo|
13
+ memo[fk.from_table].add(fk)
14
+ end
15
+ end
16
+
17
+ def has_many
18
+ @has_many ||= foreign_keys.each_with_object(Hash.new { |h, k| h[k] = Set.new }) do |fk, memo|
19
+ memo[fk.to_table].add(fk)
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def foreign_keys
26
+ @foreign_keys ||= manifest_foreign_keys + schema_foreign_keys
27
+ end
28
+
29
+ def manifest_foreign_keys
30
+ manifest.foreign_keys.map do |fk|
31
+ TableSaw::ForeignKey.new(from_table: fk['from_table'], from_column: fk['from_column'],
32
+ to_table: fk['to_table'], to_column: fk['to_column'])
33
+ end
34
+ end
35
+
36
+ def schema_foreign_keys
37
+ TableSaw.information_schema.foreign_key_relationships.foreign_keys
38
+ end
39
+ end
40
+ end
@@ -49,7 +49,7 @@ module TableSaw
49
49
 
50
50
  formatter = FORMATS.fetch(format.fetch('type', 'copy'), TableSaw::Formats::Copy).new(name, options: format)
51
51
 
52
- Array.wrap(formatter.header).each { |line| write_to_file(line) }
52
+ Array(formatter.header).each { |line| write_to_file(line) }
53
53
 
54
54
  TableSaw::Connection.with do |conn|
55
55
  conn.copy_data "COPY (#{table.copy_statement}) TO STDOUT", formatter.coder do
@@ -59,7 +59,7 @@ module TableSaw
59
59
  end
60
60
  end
61
61
 
62
- Array.wrap(formatter.footer).each { |line| write_to_file(line) }
62
+ Array(formatter.footer).each { |line| write_to_file(line) }
63
63
  end
64
64
 
65
65
  write_to_file 'COMMIT;'
@@ -3,42 +3,46 @@
3
3
  module TableSaw
4
4
  module DependencyGraph
5
5
  class BelongsToDirectives
6
- attr_reader :directive
6
+ QUERY = <<~SQL
7
+ select distinct %{column} from %{table_name} where %{clause} and %{column} is not null and %{polymorphic}
8
+ SQL
7
9
 
8
- def initialize(directive)
10
+ attr_reader :manifest, :directive
11
+
12
+ def initialize(manifest, directive)
13
+ @manifest = manifest
9
14
  @directive = directive
10
15
  end
11
16
 
12
17
  def call
13
- associations.map do |from_column, to_table|
14
- TableSaw::DependencyGraph::AddDirective.new(to_table, ids: ids[from_column], partial: directive.partial?)
18
+ associations.map do |fk|
19
+ TableSaw::DependencyGraph::AddDirective.new(fk.to_table, ids: ids[fk.column.primary_key],
20
+ partial: directive.partial?)
15
21
  end
16
22
  end
17
23
 
18
24
  private
19
25
 
20
26
  def associations
21
- TableSaw.information_schema.belongs_to.fetch(directive.table_name, {})
27
+ manifest.associations.belongs_to.fetch(directive.table_name, Set.new)
22
28
  end
23
29
 
24
30
  def ids
25
- @ids ||= associations.each_key.each_with_object({}) do |column, memo|
26
- memo[column] = query_result(column).map { |row| row[column] }
31
+ @ids ||= associations.each_with_object({}) do |fk, memo|
32
+ memo[fk.column.primary_key] = query_result(fk).map { |row| row[fk.column.primary_key] }
27
33
  end
28
34
  end
29
35
 
30
36
  # rubocop:disable Metrics/AbcSize
31
- def query_result(column)
37
+ def query_result(foreign_key)
32
38
  return [] unless directive.selectable?
33
39
 
34
40
  TableSaw::Connection.exec(
35
- format(
36
- 'select distinct %{column} from %{table_name} where %{clause} and %{column} is not null',
37
- primary_key: directive.primary_key, column: column, table_name: directive.table_name,
38
- clause: TableSaw::Queries::SerializeSqlInClause.new(directive.table_name,
39
- directive.primary_key,
40
- directive.ids).call
41
- )
41
+ format(QUERY, column: foreign_key.column.primary_key, table_name: directive.table_name,
42
+ clause: TableSaw::Queries::SerializeSqlInClause.new(directive.table_name,
43
+ directive.primary_key,
44
+ directive.ids).call,
45
+ polymorphic: foreign_key.type_condition)
42
46
  )
43
47
  end
44
48
  # rubocop:enable Metrics/AbcSize
@@ -31,7 +31,7 @@ module TableSaw
31
31
  private
32
32
 
33
33
  def fetch_belongs_to(directive)
34
- TableSaw::DependencyGraph::BelongsToDirectives.new(directive).call
34
+ TableSaw::DependencyGraph::BelongsToDirectives.new(manifest, directive).call
35
35
  end
36
36
 
37
37
  def fetch_has_many(directive)
@@ -3,6 +3,10 @@
3
3
  module TableSaw
4
4
  module DependencyGraph
5
5
  class HasManyDirectives
6
+ QUERY = <<~SQL
7
+ select %{primary_key} from %{table} where %{clause} and %{polymorphic}
8
+ SQL
9
+
6
10
  attr_reader :manifest, :directive
7
11
 
8
12
  def initialize(manifest, directive)
@@ -11,10 +15,10 @@ module TableSaw
11
15
  end
12
16
 
13
17
  def call
14
- valid_associations.map do |table, column|
18
+ valid_associations.map do |fk|
15
19
  TableSaw::DependencyGraph::AddDirective.new(
16
- table,
17
- ids: query_result(table, column).map { |r| r[TableSaw.schema_cache.primary_keys(table)] },
20
+ fk.from_table,
21
+ ids: query_result(fk).map { |r| r[TableSaw.schema_cache.primary_keys(fk.from_table)] },
18
22
  partial: directive.partial?
19
23
  )
20
24
  end
@@ -23,31 +27,32 @@ module TableSaw
23
27
  private
24
28
 
25
29
  def associations
26
- TableSaw.information_schema.has_many.fetch(directive.table_name, [])
30
+ manifest.associations.has_many.fetch(directive.table_name, Set.new)
27
31
  end
28
32
 
29
33
  # rubocop:disable Metrics/AbcSize
30
34
  def valid_associations
31
- associations.select do |table, _column|
32
- next false if directive.partial? && TableSaw.schema_cache.primary_keys(table).nil?
33
- next true if directive.has_many.include?(table)
35
+ associations.select do |fk|
36
+ next false if directive.partial? && TableSaw.schema_cache.primary_keys(fk.from_table).nil?
37
+ next true if directive.has_many.include?(fk.from_table)
34
38
 
35
- manifest.has_many.fetch(directive.table_name, []).include?(table)
39
+ manifest.has_many.fetch(directive.table_name, []).include?(fk.from_table)
36
40
  end
37
41
  end
38
- # rubocop:enable Metrics/AbcSize
39
42
 
40
- def query_result(table, column)
43
+ def query_result(foreign_key)
41
44
  return [] unless directive.selectable?
42
45
 
43
46
  TableSaw::Connection.exec(
44
- format(
45
- 'select %{primary_key} from %{table} where %{clause}',
46
- primary_key: TableSaw.schema_cache.primary_keys(table), table: table,
47
- clause: TableSaw::Queries::SerializeSqlInClause.new(table, column, directive.ids).call
48
- )
47
+ format(QUERY, primary_key: TableSaw.schema_cache.primary_keys(foreign_key.from_table),
48
+ table: foreign_key.from_table,
49
+ clause: TableSaw::Queries::SerializeSqlInClause.new(foreign_key.from_table,
50
+ foreign_key.column.primary_key,
51
+ directive.ids).call,
52
+ polymorphic: foreign_key.type_condition)
49
53
  )
50
54
  end
55
+ # rubocop:enable Metrics/AbcSize
51
56
  end
52
57
  end
53
58
  end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TableSaw
4
+ class ForeignKey
5
+ class Column
6
+ REGEX = /(\w+)(?::(\w+)\((\w+)\))?/.freeze
7
+
8
+ attr_reader :value
9
+
10
+ def initialize(value)
11
+ @value = value
12
+ end
13
+
14
+ def primary_key
15
+ value[REGEX, 1]
16
+ end
17
+
18
+ def type_condition
19
+ polymorphic? ? "#{type_column} = '#{type_value}'" : '1 = 1'
20
+ end
21
+
22
+ private
23
+
24
+ def type_column
25
+ value[REGEX, 2]
26
+ end
27
+
28
+ def type_value
29
+ value[REGEX, 3]
30
+ end
31
+
32
+ def polymorphic?
33
+ !(type_column.nil? || type_value.nil?)
34
+ end
35
+ end
36
+
37
+ attr_reader :name, :from_table, :from_column, :to_table, :to_column
38
+
39
+ def initialize(name: nil, from_table:, from_column:, to_table:, to_column:)
40
+ @name = name
41
+ @from_table = from_table
42
+ @from_column = from_column
43
+ @to_table = to_table
44
+ @to_column = to_column
45
+ end
46
+
47
+ def type_condition
48
+ @type_condition ||= column.type_condition
49
+ end
50
+
51
+ def column
52
+ @column ||= Column.new(from_column)
53
+ end
54
+
55
+ def eql?(other)
56
+ hash == other.hash
57
+ end
58
+
59
+ def hash
60
+ [from_table, from_column, to_table, to_column].hash
61
+ end
62
+ end
63
+ end
@@ -2,14 +2,10 @@
2
2
 
3
3
  module TableSaw
4
4
  class InformationSchema
5
- %i(belongs_to constraint_names has_many).each do |method_name|
6
- define_method method_name do
7
- foreign_key_relationships.public_send method_name
8
- end
5
+ def constraint_names
6
+ foreign_key_relationships.constraint_names
9
7
  end
10
8
 
11
- private
12
-
13
9
  def foreign_key_relationships
14
10
  @foreign_key_relationships ||= TableSaw::Queries::ForeignKeyRelationships.new
15
11
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'yaml'
4
+ require 'table_saw/associations'
4
5
 
5
6
  module TableSaw
6
7
  class Manifest
@@ -58,5 +59,13 @@ module TableSaw
58
59
  def has_many
59
60
  @has_many ||= config.fetch('has_many', {})
60
61
  end
62
+
63
+ def foreign_keys
64
+ @foreign_keys ||= config.fetch('foreign_keys', [])
65
+ end
66
+
67
+ def associations
68
+ @associations ||= TableSaw::Associations.new(self)
69
+ end
61
70
  end
62
71
  end
@@ -18,16 +18,17 @@ module TableSaw
18
18
 
19
19
  def values
20
20
  TableSaw.schema_cache.columns(statement.table_name).zip(row)
21
- .map { |column, value| connection.quote(connection.type_cast_from_column(column, value)) }
21
+ .map { |column, value| quote_value(column, value) }
22
22
  .join(', ')
23
23
  end
24
24
 
25
- def schema_cache
26
- TableSaw.schema_cache
25
+ def connection
26
+ TableSaw.schema_cache.connection
27
27
  end
28
28
 
29
- def connection
30
- schema_cache.connection
29
+ def quote_value(column, value)
30
+ type = connection.lookup_cast_type_from_column(column)
31
+ connection.quote(type.serialize(type.deserialize(value)))
31
32
  end
32
33
  end
33
34
  end
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'table_saw/foreign_key'
4
+ require 'set'
5
+
3
6
  module TableSaw
4
7
  module Queries
5
8
  class ForeignKeyRelationships
@@ -16,24 +19,20 @@ module TableSaw
16
19
  where tc.constraint_type = 'FOREIGN KEY'
17
20
  SQL
18
21
 
19
- def belongs_to
20
- @belongs_to ||= result.each_with_object(Hash.new { |h, k| h[k] = {} }) do |row, memo|
21
- memo[row['from_table']][row['from_column']] = row['to_table']
22
- end
23
- end
24
-
25
- def has_many
26
- @has_many ||= result.each_with_object(Hash.new { |h, k| h[k] = [] }) do |row, memo|
27
- memo[row['to_table']].push([row['from_table'], row['from_column']])
28
- end
29
- end
30
-
31
22
  def constraint_names
32
23
  @constraint_names ||= result.each_with_object(Hash.new { |h, k| h[k] = [] }) do |row, memo|
33
24
  memo[row['from_table']].push(row['constraint_name'])
34
25
  end
35
26
  end
36
27
 
28
+ def foreign_keys
29
+ @foreign_keys ||= result.map do |row|
30
+ TableSaw::ForeignKey.new(name: row['constraint_name'],
31
+ from_table: row['from_table'], from_column: row['from_column'],
32
+ to_table: row['to_table'], to_column: row['to_column'])
33
+ end
34
+ end
35
+
37
36
  private
38
37
 
39
38
  def result
@@ -31,7 +31,9 @@ module TableSaw
31
31
  end
32
32
 
33
33
  def column_names
34
- TableSaw.schema_cache.columns(table_name).map(&:name).join(', ')
34
+ TableSaw.schema_cache.columns(table_name)
35
+ .map { |column| TableSaw.schema_cache.connection.quote_column_name(column.name) }
36
+ .join(', ')
35
37
  end
36
38
 
37
39
  def values_clause
@@ -23,7 +23,7 @@ module TableSaw
23
23
 
24
24
  def serialized_values
25
25
  values.map do |value|
26
- connection.quote(connection.type_cast_from_column(db_column, value))
26
+ connection.quote_default_expression(value, db_column)
27
27
  end
28
28
  end
29
29
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TableSaw
4
- VERSION = '2.4.3'
4
+ VERSION = '2.8.1'
5
5
  end
@@ -28,10 +28,10 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency 'thor'
29
29
 
30
30
  spec.add_development_dependency 'bundler', '~> 2.0'
31
- spec.add_development_dependency 'combustion', '~> 1.1'
31
+ spec.add_development_dependency 'combustion', '~> 1.3'
32
32
  spec.add_development_dependency 'database_cleaner', '~> 1.7'
33
33
  spec.add_development_dependency 'pry'
34
- spec.add_development_dependency 'rake', '~> 10.0'
34
+ spec.add_development_dependency 'rake', '~> 13.0'
35
35
  spec.add_development_dependency 'rspec', '~> 3.0'
36
36
  spec.add_development_dependency 'rubocop-rspec', '~> 1.33'
37
37
  spec.add_development_dependency 'scenic', '~> 1.5'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: table_saw
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.3
4
+ version: 2.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hamed Asghari
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-25 00:00:00.000000000 Z
11
+ date: 2020-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.1'
75
+ version: '1.3'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.1'
82
+ version: '1.3'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: database_cleaner
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '10.0'
117
+ version: '13.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '10.0'
124
+ version: '13.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rspec
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -178,7 +178,7 @@ dependencies:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0.16'
181
- description:
181
+ description:
182
182
  email:
183
183
  - hasghari@gmail.com
184
184
  executables:
@@ -186,12 +186,14 @@ executables:
186
186
  extensions: []
187
187
  extra_rdoc_files: []
188
188
  files:
189
+ - ".github/workflows/ruby.yml"
189
190
  - ".gitignore"
190
191
  - ".rspec"
191
192
  - ".rubocop.yml"
192
193
  - ".ruby-gemset"
193
194
  - ".ruby-version"
194
- - ".travis.yml"
195
+ - ".tool-versions"
196
+ - Appraisals
195
197
  - CODE_OF_CONDUCT.md
196
198
  - Gemfile
197
199
  - Gemfile.lock
@@ -201,7 +203,13 @@ files:
201
203
  - bin/console
202
204
  - bin/setup
203
205
  - exe/table-saw
206
+ - gemfiles/.bundle/config
207
+ - gemfiles/activerecord_6.0.0.gemfile
208
+ - gemfiles/activerecord_6.0.0.gemfile.lock
209
+ - gemfiles/activerecord_6.1.0.gemfile
210
+ - gemfiles/activerecord_6.1.0.gemfile.lock
204
211
  - lib/table_saw.rb
212
+ - lib/table_saw/associations.rb
205
213
  - lib/table_saw/configuration.rb
206
214
  - lib/table_saw/connection.rb
207
215
  - lib/table_saw/create_dump_file.rb
@@ -211,6 +219,7 @@ files:
211
219
  - lib/table_saw/dependency_graph/build.rb
212
220
  - lib/table_saw/dependency_graph/dump_table.rb
213
221
  - lib/table_saw/dependency_graph/has_many_directives.rb
222
+ - lib/table_saw/foreign_key.rb
214
223
  - lib/table_saw/formats.rb
215
224
  - lib/table_saw/formats/base.rb
216
225
  - lib/table_saw/formats/copy.rb
@@ -230,7 +239,7 @@ homepage: https://github.com/hasghari/table_saw
230
239
  licenses:
231
240
  - MIT
232
241
  metadata: {}
233
- post_install_message:
242
+ post_install_message:
234
243
  rdoc_options: []
235
244
  require_paths:
236
245
  - lib
@@ -245,8 +254,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
254
  - !ruby/object:Gem::Version
246
255
  version: '0'
247
256
  requirements: []
248
- rubygems_version: 3.0.6
249
- signing_key:
257
+ rubygems_version: 3.1.4
258
+ signing_key:
250
259
  specification_version: 4
251
260
  summary: Create a postgres dump file from a subset of tables
252
261
  test_files: []
@@ -1,24 +0,0 @@
1
- ---
2
- sudo: false
3
- env:
4
- global:
5
- - CC_TEST_REPORTER_ID=5432d4e95a7749f237cf9e659c44ba28c5c91fa65436b15c5bc849d6d9ebc049
6
- language: ruby
7
- cache: bundler
8
- rvm:
9
- - 2.5.5
10
- - 2.6.5
11
- - 2.7.0
12
- before_install: gem install bundler -v 2.0.1
13
- before_script:
14
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
15
- - chmod +x ./cc-test-reporter
16
- - ./cc-test-reporter before-build
17
- script:
18
- - bundle exec rspec
19
- after_script:
20
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
21
- addons:
22
- postgresql: "9.6"
23
- services:
24
- - postgresql