miau 1.0.0 → 1.0.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: 9f13c1ca4815ddfd75626afa968a0a5544facd84bd57e1d2f12c7c537fc5a1c2
4
- data.tar.gz: 424d58b4351a0f6c6c84e3e16940ca7bc38f175af133bfb7f49550b3fb5a2645
3
+ metadata.gz: d8a96cf2921c9a1b4e82104205f3a8f583d28fb27424aabc6a689c67f1cf5456
4
+ data.tar.gz: 0a176ee2311f8a8ebc13279e9ccb31209a3c0fce62e5db9e5a64a2305afad199
5
5
  SHA512:
6
- metadata.gz: de5c532eda2225455344017188f2e298bd57b4d8039a36a5e07234e04f44f9be485f1f33f7106c99df4e62340e7c102d8431d9585c25680e50c8b7c44413c333
7
- data.tar.gz: 68f1825816a29c44ebb6c6597d8c9d93c2f7b751bb284a73b8e60f859060ea93d66d48881073ed42c804b6484145e296b1e1ef1010c3ba898d67e7a3f505c661
6
+ metadata.gz: f23488dbe4e46ffe75d4626dcf9d36d6d89f5b29218ed95e75aab005b7c9441764a303643c4a88da70ea5a3cbfd2206bcf53fadedca68676f4315716c788a6a8
7
+ data.tar.gz: 9d40fd3e56874a5419f757f7f6cda20d4c3f5785c6b87318b5dec8482430faaa80f67dcb900234418cf9a7691e999a79a37ba368f522fdc6c90a7a749590deea
@@ -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,72 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- miau (1.0.0)
4
+ miau (1.0.1)
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.0.4.3)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (>= 1.6, < 2)
13
13
  minitest (>= 5.1)
14
14
  tzinfo (~> 2.0)
15
15
  ast (2.4.2)
16
- benchmark-ips (2.9.2)
17
- concurrent-ruby (1.1.9)
16
+ benchmark-ips (2.12.0)
17
+ concurrent-ruby (1.2.2)
18
18
  docile (1.4.0)
19
- i18n (1.8.11)
19
+ i18n (1.12.0)
20
20
  concurrent-ruby (~> 1.0)
21
- minitest (5.15.0)
21
+ json (2.6.3)
22
+ language_server-protocol (3.17.0.3)
23
+ lint_roller (1.0.0)
24
+ minitest (5.18.0)
22
25
  observr (1.0.5)
23
- parallel (1.21.0)
24
- parser (3.1.0.0)
26
+ parallel (1.23.0)
27
+ parser (3.2.2.0)
25
28
  ast (~> 2.4.1)
26
29
  rainbow (3.1.1)
27
30
  rake (13.0.6)
28
- regexp_parser (2.2.0)
31
+ regexp_parser (2.8.0)
29
32
  rexml (3.2.5)
30
33
  ricecream (0.2.1)
31
- rubocop (1.25.0)
34
+ rubocop (1.50.2)
35
+ json (~> 2.3)
32
36
  parallel (~> 1.10)
33
- parser (>= 3.1.0.0)
37
+ parser (>= 3.2.0.0)
34
38
  rainbow (>= 2.2.2, < 4.0)
35
39
  regexp_parser (>= 1.8, < 3.0)
36
- rexml
37
- rubocop-ast (>= 1.15.1, < 2.0)
40
+ rexml (>= 3.2.5, < 4.0)
41
+ rubocop-ast (>= 1.28.0, < 2.0)
38
42
  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)
43
+ unicode-display_width (>= 2.4.0, < 3.0)
44
+ rubocop-ast (1.28.0)
45
+ parser (>= 3.2.1.0)
46
+ rubocop-performance (1.16.0)
43
47
  rubocop (>= 1.7.0, < 2.0)
44
48
  rubocop-ast (>= 0.4.0)
45
- ruby-progressbar (1.11.0)
46
- simplecov (0.21.2)
49
+ ruby-progressbar (1.13.0)
50
+ simplecov (0.22.0)
47
51
  docile (~> 1.1)
48
52
  simplecov-html (~> 0.11)
49
53
  simplecov_json_formatter (~> 0.1)
50
54
  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)
55
+ simplecov_json_formatter (0.1.4)
56
+ standard (1.28.0)
57
+ language_server-protocol (~> 3.17.0.2)
58
+ lint_roller (~> 1.0)
59
+ rubocop (~> 1.50.2)
60
+ standard-custom (~> 1.0.0)
61
+ standard-performance (~> 1.0.1)
62
+ standard-custom (1.0.0)
63
+ lint_roller (~> 1.0)
64
+ standard-performance (1.0.1)
65
+ lint_roller (~> 1.0)
66
+ rubocop-performance (~> 1.16.0)
67
+ tzinfo (2.0.6)
56
68
  concurrent-ruby (~> 1.0)
57
- unicode-display_width (2.1.0)
69
+ unicode-display_width (2.4.2)
58
70
 
59
71
  PLATFORMS
60
72
  x86_64-linux
@@ -69,4 +81,4 @@ DEPENDENCIES
69
81
  standard
70
82
 
71
83
  BUNDLED WITH
72
- 2.3.3
84
+ 2.4.10
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,28 +7,27 @@ 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
30
+ ```ruby
32
31
  # app/controllers/posts_controller.rb # app/views/posts/update.rb
33
32
  class PostsController < ApplicationController <% if authorized? %>
34
33
  ... ...
@@ -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,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Miau
4
- VERSION = "1.0.0" # 2022-01-23
4
+ VERSION = "1.0.1" # 2023-04-24
5
+ # VERSION = "1.0.0" # 2022-01-23
5
6
  # VERSION = "0.1.2" # 2021-12-10
6
7
  # VERSION = "0.1.1" # 2021-11-06
7
8
  # VERSION = "0.1.0" # 2021-09-13
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://matiq.com"
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.1
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-04-24 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://matiq.com
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.10
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