Permalink
Browse files

using Bundler for gem management, updated the gemspec changing gem de…

…pendency for rubyist-aasm to aasm, whitespace cleanup
  • Loading branch information...
1 parent 4c8674b commit 7d7d2b7ed404a34174e7041697eeda7fe7778469 @ttdonovan ttdonovan committed Dec 14, 2011
View
@@ -0,0 +1,4 @@
+*.gem
+.bundle
+Gemfile.lock
+pkg
View
@@ -0,0 +1 @@
+--color
View
@@ -0,0 +1,4 @@
+source 'http://rubygems.org'
+
+# Specify your gem's dependencies in circuit_breaker.gemspec
+gemspec
View
@@ -1,11 +0,0 @@
-History.txt
-Manifest.txt
-README.txt
-Rakefile
-circuit_breaker.gemspec
-lib/circuit_breaker.rb
-lib/circuit_breaker/circuit_state.rb
-lib/circuit_breaker/circuit_handler.rb
-lib/circuit_breaker/circuit_broken_exception.rb
-spec/unit_spec_helper.rb
-spec/unit/circuit_breaker_spec.rb
View
@@ -28,7 +28,7 @@
invocation timeout threshold is provided. If the service fails to return
before the invocation_timeout duration has passed, the circuit will "trip",
setting the circuit into an "open" state.
-
+
require 'circuit_breaker'
class TestService
@@ -37,7 +37,7 @@
def call_remote_service() ...
circuit_method :call_remote_service
-
+
# Optional
circuit_handler do |handler|
handler.logger = Logger.new(STDOUT)
@@ -66,9 +66,7 @@
== INSTALL:
-* gem sources -a http://gems.github.com
-* gem install rubyist-aasm
-* gem install wsargent_circuit-breaker
+* gem install circuit-breaker
== LICENSE:
@@ -91,4 +89,4 @@ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
View
@@ -1,27 +1,6 @@
-# -*- ruby -*-
-$:.unshift(File.dirname(__FILE__) + "/lib")
+require 'bundler/gem_tasks'
+require 'rspec/core/rake_task'
-require 'rubygems'
-require 'hoe'
-require 'circuit_breaker'
-
-hoe = Hoe.spec 'circuit_breaker' do |p|
- self.rubyforge_name = 'circuit-breaker'
- developer('Will Sargent', 'will.sargent@gmail.com')
-
- p.remote_rdoc_dir = '' # Release to root only one project
-
- p.extra_deps << [ 'rubyist-aasm' ]
- p.extra_dev_deps << [ 'rspec' ]
- File.open(File.join(File.dirname(__FILE__), 'VERSION'), 'w') do |file|
- file.puts CircuitBreaker::VERSION
- end
-end
-
-begin
- require 'jeweler'
- Jeweler::Tasks.new(hoe.spec)
-rescue LoadError
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
-end
+RSpec::Core::RakeTask.new(:spec)
+task :default => :spec
@@ -1,12 +1,16 @@
# -*- encoding: utf-8 -*-
+$:.push File.expand_path('../lib', __FILE__)
+require 'circuit_breaker/version'
Gem::Specification.new do |s|
- s.name = %q{circuit_breaker}
- s.version = "1.0.0"
+ s.name = %q{circuit_breaker}
+ s.version = CircuitBreaker::VERSION
+ s.date = %q{2009-07-13}
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Will Sargent"]
- s.date = %q{2009-07-13}
+ s.authors = ["Will Sargent"]
+ s.email = ["will.sargent@gmail.com"]
+ s.homepage = %q{http://github.com/wsargent/circuit_breaker}
+ s.summary = %q{CircuitBreaker is a relatively simple Ruby mixin that will wrap a call to a given service in a circuit breaker pattern}
s.description = %q{CircuitBreaker is a relatively simple Ruby mixin that will wrap
a call to a given service in a circuit breaker pattern.
@@ -33,7 +37,7 @@ Gem::Specification.new do |s|
def call_remote_service() ...
circuit_method :call_remote_service
-
+
# Optional
circuit_handler do |handler|
handler.logger = Logger.new(STDOUT)
@@ -44,33 +48,19 @@ Gem::Specification.new do |s|
# Optional
circuit_handler_class MyCustomCircuitHandler
end}
- s.email = ["will.sargent@gmail.com"]
- s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
- s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile", "circuit_breaker.gemspec", "lib/circuit_breaker.rb", "lib/circuit_breaker/circuit_state.rb", "lib/circuit_breaker/circuit_handler.rb", "lib/circuit_breaker/circuit_broken_exception.rb", "spec/unit_spec_helper.rb", "spec/unit/circuit_breaker_spec.rb"]
- s.homepage = %q{http://github.com/wsargent/circuit_breaker}
- s.rdoc_options = ["--main", "README.txt", "--charset=UTF-8"]
- s.require_paths = ["lib"]
+
s.rubyforge_project = %q{will_sargent}
- s.rubygems_version = %q{1.3.4}
- s.summary = %q{CircuitBreaker is a relatively simple Ruby mixin that will wrap a call to a given service in a circuit breaker pattern}
- s.test_files = ["spec/unit/circuit_breaker_spec.rb", "spec/unit_spec_helper.rb"]
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
-
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<rubyist-aasm>, [">= 0"])
- s.add_development_dependency(%q<rspec>, [">= 0"])
- s.add_development_dependency(%q<hoe>, [">= 2.3.1"])
- else
- s.add_dependency(%q<rubyist-aasm>, [">= 0"])
- s.add_dependency(%q<rspec>, [">= 0"])
- s.add_dependency(%q<hoe>, [">= 2.3.1"])
- end
- else
- s.add_dependency(%q<rubyist-aasm>, [">= 0"])
- s.add_dependency(%q<rspec>, [">= 0"])
- s.add_dependency(%q<hoe>, [">= 2.3.1"])
- end
+
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+
+ s.extra_rdoc_files = ["History.txt", "README.txt"]
+ s.rdoc_options = ["--main", "README.txt", "--charset=UTF-8"]
+
+ s.add_runtime_dependency "aasm"
+
+ s.add_development_dependency "rake"
+ s.add_development_dependency "rspec"
end
@@ -48,9 +48,10 @@
# Author: Will Sargent <will.sargent@gmail.com>
# Many thanks to Devin Mullins
#
+
+require 'circuit_breaker/version'
+
module CircuitBreaker
- VERSION = '1.0.1'
-
#
# Extends the included class with CircuitBreaker
#
@@ -7,4 +7,4 @@ def initialize(msg, circuit_state = :closed)
attr_reader :circuit_state
-end
+end
@@ -45,7 +45,7 @@ def initialize(logger = nil)
def new_circuit_state
::CircuitBreaker::CircuitState.new
end
-
+
#
# Handles the method covered by the circuit breaker.
#
@@ -104,7 +104,7 @@ def is_tripped(circuit_state)
end
#
- # Called when an individual success happens.
+ # Called when an individual success happens.
#
def on_success(circuit_state)
@logger.debug("on_success: #{circuit_state.inspect}") if @logger
@@ -125,7 +125,7 @@ def on_success(circuit_state)
#
def on_failure(circuit_state)
@logger.debug("on_failure: circuit_state = #{circuit_state.inspect}") if @logger
-
+
circuit_state.increment_failure_count
if is_failure_threshold_reached(circuit_state) || circuit_state.half_open?
@@ -136,12 +136,12 @@ def on_failure(circuit_state)
end
#
- # Called when a call is made and the circuit is open. Raises a CircuitBrokenException exception.
+ # Called when a call is made and the circuit is open. Raises a CircuitBrokenException exception.
#
def on_circuit_open(circuit_state)
@logger.debug("on_circuit_open: raising for #{circuit_state.inspect}") if @logger
-
+
raise CircuitBreaker::CircuitBrokenException.new("Circuit broken, please wait for timeout", circuit_state)
end
-
-end
+
+end
@@ -55,6 +55,6 @@ def increment_failure_count
def reset_failure_count
@failure_count = 0
end
-
+
end
@@ -0,0 +1,3 @@
+module CircuitBreaker
+ VERSION = '1.0.1'
+end
@@ -1,5 +1,4 @@
-require File.dirname(__FILE__) + '/../unit_spec_helper'
-
+require 'spec_helper'
require 'logger'
describe CircuitBreaker do
@@ -78,7 +77,7 @@ def unresponsive_method
@test_object.circuit_state.closed?.should == true
@test_object.circuit_state.failure_count.should == 1
end
-
+
it 'should trip the circuit when too many failures occur' do
@test_object.fail!
@@ -109,7 +108,7 @@ def unresponsive_method
@test_object.fail!
TestClass.circuit_handler.failure_threshold = 0
- lambda { @test_object.call_external_method() }.should raise_error
+ lambda { @test_object.call_external_method() }.should raise_error
@test_object.circuit_state.open?.should == true
@test_object.circuit_state.failure_count.should == 1
end
@@ -118,7 +117,7 @@ def unresponsive_method
lambda { @test_object.unresponsive_method }.should raise_error(CircuitBreaker::CircuitBrokenException)
@test_object.circuit_state.open?.should == true
end
-
+
end
describe "when open" do
@@ -193,4 +192,4 @@ def unresponsive_method
end
-end
+end
View
@@ -0,0 +1 @@
+require 'circuit_breaker'
@@ -1,5 +0,0 @@
-$:.unshift File.join(File.dirname(__FILE__),'..','lib')
-require 'rubygems'
-require 'aasm'
-require 'spec'
-require 'circuit_breaker'

0 comments on commit 7d7d2b7

Please sign in to comment.