ocean-rails 8.0.4 → 8.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6410275c0be170157e6066f8cb066943f4e799d7e1ed08f04f9b4af49ccc1a3e
4
- data.tar.gz: 197f838aef582a7273e7fd4c90de1ceece45b9a11c827707742d64bade485e54
3
+ metadata.gz: bcab533eb7e89aa0b95f905ef960c9cfdb12b72b160bd4dbbf84ee44eadd284c
4
+ data.tar.gz: 0d693e526d8d85396a67ff368b790a9fe19b9cd34d654d40ab3222b99d25a31c
5
5
  SHA512:
6
- metadata.gz: 6869bb1d90ede9a68a4d84fe3048d8e001eba8d6332de41ab08b40121af14da8a49a941cbd4c2efb171d4ed3a2b1ec8a7294aa360b153f542d000171ad902453
7
- data.tar.gz: 41101939b918213a5bf914ad62f23a23c1b5005e4ae1579fd2bd45d33c99c929d21ecf3d20aa196730f6e9af950c5492dd5bf8239227776188e1854c8d35ba07
6
+ metadata.gz: 97c5e92ab3ac19b360ce1e1c2f0b65618c5bef1f4e2c9f56963f0db5d188a40323568e7821d6194df890216fbf6d2f3fcb283cf2f8fbb0f6bbcb4fc273b81c91
7
+ data.tar.gz: 773acfca0d1fa0b346aec42d87d3ef25e0dd2a3abfe87d4b276f70ff3a6f3f4751e6d76c97f4394e10acb798077f95a526ff27f2ed407b7e97287311db6b7b0e
@@ -5,7 +5,7 @@ class AliveController < ApplicationController
5
5
 
6
6
 
7
7
  def index
8
- render text: "ALIVE", status: 200
8
+ render plain: "ALIVE", status: 200
9
9
  end
10
10
 
11
11
  end
@@ -10,8 +10,8 @@ module OceanApplicationController
10
10
  def default_url_options(options = nil)
11
11
  { :protocol => "https", :host => OCEAN_API_HOST }
12
12
  end
13
-
14
-
13
+
14
+
15
15
  #
16
16
  # Ensures that there is an +X-API-Token+ HTTP header in the request.
17
17
  # Stores the token in @x_api_token for use during authorisation of the
@@ -40,7 +40,7 @@ module OceanApplicationController
40
40
  expires_in 0, must_revalidate: true
41
41
  false
42
42
  end
43
-
43
+
44
44
 
45
45
 
46
46
  #
@@ -65,7 +65,7 @@ module OceanApplicationController
65
65
  end
66
66
  # Create a query string and call Auth
67
67
  qs = Api.authorization_string(@@extra_actions, controller_name, action_name)
68
- response = Api.permitted?(@x_api_token, query: qs)
68
+ response = Api.permitted?(@x_api_token, query: qs)
69
69
  if response.status == 200
70
70
  a = response.body['authentication']
71
71
  @auth_api_user_id = a['user_id'] # Deprecate and remove
@@ -98,10 +98,10 @@ module OceanApplicationController
98
98
  obj.updated_by = @auth_api_user_uri
99
99
  end
100
100
  end
101
-
102
-
101
+
102
+
103
103
  #
104
- # Renders an API level error. The body will be a JSON hash with a single key,
104
+ # Renders an API level error. The body will be a JSON hash with a single key,
105
105
  # +_api_error+. The value is an array containing the +messages+.
106
106
  #
107
107
  # render_api_error(500, "An unforeseen error occurred")
@@ -117,14 +117,14 @@ module OceanApplicationController
117
117
  def render_api_error(status_code, *messages)
118
118
  render json: {_api_error: messages}, status: status_code
119
119
  end
120
-
120
+
121
121
  #
122
122
  # Renders a +HEAD+ response with HTTP status 204 No Content.
123
123
  #
124
124
  def render_head_204
125
- render text: '', status: 204 #, content_type: 'application/json'
125
+ render plain: '', status: 204, content_type: 'application/json'
126
126
  end
127
-
127
+
128
128
  #
129
129
  # Renders a HTTP 422 Unprocessable Entity response with a body enumerating
130
130
  # each invalid Rails resource attribute and all their errors. This is usually
@@ -147,7 +147,7 @@ module OceanApplicationController
147
147
  except = except.collect(&:to_sym)
148
148
  render json: r.errors.messages.except(*except), status: 422
149
149
  end
150
-
150
+
151
151
  #
152
152
  # This is the main rendering function in Ocean. The argument +x+ can be a resource
153
153
  # or a collection of resources (which need not be of the same type).
@@ -159,9 +159,9 @@ module OceanApplicationController
159
159
  # their standard position, begin with an underscore, etc. The +ocean+ gem generator
160
160
  # for resources creates a partial in the proper location.
161
161
  #
162
- def api_render(x,
163
- new: false,
164
- href: x.present? && url_for(params),
162
+ def api_render(x,
163
+ new: false,
164
+ href: x.present? && url_for(params.permit!),
165
165
  override_partial: false
166
166
  )
167
167
  if !x.is_a?(Array) && !(defined?(ActiveRecord) && x.is_a?(ActiveRecord::Relation))
@@ -173,7 +173,7 @@ module OceanApplicationController
173
173
  end
174
174
  return
175
175
  else
176
- resources = x.dup.collect { |m| render_to_string(partial: m.to_partial_path,
176
+ resources = x.dup.collect { |m| render_to_string(partial: m.to_partial_path,
177
177
  locals: {m.class.model_name.i18n_key => m}) }
178
178
  count = resources.count
179
179
  total_count = x.respond_to?(:unscope) ? x.unscope(:limit, :offset).count : count
@@ -198,17 +198,18 @@ module OceanApplicationController
198
198
  links['next_page'] = {href: url_for(params.merge(page: next_page)), type: 'application/json'} if next_page
199
199
  end
200
200
  end
201
-
201
+
202
202
  attrs['_links'] = links if links
203
203
  attrs['page'] = page if page
204
204
  attrs['page_size'] = page_size if page_size
205
205
  attrs['total_pages'] = total_pages if total_pages
206
206
 
207
- render text: '{"_collection":{"resources":[' + resources.join(',') + ']' +
207
+ render plain: '{"_collection":{"resources":[' + resources.join(',') + ']' +
208
208
  (attrs.collect do |k, v|
209
209
  ',"' + k.to_s + '":' + v.to_json
210
210
  end).join('') +
211
- '}}'
211
+ '}}',
212
+ content_type: 'application/json'
212
213
  end
213
214
  end
214
215
 
@@ -221,7 +222,7 @@ module OceanApplicationController
221
222
  #
222
223
  def filtered_params(klass)
223
224
  result = {}
224
- params.each do |k, v|
225
+ params.each do |k, v|
225
226
  result[k] = v if klass.accessible_attributes.include?(k)
226
227
  end
227
228
  result
@@ -229,10 +230,10 @@ module OceanApplicationController
229
230
 
230
231
 
231
232
  #
232
- # Cache values for collections. Accepts a class, a scope, or an array.
233
- # The cache value is based on three components:
234
- # (1) the name of the class,
235
- # (2) the number of members in the collection, and
233
+ # Cache values for collections. Accepts a class, a scope, or an array.
234
+ # The cache value is based on three components:
235
+ # (1) the name of the class,
236
+ # (2) the number of members in the collection, and
236
237
  # (3) the modification time of the last updated member.
237
238
  # If an array is given, the class of the first member will be used to
238
239
  # create a scope. If the array is empty, the optional second argument
@@ -1,3 +1,3 @@
1
1
  module Ocean
2
- VERSION = "8.0.4"
2
+ VERSION = "8.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocean-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.4
4
+ version: 8.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Bengtson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-09 00:00:00.000000000 Z
11
+ date: 2018-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '4'
61
+ version: 5.0.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '4'
68
+ version: 5.0.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sqlite3
71
71
  requirement: !ruby/object:Gem::Requirement