Module: Pushover
- Extended by:
- Pushover
- Included in:
- Pushover
- Defined in:
- lib/pushover.rb,
lib/pushover/app.rb,
lib/pushover/user.rb,
lib/pushover/config.rb,
lib/pushover/version.rb,
lib/pushover/optparser.rb
Overview
The primary pushover namespace.
Defined Under Namespace
Modules: App, User Classes: ConfigBlob, OptionParser
Constant Summary collapse
- Config =
A convenience instance of config, provides Pushover.Config.
ConfigBlob.new
- VERSION =
The current version of Pushover.
"0.3.1"
- Options =
Add a built in Options to the Pushover namespace, purely a convenience thing.
OptionParser.new
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Adds a rails style configure method.
- #keys ⇒ Object
-
#notification(message, title = nil, tokens = {}) ⇒ Object
push a message to across pushover, must supply all variables.
-
#parameters ⇒ Object
List available parameters and values in those params.
-
#parameters? ⇒ Boolean
Returns true or false if all parameters are set.
- #params ⇒ Object
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
19 20 21 |
# File 'lib/pushover.rb', line 19 def token @token end |
#user ⇒ Object
Returns the value of attribute user.
19 20 21 |
# File 'lib/pushover.rb', line 19 def user @user end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Adds a rails style configure method
33 34 35 36 |
# File 'lib/pushover.rb', line 33 def configure yield self parameters end |
#keys ⇒ Object
50 51 52 |
# File 'lib/pushover.rb', line 50 def keys keys ||= [:token, :user] end |
#notification(message, title = nil, tokens = {}) ⇒ Object
push a message to across pushover, must supply all variables.
22 23 24 25 26 27 28 29 30 |
# File 'lib/pushover.rb', line 22 def notification(, title = nil, tokens={}) url = URI.parse("https://api.pushover.net/1/messages.json") req = Net::HTTP::Post.new(url.path) req.set_form_data((params.merge(tokens.merge({:message => , :title => title})))) res = Net::HTTP.new(url.host, url.port) res.use_ssl = true res.verify_mode = OpenSSL::SSL::VERIFY_PEER res.start {|http| http.request(req) } end |
#parameters ⇒ Object
List available parameters and values in those params
39 40 41 42 43 |
# File 'lib/pushover.rb', line 39 def parameters @values = {} keys.each { |k| @values.merge! k => get_var("@#{k}") } @values end |
#parameters? ⇒ Boolean
Returns true or false if all parameters are set.
46 47 48 |
# File 'lib/pushover.rb', line 46 def parameters? parameters.values.all? end |
#params ⇒ Object
13 14 15 |
# File 'lib/pushover.rb', line 13 def params Pushover.parameters end |