jsender 0.1.2 → 0.1.3

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: 682b13b42b3e8704bcc8b24c20f94c596c937219
4
- data.tar.gz: 5e6270d09e74ec0aab05167814bc71fa06990bce
3
+ metadata.gz: d6a6f7c896c804935eb73e7be0ebf27a41065fef
4
+ data.tar.gz: 558767f25b6284dfe5a9939ab909641a0bcbe1dc
5
5
  SHA512:
6
- metadata.gz: cb82eb37911d290ff83e3d39bd3a9fa267eb1b88b1bacefadfee6d6eeef543da9c7efd5dbd9e1b8305040455f64187920bb5e631c60e0094d29211c768772a01
7
- data.tar.gz: f4e81e85cbeef060b72732d0b0eedffd736557854a864e3daf28dd377a8e438284bfc129827a66918b1c89b622a12ec116a8d820367c30705a74137b52ffcb29
6
+ metadata.gz: a0ed92bba9f996ac7d1e2e3b28076411fab1d334c90b96c3e5d5c6816e851b6fd44d3126cd67d6ba0f063375ea6722ad912b2ff63f2c21991fcd6719176692d7
7
+ data.tar.gz: 109f357e1429d7872873aa1cc63c35b291b3bce9d2f24bb4c15ad202d2de419846d6a98dd62b9679ff417dab6079ac826724a3ec034fb08fa55e7b62df37d3d3
data/README.md CHANGED
@@ -34,6 +34,8 @@ Or install it yourself as:
34
34
  return fail('code 5 selected') if code == 5
35
35
  return fail_data({ 'a' => 'A', 'b' => 'B' }) if code == 6
36
36
  return fail('some errors for you', ['d', 'a', 't', 'a']) if code == 7
37
+ return error if code == 8
38
+ return error('something went wrong') if code == 9
37
39
  fail
38
40
  end
39
41
  end
@@ -64,15 +66,20 @@ Or install it yourself as:
64
66
 
65
67
  iut.action(7)
66
68
  => {"status"=>"fail", "data"=>{"result"=>["d", "a", "t", "a"], "notifications"=>["some errors for you"]}}
67
-
68
- iut.action(0)
69
- => {"status"=>"fail", "data"=>{"result"=>nil, "notifications"=>["fail"]}}
70
-
71
69
  iut.has_data?(result, 'a')
72
70
  => true
73
71
  iut.has_data?(result, 'z')
74
72
  => false
75
73
 
74
+ iut.action(0)
75
+ => {"status"=>"fail", "data"=>{"result"=>nil, "notifications"=>["fail"]}}
76
+
77
+ iut.action(8)
78
+ => {"status"=>"error", "message"=>nil}
79
+
80
+ iut.action(9)
81
+ => {"status"=>"error", "message"=>"something went wrong"}
82
+
76
83
  result = iut.action(6)
77
84
  iut.notifications_include?(result, "ail")
78
85
  => true
@@ -1,3 +1,3 @@
1
1
  module Jsender
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/jsender.rb CHANGED
@@ -2,11 +2,16 @@ require "jsender/version"
2
2
 
3
3
  module Jsender
4
4
  def report(status, message, result = nil)
5
+ return { 'status' => 'error', 'message' => message } if status == 'error'
5
6
  data = compile_data(result)
6
7
  data['notifications'] = message.is_a?(Array) ? message : [ message ]
7
8
  { 'status' => status, 'data' => data }
8
9
  end
9
10
 
11
+ def error(message = nil)
12
+ report('error', message)
13
+ end
14
+
10
15
  def fail(message = nil, data = nil)
11
16
  message ||= 'fail'
12
17
  report('fail', message, data)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsender
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernst van Graan