jsender 0.1.3 → 0.1.4

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
  SHA1:
3
- metadata.gz: d6a6f7c896c804935eb73e7be0ebf27a41065fef
4
- data.tar.gz: 558767f25b6284dfe5a9939ab909641a0bcbe1dc
3
+ metadata.gz: 0f0661843afe7b020404bc6a01adc660548d9b55
4
+ data.tar.gz: 84fcc7dd25a954ccd5e00f9fc7dcdb08627af972
5
5
  SHA512:
6
- metadata.gz: a0ed92bba9f996ac7d1e2e3b28076411fab1d334c90b96c3e5d5c6816e851b6fd44d3126cd67d6ba0f063375ea6722ad912b2ff63f2c21991fcd6719176692d7
7
- data.tar.gz: 109f357e1429d7872873aa1cc63c35b291b3bce9d2f24bb4c15ad202d2de419846d6a98dd62b9679ff417dab6079ac826724a3ec034fb08fa55e7b62df37d3d3
6
+ metadata.gz: fbec52bcd8f5d0f92b67172eed08bc60161f1a351ad5334a9c564beba963b7e7af3d8d5bad8bcb2e0a84aa11e3aab7867196cb8566ff8723d7d8cec70264a302
7
+ data.tar.gz: 6a7a53dc0634d2e6c8f63cbceb41b7def6de00a4ded97ea0c3236771893fc777af1444f0d05cc0a49199b7d0e95c2e78d74fd1afa5c818f982f6816cfd662e8d
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Jsender
2
2
 
3
- JSender facilitates a simple jsend implementation for ruby. You can report success, fail, success with data, fail with data. The jsend response contains 'status' and 'data'. 'data' contains what-ever you put in it, as well as a 'notifications' array. Helpers are provided to check whether a notification is present and whether a specific data key is present.
3
+ JSender facilitates a simple jsend implementation for ruby. You can report success, error, fail, success with data, fail with data. The jsend response contains 'status' and 'data'. 'data' contains what-ever you put in it, as well as a 'notifications' array. Helpers are provided to check whether a notification is present and whether a specific data key is present. On error the response contains 'message'.
4
4
 
5
5
  ## Installation
6
6
 
@@ -25,20 +25,41 @@ Or install it yourself as:
25
25
 
26
26
  class CodeClass
27
27
  include Jsender
28
-
29
- def action(code)
30
- return success if code == 1
31
- return success('code 2 selected') if code == 2
32
- return success_data({ 'a' => 'A', 'b' => 'B' }) if code == 3
33
- return success('some data for you', ['d', 'a', 't', 'a']) if code == 4
34
- return fail('code 5 selected') if code == 5
35
- return fail_data({ 'a' => 'A', 'b' => 'B' }) if code == 6
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
39
- fail
40
- end
41
28
  end
29
+
30
+ iut = CodeClass.new
31
+ iut.success
32
+ => {"status"=>"success", "data"=>{"result"=>nil, "notifications"=>["success"]}}
33
+
34
+ iut.success('happy day')
35
+ => {"status"=>"success", "data"=>{"result"=>nil, "notifications"=>["happy day"]}}
36
+
37
+ result = iut.success_data({ 'a' => 'A', 'b' => 'B' })
38
+ => {"status"=>"success", "data"=>{"a"=>"A", "b"=>"B", "notifications"=>["success"]}}
39
+ iut.has_data?(result, 'b')
40
+ => true
41
+
42
+ result = iut.success('some data for you', ['d', 'a', 't', 'a'])
43
+ => {"status"=>"success", "data"=>{"result"=>["d", "a", "t", "a"], "notifications"=>["some data for you"]}}
44
+ iut.has_data?(result, 'result')
45
+ => true
46
+ iut.notifications_include?(result, 'ata fo')
47
+ => true
48
+
49
+ iut.error
50
+ => {"status"=>"error", "message"=>nil}
51
+
52
+ iut.error('something went wrong')
53
+ => {"status"=>"error", "message"=>"something went wrong"}
54
+
55
+ iut.fail
56
+ => {"status"=>"fail", "data"=>{"result"=>nil, "notifications"=>["fail"]}}
57
+
58
+ iut.fail('a failure occurred')
59
+ => {"status"=>"fail", "data"=>{"result"=>nil, "notifications"=>["a failure occurred"]}}
60
+
61
+ iut.fail('a failure occurred', ['d', 'a', 't', 'a'])
62
+ => {"status"=>"fail", "data"=>{"result"=>["d", "a", "t", "a"], "notifications"=>["a failure occurred"]}}
42
63
  ```
43
64
 
44
65
  ```
data/jsender.gemspec CHANGED
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "bundler", "~> 1.10"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  spec.add_development_dependency "rspec"
26
+ # spec.add_development_dependency "byebug"
26
27
  end
@@ -1,3 +1,3 @@
1
1
  module Jsender
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
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.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernst van Graan