ocean-rails 4.1.6 → 5.0.0

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
  SHA1:
3
- metadata.gz: 63ca7637df130db08dda89487685ab261006299d
4
- data.tar.gz: 2ad788ad6233fa6c819deaba1bc9e615bf9f3fc7
3
+ metadata.gz: 64668e1ca09bd9c947e446be490c552d737030a6
4
+ data.tar.gz: 5e7bee38908ac4bb03ac768d34aab6b4fb78ad48
5
5
  SHA512:
6
- metadata.gz: 48512b574084859bb88862cfc565e74fece0c52ae8f15138a013a2852dd8a2f3b4341a5773239a0680108862d444f010604f4f4bc61e22ee42746c280a3d6382
7
- data.tar.gz: dbfb5e8a596c89e3812a8eb9d4c1c8534068a407d38d83699bb342a464dc1a9d8a8175f554a6db1f33e58fa577ac1fc24c8f53c636578770deb16c30adde6868
6
+ metadata.gz: 2803f8a963a01bd1b3e81e625d9aaad670e406c97c9637467634f2a0c8b42e0cc3b2a0496a0f19d2831c76b3a09dbebf2c9de41d2c16edce900fb0c24eb22843
7
+ data.tar.gz: 9c299822c58f17b33d131c1e635ad51dc9aabf8ce58f8c3103e0a4c5c514febe612d220026dc9689c0a4a1c17dc39132bd9372c25829e2fae24c7a3ccdd652bc
data/lib/ocean-rails.rb CHANGED
@@ -96,3 +96,51 @@ def add_right_restrictions(rel, restrictions)
96
96
  rel.where(cond)
97
97
  end
98
98
  end
99
+
100
+
101
+ #
102
+ # Used in Jbuilder templates to build hyperlinks
103
+ #
104
+ def hyperlinks(links={})
105
+ result = {}
106
+ links.each do |qi, val|
107
+ next unless val.present?
108
+ result[qi.to_s] = {
109
+ "href" => val.kind_of?(String) ? val : val[:href],
110
+ "type" => val.kind_of?(String) ? "application/json" : val[:type]
111
+ }
112
+ end
113
+ result
114
+ end
115
+
116
+ #
117
+ # This renders creator and updater links correctly.
118
+ #
119
+ def smart_api_user_url(x)
120
+ if x.blank?
121
+ "#{OCEAN_API_URL}/#{Api.version_for :api_user}/api_users/0-0-0-0-0"
122
+ elsif x.is_a?(Integer)
123
+ "#{OCEAN_API_URL}/#{Api.version_for :api_user}/api_users/#{x}"
124
+ elsif x.is_a?(String)
125
+ x =~ /^http(s)?:\/\// ? x : "#{OCEAN_API_URL}/#{Api.version_for :api_user}/api_users/#{x}"
126
+ else
127
+ raise "api_user_url takes an integer, a string, or nil"
128
+ end
129
+ end
130
+
131
+
132
+ #
133
+ # View helper predicates to determine if the ApiUser behind the current
134
+ # authorisation belongs to one or more of a list of Groups.
135
+ #
136
+ def member_of_group?(*names)
137
+ @group_names && @group_names.intersect?(names.to_set)
138
+ end
139
+
140
+ #
141
+ # Returns true if the ApiUser behind the current authorisation belongs
142
+ # to the Ocean Group "Superusers".
143
+ #
144
+ def superuser?
145
+ member_of_group?("Superusers")
146
+ end
data/lib/ocean/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ocean
2
- VERSION = "4.1.6"
2
+ VERSION = "5.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocean-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.6
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Bengtson
@@ -206,7 +206,6 @@ files:
206
206
  - Rakefile
207
207
  - app/controllers/alive_controller.rb
208
208
  - app/controllers/errors_controller.rb
209
- - app/helpers/application_helper.rb
210
209
  - config/initializers/_api_constants.rb
211
210
  - config/initializers/_aws_config.rb
212
211
  - config/initializers/_ocean_constants.rb
@@ -1,58 +0,0 @@
1
- module ApplicationHelper
2
-
3
- #
4
- # Used in Jbuilder templates to build hyperlinks
5
- #
6
- def hyperlinks(links={})
7
- result = {}
8
- links.each do |qi, val|
9
- next unless val.present?
10
- result[qi.to_s] = {
11
- "href" => val.kind_of?(String) ? val : val[:href],
12
- "type" => val.kind_of?(String) ? "application/json" : val[:type]
13
- }
14
- end
15
- result
16
- end
17
-
18
-
19
- #
20
- # This is needed everywhere except inside the Auth service to render creator
21
- # and updater links correctly.
22
- #
23
- def api_user_url(x)
24
- if x.blank?
25
- "#{OCEAN_API_URL}/#{Api.version_for :api_user}/api_users/0-0-0-0-0"
26
- elsif x.is_a?(Integer)
27
- "#{OCEAN_API_URL}/#{Api.version_for :api_user}/api_users/#{x}"
28
- elsif x.is_a?(String)
29
- x =~ /^http(s)?:\/\// ? x : "#{OCEAN_API_URL}/#{Api.version_for :api_user}/api_users/#{x}"
30
- else
31
- raise "api_user_url takes an integer, a string, or nil"
32
- end
33
- end
34
-
35
- #
36
- # This is an alias of +api_user_url+.
37
- #
38
- def api_user_url_smart(x)
39
- api_user_url(x)
40
- end
41
-
42
-
43
- #
44
- # View helper predicates to determine if the ApiUser behind the current
45
- # authorisation belongs to one or more of a list of Groups.
46
- #
47
- def member_of_group?(*names)
48
- @group_names && @group_names.intersect?(names.to_set)
49
- end
50
-
51
- #
52
- # Returns true if the ApiUser behind the current authorisation belongs
53
- # to the Ocean Group "Superusers".
54
- #
55
- def superuser?
56
- member_of_group?("Superusers")
57
- end
58
- end