campfire-bot-absentee-camper 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ # 0.2.0
2
+
3
+ * Message now prefixed with "_user_ says:"
4
+
5
+ # 0.1.0
6
+
7
+ * Initial release
data/Gemfile CHANGED
@@ -8,6 +8,5 @@ group :development, :test do
8
8
  gem 'guard'
9
9
  gem 'guard-rspec'
10
10
  gem 'rake'
11
- gem 'ruby-debug19'
12
11
  gem 'growl'
13
12
  end
@@ -29,7 +29,7 @@ module CampfireBot
29
29
 
30
30
  # If the user isn't in the room, fire off a notification
31
31
  unless room.users.map { |u| u['id'] }.include? user_id_from_config(mentioned)
32
- NotificationManager.new(room, plugin_config['users'][mentioned]).send_notifications body
32
+ NotificationManager.new(msg, plugin_config['users'][mentioned]).send_notifications
33
33
  room.speak("[Notified #{mentioned}]")
34
34
  end
35
35
  end
@@ -3,7 +3,10 @@ module CampfireBot
3
3
  module Notification
4
4
  class NotificationManager
5
5
 
6
- def initialize(room, user_config)
6
+ def initialize(message, user_config)
7
+ @message = message
8
+ room = message[:room]
9
+
7
10
  if user_config.is_a?(Hash) and user_config['notification_methods']
8
11
  user_config['notification_methods'].each do |notifier, initialization_info|
9
12
  add_notifier Notification.const_get("#{notifier}Notifier".to_sym).new(room, initialization_info)
@@ -17,12 +20,16 @@ module CampfireBot
17
20
  end
18
21
  end
19
22
 
20
- def send_notifications(message)
21
- @notifiers.each { |notifier| notifier.notify message }
23
+ def send_notifications
24
+ @notifiers.each { |notifier| notifier.notify format_message(@message) }
22
25
  end
23
26
 
24
27
  private
25
28
 
29
+ def format_message(message)
30
+ "#{message[:person]} says: #{message[:message]}"
31
+ end
32
+
26
33
  def add_notifier(notifier)
27
34
  @notifiers ||= []
28
35
  @notifiers << notifier
@@ -1,5 +1,5 @@
1
1
  module CampfireBot
2
2
  module AbsenteeCamper
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -5,7 +5,6 @@ module CampfireBot
5
5
  module Notification
6
6
  describe EmailNotifier do
7
7
 
8
- let(:email_address) { "johnny@test.com" }
9
8
  let(:uri) { 'http://www.google.com' }
10
9
  let(:body) do
11
10
  body = <<-BODY
@@ -16,7 +15,7 @@ Come back to the campfire! We're having a good time telling ghost stories! Her
16
15
  #{uri}
17
16
  BODY
18
17
  end
19
- let(:message) { "this is a test" }
18
+ let(:message) { "Jon Levin says: this is a test" }
20
19
  let(:user_id) { 1 }
21
20
  let(:email_address) { 'jon.levin@shredders-r-us.com' }
22
21
  let(:room) do
@@ -41,7 +40,7 @@ BODY
41
40
  it "logs a message indicating the message is being sent" do
42
41
  Pony.stub(:mail)
43
42
  Logger.instance.should_receive(:debug).with("sending email to #{email_address}")
44
- subject.notify(message)
43
+ subject.notify message
45
44
  end
46
45
 
47
46
  it "sends the email with the correct information" do
@@ -50,7 +49,7 @@ BODY
50
49
  :body => body
51
50
  }.merge(pony_options))
52
51
 
53
- subject.notify(message)
52
+ subject.notify message
54
53
  end
55
54
  end
56
55
  end
@@ -6,6 +6,13 @@ module CampfireBot
6
6
  describe NotificationManager do
7
7
  let(:room) { double('room').as_null_object }
8
8
  let(:user_id) { 1 }
9
+ let(:message) do
10
+ {
11
+ :person => "Chad Boyd",
12
+ :message => "test",
13
+ :room => room
14
+ }
15
+ end
9
16
 
10
17
  before(:all) do
11
18
  NotificationManager.send :public, :add_notifier
@@ -103,12 +110,12 @@ module CampfireBot
103
110
 
104
111
  it "logs a message" do
105
112
  Logger.instance.should_receive(:debug).with(log_message)
106
- NotificationManager.new(room, user_info)
113
+ NotificationManager.new(message, user_info)
107
114
  end
108
115
 
109
116
  it "creates an EmailNotifier by default" do
110
117
  EmailNotifier.should_receive(:new).with(room, user_info)
111
- NotificationManager.new(room, user_info)
118
+ NotificationManager.new(message, user_info)
112
119
  end
113
120
  end
114
121
  end
@@ -118,7 +125,8 @@ module CampfireBot
118
125
  let(:user_info) do
119
126
  { 'id' => user_id }
120
127
  end
121
- let(:message) { "test" }
128
+ let(:user_name) { "Chad" }
129
+ let(:formatted_message) { "#{message[:person]} says: #{message[:message]}" }
122
130
 
123
131
  context "when there is only one notifier" do
124
132
  before do
@@ -127,8 +135,8 @@ module CampfireBot
127
135
 
128
136
  it "only sends one notification" do
129
137
  ProwlNotifier.any_instance.should_receive(:notify)
130
- manager = NotificationManager.new(room, user_info)
131
- manager.send_notifications message
138
+ manager = NotificationManager.new(message, user_info)
139
+ manager.send_notifications
132
140
  end
133
141
  end
134
142
 
@@ -143,15 +151,15 @@ module CampfireBot
143
151
  it "only sends one notification" do
144
152
  ProwlNotifier.any_instance.should_receive(:notify)
145
153
  EmailNotifier.any_instance.should_receive(:notify)
146
- manager = NotificationManager.new(room, user_info)
147
- manager.send_notifications message
154
+ manager = NotificationManager.new(message, user_info)
155
+ manager.send_notifications
148
156
  end
149
157
  end
150
158
 
151
159
  it "sends the correct message" do
152
- EmailNotifier.any_instance.should_receive(:notify).with(message)
153
- manager = NotificationManager.new(room, user_id)
154
- manager.send_notifications message
160
+ EmailNotifier.any_instance.should_receive(:notify).with(formatted_message)
161
+ manager = NotificationManager.new(message, user_id)
162
+ manager.send_notifications
155
163
  end
156
164
  end
157
165
  end
@@ -91,11 +91,11 @@ module CampfireBot
91
91
 
92
92
  NotificationManager
93
93
  .should_receive(:new)
94
- .with(room, users_in_config[name])
94
+ .with(message, users_in_config[name])
95
95
  .and_return(notification_manager)
96
96
  end
97
97
 
98
- notification_manager.should_receive(:send_notifications).with(message['body']).exactly(times).times
98
+ notification_manager.should_receive(:send_notifications).exactly(times).times
99
99
  subject.role_call message
100
100
  end
101
101
  end
@@ -130,10 +130,10 @@ module CampfireBot
130
130
  def sends_notification_to(name)
131
131
  NotificationManager
132
132
  .should_receive(:new)
133
- .with(room, users_in_config[name])
133
+ .with(message, users_in_config[name])
134
134
  .and_return(notification_manager)
135
135
 
136
- notification_manager.should_receive(:send_notifications).with(message['body'])
136
+ notification_manager.should_receive(:send_notifications)
137
137
  end
138
138
 
139
139
  def does_not_send_notification
@@ -1,7 +1,6 @@
1
1
  require "rubygems"
2
2
  require "bundler/setup"
3
3
  Bundler.require(:default, :test)
4
- require 'ruby-debug'
5
4
 
6
5
  BOT_ROOT = File.join(FileUtils.pwd, 'spec')
7
6
  BOT_ENVIRONMENT = 'test'
@@ -11,6 +10,9 @@ require 'absentee_camper'
11
10
  RSpec.configure do |config|
12
11
  config.include CampfireBot::AbsenteeCamper::Notification
13
12
  config.include CampfireBot::AbsenteeCamper::Config
13
+ config.treat_symbols_as_metadata_keys_with_true_values = true
14
+ config.filter_run focus: true
15
+ config.run_all_when_everything_filtered = true
14
16
 
15
17
  config.before do
16
18
  CampfireBot::AbsenteeCamper::Logger.stub(:instance).and_return(double('logger').as_null_object)
metadata CHANGED
@@ -1,60 +1,80 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: campfire-bot-absentee-camper
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - hoverlover
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2011-10-13 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
16
+
17
+ date: 2011-12-07 00:00:00 -06:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: campfire-bot
16
- requirement: &70221517964260 !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
17
24
  none: false
18
- requirements:
25
+ requirements:
19
26
  - - ~>
20
- - !ruby/object:Gem::Version
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ - 0
31
+ - 1
21
32
  version: 0.0.1
22
33
  type: :runtime
23
- prerelease: false
24
- version_requirements: *70221517964260
25
- - !ruby/object:Gem::Dependency
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
26
36
  name: pony
27
- requirement: &70221517963420 !ruby/object:Gem::Requirement
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
28
39
  none: false
29
- requirements:
40
+ requirements:
30
41
  - - ~>
31
- - !ruby/object:Gem::Version
32
- version: '1.3'
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 1
45
+ - 3
46
+ version: "1.3"
33
47
  type: :runtime
34
- prerelease: false
35
- version_requirements: *70221517963420
36
- - !ruby/object:Gem::Dependency
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
37
50
  name: prowl
38
- requirement: &70221517962640 !ruby/object:Gem::Requirement
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
39
53
  none: false
40
- requirements:
54
+ requirements:
41
55
  - - ~>
42
- - !ruby/object:Gem::Version
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 0
59
+ - 1
60
+ - 3
43
61
  version: 0.1.3
44
62
  type: :runtime
45
- prerelease: false
46
- version_requirements: *70221517962640
47
- description: Plugin for campfire-bot that monitors incoming messages and notifies
48
- a user that is @mentioned if they aren't present.
49
- email:
63
+ version_requirements: *id003
64
+ description: Plugin for campfire-bot that monitors incoming messages and notifies a user that is @mentioned if they aren't present.
65
+ email:
50
66
  - hoverlover@gmail.com
51
67
  executables: []
68
+
52
69
  extensions: []
70
+
53
71
  extra_rdoc_files: []
54
- files:
72
+
73
+ files:
55
74
  - .gitignore
56
75
  - .rspec
57
76
  - .travis.yml
77
+ - CHANGELOG.md
58
78
  - Gemfile
59
79
  - Guardfile
60
80
  - README.md
@@ -75,32 +95,39 @@ files:
75
95
  - spec/lib/campfire_bot/absentee_camper/notification/prowl_notifier_spec.rb
76
96
  - spec/lib/campfire_bot/absentee_camper_spec.rb
77
97
  - spec/spec_helper.rb
78
- homepage: ''
98
+ has_rdoc: true
99
+ homepage: ""
79
100
  licenses: []
101
+
80
102
  post_install_message:
81
103
  rdoc_options: []
82
- require_paths:
104
+
105
+ require_paths:
83
106
  - lib/campfire_bot
84
- required_ruby_version: !ruby/object:Gem::Requirement
107
+ required_ruby_version: !ruby/object:Gem::Requirement
85
108
  none: false
86
- requirements:
87
- - - ! '>='
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ segments:
113
+ - 0
114
+ version: "0"
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
116
  none: false
92
- requirements:
93
- - - ! '>='
94
- - !ruby/object:Gem::Version
95
- version: '0'
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ segments:
121
+ - 0
122
+ version: "0"
96
123
  requirements: []
124
+
97
125
  rubyforge_project: campfire-bot-absentee-camper
98
- rubygems_version: 1.8.10
126
+ rubygems_version: 1.3.7
99
127
  signing_key:
100
128
  specification_version: 3
101
- summary: Plugin for campfire-bot that monitors incoming messages and notifies a user
102
- that is @mentioned if they aren't present.
103
- test_files:
129
+ summary: Plugin for campfire-bot that monitors incoming messages and notifies a user that is @mentioned if they aren't present.
130
+ test_files:
104
131
  - spec/absentee-camper-config.yml
105
132
  - spec/config.yml
106
133
  - spec/lib/campfire_bot/absentee_camper/notification/email_notifier_spec.rb