Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

FIXED: Register multiple notification causes error.

  • Loading branch information...
commit 43f5e34e7a5992db620166a5284899ea9ba7f087 1 parent ec51b5d
snaka authored
48 ChangeLog
View
@@ -1,37 +1,41 @@
= ruby_gntp change log
-== Version 0.0.0
-* Create public Git repository
-
-== Version 0.0.1
-* Initial version
+== Version 0.3.4 - 2010/02/02
+* FIXED: Register doesn't work with multiple notifications.
+* Modify ChangeLog order.
-== Version 0.0.2
-* Fixed Japanese translated MIT License page URL.
+== Version 0.3.3 - 2010/01/26
+* Temporary patchwork fix - The code was commented out that recognize version
+of the OS causes some defects -
-== Version 0.1.0 - 2009/4/17
-* Add GNTP.notify method for instant notification.
-* Add ruby script examples.
+== Version 0.3.1 - yyyy/mm/dd
-== Version 0.1.1 - 2009/4/17
-* Add NOTE to example directory.
+== Version 0.3.0 - yyyy/mm/dd
-== Version 0.1.2 - 2009/08/15
-* Enabled password authentication mainly for sending notifications to a network machine.
+== Version 0.2.0 - 2009/11/03
+* Merge spidahman's commits. Lot of thanks, spidahman!
+* Add some test(spec).
== Version 0.1.3 - 2009/08/19
* Added notification icon sending.
* Now sends out Origin-X headers.
* Use \r\n instead of \n in the header lines.
-== Version 0.2.0 - 2009/11/03
-* Merge spidahman's commits. Lot of thanks, spidahman!
-* Add some test(spec).
+== Version 0.1.2 - 2009/08/15
+* Enabled password authentication mainly for sending notifications to a network machine.
-== Version 0.3.0 - yyyy/mm/dd
+== Version 0.1.1 - 2009/4/17
+* Add NOTE to example directory.
-== Version 0.3.1 - yyyy/mm/dd
+== Version 0.1.0 - 2009/4/17
+* Add GNTP.notify method for instant notification.
+* Add ruby script examples.
-== Version 0.3.2 - 2010/01/26
-* Temporary patchwork fix - The code was commented out that recognize version
-of the OS causes some defects -
+== Version 0.0.2
+* Fixed Japanese translated MIT License page URL.
+
+== Version 0.0.1
+* Initial version
+
+== Version 0.0.0
+* Create public Git repository
8 example/NOTE
View
@@ -0,0 +1,8 @@
+Attention when twitter_notifier.rb is used
+Following gem is necessary to operate this script.
+- json_pure
+- pit
+
+Please ensure that an appropriate value to environment variable EDITOR is set if you start and use Pit.
+Pit starts executing the editor command set to EDITOR for the edit of account information, and the script will not operate correctly when this variable is not appropriately set.
+
BIN  gems/ruby_gntp-0.1.0.gem
View
Binary file not shown
BIN  gems/ruby_gntp-0.3.4.gem
View
Binary file not shown
9 lib/ruby_gntp.rb
View
@@ -42,7 +42,7 @@ class GNTP
attr_reader :message if $DEBUG
RUBY_GNTP_NAME = 'ruby_gntp'
- RUBY_GNTP_VERSION = '0.3.3'
+ RUBY_GNTP_VERSION = '0.3.4'
def initialize(app_name = 'Ruby/GNTP', host = 'localhost', password = '', port = 23053)
@app_name = app_name
@@ -75,16 +75,17 @@ def register(params)
icon = notification[:icon]
message << "Notification-Name: #{name}\r\n"
- message << "Notification-Enabled: #{enabled ? 'True' : 'False'}\r\n"
message << "Notification-Display-Name: #{disp_name}\r\n"
+ message << "Notification-Enabled: #{enabled ? 'True' : 'False'}\r\n"
message << "#{handle_icon(icon, 'Notification')}\r\n" if icon
+ message << "\r\n"
end
@binaries.each {|binary|
message << output_binary(binary)
+ message << "\r\n"
}
- message << "\r\n"
unless (ret = send_and_recieve(message))
raise "Register failed"
@@ -238,7 +239,7 @@ def output_origin_headers
# platformname, platformversion = `uname -s`, `uname -r`
#end
platformname = "Windows"
- platformname = "0.0"
+ platformversion = "0.0"
message << "Origin-Platform-Name: #{platformname.strip}\r\n"
message << "Origin-Platform-Version: #{platformversion.strip}\r\n"
29 test/many_notifications.rb
View
@@ -0,0 +1,29 @@
+require '../lib/ruby_gntp'
+
+g = GNTP.new("test")
+
+g.register( :notifications => [
+ { :name => "notify", :enabled => true },
+ { :name => "warning", :enabled => true },
+ { :name => "error", :enabled => true },
+])
+
+g.notify(
+ :name => "notify",
+ :title => "Test",
+ :text => "hoge fuga"
+)
+
+g.notify(
+ :name => "warning",
+ :title => "warning",
+ :text => "Warn!"
+)
+
+g.notify(
+ :name => "error",
+ :title => "error",
+ :text => "ERROR"
+)
+
+
36 test/ruby_gntp_spec.rb
View
@@ -11,7 +11,9 @@
include GNTPExampleHelperMethods
DEFAULT_APP_NAME = "Ruby/GNTP"
- NOTIFICATION_NAME = "TestApp"
+ NOTIFICATION_NAME = "Notify"
+ NOTIFICATION_NAME2 = "Notify2"
+ NOTIFICATION_NAME3 = "Notify3"
before do
@sended_messages = []
@@ -19,7 +21,7 @@
@opened_socket = create_stub_socket(@ok_response, @sended_messages)
end
- it "can register notifications with minimum params" do
+ it "can register notification with minimum params" do
@gntp = GNTP.new
@gntp.register :notifications => [{:name => NOTIFICATION_NAME}]
@@ -37,6 +39,36 @@
end
+ #
+ it "can register many notifications" do
+ @gntp = GNTP.new
+ @gntp.register :notifications => [
+ {:name => NOTIFICATION_NAME},
+ {:name => NOTIFICATION_NAME2},
+ ]
+
+ @sended_messages.first.should == [
+ "GNTP/1.0 REGISTER NONE\r\n",
+ "Application-Name: #{DEFAULT_APP_NAME}\r\n",
+ "Origin-Machine-Name: #{Socket.gethostname}\r\n",
+ "Origin-Software-Name: #{GNTP::RUBY_GNTP_NAME}\r\n",
+ "Origin-Software-Version: #{GNTP::RUBY_GNTP_VERSION}\r\n",
+ "Origin-Platform-Name: Windows\r\n",
+ "Origin-Platform-Version: 0.0\r\n",
+ "Notifications-Count: 2\r\n",
+ "\r\n",
+ "Notification-Name: #{NOTIFICATION_NAME}\r\n",
+ "Notification-Display-Name: #{NOTIFICATION_NAME}\r\n",
+ "Notification-Enabled: True\r\n",
+ "\r\n",
+ "Notification-Name: #{NOTIFICATION_NAME2}\r\n",
+ "Notification-Display-Name: #{NOTIFICATION_NAME2}\r\n",
+ "Notification-Enabled: True\r\n",
+ "\r\n",
+ ]
+
+ end
+
it "can register notifications to remote host" do
@gntp = GNTP.new "TestApp", "1.2.3.4", "password", 12345
@gntp.register :notifications => [{:name => NOTIFICATION_NAME}]
Please sign in to comment.
Something went wrong with that request. Please try again.