cosm 0.0.2 → 0.0.3
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/cosm/command/help.rb +1 -1
- data/lib/cosm/command/subscribe.rb +12 -6
- data/lib/cosm/version.rb +1 -1
- metadata +3 -3
data/lib/cosm/command/help.rb
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
require 'cosm/command/base'
|
2
2
|
require 'socket'
|
3
3
|
|
4
|
-
# Subscribe to a datastream via the Cosm PAWS (Socket Server)
|
4
|
+
# Subscribe to a feed or datastream via the Cosm PAWS (Socket Server)
|
5
5
|
#
|
6
6
|
class Cosm::Command::Subscribe < Cosm::Command::Base
|
7
7
|
|
8
8
|
# subscribe
|
9
9
|
#
|
10
|
-
# connect to a tcp socket for a datastream
|
10
|
+
# connect to a tcp socket for a feed or datastream
|
11
11
|
#
|
12
12
|
# -k, --key API_KEY # your api key
|
13
13
|
# -f, --feed FEED # the feed id
|
14
|
-
# -d, --datastream DATASTREAM # the datastream id
|
14
|
+
# -d, --datastream DATASTREAM # the datastream id (optional)
|
15
15
|
#
|
16
16
|
#Example:
|
17
17
|
#
|
18
|
-
# $ cosm subscribe -k ABCD1234 -f 504 -d 0
|
18
|
+
# $ cosm subscribe -k ABCD1234 -f 504 -d 0 # subscribe to datastream
|
19
|
+
# $ cosm subscribe -k ABCD1234 -f 504 # subscribe to feed
|
19
20
|
#
|
20
21
|
def index
|
21
22
|
api_key = options[:key]
|
@@ -24,12 +25,17 @@ class Cosm::Command::Subscribe < Cosm::Command::Base
|
|
24
25
|
|
25
26
|
validate_arguments!
|
26
27
|
|
27
|
-
unless api_key && feed_id
|
28
|
+
unless api_key && feed_id
|
28
29
|
puts Cosm::Command::Help.usage_for_command("subscribe")
|
29
30
|
exit(1)
|
30
31
|
end
|
31
32
|
|
32
|
-
|
33
|
+
resource = "/feeds/#{feed_id}"
|
34
|
+
resource += "/datastreams/#{datastream_id}" if datastream_id
|
35
|
+
|
36
|
+
puts "Subscribing to updates for #{resource}"
|
37
|
+
|
38
|
+
subscribe = "{\"method\":\"subscribe\", \"resource\":\"#{resource}\", \"headers\":{\"X-ApiKey\":\"#{api_key}\"}}"
|
33
39
|
s = TCPSocket.new 'api.cosm.com', 8081
|
34
40
|
s.puts subscribe
|
35
41
|
while line = s.gets
|
data/lib/cosm/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cosm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -44,7 +44,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
44
44
|
version: '0'
|
45
45
|
segments:
|
46
46
|
- 0
|
47
|
-
hash:
|
47
|
+
hash: 2287985111779659553
|
48
48
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
53
|
version: '0'
|
54
54
|
segments:
|
55
55
|
- 0
|
56
|
-
hash:
|
56
|
+
hash: 2287985111779659553
|
57
57
|
requirements: []
|
58
58
|
rubyforge_project:
|
59
59
|
rubygems_version: 1.8.23
|