shoutbox-client 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -11,9 +11,14 @@ You can use it via ruby
11
11
  ruby-1.9.2-p0 > ShoutboxClient.shout :name => "My Rake Task", :status => :red, :message => 'failed miserably'
12
12
  true
13
13
 
14
- ruby-1.9.2-p0 > ShoutboxClient.shout :name => "My Other Task", :status => :green, :expires_in => 1.hour
15
- true
16
-
14
+ ruby-1.9.2-p0 > ShoutboxClient.shout :name => "My Other Task", :status => :green, :expires_in => 1.hour
15
+ true
16
+
17
+ if you want to set an explicit name to be displayed on your shoutbox, pass the option :display_name
18
+
19
+ ruby-1.9.2-p0 > ShoutboxClient.shout :name => "My Other Task", :status => :green, :expires_in => 1.hour, :display_name => 'TOLD YOU SO!'
20
+ true
21
+
17
22
  or as a shell script
18
23
 
19
24
  benjamin@Jiji % shout green 'important task'
@@ -24,8 +29,7 @@ Configuration
24
29
  The shoutbox-client will look for a ~/.shoutbox config file with a hostname and portnumber
25
30
  in YAML format, like this
26
31
 
27
- host: localhost
28
- port: 3001
32
+ host: http://shoutbox.io
29
33
  auth_token: my-shoutbox-auth-token
30
34
 
31
35
 
@@ -33,12 +37,13 @@ Otherwise you can set the configuration manually via ruby
33
37
 
34
38
  ShoutboxClient.configuration.config_file = 'some/file'
35
39
  # or
36
- ShoutboxClient.configuration.host = 'shoutbox.moviepilot.com'
37
- ShoutboxClient.configuration.port = 80
40
+ ShoutboxClient.configuration.host = 'http://shoutbox.moviepilot.com:991'
38
41
 
39
42
  The shell script accepts host and port parameters
40
43
 
41
- benjamin@Jiji % shout red important-task -h shoutbox.moviepilot.com -p 80
44
+ benjamin@Jiji % shout red important-task "failed!" -h "http://shoutbox.moviepilot.com"
45
+
46
+ Try shout --help for all the options
42
47
 
43
48
 
44
49
  Contributing to shoutbox-client
@@ -28,10 +28,11 @@ shout remove db-export
28
28
  shout allows the folling options:
29
29
  EOS
30
30
  opt :host, "The hostname of the Shoutbox", :type => String
31
- opt :port, "The port of the Shoutbox", :type => Integer
32
31
  opt :proxy_host, "The proxy host to use", :type => String
33
32
  opt :proxy_port, "The proxy port to use", :type => Integer
34
33
  opt :group, "The group to use", :type => String
34
+ opt :display, "The display name", :type => String
35
+ opt :auth_token, "The auth-token to use", :type => String
35
36
  opt :expires_in, "Number of seconds this status should expire in", :type => Integer
36
37
  end
37
38
 
@@ -54,12 +55,13 @@ EOS
54
55
 
55
56
  Trollop::die "provide <status> and <name>" unless @conf[:status] and @conf[:name]
56
57
 
57
- ShoutboxClient.configuration.host = @conf[:host] if @conf[:host]
58
- ShoutboxClient.configuration.port = @conf[:port] if @conf[:port]
58
+ ShoutboxClient.configuration.host = @conf[:host] if @conf[:host]
59
+ ShoutboxClient.configuration.port = @conf[:port] if @conf[:port]
60
+ ShoutboxClient.configuration.auth_token = @conf[:auth_token] if @conf[:auth_token]
59
61
  end
60
62
 
61
63
  def do_it
62
- ShoutboxClient.shout :name => @conf[:name], :status => @conf[:status], :group => @conf[:group], :message => @conf[:message], :expires_in => @conf[:expires_in]
64
+ ShoutboxClient.shout :name => @conf[:name], :status => @conf[:status], :group => @conf[:group], :message => @conf[:message], :expires_in => @conf[:expires_in], :display_name => @conf[:display]
63
65
  end
64
66
  end
65
67
  end
@@ -32,8 +32,9 @@ class ShoutboxClient
32
32
  req = Net::HTTP::Put.new( request_url(options) )
33
33
  default_headers(req)
34
34
  body_data = { :name => options[:name], :group => (options[:group] || configuration.default_group), :status => options[:status].to_s }
35
- body_data[:message] = options[:message] if options[:message]
36
- body_data[:expires_in] = options[:expires_in] if options[:expires_in]
35
+ body_data[:message] = options[:message] if options[:message]
36
+ body_data[:expires_in] = options[:expires_in] if options[:expires_in]
37
+ body_data[:display_name] = options[:display_name] if options[:display_name]
37
38
  raise ArgumentError if (options[:status] == :red or options[:status] == :yellow) and body_data[:message].to_s.empty?
38
39
  req.body = body_data.to_json
39
40
  http.request(req)
@@ -73,4 +74,4 @@ class ShoutboxClient
73
74
  def self.valid_status?( status )
74
75
  VALID_STATUS.keys.include?( status.to_s )
75
76
  end
76
- end
77
+ end
@@ -79,6 +79,16 @@ describe "ShoutboxClient" do
79
79
  ShoutboxClient.shout( :name => "test_status", :status => :red, :message => "This is what you should do now.." ).should == true
80
80
  end
81
81
 
82
+ it 'should contain the display name when option given' do
83
+ stub_request(:put, "http://shoutbox.io/status").
84
+ with(:body => "{\"name\":\"test_status\",\"group\":\"my_group\",\"status\":\"green\",\"display_name\":\"I TOLD YOU SO!\"}",
85
+ :headers => {'Accept'=>'application/json', 'User-Agent'=>'Ruby shoutbox-client', 'X-Shoutbox-Auth-Token' => 'invalid-auth-token'}).
86
+ to_return(:status => 200, :body => "OK", :headers => {})
87
+
88
+ ShoutboxClient.shout( :group => "my_group", :name => "test_status", :status => :green, :display_name => 'I TOLD YOU SO!' ).should == true
89
+
90
+ end
91
+
82
92
  it 'should include an expiration time when given' do
83
93
  stub_request(:put, "http://shoutbox.io/status").
84
94
  with(:body => "{\"name\":\"test_status\",\"group\":\"Home\",\"status\":\"green\",\"expires_in\":3600}",
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: shoutbox-client
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.1
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Benjamin Krause
@@ -10,7 +10,7 @@ autorequire: shoutbox_client
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-14 00:00:00 +02:00
13
+ date: 2011-07-18 00:00:00 +02:00
14
14
  default_executable: shout
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -111,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
111
  requirements:
112
112
  - - ">="
113
113
  - !ruby/object:Gem::Version
114
- hash: 4047158430543841235
114
+ hash: 2560211999808166080
115
115
  segments:
116
116
  - 0
117
117
  version: "0"