thingdom 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/README.md +1 -1
- data/lib/tasks/baseTask.rb +12 -1
- data/lib/tasks/feedTask.rb +9 -0
- data/lib/tasks/statusTask.rb +9 -0
- data/lib/tasks/thingTask.rb +10 -1
- data/lib/thingdom/version.rb +1 -1
- data/lib/webService.rb +2 -1
- metadata +1 -1
data/README.md
CHANGED
data/lib/tasks/baseTask.rb
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
#
|
|
2
|
+
# A psuedo abstract class that provides common functionality for performing Thing tasks.
|
|
3
|
+
# These are: retrieving a thing, updating status and sending a feed.
|
|
4
|
+
#
|
|
2
5
|
class BaseTask
|
|
3
6
|
|
|
7
|
+
#
|
|
8
|
+
# Constructor method for base task. Initialize web service and the thing for which
|
|
9
|
+
# tasks will be performed.
|
|
10
|
+
#
|
|
11
|
+
# @param [WebService] webService A web service to be used by the task.
|
|
12
|
+
# @param [Thing] thing The thing for which the task is being performed.
|
|
13
|
+
# @param [boolean] isThingTask True if the task is retrieving or creating a thing.
|
|
14
|
+
#
|
|
4
15
|
def initialize( webService, thing, isThingTask )
|
|
5
16
|
@web = webService
|
|
6
17
|
@thing = thing
|
data/lib/tasks/feedTask.rb
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
#
|
|
2
|
+
# A class that does the work for adding a feed to a thing.
|
|
3
|
+
#
|
|
1
4
|
require_relative( 'baseTask' )
|
|
2
5
|
|
|
3
6
|
class FeedTask < BaseTask
|
|
4
7
|
|
|
8
|
+
#
|
|
9
|
+
# Constructor method for feed task. Initialize feed attributes.
|
|
10
|
+
#
|
|
5
11
|
def initialize( webService, thing, category, message, feedOptions )
|
|
6
12
|
super( webService, thing, false )
|
|
7
13
|
@web = webService
|
|
@@ -11,6 +17,9 @@ class FeedTask < BaseTask
|
|
|
11
17
|
@feedOptions = feedOptions
|
|
12
18
|
end
|
|
13
19
|
|
|
20
|
+
#
|
|
21
|
+
# Do the work for the feed task.
|
|
22
|
+
#
|
|
14
23
|
def do_task_work
|
|
15
24
|
@web.add_feed( @thing, @category, @message, @feedOptions )
|
|
16
25
|
end
|
data/lib/tasks/statusTask.rb
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
#
|
|
2
|
+
# A class that does the work for updating the status for a thing.
|
|
3
|
+
#
|
|
1
4
|
require_relative( 'baseTask' )
|
|
2
5
|
|
|
3
6
|
class StatusTask < BaseTask
|
|
4
7
|
|
|
8
|
+
#
|
|
9
|
+
# Constructor method for status task. Initialize status update array.
|
|
10
|
+
#
|
|
5
11
|
def initialize( webService, thing, *args )
|
|
6
12
|
super( webService, thing, false )
|
|
7
13
|
@web = webService
|
|
@@ -9,6 +15,9 @@ class StatusTask < BaseTask
|
|
|
9
15
|
@statusUpdates = statusArgsToArray( *args )
|
|
10
16
|
end
|
|
11
17
|
|
|
18
|
+
#
|
|
19
|
+
# Do the work for the status task.
|
|
20
|
+
#
|
|
12
21
|
def do_task_work
|
|
13
22
|
@web.add_status( @thing, @statusUpdates )
|
|
14
23
|
end
|
data/lib/tasks/thingTask.rb
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
|
+
#
|
|
2
|
+
# A class that does the work for creating or retrieving a thing.
|
|
3
|
+
#
|
|
1
4
|
require_relative ( 'baseTask' )
|
|
2
5
|
|
|
3
6
|
class ThingTask < BaseTask
|
|
4
7
|
|
|
8
|
+
#
|
|
9
|
+
# The constructor method for thing task.
|
|
10
|
+
#
|
|
5
11
|
def initialize( webService, thing )
|
|
6
12
|
super( webService, thing, true )
|
|
7
13
|
@web = webService
|
|
8
|
-
@thing =
|
|
14
|
+
@thing = thing
|
|
9
15
|
end
|
|
10
16
|
|
|
17
|
+
#
|
|
18
|
+
# Do the work for the thing task.
|
|
19
|
+
#
|
|
11
20
|
def do_task_work
|
|
12
21
|
@web.add_thing( @thing )
|
|
13
22
|
end
|
data/lib/thingdom/version.rb
CHANGED
data/lib/webService.rb
CHANGED
|
@@ -32,7 +32,8 @@ class WebService
|
|
|
32
32
|
# @return [Hash] A hash containing the authorization response:
|
|
33
33
|
# application_token - The token used in subsequent communications with Thingdom
|
|
34
34
|
# expires_in - The number of seconds remaining before above token expires.
|
|
35
|
-
# device_secret - A unique identifier for device running this application
|
|
35
|
+
# device_secret - A unique identifier for device running this application
|
|
36
|
+
# (always "none" for the Ruby wrapper)
|
|
36
37
|
#
|
|
37
38
|
def get_authorization()
|
|
38
39
|
data = {
|