miau 1.0.0 → 1.0.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: 9f13c1ca4815ddfd75626afa968a0a5544facd84bd57e1d2f12c7c537fc5a1c2
4
- data.tar.gz: 424d58b4351a0f6c6c84e3e16940ca7bc38f175af133bfb7f49550b3fb5a2645
3
+ metadata.gz: 51787808adea91ad47f3319fa6e213bf6a648a028b58b037510aa4aa4c61a1d9
4
+ data.tar.gz: abfba8aa4d1dd6525b6815cf3507f5d2ad6a2c1a100622c3ae9eff6f739e8c7f
5
5
  SHA512:
6
- metadata.gz: de5c532eda2225455344017188f2e298bd57b4d8039a36a5e07234e04f44f9be485f1f33f7106c99df4e62340e7c102d8431d9585c25680e50c8b7c44413c333
7
- data.tar.gz: 68f1825816a29c44ebb6c6597d8c9d93c2f7b751bb284a73b8e60f859060ea93d66d48881073ed42c804b6484145e296b1e1ef1010c3ba898d67e7a3f505c661
6
+ metadata.gz: 15281ba513735520710c4d29e8a6791ba429497a826cbb4c05e37e061335eea99ce88f27f53f468be4eb943357ec234e29317b6a889fd51357ed300ed8092641
7
+ data.tar.gz: 58fe526fe70fb79ad6c97d216855541b2caa4a5e66307853441bf5c27cd96389d64d5d7d48959926a7d46c72b0f4778884d0a0146939c19a781b1863c71a58b8
@@ -1,7 +1,6 @@
1
1
  # see also https://github.com/whitequark/parser/blob/master/.github/workflows/test.yml
2
2
  name: Rake
3
3
 
4
- #on: [push, pull_request]
5
4
  on: [push]
6
5
 
7
6
  jobs:
@@ -9,16 +8,13 @@ jobs:
9
8
  strategy:
10
9
  fail-fast: false
11
10
  matrix:
12
- # os: [ubuntu-latest, macos-latest]
13
11
  os: [ubuntu-latest]
14
- # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
15
- # ruby: [2.5, 2.6, 2.7, '3.0', head, jruby, jruby-head, truffleruby, truffleruby-head]
16
- ruby: ["2.7.2", "3.0.1", 3.1.0]
12
+ ruby: ["2.7", "3.0", "3.2", head]
17
13
  test_command: ["bundle exec rake test"]
18
14
  runs-on: ${{ matrix.os }}
19
15
 
20
16
  steps:
21
- - uses: actions/checkout@v2
17
+ - uses: actions/checkout@v3
22
18
  - uses: ruby/setup-ruby@v1
23
19
  with:
24
20
  ruby-version: ${{ matrix.ruby }}
data/.gitignore CHANGED
@@ -1,5 +1,7 @@
1
1
  /.bundle/
2
2
  /Gemfile.lock
3
3
  /coverage/
4
+ .watchr
5
+
4
6
  /doc/
5
7
  /tmp/
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-3.1.0
1
+ ruby-3.2.2
data/Gemfile.lock CHANGED
@@ -1,60 +1,89 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- miau (1.0.0)
4
+ miau (1.0.2)
5
5
  activesupport
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (7.0.1)
10
+ activesupport (7.1.1)
11
+ base64
12
+ bigdecimal
11
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ connection_pool (>= 2.2.5)
15
+ drb
12
16
  i18n (>= 1.6, < 2)
13
17
  minitest (>= 5.1)
18
+ mutex_m
14
19
  tzinfo (~> 2.0)
15
20
  ast (2.4.2)
16
- benchmark-ips (2.9.2)
17
- concurrent-ruby (1.1.9)
21
+ base64 (0.1.1)
22
+ benchmark-ips (2.12.0)
23
+ bigdecimal (3.1.4)
24
+ concurrent-ruby (1.2.2)
25
+ connection_pool (2.4.1)
18
26
  docile (1.4.0)
19
- i18n (1.8.11)
27
+ drb (2.1.1)
28
+ ruby2_keywords
29
+ i18n (1.14.1)
20
30
  concurrent-ruby (~> 1.0)
21
- minitest (5.15.0)
31
+ json (2.6.3)
32
+ language_server-protocol (3.17.0.3)
33
+ lint_roller (1.1.0)
34
+ minitest (5.20.0)
35
+ mutex_m (0.1.2)
22
36
  observr (1.0.5)
23
- parallel (1.21.0)
24
- parser (3.1.0.0)
37
+ parallel (1.23.0)
38
+ parser (3.2.2.4)
25
39
  ast (~> 2.4.1)
40
+ racc
41
+ racc (1.7.3)
26
42
  rainbow (3.1.1)
27
- rake (13.0.6)
28
- regexp_parser (2.2.0)
29
- rexml (3.2.5)
43
+ rake (13.1.0)
44
+ regexp_parser (2.8.2)
45
+ rexml (3.2.6)
30
46
  ricecream (0.2.1)
31
- rubocop (1.25.0)
47
+ rubocop (1.56.4)
48
+ base64 (~> 0.1.1)
49
+ json (~> 2.3)
50
+ language_server-protocol (>= 3.17.0)
32
51
  parallel (~> 1.10)
33
- parser (>= 3.1.0.0)
52
+ parser (>= 3.2.2.3)
34
53
  rainbow (>= 2.2.2, < 4.0)
35
54
  regexp_parser (>= 1.8, < 3.0)
36
- rexml
37
- rubocop-ast (>= 1.15.1, < 2.0)
55
+ rexml (>= 3.2.5, < 4.0)
56
+ rubocop-ast (>= 1.28.1, < 2.0)
38
57
  ruby-progressbar (~> 1.7)
39
- unicode-display_width (>= 1.4.0, < 3.0)
40
- rubocop-ast (1.15.1)
41
- parser (>= 3.0.1.1)
42
- rubocop-performance (1.13.2)
58
+ unicode-display_width (>= 2.4.0, < 3.0)
59
+ rubocop-ast (1.30.0)
60
+ parser (>= 3.2.1.0)
61
+ rubocop-performance (1.19.1)
43
62
  rubocop (>= 1.7.0, < 2.0)
44
63
  rubocop-ast (>= 0.4.0)
45
- ruby-progressbar (1.11.0)
46
- simplecov (0.21.2)
64
+ ruby-progressbar (1.13.0)
65
+ ruby2_keywords (0.0.5)
66
+ simplecov (0.22.0)
47
67
  docile (~> 1.1)
48
68
  simplecov-html (~> 0.11)
49
69
  simplecov_json_formatter (~> 0.1)
50
70
  simplecov-html (0.12.3)
51
- simplecov_json_formatter (0.1.3)
52
- standard (1.7.0)
53
- rubocop (= 1.25.0)
54
- rubocop-performance (= 1.13.2)
55
- tzinfo (2.0.4)
71
+ simplecov_json_formatter (0.1.4)
72
+ standard (1.31.2)
73
+ language_server-protocol (~> 3.17.0.2)
74
+ lint_roller (~> 1.0)
75
+ rubocop (~> 1.56.4)
76
+ standard-custom (~> 1.0.0)
77
+ standard-performance (~> 1.2)
78
+ standard-custom (1.0.2)
79
+ lint_roller (~> 1.0)
80
+ rubocop (~> 1.50)
81
+ standard-performance (1.2.1)
82
+ lint_roller (~> 1.1)
83
+ rubocop-performance (~> 1.19.1)
84
+ tzinfo (2.0.6)
56
85
  concurrent-ruby (~> 1.0)
57
- unicode-display_width (2.1.0)
86
+ unicode-display_width (2.5.0)
58
87
 
59
88
  PLATFORMS
60
89
  x86_64-linux
@@ -69,4 +98,4 @@ DEPENDENCIES
69
98
  standard
70
99
 
71
100
  BUNDLED WITH
72
- 2.3.3
101
+ 2.4.20
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- MIT License
1
+ The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021-2022 Dittmar Krall
3
+ Copyright (c) 2021-2023 Dittmar Krall (www.matiq.com)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -7,29 +7,28 @@ inspired by Pundit and Banken.
7
7
  Miau provides a set of helpers which restricts what resources
8
8
  a given user is allowed to access.
9
9
 
10
- Installation
11
- ------------
10
+ ## Installation
12
11
 
13
- ~~~ ruby
12
+ As usual:
13
+ ```ruby
14
14
  # Gemfile
15
15
  gem "miau"
16
- ~~~
16
+ ```
17
17
  and run "bundle install".
18
18
 
19
- Usage (as intended)
20
- -------------------
19
+ ## Usage (as intended)
21
20
 
22
- ~~~ ruby
21
+ ```ruby
23
22
  # app/models/application_controller.rb
24
23
  class ApplicationController < ActionController::Base
25
24
  ...
26
25
  include Miau
27
26
  ...
28
27
  end
29
- ~~~
28
+ ```
30
29
 
31
- ~~~ ruby
32
- # app/controllers/posts_controller.rb # app/views/posts/update.rb
30
+ ```ruby
31
+ # app/controllers/posts_controller.rb # app/views/posts/update.erb
33
32
  class PostsController < ApplicationController <% if authorized? %>
34
33
  ... ...
35
34
  def update <% else %>
@@ -39,9 +38,9 @@ end
39
38
  end
40
39
  ...
41
40
  end
42
- ~~~
41
+ ```
43
42
 
44
- ~~~ ruby
43
+ ```ruby
45
44
  # app/policies/application_policy.rb # app/policies/posts_policy.rb
46
45
  class ApplicationPolicy class PostsPolicy < ApplicationPolicy
47
46
  attr_reader :user, :resource ...
@@ -51,7 +50,7 @@ end
51
50
  @resource = resource ...
52
51
  end end
53
52
  end
54
- ~~~
53
+ ```
55
54
 
56
55
  "authorize!" will raise an exception (which can be handled by "rescue")
57
56
  in case a policy returns "false" or isn't available.
@@ -70,14 +69,14 @@ The policy method has access to the "user" and the "resource".
70
69
 
71
70
  "user" is set by the default method "miau_user" (can be overwritten) as:
72
71
 
73
- ~~~
72
+ ```ruby
74
73
  # app/models/application_controller.rb
75
74
  ...
76
75
  def miau_user
77
76
  current_user
78
77
  end
79
78
  ...
80
- ~~~
79
+ ```
81
80
 
82
81
  The default value for "policy" is inferred from "params[:controller]",
83
82
  i.e. "authorize!" called from "PostsController" will
@@ -89,14 +88,14 @@ The default value for "action" is set by "params[:action]".
89
88
 
90
89
  A full blown sample :
91
90
 
92
- ~~~
91
+ ```ruby
93
92
  authorize! article, policy: :posts, action: :show
94
- ~~~
93
+ ```
95
94
 
96
95
  Usage (more elaborated)
97
96
  -----------------------
98
97
 
99
- ~~~ ruby
98
+ ```ruby
100
99
  # app/models/application_controller.rb
101
100
  class ApplicationController
102
101
  ...
@@ -120,7 +119,7 @@ class ApplicationController
120
119
 
121
120
  ...
122
121
  end
123
- ~~~
122
+ ```
124
123
 
125
124
  Policies remain as before.
126
125
  Rescue's may be inserted previously in the exception chain.
@@ -130,7 +129,7 @@ Rescue's may be inserted previously in the exception chain.
130
129
  DRYing
131
130
  ------
132
131
 
133
- ~~~ ruby
132
+ ```ruby
134
133
  # app/policies/posts_policy.rb --> # app/policies/posts_policy.rb
135
134
  class PostsPolicy < ApplicationPolicy class PostsPolicy < ApplicationPolicy
136
135
  def new miau %i[create edit], :new
@@ -146,7 +145,7 @@ DRYing
146
145
  end
147
146
  ...
148
147
  end
149
- ~~~
148
+ ```
150
149
 
151
150
  PORO
152
151
  ----
@@ -156,3 +155,10 @@ allowing DRY, encapsulation, aliasing and inheritance.
156
155
 
157
156
  There is no magic behind the scenes.
158
157
  Just the embedding in Rails required some specific knowledge.
158
+
159
+ ## Miscellaneous
160
+
161
+ Copyright (c) 2021-2023 Dittmar Krall (www.matiq.com),
162
+ released under the MIT license:
163
+
164
+ * https://opensource.org/licenses/MIT
data/lib/miau/version.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Miau
4
- VERSION = "1.0.0" # 2022-01-23
4
+ VERSION = "1.0.2" # 2023-11-05
5
+ # VERSION = "1.0.1" # 2023-04-24
6
+ # VERSION = "1.0.0" # 2022-01-23
5
7
  # VERSION = "0.1.2" # 2021-12-10
6
8
  # VERSION = "0.1.1" # 2021-11-06
7
9
  # VERSION = "0.1.0" # 2021-09-13
data/lib/miau.rb CHANGED
@@ -53,6 +53,6 @@ module Miau
53
53
  klass ||= params[:controller]
54
54
  action = hsh[:action]
55
55
  action ||= params[:action]
56
- [klass, action]
56
+ [klass.to_sym, action.to_sym]
57
57
  end
58
58
  end
data/miau.gemspec CHANGED
@@ -17,8 +17,8 @@ Gem::Specification.new do |s|
17
17
  s.require_paths = ["lib"]
18
18
 
19
19
  s.authors = ["Dittmar Krall"]
20
- s.email = "dittmar.krall@matique.com"
21
- s.homepage = "https://matique.com"
20
+ s.email = "dittmar.krall@matiq.com"
21
+ s.homepage = "https://github.com/matique/miau"
22
22
 
23
23
  s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|features)/}) }
24
24
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miau
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dittmar Krall
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-23 00:00:00.000000000 Z
11
+ date: 2023-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -55,7 +55,7 @@ dependencies:
55
55
  description: |
56
56
  MIAU (MIcro AUthorization) provides a set of helpers which restricts what
57
57
  resources a given user is allowed to access.
58
- email: dittmar.krall@matique.com
58
+ email: dittmar.krall@matiq.com
59
59
  executables: []
60
60
  extensions: []
61
61
  extra_rdoc_files: []
@@ -64,7 +64,6 @@ files:
64
64
  - ".gitignore"
65
65
  - ".ruby-gemset"
66
66
  - ".ruby-version"
67
- - ".watchr"
68
67
  - Gemfile
69
68
  - Gemfile.lock
70
69
  - LICENSE
@@ -76,7 +75,7 @@ files:
76
75
  - lib/miau/storage.rb
77
76
  - lib/miau/version.rb
78
77
  - miau.gemspec
79
- homepage: https://matique.com
78
+ homepage: https://github.com/matique/miau
80
79
  licenses:
81
80
  - MIT
82
81
  metadata:
@@ -96,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
95
  - !ruby/object:Gem::Version
97
96
  version: '0'
98
97
  requirements: []
99
- rubygems_version: 3.3.3
98
+ rubygems_version: 3.4.20
100
99
  signing_key:
101
100
  specification_version: 4
102
101
  summary: Simple and lightweight authorization solution for Rails.
data/.watchr DELETED
@@ -1,59 +0,0 @@
1
- TESTING = %w[test]
2
- HH = "#" * 22 unless defined?(HH)
3
- H = "#" * 5 unless defined?(H)
4
-
5
- def usage
6
- puts <<-EOS
7
- Ctrl-\\ or ctrl-4 Running all tests
8
- Ctrl-C Exit
9
- EOS
10
- end
11
-
12
- def run(cmd)
13
- puts "#{HH} #{Time.now} #{HH}"
14
- puts "#{H} #{cmd}"
15
- system "/usr/bin/time --format '#{HH} Elapsed time %E' #{cmd}"
16
- end
17
-
18
- def run_it(type, file)
19
- case type
20
- when "test" then run %(bundle exec ruby -I test #{file})
21
- # when 'spec'; run %(rspec -X #{file})
22
- else; puts "#{H} unknown type: #{type}, file: #{file}"
23
- end
24
- end
25
-
26
- def run_all_tests
27
- puts "\n#{HH} Running all tests #{HH}\n"
28
- TESTING.each { |dir| run "bundle exec rake #{dir}" if File.exist?(dir) }
29
- end
30
-
31
- def run_matching_files(base)
32
- base = base.split("_").first
33
- TESTING.each { |type|
34
- files = Dir["#{type}/**/*.rb"].select { |file| file =~ /#{base}_.*\.rb/ }
35
- run_it type, files.join(" ") unless files.empty?
36
- }
37
- end
38
-
39
- TESTING.each { |type|
40
- watch("#{type}/#{type}_helper\.rb") { run_all_tests }
41
- watch("lib/.*\.rb") { run_all_tests }
42
- watch("#{type}/.*/*_#{type}\.rb") { |match| run_it type, match[0] }
43
- watch("#{type}/data/(.*)\.rb") { |match|
44
- m1 = match[1]
45
- run_matching_files("#{type}/#{m1}/#{m1}_#{type}.rb")
46
- }
47
- }
48
-
49
- %w[rb erb haml slim].each { |type|
50
- watch(".*/(.*)\.#{type}") { |match|
51
- run_matching_files(match[1])
52
- }
53
- }
54
-
55
- # Ctrl-\ or ctrl-4
56
- Signal.trap("QUIT") { run_all_tests }
57
- # Ctrl-C
58
- Signal.trap("INT") { abort("Interrupted\n") }
59
- usage