pragma-rails 2.1.1 → 2.2.0
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 +3 -4
- data/.travis.yml +3 -0
- data/CHANGELOG.md +12 -1
- data/Gemfile +4 -0
- data/README.md +3 -1
- data/Rakefile +5 -3
- data/lib/generators/pragma/resource_generator.rb +3 -5
- data/lib/pragma/rails/controller.rb +12 -2
- data/lib/pragma/rails/version.rb +1 -1
- data/pragma-rails.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6e2a68743a821815f7829d534b473c0d7ea6586c6090d2b238ec2de1e2b43fe
|
4
|
+
data.tar.gz: 1ef22df33406ca6611526d3c080895c5ae1412ead86d4f2b9529bd5ab6a607fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02c720a8770b02cc61ad7ee352b895c317f5d04c9871dd324a6e28048df8ab663bc86542dc6af1c550377ae31b1eb6904b8fd9d1f1b98ba735d255a3ea68b5f9
|
7
|
+
data.tar.gz: 657e38ecf81f45f9cf98523a4e7eb20a60670116d48704881893d69bb1011c77a939235365ecdffa2ea796c5cca40d71a89a5e8f48977674e1d014d950587bae
|
data/.rubocop.yml
CHANGED
@@ -3,8 +3,9 @@ require: rubocop-rspec
|
|
3
3
|
AllCops:
|
4
4
|
TargetRubyVersion: 2.3
|
5
5
|
Include:
|
6
|
-
- '
|
6
|
+
- '**/*.rb'
|
7
7
|
- '**/Rakefile'
|
8
|
+
- '**/Gemfile'
|
8
9
|
Exclude:
|
9
10
|
- 'bin/*'
|
10
11
|
- 'db/**/*'
|
@@ -14,8 +15,6 @@ AllCops:
|
|
14
15
|
- 'spec/support/**/*'
|
15
16
|
- 'spec/dummy/**/*'
|
16
17
|
- 'config/**/*'
|
17
|
-
- '**/Rakefile'
|
18
|
-
- '**/Gemfile'
|
19
18
|
|
20
19
|
RSpec/DescribeClass:
|
21
20
|
Exclude:
|
@@ -57,7 +56,7 @@ Style/SignalException:
|
|
57
56
|
Style/BracesAroundHashParameters:
|
58
57
|
EnforcedStyle: context_dependent
|
59
58
|
|
60
|
-
|
59
|
+
Layout/EndAlignment:
|
61
60
|
EnforcedStyleAlignWith: variable
|
62
61
|
AutoCorrect: true
|
63
62
|
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [2.2.0]
|
11
|
+
|
12
|
+
## Added
|
13
|
+
|
14
|
+
- Added support for passing additional context to policies via `#policy_context`
|
15
|
+
|
16
|
+
## Fixed
|
17
|
+
|
18
|
+
- Allowed support for accessing operation params by either string or symbol
|
19
|
+
|
10
20
|
## [2.1.1]
|
11
21
|
|
12
22
|
### Fixed
|
@@ -31,7 +41,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
31
41
|
|
32
42
|
First Pragma 2 release.
|
33
43
|
|
34
|
-
[Unreleased]: https://github.com/pragmarb/pragma-rails/compare/v2.
|
44
|
+
[Unreleased]: https://github.com/pragmarb/pragma-rails/compare/v2.2.0...HEAD
|
45
|
+
[2.2.0]: https://github.com/pragmarb/pragma-rails/compare/v2.1.1...v2.2.0
|
35
46
|
[2.1.1]: https://github.com/pragmarb/pragma-rails/compare/v2.1.0...v2.1.1
|
36
47
|
[2.1.0]: https://github.com/pragmarb/pragma-rails/compare/v2.0.0...v2.1.0
|
37
48
|
[2.0.0]: https://github.com/pragmarb/pragma-rails/compare/v1.2.4...v2.0.0
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Pragma on Rails
|
2
2
|
|
3
3
|
[](https://travis-ci.org/pragmarb/pragma-rails)
|
4
|
-
[](https://gemnasium.com/github.com/pragmarb/pragma-rails)
|
5
4
|
[](https://coveralls.io/github/pragmarb/pragma-rails?branch=master)
|
6
5
|
[](https://codeclimate.com/github/pragmarb/pragma-rails/maintainability)
|
7
6
|
|
@@ -131,6 +130,9 @@ module API
|
|
131
130
|
end
|
132
131
|
```
|
133
132
|
|
133
|
+
You may also define `#policy_context` to [pass additional context](https://github.com/pragmarb/pragma-policy#passing-additional-context)
|
134
|
+
to your policies.
|
135
|
+
|
134
136
|
### Resource Controllers
|
135
137
|
|
136
138
|
Resource controllers (provided by the `Pragma::Rails::ResourceController` module) abstract even more
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Pragma
|
4
4
|
class ResourceGenerator < ::Rails::Generators::NamedBase # :nodoc:
|
5
|
-
source_root File.expand_path('
|
5
|
+
source_root File.expand_path('templates', __dir__)
|
6
6
|
|
7
7
|
class_option :version, type: :numeric, default: 1, desc: 'The API version to use', aliases: '-v'
|
8
8
|
|
@@ -16,7 +16,7 @@ module Pragma
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def factory_name
|
19
|
-
[namespace, class_name].join.underscore.
|
19
|
+
[namespace, class_name].join.underscore.tr('/', '_')
|
20
20
|
end
|
21
21
|
|
22
22
|
def full_class_name
|
@@ -60,9 +60,7 @@ module Pragma
|
|
60
60
|
write("namespace :#{namespace} do", index + 1)
|
61
61
|
end
|
62
62
|
|
63
|
-
path_fragment = if file_name.include?('_')
|
64
|
-
", path: '#{file_name.pluralize.tr('_', '-')}'"
|
65
|
-
end
|
63
|
+
path_fragment = (", path: '#{file_name.pluralize.tr('_', '-')}'" if file_name.include?('_'))
|
66
64
|
|
67
65
|
# rubocop:disable Metrics/LineLength
|
68
66
|
write(
|
@@ -24,7 +24,8 @@ module Pragma
|
|
24
24
|
|
25
25
|
result = operation_const.call(
|
26
26
|
operation_params,
|
27
|
-
'current_user' => operation_user
|
27
|
+
'current_user' => operation_user,
|
28
|
+
'policy.context' => policy_context
|
28
29
|
)
|
29
30
|
|
30
31
|
result['result.response'].headers.each_pair do |key, value|
|
@@ -49,7 +50,7 @@ module Pragma
|
|
49
50
|
#
|
50
51
|
# @return [Hash]
|
51
52
|
def operation_params
|
52
|
-
params.to_unsafe_h
|
53
|
+
params.to_unsafe_h.with_indifferent_access
|
53
54
|
end
|
54
55
|
|
55
56
|
# Returns the currently authenticated user (for policies).
|
@@ -61,6 +62,15 @@ module Pragma
|
|
61
62
|
current_user if respond_to?(:current_user)
|
62
63
|
end
|
63
64
|
|
65
|
+
# Returns the context to pass to Pragma policies.
|
66
|
+
#
|
67
|
+
# By default, calls {#operation_user}.
|
68
|
+
#
|
69
|
+
# @return [Object]
|
70
|
+
def policy_context
|
71
|
+
operation_user
|
72
|
+
end
|
73
|
+
|
64
74
|
private
|
65
75
|
|
66
76
|
def entity_to_hash(entity)
|
data/lib/pragma/rails/version.rb
CHANGED
data/pragma-rails.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pragma-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Desantis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pragma
|