cosm 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,7 +31,7 @@ class Cosm::Command::Help < Cosm::Command::Base
31
31
 
32
32
  def self.usage_for_command(command)
33
33
  command = new.send(:commands)[command]
34
- "Usage: cosm #{command[:banner]}" if command
34
+ "Usage: cosm #{command[:help]}" if command
35
35
  end
36
36
 
37
37
  private
@@ -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 && datastream_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
- subscribe = "{\"method\":\"subscribe\", \"resource\":\"/feeds/#{feed_id}/datastreams/#{datastream_id}\", \"headers\":{\"X-ApiKey\":\"#{api_key}\"}}"
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
@@ -1,3 +1,3 @@
1
1
  module Cosm
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.2
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: -153491597975561020
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: -153491597975561020
56
+ hash: 2287985111779659553
57
57
  requirements: []
58
58
  rubyforge_project:
59
59
  rubygems_version: 1.8.23