jeapie 0.1.0 → 0.1.1
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.
- data/jeapie.gemspec +6 -0
- data/lib/jeapie.rb +15 -4
- data/lib/jeapie/version.rb +1 -1
- data/whatsnew.md +2 -0
- metadata +15 -3
data/jeapie.gemspec
CHANGED
@@ -20,4 +20,10 @@ Gem::Specification.new do |gem|
|
|
20
20
|
|
21
21
|
gem.add_dependency('activesupport')
|
22
22
|
gem.add_development_dependency 'fakeweb', ['~> 1.3']
|
23
|
+
|
24
|
+
# documentation
|
25
|
+
gem.extra_rdoc_files = Dir.glob('*.md')
|
26
|
+
gem.rdoc_options = %w(--line-numbers --inline-source --no-private --protected --title Jeapie --main README.md --encoding=UTF-8)
|
27
|
+
gem.has_rdoc = 'yard'
|
28
|
+
|
23
29
|
end
|
data/lib/jeapie.rb
CHANGED
@@ -3,12 +3,14 @@ require 'jeapie/version'
|
|
3
3
|
require 'active_support/core_ext/object/blank'
|
4
4
|
require 'active_support/json'
|
5
5
|
|
6
|
+
# The primary namespace.
|
6
7
|
module Jeapie
|
7
8
|
class DeliverException < StandardError ; end
|
8
9
|
extend self
|
9
10
|
# app_token and user_key, you can get it from dashboard.jeapie.com
|
10
11
|
attr_accessor :token, :user
|
11
12
|
attr_accessor :message, :title, :device, :priority
|
13
|
+
# After call notify it contain result as {Net::HTTPCreated} object, for check result better see {#errors}
|
12
14
|
attr_reader :result
|
13
15
|
|
14
16
|
API_URL= 'https://api.jeapie.com/v1/send/message.json'
|
@@ -30,16 +32,20 @@ module Jeapie
|
|
30
32
|
end
|
31
33
|
alias_method :params, :parameters
|
32
34
|
|
35
|
+
# List of available fields, useful for unit test.
|
36
|
+
# @return Hash
|
33
37
|
def keys
|
34
38
|
@keys||= [:token, :user, :message, :title, :device, :priority]
|
35
39
|
end
|
36
40
|
|
41
|
+
# Clear stored params, useful for unit tests.
|
37
42
|
def clear
|
38
43
|
keys.each do |k|
|
39
44
|
Jeapie.instance_variable_set("@#{k}", nil)
|
40
45
|
end
|
41
46
|
end
|
42
47
|
|
48
|
+
# After call {#notify} it contain "false" if all OK, or [string] with error in other case.
|
43
49
|
def errors
|
44
50
|
return "Params not valid: #{@params_errors}" unless @params_errors && @params_errors.empty?
|
45
51
|
return false if result.nil?
|
@@ -53,10 +59,14 @@ module Jeapie
|
|
53
59
|
"code: #{result.code}, errors: #{arr['errors']}"
|
54
60
|
end
|
55
61
|
|
56
|
-
#
|
57
|
-
# example:
|
58
|
-
#
|
59
|
-
#
|
62
|
+
# Send message to Jeapie.
|
63
|
+
# example:
|
64
|
+
# notify message:'Backup complete'
|
65
|
+
# or:
|
66
|
+
# notify title:'Backup complete', message:'Time elapsed 50s, size: 500Mb', priority:-1, device:'Nexus7', user:'', token:''
|
67
|
+
#
|
68
|
+
# If this method return +false+, you can check {#errors} for text, or you can use {#notify!} for raise +DeliverException+ if any problem
|
69
|
+
# @return [true, false]
|
60
70
|
def notify(opts={message:''})
|
61
71
|
data = params.merge(opts).select { |_, v| v != nil }
|
62
72
|
return false unless params_errors(data).empty?
|
@@ -71,6 +81,7 @@ module Jeapie
|
|
71
81
|
errors ? false : true
|
72
82
|
end
|
73
83
|
|
84
|
+
# @return [true]
|
74
85
|
def notify!(opts={message:''})
|
75
86
|
raise DeliverException, errors unless notify(opts)
|
76
87
|
true
|
data/lib/jeapie/version.rb
CHANGED
data/whatsnew.md
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jeapie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -48,7 +48,9 @@ email:
|
|
48
48
|
- regrahc@gmail.com
|
49
49
|
executables: []
|
50
50
|
extensions: []
|
51
|
-
extra_rdoc_files:
|
51
|
+
extra_rdoc_files:
|
52
|
+
- whatsnew.md
|
53
|
+
- README.md
|
52
54
|
files:
|
53
55
|
- .gitignore
|
54
56
|
- Gemfile
|
@@ -60,10 +62,20 @@ files:
|
|
60
62
|
- lib/jeapie/version.rb
|
61
63
|
- spec/lib/jeapie_spec.rb
|
62
64
|
- spec/spec_helper.rb
|
65
|
+
- whatsnew.md
|
63
66
|
homepage: https://github.com/charger/jeapie
|
64
67
|
licenses: []
|
65
68
|
post_install_message:
|
66
|
-
rdoc_options:
|
69
|
+
rdoc_options:
|
70
|
+
- --line-numbers
|
71
|
+
- --inline-source
|
72
|
+
- --no-private
|
73
|
+
- --protected
|
74
|
+
- --title
|
75
|
+
- Jeapie
|
76
|
+
- --main
|
77
|
+
- README.md
|
78
|
+
- --encoding=UTF-8
|
67
79
|
require_paths:
|
68
80
|
- lib
|
69
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|