access_forge-permissions 0.1.1 → 0.1.2

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
2
  SHA256:
3
- metadata.gz: 8329e8029066639008602ab2734da60ffa605467afca60396c56ca1e809d54a7
4
- data.tar.gz: efafbc53c7ca00f367cd4161be316c2f234d89e8f69282edd7bbc4cb1e2baae3
3
+ metadata.gz: fa5e73556453d6a607b119e7940db5ead024c7c413b4d63e37826f9b0f055656
4
+ data.tar.gz: cdc6ee945f57ebbe35e285e484291b9a5ab2ffb4608275f3ebecc6c18f4ba671
5
5
  SHA512:
6
- metadata.gz: cfebb52125ab97bfe09dc22851a12794bbdd6911a12bcbe19407ad35e364c0313ed76cb983b49999d2d83fb42983748d9314261786c25a51407922809ccd4760
7
- data.tar.gz: fcfe4cbf03a18d6fb2936ebc74975e98daf170bcfe97b3533af664b2b13f6f2d50b5cb0827f921e672cc89db53735812ccb18198aea778ce735b05a8b7931fa5
6
+ metadata.gz: dedbf211e66502050166bcfb00a881b92ef68371d149b16cc1c9484c7597a684a69b4ffe3f87dc575db1338eba805e4a7c09f55fe525a5126afdcb8835141f26
7
+ data.tar.gz: 32bae7dad9bf20c24b73875d427344c30c414d2d1fee5456ca689c497a67efbb5176b750e12b1e04832ae4e1e14969f94d6bc82894d4ce22041d81047d8b678f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- access_forge-permissions (0.1.0)
4
+ access_forge-permissions (0.1.2)
5
5
  rails (>= 6.1)
6
6
 
7
7
  GEM
@@ -1,5 +1,5 @@
1
1
  module AccessForge
2
2
  module Permissions
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -0,0 +1,46 @@
1
+ require "rails/generators"
2
+ require "rails/generators/named_base"
3
+ require "rails/generators/migration"
4
+
5
+ module AccessForge
6
+ module Generators
7
+ class AccessGroupsGenerator < Rails::Generators::Base
8
+ include Rails::Generators::Migration
9
+
10
+ source_root File.expand_path("templates", __dir__)
11
+
12
+ desc "Creates the necessary models and mirations for access-group authorisation."
13
+
14
+ def create_models
15
+ template "access_group.rb", "app/models/access_group.rb"
16
+ template "permission.rb", "app/models/permission.rb"
17
+ template "access_group_permission.rb", "app/models/access_group_permission.rb"
18
+ template "access_group_user.rb", "app/models/access_group_user.rb"
19
+ end
20
+
21
+ def create_migrations
22
+ migration_template "migrations/create_access_groups.rb",
23
+ "db/migrate/create_access_groups.rb"
24
+
25
+ migration_template "migrations/create_permissions.rb",
26
+ "db/migrate/create_permissions.rb"
27
+
28
+ migration_template "migrations/create_access_group_permissions.rb",
29
+ "db/migrate/create_access_group_permissions.rb"
30
+
31
+ migration_template "migrations/create_access_group_users.rb",
32
+ "db/migrate/create_access_group_users.rb"
33
+ end
34
+
35
+ def self.next_migration_number(dirname)
36
+ if ActiveRecord::Base.timestamped_migrations
37
+ @@migration_number ||= Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
38
+ @@migration_number += 1
39
+ @@migration_number.to_s
40
+ else
41
+ format("%03d", current_migration_number(dirname) + 1)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,8 @@
1
+ class AccessGroup < ApplicationRecord
2
+ has_many :access_group_permissions, inverse_of: :access_group, dependent: :destroy
3
+ has_many :permissions, through: :access_group_permissions
4
+ has_many :access_group_users, inverse_of: :access_group, dependent: :destroy
5
+ has_many :users, through: :access_group_users
6
+
7
+ validates :name, presence: true, uniqueness: true
8
+ end
@@ -0,0 +1,4 @@
1
+ class AccessGroupPermission < ApplicationRecord
2
+ belongs_to :access_group
3
+ belongs_to :permission
4
+ end
@@ -0,0 +1,4 @@
1
+ class AccessGroupUser < ApplicationRecord
2
+ belongs_to :access_group
3
+ belongs_to :user
4
+ end
@@ -0,0 +1,11 @@
1
+ class CreateAccessGroupPermissions < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :access_group_permissions do |t|
4
+ t.references :access_group, foreign_key: true
5
+ t.references :permission, foreign_key: true
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
11
+
@@ -0,0 +1,11 @@
1
+ class CreateAccessGroupUsers < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :access_group_users do |t|
4
+ t.references :access_group, foreign_key: true
5
+ t.references :user, foreign_key: true
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
11
+
@@ -0,0 +1,11 @@
1
+ class CreateAccessGroups < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :access_groups do |t|
4
+ t.string :name, null: false
5
+ t.string :description
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
11
+
@@ -0,0 +1,10 @@
1
+ class CreatePermissions < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :permissions do |t|
4
+ t.string :name, null: false
5
+ t.string :description
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ class Permission < ApplicationRecord
2
+ has_many :access_group_permissions, dependent: :destroy
3
+ has_many :access_groups, through: :access_group_permissions
4
+ has_many :users, through: :access_groups
5
+
6
+ validates :name, presence: true, uniqueness: true
7
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: access_forge-permissions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Harbison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-02-15 00:00:00.000000000 Z
11
+ date: 2026-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -90,6 +90,15 @@ files:
90
90
  - lib/access_forge/permissions.rb
91
91
  - lib/access_forge/permissions/permission_policy_rule.rb
92
92
  - lib/access_forge/permissions/version.rb
93
+ - lib/generators/access_forge/access_groups/access_groups_generator.rb
94
+ - lib/generators/access_forge/access_groups/templates/access_group.rb
95
+ - lib/generators/access_forge/access_groups/templates/access_group_permission.rb
96
+ - lib/generators/access_forge/access_groups/templates/access_group_user.rb
97
+ - lib/generators/access_forge/access_groups/templates/migrations/create_access_group_permissions.rb
98
+ - lib/generators/access_forge/access_groups/templates/migrations/create_access_group_users.rb
99
+ - lib/generators/access_forge/access_groups/templates/migrations/create_access_groups.rb
100
+ - lib/generators/access_forge/access_groups/templates/migrations/create_permissions.rb
101
+ - lib/generators/access_forge/access_groups/templates/permission.rb
93
102
  - sig/access_forge-permissions.rbs
94
103
  - spec/access_forge/permissions_spec.rb
95
104
  - spec/spec_helper.rb