pinkman 1.5.0 → 1.5.5

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
- SHA256:
3
- metadata.gz: fa1bf2864f22809f8c499dc3437a155460de8f51a24c7c8b37b96b404545ffe7
4
- data.tar.gz: 0a2f8064c7976a7e1e531aa07dad167a847e6bd39a782aa0e598cbbd47c4b517
2
+ SHA1:
3
+ metadata.gz: f5ae7dc5426b1991dfceff32ae73e6c5eb09b12e
4
+ data.tar.gz: c9e54763e2944487ba19c95d5a09a364eaed822c
5
5
  SHA512:
6
- metadata.gz: 0e3bf8479041f58f137d70ac296cb7f353db73e1ac73bd4fa912748da5dfde4096b099091498b0d24e474f75609929ffc0d8ff500b5acbb099827fe9f3fe6129
7
- data.tar.gz: 93710f4576d813674cfde8feb99420c0cd4f1a0739f13135a373baa621817c95f9affc15a60b8b50b96b3eb48d64ed8e1b90fd4e451cb9fa9f02432eaaa3ad60
6
+ metadata.gz: 31df578621909b49388c30cedca3a45562e66a77eeec0040f854504e1fe1995e2e76336576f49c36451888bbd78883e38261abfa0d67bb42488b35703aff2ba6
7
+ data.tar.gz: ff4493e22c00d4318bf9d4ed4f980d2292af75ed19c9cf5eee326a42c11e17be286b78f8a3ac67405fc98f3e3c1e7d286fbf69e59ec4baf278d828088724f2e5
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  /dummy/
11
+ .tool-versions
@@ -23,7 +23,7 @@ class window.PinkmanObject extends window.PinkmanCommon
23
23
  for instance in @instances
24
24
  i = i + 1
25
25
  if instance.id? and instance.id == obj.id
26
- if obj.isPink then instance.assign(obj.attributes()) else instance.assign(obj)
26
+ if obj.isPink then instance.assign(obj.json()) else instance.assign(obj)
27
27
  each(instance) if $p.isFunction(each) and obj.pinkey != instance.pinkey
28
28
  callback() if (length == i) and $p.isFunction(callback)
29
29
  else
@@ -187,7 +187,7 @@ class window.PinkmanObject extends window.PinkmanCommon
187
187
  update: (callback='') ->
188
188
  if @id?
189
189
  Pinkman.ajax.patch
190
- url: @api() + @id
190
+ url: @api(@id)
191
191
  data: @_data()
192
192
  complete: (response) =>
193
193
  @default_response_handling(response,callback)
@@ -202,7 +202,7 @@ class window.PinkmanObject extends window.PinkmanCommon
202
202
  params = new Object
203
203
  params.scope = Pinkman.scope(this)
204
204
  Pinkman.ajax.get
205
- url: Pinkman.json2url(@api() + @id,params)
205
+ url: Pinkman.json2url(@api(@id),params)
206
206
  complete: (response) =>
207
207
  @assign(response)
208
208
  if @error? or @errors?
@@ -220,15 +220,39 @@ class window.PinkmanObject extends window.PinkmanCommon
220
220
  return false
221
221
 
222
222
  save: (callback='') ->
223
- if @id? and @id!='' then @update(callback) else @create(callback)
223
+ @handleBeforeSave()
224
+ callback = @handleAfterSaveCallback(callback)
225
+ if @id? and @id!='' then @update(callback) else @create(callback)
226
+
227
+ handleBeforeSave: ->
228
+ if $p.isArray(@beforeSave)
229
+ for f in @beforeSave
230
+ f(this) if $p.isFunction(f)
231
+ else if $p.isFunction(@beforeSave)
232
+ @beforeSave(this)
233
+
234
+ handleAfterSaveCallback: (callback) ->
235
+ if $p.isArray(@afterSave)
236
+ (obj) =>
237
+ i = 0
238
+ for f in @afterSave
239
+ f(obj) if $p.isFunction(f)
240
+ i = i + 1
241
+ callback(obj) if i == @afterSave.length and $p.isFunction(callback)
242
+ else if $p.isFunction(@afterSave)
243
+ (obj) =>
244
+ @afterSave(obj)
245
+ callback(obj) if $p.isFunction()
246
+ else
247
+ callback
224
248
 
225
249
  # delete and remove from collections
226
250
  destroy: (callback='') ->
227
251
  if @id?
228
252
  @removeFromAllCollections()
229
253
  Pinkman.ajax.delete
230
- url: @api() + @id
231
- data: { scope: Pinkman.scope(this) }
254
+ url: @api(@id)
255
+ data: @_data()
232
256
  complete: (response) =>
233
257
  @assign(response)
234
258
  delete @errors unless response.errors?
@@ -242,8 +266,8 @@ class window.PinkmanObject extends window.PinkmanCommon
242
266
  delete: (callback='') ->
243
267
  if @id?
244
268
  Pinkman.ajax.delete
245
- url: @api() + @id
246
- data: { scope: Pinkman.scope(this) }
269
+ url: @api(@id)
270
+ data: @_data()
247
271
  complete: (response) =>
248
272
  @assign(response)
249
273
  delete @errors unless response.errors?
@@ -280,12 +280,11 @@ class window.Pinkman
280
280
  contentType: false
281
281
  ajax.done (response) =>
282
282
  if response? and response.errors?
283
- options.error(this) if options.error? and typeof options.error == 'function'
284
- return false
283
+ options.error(response) if $p.isFunction(options.error)
285
284
  else
286
- options.success(response) if options.success? and typeof options.success == 'function'
287
- options.complete(response) if options.complete? and typeof options.complete == 'function'
288
- return this
285
+ options.success(response) if $p.isFunction(options.success)
286
+ options.complete(response) if $p.isFunction(options.complete)
287
+ return response
289
288
  else
290
289
  return false
291
290
 
@@ -235,16 +235,19 @@ class window.PinkmanRouter
235
235
 
236
236
  @analytics:
237
237
  create: (id) ->
238
- # console.log 'chamou'
239
- # console.log id
240
- ga('create', id, 'auto');
241
- ga('send', 'pageview');
238
+ try
239
+ ga('create', id, 'auto');
240
+ ga('send', 'pageview');
241
+ true
242
+ catch
243
+ console.log('ga blocked')
244
+ false
245
+
242
246
 
243
247
  send: (route,path) ->
244
248
  unless @created? and @created
245
249
  # console.log this
246
- @create(Pinkman.router._config.analytics)
247
- @created = true
250
+ @created = @create(Pinkman.router._config.analytics)
248
251
  else
249
252
  host = new RegExp(window.location.origin)
250
253
  path = if host.test(path) then path.replace(host,'') else path
@@ -1,3 +1,3 @@
1
1
  module Pinkman
2
- VERSION = "1.5.0"
2
+ VERSION = "1.5.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pinkman
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Agilso Oliveira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-28 00:00:00.000000000 Z
11
+ date: 2021-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -322,7 +322,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
322
322
  - !ruby/object:Gem::Version
323
323
  version: '0'
324
324
  requirements: []
325
- rubygems_version: 3.0.6
325
+ rubyforge_project:
326
+ rubygems_version: 2.6.14.4
326
327
  signing_key:
327
328
  specification_version: 4
328
329
  summary: Small Rails-js framework.