From a51fe235124127ed400d9d2d644493b1fe6b9e20 Mon Sep 17 00:00:00 2001 From: Matthew Shafer Date: Wed, 10 Apr 2013 16:47:24 -0700 Subject: [PATCH] Remove pry from development dependancies. Add documentation --- growl_car.gemspec | 1 - lib/growl_car/client.rb | 4 ++++ lib/growl_car/configuration.rb | 11 +++++++++++ lib/growl_car/growl_notification.rb | 7 +++++++ lib/growl_car/request.rb | 1 + 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/growl_car.gemspec b/growl_car.gemspec index 7c64333..1218903 100644 --- a/growl_car.gemspec +++ b/growl_car.gemspec @@ -21,7 +21,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency "bundler", "~> 1.3" spec.add_development_dependency "rake" spec.add_development_dependency "rspec", "~> 2.13.0" - spec.add_development_dependency "pry", "~> 0.9.12" spec.add_development_dependency "webmock", "~> 1.11.0" spec.add_development_dependency "simplecov", "~> 0.7.1" spec.add_development_dependency "coveralls", "~> 0.6.4" diff --git a/lib/growl_car/client.rb b/lib/growl_car/client.rb index 4de031b..9a02ba9 100644 --- a/lib/growl_car/client.rb +++ b/lib/growl_car/client.rb @@ -7,6 +7,10 @@ class Client include GrowlCar::Request include GrowlCar::GrowlNotification + # Initialize a new GrowlCar::Client + # + # @param options [Hash] + # @return [GrowlCar::Client] def initialize(options={}) GrowlCar::Configuration.keys.each do |key| instance_variable_set(:"@#{key}", options[key]) diff --git a/lib/growl_car/configuration.rb b/lib/growl_car/configuration.rb index 1fea932..759efe7 100644 --- a/lib/growl_car/configuration.rb +++ b/lib/growl_car/configuration.rb @@ -3,6 +3,10 @@ module Configuration attr_writer :username, :password class << self + + # List of keys used for configuration + # + # @return [Array] def keys @keys ||= [ :username, @@ -10,17 +14,24 @@ def keys ] end + # Url for boxcar.io + # + # @return [String] def boxcar_url "https://boxcar.io/notifications" end end + # Convenience method to allow GrowlCar configuration to be set in a block + # + # @raise [GrowlCar::Error::ConfigurationError] if credentials are not in the form of a string def configure yield self validate_credentials! self end + # Set all configuration values to nil def reset! GrowlCar::Configuration.keys.each do |key| instance_variable_set(:"@#{key}", nil) diff --git a/lib/growl_car/growl_notification.rb b/lib/growl_car/growl_notification.rb index 99f5cb2..06b5a1d 100644 --- a/lib/growl_car/growl_notification.rb +++ b/lib/growl_car/growl_notification.rb @@ -1,6 +1,13 @@ module GrowlCar module GrowlNotification + # Sends a notification to the boxcar.io growl provider + # + # @param from [String] name of the sender of the message + # @param message [String] message to be sent to boxcar + # @raise [GrowlCar::Error::UnauthorizedError] if username or password is incorrect + # @raise [GrowlCar::Error::HttpError] if http response is not 200 or 401 + # @return [Boolean] on successful notification def send_growl_notification(from, message) boxcar_post_fields = { "notification[from_screen_name]" => from, diff --git a/lib/growl_car/request.rb b/lib/growl_car/request.rb index d56e3c9..c8c5feb 100644 --- a/lib/growl_car/request.rb +++ b/lib/growl_car/request.rb @@ -3,6 +3,7 @@ module GrowlCar module Request + # Initialize HTTPClient for requests def initialize @http = HTTPClient.new end