duwanis-rubyku 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/lib/rubyku/errors.rb +6 -0
- data/lib/rubyku/request.rb +28 -1
- data/lib/rubyku/settings.rb +3 -3
- metadata +1 -2
data/lib/rubyku/errors.rb
CHANGED
data/lib/rubyku/request.rb
CHANGED
@@ -9,8 +9,13 @@ module Rubyku
|
|
9
9
|
# This method uses the given url and credentials to retrieve
|
10
10
|
# JSON data from the Jaiku servers.
|
11
11
|
# returns: +Hash+ containing the JSON data.
|
12
|
+
#
|
13
|
+
# raises:
|
14
|
+
# - Rubyku::Error if there is a problem communicating with the servers.
|
15
|
+
# - Rubyku::UpdateError if there was an error within Jaiku attempting to
|
16
|
+
# parse the update.
|
12
17
|
#
|
13
|
-
def retrieve_json_object(url_path, jaiku_credentials)
|
18
|
+
def retrieve_json_object(url_path, jaiku_credentials = Rubyku::Settings.jaiku_credentials)
|
14
19
|
log = Rubyku::Settings.logger
|
15
20
|
log.info("About to request JSON from #{url_path}")
|
16
21
|
url_path += jaiku_credentials.request_string
|
@@ -25,6 +30,28 @@ module Rubyku
|
|
25
30
|
log.debug("About to return JSON: " + res.body)
|
26
31
|
JSON(res.body)
|
27
32
|
end
|
33
|
+
|
34
|
+
def update(message, generated = false, icon = 300,
|
35
|
+
jaiku_credentials = Rubyku::Settings.jaiku_credentials)
|
36
|
+
log = Rubyku::Settings.logger
|
37
|
+
log.info("Attempting to update with message #{message}")
|
38
|
+
url = URI.parse('http://api.jaiku.com/json')
|
39
|
+
res = Net::HTTP.post_form(url,
|
40
|
+
{'method'=> 'presence.send',
|
41
|
+
'message'=> message,
|
42
|
+
'icon'=> icon,
|
43
|
+
'generated' => generated,
|
44
|
+
'user' => jaiku_credentials.username,
|
45
|
+
'personal_key' => jaiku_credentials.api_key})
|
46
|
+
unless res.code == "200"
|
47
|
+
raise Rubyku::Error, "Problem communicating with Jaiku servers."
|
48
|
+
end
|
49
|
+
response = JSON(res.body)
|
50
|
+
unless response['status'] == "ok"
|
51
|
+
raise Rubyku::UpdateError, "Error updating presence, #{response.status}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
28
55
|
end
|
29
56
|
end
|
30
57
|
|
data/lib/rubyku/settings.rb
CHANGED
@@ -8,8 +8,8 @@ module Rubyku
|
|
8
8
|
# - +proxy_url+: the url for an http proxy, if needed.
|
9
9
|
# - +proxy_port+: the port for an http proxy, if needed.
|
10
10
|
#
|
11
|
-
# The logger, by default, will log at Logger::INFO to
|
12
|
-
#
|
11
|
+
# The logger, by default, will log at Logger::INFO to STDOUT.
|
12
|
+
# If you would like to integrate the rubyku
|
13
13
|
# logging statements into your own logs, simply replace the logger with your own
|
14
14
|
# at some point after including rubyku in your project.
|
15
15
|
# *WARNING*: a logger set to Logger::DEBUG will spit all kinds of user-sensitive
|
@@ -36,7 +36,7 @@ module Rubyku
|
|
36
36
|
end
|
37
37
|
|
38
38
|
#initialize the default logger
|
39
|
-
Rubyku::Settings.logger= Logger.new(
|
39
|
+
Rubyku::Settings.logger= Logger.new(STDOUT)
|
40
40
|
Rubyku::Settings.logger.sev_threshold = Logger::INFO #DON'T set this line to DEBUG.
|
41
41
|
# Do that in your own code if you want. Rubyku spews user information and such on DEBUG
|
42
42
|
# And so it would be a very bad idea for DEBUG to make it into the gem.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: duwanis-rubyku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tommy Morgan
|
@@ -40,7 +40,6 @@ files:
|
|
40
40
|
- lib/rubyku/version.rb
|
41
41
|
- LICENSE
|
42
42
|
- README
|
43
|
-
- logs/
|
44
43
|
has_rdoc: true
|
45
44
|
homepage: http://github.com/duwanis/rubyku
|
46
45
|
post_install_message:
|