Permalink
Browse files

Added YARD, removed the test methods test

  • Loading branch information...
1 parent 3024029 commit e70f749bd4af38150d42949dcd771070388358ad @toolmantim toolmantim committed Sep 16, 2009
Showing with 73 additions and 54 deletions.
  1. +3 −1 .gitignore
  2. +21 −0 LICENSE
  3. +10 −1 Rakefile
  4. +37 −36 lib/toadhopper.rb
  5. +0 −12 test/test_test.rb
  6. +2 −4 toadhopper.gemspec
View
@@ -1 +1,3 @@
-/dist/
+/dist/
+.yardoc
+/doc/
View
21 LICENSE
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2009 Tim Lucas
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
View
@@ -10,5 +10,14 @@ begin
gem "sr-mg", "<= 0.0.5"
require "mg"
MG.new("toadhopper.gemspec")
-rescue LoadError
+rescue Gem::LoadError
+end
+
+begin
+ gem "yard"
+ require 'yard'
+ YARD::Rake::YardocTask.new do |t|
+ t.options = ['-r', 'Readme.md', '--files', 'LICENSE'] # optional
+ end
+rescue Gem::LoadError
end
View
@@ -7,7 +7,7 @@ class << self
def api_key=(key)
@api_key = key
end
- # Returns the key set by Toadhopper.api_key=
+ # Returns the API key
def api_key
@api_key
end
@@ -17,17 +17,10 @@ def api_key
def filters=(*filters)
@filters = filters.flatten
end
- # Returns the filters set by Toadhopper.filters=
+ # Returns the filters
def filters
[@filters].flatten.compact
end
- # Replaces the values of the keys matching Toadhopper.filters with [FILTERED]. Typically used on the params and environment hashes.
- def filter(hash)
- hash.inject({}) do |acc, (key, val)|
- acc[key] = filters.any? {|f| key.to_s =~ Regexp.new(f)} ? "[FILTERED]" : val
- acc
- end
- end
# Posts an error to Hoptoad
def post!(error, options={}, header_options={})
uri = URI.parse("http://hoptoadapp.com/notices/")
@@ -45,34 +38,42 @@ def post!(error, options={}, header_options={})
end
end
end
- def notice_params(error, options={}) # :nodoc:
- clean_non_serializable_data(stringify_keys(
- {
- :api_key => api_key,
- :error_class => error.class.name,
- :error_message => error.message,
- :backtrace => error.backtrace,
- }.merge(options)
- ))
- end
- def stringify_keys(hash) #:nodoc:
- hash.inject({}) do |h, pair|
- h[pair.first.to_s] = pair.last.is_a?(Hash) ? stringify_keys(pair.last) : pair.last
- h
+ private
+ # Replaces the values of the keys matching Toadhopper.filters with [FILTERED]. Typically used on the params and environment hashes.
+ def filter(hash)
+ hash.inject({}) do |acc, (key, val)|
+ acc[key] = filters.any? {|f| key.to_s =~ Regexp.new(f)} ? "[FILTERED]" : val
+ acc
+ end
end
- end
- def serializable?(value) #:nodoc:
- value.is_a?(Fixnum) ||
- value.is_a?(Array) ||
- value.is_a?(String) ||
- value.is_a?(Hash) ||
- value.is_a?(Bignum)
- end
- def clean_non_serializable_data(data) #:nodoc:
- data.select{|k,v| serializable?(v) }.inject({}) do |h, pair|
- h[pair.first] = pair.last.is_a?(Hash) ? clean_non_serializable_data(pair.last) : pair.last
- h
+ def notice_params(error, options={}) # :nodoc:
+ clean_non_serializable_data(stringify_keys(
+ {
+ :api_key => api_key,
+ :error_class => error.class.name,
+ :error_message => error.message,
+ :backtrace => error.backtrace,
+ }.merge(options)
+ ))
+ end
+ def stringify_keys(hash) #:nodoc:
+ hash.inject({}) do |h, pair|
+ h[pair.first.to_s] = pair.last.is_a?(Hash) ? stringify_keys(pair.last) : pair.last
+ h
+ end
+ end
+ def serializable?(value) #:nodoc:
+ value.is_a?(Fixnum) ||
+ value.is_a?(Array) ||
+ value.is_a?(String) ||
+ value.is_a?(Hash) ||
+ value.is_a?(Bignum)
+ end
+ def clean_non_serializable_data(data) #:nodoc:
+ data.select{|k,v| serializable?(v) }.inject({}) do |h, pair|
+ h[pair.first] = pair.last.is_a?(Hash) ? clean_non_serializable_data(pair.last) : pair.last
+ h
+ end
end
- end
end
end
View
@@ -1,12 +0,0 @@
-require File.dirname(__FILE__) + "/../lib/toadhopper/test"
-
-require 'test/unit'
-
-class Toadhopper::TestTest < Test::Unit::TestCase
- include Toadhopper::Test::Methods
- def test_stub_toadhopper_post!
- stub_toadhopper_post!
- Toadhopper.post!(:error, :options, :header_options)
- assert_equal [:error, :options, :header_options], last_toadhopper_post_arguments
- end
-end
View
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "toadhopper"
- s.version = "0.5"
+ s.version = "0.6"
s.extra_rdoc_files = ["Readme.md"]
s.summary = "Post error notifications to Hoptoad"
s.description = s.summary
@@ -12,13 +12,11 @@ Gem::Specification.new do |s|
s.files = %w(
Readme.md
Rakefile
+ LICENSE
lib/toadhopper.rb
- lib/toadhopper/test.rb
- lib/toadhopper/test/methods.rb
test/test_filter.rb
test/test_notice_params.rb
test/test_setters.rb
- test/test_test.rb
)
s.has_rdoc = true
end

0 comments on commit e70f749

Please sign in to comment.