Module: Groem::Marshal::Request
Defined Under Namespace
Modules: ClassMethods
Constant Summary
Constants included from Constants
Constants::ENVIRONMENT_KEY, Constants::GNTP_APPLICATION_ICON_KEY, Constants::GNTP_APPLICATION_NAME_KEY, Constants::GNTP_CALLBACK_RESPONSE, Constants::GNTP_CLICK_CALLBACK_RESULT, Constants::GNTP_CLOSE_CALLBACK_RESULT, Constants::GNTP_DEFAULT_ENVIRONMENT, Constants::GNTP_ENCRYPTION_ID_KEY, Constants::GNTP_ERROR_CODE_KEY, Constants::GNTP_ERROR_CODE_OK, Constants::GNTP_ERROR_RESPONSE, Constants::GNTP_NOTIFICATION_CALLBACK_CONTEXT_KEY, Constants::GNTP_NOTIFICATION_CALLBACK_CONTEXT_TYPE_KEY, Constants::GNTP_NOTIFICATION_CALLBACK_RESULT_KEY, Constants::GNTP_NOTIFICATION_CALLBACK_TARGET_KEY, Constants::GNTP_NOTIFICATION_CALLBACK_TIMESTAMP_KEY, Constants::GNTP_NOTIFICATION_COUNT_KEY, Constants::GNTP_NOTIFICATION_ICON_KEY, Constants::GNTP_NOTIFICATION_ID_KEY, Constants::GNTP_NOTIFICATION_NAME_KEY, Constants::GNTP_NOTIFY_METHOD, Constants::GNTP_OK_RESPONSE, Constants::GNTP_PROTOCOL_KEY, Constants::GNTP_REGISTER_METHOD, Constants::GNTP_REQUEST_METHOD_KEY, Constants::GNTP_RESPONSE_ACTION_KEY, Constants::GNTP_RESPONSE_METHOD_KEY, Constants::GNTP_SUBSCRIBE_METHOD, Constants::GNTP_TIMEDOUT_CALLBACK_RESULT, Constants::GNTP_VERSION_KEY, Constants::HEADERS_KEY, Constants::NOTIFICATIONS_KEY
Class Method Summary collapse
Instance Method Summary collapse
-
#dump ⇒ Object
write GNTP request string, print lines as rn assumes that including class delegates :[] to raw hash (described below under load).
Methods included from Constants
#growlify_action, #growlify_key
Class Method Details
.included(mod) ⇒ Object
9 10 11 |
# File 'lib/groem/marshal.rb', line 9 def self.included(mod) mod.extend ClassMethods end |
Instance Method Details
#dump ⇒ Object
write GNTP request string, print lines as rn assumes that including class delegates :[] to raw hash
(described below under load).
TODO: calculate UUIDs for binary sections and output them
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/groem/marshal.rb', line 17 def dump out = [] env = GNTP_DEFAULT_ENVIRONMENT.merge(self[ENVIRONMENT_KEY]) hdrs = self[HEADERS_KEY] notifs = self[NOTIFICATIONS_KEY] out << "#{env[(GNTP_PROTOCOL_KEY)]}" + "/#{env[(GNTP_VERSION_KEY)]} "+ "#{env[(GNTP_REQUEST_METHOD_KEY)]} "+ "#{env[(GNTP_ENCRYPTION_ID_KEY)]}" hdrs.each_pair do |k, v| unless v.nil? out << "#{(k)}: #{v}" end end if env[(GNTP_REQUEST_METHOD_KEY)] == GNTP_REGISTER_METHOD out << "#{GNTP_NOTIFICATION_COUNT_KEY}: #{notifs.keys.count}" out << nil notifs.each_pair do |name, pairs| out << "#{GNTP_NOTIFICATION_NAME_KEY}: #{name}" pairs.each do |pair| unless pair[1].nil? out << "#{(pair[0])}: #{pair[1]}" end end out << nil end end if out.last.nil? 1.times { out << nil } else 2.times { out << nil } end out.join("\r\n") end |