pg_rls 0.2.5 → 1.0.1
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 +4 -4
- data/.rubocop.yml +55 -17
- data/.ruby-version +1 -0
- data/CHANGELOG.md +19 -2
- data/CODE_OF_CONDUCT.md +77 -29
- data/Guardfile +44 -0
- data/README.md +247 -83
- data/Rakefile +5 -12
- data/Steepfile +29 -0
- data/UPGRADE.md +106 -0
- data/app/models/pg_rls/admin.rb +24 -0
- data/app/models/pg_rls/current.rb +48 -0
- data/app/models/pg_rls/record.rb +13 -0
- data/app/models/pg_rls/tenant/searchable.rb +60 -0
- data/app/models/pg_rls/tenant/securable.rb +67 -0
- data/app/models/pg_rls/tenant/switchable.rb +40 -0
- data/app/models/pg_rls/tenant.rb +9 -0
- data/assets/logo.svg +8 -0
- data/docker-compose.yml +14 -0
- data/lib/generators/pg_rls/active_record/active_record_generator.rb +62 -65
- data/lib/generators/pg_rls/install/install_generator.rb +38 -0
- data/lib/generators/pg_rls/pg_rls_generator.rb +2 -1
- data/lib/generators/pg_rls/templates/USAGE +28 -0
- data/lib/generators/pg_rls/{active_record/templates → templates/app/models}/abstract_base_class.rb.tt +1 -3
- data/lib/generators/pg_rls/{active_record/templates → templates/app/models}/model.rb.tt +0 -2
- data/lib/generators/pg_rls/templates/config/initializers/pg_rls.rb.tt +58 -0
- data/lib/generators/pg_rls/templates/db/migrate/backport_pg_rls_table.rb.tt +14 -0
- data/lib/generators/pg_rls/templates/db/migrate/convert_to_pg_rls_table.rb.tt +5 -0
- data/lib/generators/pg_rls/templates/db/migrate/convert_to_pg_rls_tenant_table.rb.tt +5 -0
- data/lib/generators/pg_rls/templates/db/migrate/create_pg_rls_table.rb.tt +29 -0
- data/lib/generators/pg_rls/templates/db/migrate/create_pg_rls_tenant_table.rb.tt +29 -0
- data/lib/pg_rls/active_record/connection_adapters/connection_pool.rb +31 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql/check_rls_user_privileges.rb +207 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql/errors.rb +17 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql/grant_rls_user_privileges.rb +167 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql/rls_functions.rb +91 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql/rls_policies.rb +56 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql/rls_triggers.rb +95 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql/rls_user_statements.rb +127 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql/schema_dumper.rb +71 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql/schema_statements.rb +120 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql/sql_helper_method.rb +30 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql.rb +36 -0
- data/lib/pg_rls/active_record/connection_adapters.rb +12 -0
- data/lib/pg_rls/active_record/database_shards.rb +74 -0
- data/lib/pg_rls/active_record/migration/command_recorder.rb +28 -0
- data/lib/pg_rls/active_record/migration.rb +11 -0
- data/lib/pg_rls/active_record/test_databases.rb +19 -0
- data/lib/pg_rls/active_record.rb +11 -0
- data/lib/pg_rls/active_support/string_ext.rb +17 -0
- data/lib/pg_rls/active_support.rb +9 -0
- data/lib/pg_rls/connection_config.rb +61 -0
- data/lib/pg_rls/deprecation.rb +14 -0
- data/lib/pg_rls/engine.rb +8 -0
- data/lib/pg_rls/error.rb +10 -0
- data/lib/pg_rls/generators/.keep +0 -0
- data/lib/pg_rls/railtie.rb +1 -11
- data/lib/pg_rls/tasks/.keep +0 -0
- data/lib/pg_rls/version.rb +3 -1
- data/lib/pg_rls.rb +67 -151
- data/rbs_collection.lock.yaml +132 -0
- data/rbs_collection.yaml +127 -0
- data/review_code.sh +33 -0
- data/sig/generators/pg_rls/active_record/active_record_generator.rbs +43 -0
- data/sig/generators/pg_rls/install/install_generator.rbs +20 -0
- data/sig/generators/pg_rls/pg_rls_generator.rbs +9 -0
- data/sig/pg_rls/active_record/connection_adapters/postgre_sql/check_rls_user_privileges.rbs +53 -0
- data/sig/pg_rls/active_record/connection_adapters/postgre_sql/errors.rbs +24 -0
- data/sig/pg_rls/active_record/connection_adapters/postgre_sql/grant_rls_user_privileges.rbs +55 -0
- data/sig/pg_rls/active_record/connection_adapters/postgre_sql/rls_functions.rbs +31 -0
- data/sig/pg_rls/active_record/connection_adapters/postgre_sql/rls_policies.rbs +28 -0
- data/sig/pg_rls/active_record/connection_adapters/postgre_sql/rls_triggers.rbs +35 -0
- data/sig/pg_rls/active_record/connection_adapters/postgre_sql/rls_user_statements.rbs +48 -0
- data/sig/pg_rls/active_record/connection_adapters/postgre_sql/schema_dumper.rbs +38 -0
- data/sig/pg_rls/active_record/connection_adapters/postgre_sql/schema_statements.rbs +67 -0
- data/sig/pg_rls/active_record/connection_adapters/postgre_sql/sql_helper_method.rbs +21 -0
- data/sig/pg_rls/active_record/connection_adapters/postgresql.rbs +10 -0
- data/sig/pg_rls/active_record/connection_adapters.rbs +50 -0
- data/sig/pg_rls/active_record/database_shards.rbs +34 -0
- data/sig/pg_rls/active_record/migration/command_recorder.rbs +14 -0
- data/sig/pg_rls/active_record/migration.rbs +8 -0
- data/sig/pg_rls/active_record.rbs +7 -0
- data/sig/pg_rls/active_support/hash_ext.rbs +11 -0
- data/sig/pg_rls/active_support/string_ext.rbs +27 -0
- data/sig/pg_rls/active_support.rbs +7 -0
- data/sig/pg_rls/app/models/pg_rls/record.rbs +4 -0
- data/sig/pg_rls/connection_config.rbs +16 -0
- data/sig/pg_rls/deprecation.rbs +9 -0
- data/sig/pg_rls/engine.rbs +7 -0
- data/sig/pg_rls/errors.rbs +14 -0
- data/sig/pg_rls/railtie.rbs +6 -0
- data/sig/pg_rls/tenant_test_helper.rbs +14 -0
- data/sig/pg_rls.rbs +60 -0
- data/sig/support/active_record.rbs +86 -0
- data/sig/support/active_support.rbs +7 -0
- data/sig/support/fowardable.rbs +2 -0
- data/sig/support/pg.rbs +12 -0
- data/sig/support/rails.rbs +38 -0
- data/start.sh +30 -0
- metadata +167 -48
- data/.rspec +0 -3
- data/Gemfile +0 -21
- data/Gemfile.lock +0 -300
- data/LICENSE.txt +0 -21
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/lib/generators/pg_rls/active_record/templates/convert_migration.rb.tt +0 -11
- data/lib/generators/pg_rls/active_record/templates/convert_migration_backport.rb.tt +0 -12
- data/lib/generators/pg_rls/active_record/templates/init_convert_migration.rb.tt +0 -11
- data/lib/generators/pg_rls/active_record/templates/init_migration.rb.tt +0 -25
- data/lib/generators/pg_rls/active_record/templates/init_model.rb.tt +0 -24
- data/lib/generators/pg_rls/active_record/templates/migration.rb.tt +0 -17
- data/lib/generators/pg_rls/base.rb +0 -36
- data/lib/generators/pg_rls/install_generator.rb +0 -90
- data/lib/generators/pg_rls.rb +0 -19
- data/lib/generators/templates/README +0 -22
- data/lib/generators/templates/pg_rls.rb.tt +0 -48
- data/lib/pg_rls/Rakefile +0 -7
- data/lib/pg_rls/current/context.rb +0 -10
- data/lib/pg_rls/database/admin_statements.rb +0 -28
- data/lib/pg_rls/database/configurations.rb +0 -46
- data/lib/pg_rls/database/prepared.rb +0 -40
- data/lib/pg_rls/database/tasks/admin_database.rake +0 -40
- data/lib/pg_rls/errors/index.rb +0 -4
- data/lib/pg_rls/errors/rake_only_error.rb +0 -12
- data/lib/pg_rls/errors/tenant_not_found.rb +0 -13
- data/lib/pg_rls/logger.rb +0 -31
- data/lib/pg_rls/middleware/set_reset_connection.rb +0 -93
- data/lib/pg_rls/middleware/sidekiq/client.rb +0 -22
- data/lib/pg_rls/middleware/sidekiq/server.rb +0 -19
- data/lib/pg_rls/middleware/sidekiq.rb +0 -11
- data/lib/pg_rls/middleware.rb +0 -8
- data/lib/pg_rls/multi_tenancy.rb +0 -32
- data/lib/pg_rls/schema/down_statements.rb +0 -54
- data/lib/pg_rls/schema/dumper.rb +0 -36
- data/lib/pg_rls/schema/statements.rb +0 -72
- data/lib/pg_rls/schema/up_statements.rb +0 -104
- data/lib/pg_rls/tenant.rb +0 -153
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 278c5a74c59b9b7b98709a4d36bd50d30facc864b140b231e5aa7d5a1bc26cfd
|
4
|
+
data.tar.gz: 30fab69ef11cf047c3c25213463160f66959c0d6f2da97a09e1bbfb6365247aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6df51d2edd3e608a4a9a0bdfd5c42c21cf9462b85e6a3b572f151991990d292b6e6fd625578254923145b836ea4129aacffcc08aeca0ca03eda9537be4dc8caa
|
7
|
+
data.tar.gz: 6f409cafedc4a4208e110cca2c8e13d76175272e4c4d022b1e87d3c1b3991e2dfe875f1fa80b6a1141654afa8fe31cbe6dd3c99faf29b5eccb50970e81207e76
|
data/.rubocop.yml
CHANGED
@@ -1,29 +1,67 @@
|
|
1
1
|
require:
|
2
|
-
- rubocop-
|
3
|
-
- rubocop-
|
4
|
-
- rubocop-rspec
|
5
|
-
- rubocop-rake
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-rake
|
6
4
|
|
7
5
|
AllCops:
|
6
|
+
SuggestExtensions: false
|
7
|
+
TargetRubyVersion: 3.0
|
8
8
|
NewCops: enable
|
9
|
-
Style/Documentation:
|
10
|
-
Enabled: false
|
11
|
-
Style/ClassVars:
|
12
9
|
Exclude:
|
13
|
-
|
14
|
-
|
10
|
+
- vendor/**/*
|
11
|
+
- bin/**/*
|
12
|
+
- db/**/*
|
13
|
+
- test/dummy/**/*
|
14
|
+
- test/dummy/db/schema.rb
|
15
|
+
- test/lib/generators/pg_rls/tmp/**/*
|
16
|
+
- test/lib/generators/tmp/**/*
|
17
|
+
- lib/pg_rls/active_record/test_databases.rb
|
18
|
+
|
19
|
+
Style/StringLiterals:
|
20
|
+
EnforcedStyle: double_quotes
|
21
|
+
|
22
|
+
Style/StringLiteralsInInterpolation:
|
23
|
+
EnforcedStyle: double_quotes
|
24
|
+
|
25
|
+
Style/ClassVars:
|
26
|
+
Enabled: true
|
15
27
|
Exclude:
|
16
|
-
|
17
|
-
|
28
|
+
- lib/pg_rls.rb
|
29
|
+
|
18
30
|
Metrics/BlockLength:
|
31
|
+
Enabled: true
|
19
32
|
Exclude:
|
20
|
-
|
21
|
-
|
33
|
+
- test/**/*
|
34
|
+
- pg_rls.gemspec
|
35
|
+
|
36
|
+
Style/Documentation:
|
37
|
+
Enabled: true
|
22
38
|
Exclude:
|
23
|
-
|
39
|
+
- test/**/*
|
40
|
+
|
24
41
|
Metrics/ModuleLength:
|
42
|
+
Enabled: true
|
25
43
|
Exclude:
|
26
|
-
|
27
|
-
|
44
|
+
- lib/pg_rls/active_record/connection_adapters/postgre_sql/check_rls_user_privileges.rb
|
45
|
+
- lib/pg_rls/active_record/connection_adapters/postgre_sql/grant_rls_user_privileges.rb
|
46
|
+
- test/**/*
|
47
|
+
Metrics/MethodLength:
|
48
|
+
Enabled: true
|
49
|
+
Exclude:
|
50
|
+
- test/pg_rls/active_record/connection_adapters/postgre_sql/shared_example/rls_table_behavior.rb
|
51
|
+
- test/pg_rls/active_record/connection_adapters/postgre_sql/shared_example/rls_tenant_table_behavior.rb
|
52
|
+
|
53
|
+
Metrics/AbcSize:
|
54
|
+
Enabled: true
|
55
|
+
Exclude:
|
56
|
+
- test/pg_rls/active_record/connection_adapters/postgre_sql/shared_example/rls_table_behavior.rb
|
57
|
+
- test/pg_rls/active_record/connection_adapters/postgre_sql/shared_example/rls_tenant_table_behavior.rb
|
58
|
+
|
59
|
+
Metrics/CyclomaticComplexity:
|
60
|
+
Enabled: true
|
61
|
+
Exclude:
|
62
|
+
- test/pg_rls/active_record/connection_adapters/postgre_sql/shared_example/rls_table_behavior.rb
|
63
|
+
|
64
|
+
Metrics/PerceivedComplexity:
|
65
|
+
Enabled: true
|
28
66
|
Exclude:
|
29
|
-
|
67
|
+
- test/pg_rls/active_record/connection_adapters/postgre_sql/shared_example/rls_table_behavior.rb
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.3.5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
|
-
## [Unreleased]
|
2
1
|
|
3
|
-
|
2
|
+
# [Released]
|
3
|
+
|
4
|
+
## [1.0.1] - 2024-10-10
|
5
|
+
|
6
|
+
### Major Changes
|
7
|
+
|
8
|
+
- **Switched to Rails native sharding**: We no longer use the `admin_execute` methods for handling admin connections. The database connections are now managed through the Rails native sharding system.
|
9
|
+
- **New user group `pg_rls`**: All users **must** be assigned to the `pg_rls` group for security and access control purposes. The server will not boot if this is not configured properly.
|
10
|
+
- **Database configuration changes**: The `database.yml` must be updated to support Rails sharding.
|
11
|
+
- **Server boot pre-checks**: The server will not boot unless the proper configuration is in place, including shard setup and user group assignment.
|
12
|
+
- **Performance recommendations**: In production, it is recommended to configure only one user per server, and consider using separate machines for resource-intensive processes.
|
13
|
+
|
14
|
+
### Breaking Changes
|
15
|
+
|
16
|
+
- `admin_execute` methods have been removed.
|
17
|
+
- You **must** assign users to the `pg_rls` group.
|
18
|
+
- `database.yml` requires modification for both development and production environments.
|
19
|
+
|
20
|
+
### [0.2.1] - 2024-09-29
|
4
21
|
|
5
22
|
- Initial release
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -2,83 +2,131 @@
|
|
2
2
|
|
3
3
|
## Our Pledge
|
4
4
|
|
5
|
-
We as members, contributors, and leaders pledge to make participation in our
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
10
|
+
identity and orientation.
|
6
11
|
|
7
|
-
We pledge to act and interact in ways that contribute to an open, welcoming,
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
13
|
+
diverse, inclusive, and healthy community.
|
8
14
|
|
9
15
|
## Our Standards
|
10
16
|
|
11
|
-
Examples of behavior that contributes to a positive environment for our
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
18
|
+
community include:
|
12
19
|
|
13
20
|
* Demonstrating empathy and kindness toward other people
|
14
21
|
* Being respectful of differing opinions, viewpoints, and experiences
|
15
22
|
* Giving and gracefully accepting constructive feedback
|
16
|
-
* Accepting responsibility and apologizing to those affected by our mistakes,
|
17
|
-
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
24
|
+
and learning from the experience
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the overall
|
26
|
+
community
|
18
27
|
|
19
28
|
Examples of unacceptable behavior include:
|
20
29
|
|
21
|
-
* The use of sexualized language or imagery, and sexual attention or
|
22
|
-
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
31
|
+
any kind
|
23
32
|
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
33
|
* Public or private harassment
|
25
|
-
* Publishing others' private information, such as a physical or email
|
26
|
-
|
34
|
+
* Publishing others' private information, such as a physical or email address,
|
35
|
+
without their explicit permission
|
27
36
|
* Other conduct which could reasonably be considered inappropriate in a
|
28
37
|
professional setting
|
29
38
|
|
30
39
|
## Enforcement Responsibilities
|
31
40
|
|
32
|
-
Community leaders are responsible for clarifying and enforcing our standards of
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
44
|
+
or harmful.
|
33
45
|
|
34
|
-
Community leaders have the right and responsibility to remove, edit, or reject
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
49
|
+
decisions when appropriate.
|
35
50
|
|
36
51
|
## Scope
|
37
52
|
|
38
|
-
This Code of Conduct applies within all community spaces, and also applies when
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
54
|
+
an individual is officially representing the community in public spaces.
|
55
|
+
Examples of representing our community include using an official email address,
|
56
|
+
posting via an official social media account, or acting as an appointed
|
57
|
+
representative at an online or offline event.
|
39
58
|
|
40
59
|
## Enforcement
|
41
60
|
|
42
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
62
|
+
reported to the community leaders responsible for enforcement at
|
63
|
+
[INSERT CONTACT METHOD].
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
43
65
|
|
44
|
-
All community leaders are obligated to respect the privacy and security of the
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
67
|
+
reporter of any incident.
|
45
68
|
|
46
69
|
## Enforcement Guidelines
|
47
70
|
|
48
|
-
Community leaders will follow these Community Impact Guidelines in determining
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
49
73
|
|
50
74
|
### 1. Correction
|
51
75
|
|
52
|
-
**Community Impact**: Use of inappropriate language or other behavior deemed
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
77
|
+
unprofessional or unwelcome in the community.
|
53
78
|
|
54
|
-
**Consequence**: A private, written warning from community leaders, providing
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
55
82
|
|
56
83
|
### 2. Warning
|
57
84
|
|
58
|
-
**Community Impact**: A violation through a single incident or series of
|
85
|
+
**Community Impact**: A violation through a single incident or series of
|
86
|
+
actions.
|
59
87
|
|
60
|
-
**Consequence**: A warning with consequences for continued behavior. No
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
92
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
93
|
+
ban.
|
61
94
|
|
62
95
|
### 3. Temporary Ban
|
63
96
|
|
64
|
-
**Community Impact**: A serious violation of community standards, including
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
98
|
+
sustained inappropriate behavior.
|
65
99
|
|
66
|
-
**Consequence**: A temporary ban from any sort of interaction or public
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
101
|
+
communication with the community for a specified period of time. No public or
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
104
|
+
Violating these terms may lead to a permanent ban.
|
67
105
|
|
68
106
|
### 4. Permanent Ban
|
69
107
|
|
70
|
-
**Community Impact**: Demonstrating a pattern of violation of community
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
71
111
|
|
72
|
-
**Consequence**: A permanent ban from any sort of public interaction within the
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
113
|
+
community.
|
73
114
|
|
74
115
|
## Attribution
|
75
116
|
|
76
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
77
|
-
available at
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
118
|
+
version 2.1, available at
|
119
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
78
120
|
|
79
|
-
Community Impact Guidelines were inspired by
|
80
|
-
|
81
|
-
[homepage]: https://www.contributor-covenant.org
|
121
|
+
Community Impact Guidelines were inspired by
|
122
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
82
123
|
|
83
124
|
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
-
https://www.contributor-covenant.org/faq. Translations are available at
|
125
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
126
|
+
[https://www.contributor-covenant.org/translations][translations].
|
127
|
+
|
128
|
+
[homepage]: https://www.contributor-covenant.org
|
129
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
130
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
131
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
132
|
+
[translations]: https://www.contributor-covenant.org/translations
|
data/Guardfile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# A sample Guardfile
|
4
|
+
# More info at https://github.com/guard/guard#readme
|
5
|
+
|
6
|
+
## Uncomment and set this to only include directories you want to watch
|
7
|
+
# directories %w(app lib config test spec features) \
|
8
|
+
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
9
|
+
|
10
|
+
## Note: if you are using the `directories` clause above and you are not
|
11
|
+
## watching the project directory ('.'), then you will want to move
|
12
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
13
|
+
#
|
14
|
+
# $ mkdir config
|
15
|
+
# $ mv Guardfile config/
|
16
|
+
# $ ln -s config/Guardfile .
|
17
|
+
#
|
18
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
19
|
+
|
20
|
+
guard :minitest, spring: "bin/test" do
|
21
|
+
# with Minitest::Unit
|
22
|
+
watch(%r{^test/(.*)/?([^/]+)_test\.rb$})
|
23
|
+
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
|
24
|
+
watch(%r{^test/test_helper\.rb$}) { "test" }
|
25
|
+
|
26
|
+
# with Minitest::Spec
|
27
|
+
# watch(%r{^spec/(.*)_spec\.rb$})
|
28
|
+
# watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
29
|
+
# watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
|
30
|
+
|
31
|
+
# Rails 4
|
32
|
+
# watch(%r{^app/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
|
33
|
+
# watch(%r{^app/controllers/application_controller\.rb$}) { 'test/controllers' }
|
34
|
+
# watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" }
|
35
|
+
# watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
|
36
|
+
# watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
|
37
|
+
# watch(%r{^test/.+_test\.rb$})
|
38
|
+
# watch(%r{^test/test_helper\.rb$}) { 'test' }
|
39
|
+
|
40
|
+
# Rails < 4
|
41
|
+
# watch(%r{^app/controllers/(.*)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
|
42
|
+
# watch(%r{^app/helpers/(.*)\.rb$}) { |m| "test/helpers/#{m[1]}_test.rb" }
|
43
|
+
# watch(%r{^app/models/(.*)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
|
44
|
+
end
|