Permalink
Browse files

added plymouth-off/on commands, added Plymouth.enable! / disable!

* version bump
  • Loading branch information...
1 parent b323903 commit 1e4fc1e13d3cca1bc4292220ad5b5d8bc14f4869 @banister committed Feb 10, 2012
Showing with 35 additions and 12 deletions.
  1. +1 −1 Rakefile
  2. +30 −7 lib/plymouth.rb
  3. +4 −4 plymouth.gemspec
View
@@ -28,7 +28,7 @@ def apply_spec_defaults(s)
s.require_path = 'lib'
s.homepage = "http://github.com/banister/#{PROJECT_NAME}"
s.has_rdoc = 'yard'
- s.add_dependency('pry-exception_explorer', '>=0.1.6')
+ s.add_dependency('pry-exception_explorer', '>=0.1.7')
s.add_development_dependency("bacon","~>1.1.0")
s.add_development_dependency('rspec')
s.required_ruby_version = '>= 1.9.2'
View
@@ -1,12 +1,28 @@
# plymouth.rb
# (C) 2012 John Mair (banisterfiend); MIT license
-require "plymouth/version"
require 'pry-exception_explorer'
+require "plymouth/version"
+require 'plymouth/commands'
-EE.enabled = true
-if ['0', 'false', 'no'].include?(ENV['USE_PLYMOUTH'].to_s.downcase)
- EE.enabled = false
+module Plymouth
+
+ # Enable plymouth.
+ # @return [Boolean]
+ def self.enable!
+ ::EE.enabled = true
+ end
+
+ # Disable plymouth.
+ # @return [Boolean]
+ def self.disable!
+ ::EE.enabled = false
+ end
+
+ # @return [Boolean] Whether Plymouth is enabled.
+ def self.enabled?
+ ::EE.enabled?
+ end
end
message = nil
@@ -26,7 +42,7 @@
EE.intercept do |frame, ex|
if ex.is_a?(Bacon::Error) && frame.method_name != :run_requirement
- message = ex
+ message = ex.message
true
else
false
@@ -39,7 +55,7 @@
EE.intercept do |frame, ex|
if ex.class.name =~ /RSpec::Expectations::ExpectationNotMetError/
- message = ex
+ message = ex.message
true
else
false
@@ -54,7 +70,7 @@
EE.intercept do |frame, ex|
if ex.is_a?(MiniTest::Assertion)
- message = ex
+ message = ex.message
true
else
false
@@ -65,4 +81,11 @@
end
end
+# Disable Plymouth if USE_PLYMOUTH environment variable is falsy
+Plymouth.enable!
+if ['0', 'false', 'no'].include?(ENV['USE_PLYMOUTH'].to_s.downcase)
+ Plymouth.disable!
+end
+# Bring in plymouth commands
+Pry.commands.import Plymouth::Commands
View
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["John Mair (banisterfiend)"]
- s.date = "2012-02-09"
+ s.date = "2012-02-10"
s.description = "Start an interactive session when a test fails"
s.email = "jrmair@gmail.com"
s.files = [".gemtest", ".gitignore", ".yardopts", "CHANGELOG", "Gemfile", "LICENSE", "README.md", "Rakefile", "examples/example_bacon.rb", "examples/example_minitest.rb", "examples/example_rspec.rb", "lib/plymouth.rb", "lib/plymouth/version.rb", "plymouth.gemspec", "test/test.rb"]
@@ -21,16 +21,16 @@ Gem::Specification.new do |s|
s.specification_version = 3
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<pry-exception_explorer>, [">= 0.1.6"])
+ s.add_runtime_dependency(%q<pry-exception_explorer>, [">= 0.1.7"])
s.add_development_dependency(%q<bacon>, ["~> 1.1.0"])
s.add_development_dependency(%q<rspec>, [">= 0"])
else
- s.add_dependency(%q<pry-exception_explorer>, [">= 0.1.6"])
+ s.add_dependency(%q<pry-exception_explorer>, [">= 0.1.7"])
s.add_dependency(%q<bacon>, ["~> 1.1.0"])
s.add_dependency(%q<rspec>, [">= 0"])
end
else
- s.add_dependency(%q<pry-exception_explorer>, [">= 0.1.6"])
+ s.add_dependency(%q<pry-exception_explorer>, [">= 0.1.7"])
s.add_dependency(%q<bacon>, ["~> 1.1.0"])
s.add_dependency(%q<rspec>, [">= 0"])
end

0 comments on commit 1e4fc1e

Please sign in to comment.