Skip to content
Browse files

remove gestalt and simplify (removes eval/interactive)

  • Loading branch information...
1 parent 6ce078e commit 803b3a0d05ccc14ecae177b34c13535180652c23 @geemus geemus committed Jan 24, 2011
Showing with 9 additions and 70 deletions.
  1. +1 −5 Gemfile.lock
  2. +8 −41 lib/shindo.rb
  3. +0 −13 lib/shindo/taciturn.rb
  4. +0 −10 lib/shindo/verbose.rb
  5. +0 −1 shindo.gemspec
View
6 Gemfile.lock
@@ -1,21 +1,17 @@
PATH
remote: .
specs:
- shindo (0.1.9)
+ shindo (0.1.12)
formatador (>= 0.0.16)
- gestalt (>= 0.0.11)
GEM
remote: http://rubygems.org/
specs:
formatador (0.0.16)
- gestalt (0.0.11)
- formatador (>= 0.0.12)
PLATFORMS
ruby
DEPENDENCIES
formatador (>= 0.0.16)
- gestalt (>= 0.0.11)
shindo!
View
49 lib/shindo.rb
@@ -1,6 +1,5 @@
require 'rubygems'
require 'formatador'
-require 'gestalt'
module Shindo
@@ -118,9 +117,14 @@ def assert(type, expectation, description, &block)
end
value, success = case type
when :raises
- raises?(expectation, &block)
+ value = begin
+ instance_eval(&block)
+ rescue => error
+ error
+ end
+ [value, value.is_a?(expectation)]
when :returns
- returns?(expectation, &block)
+ [value = instance_eval(&block), value == expectation]
end
for after in @afters.flatten.compact
after.call
@@ -161,62 +165,25 @@ def assert(type, expectation, description, &block)
def prompt(description, &block)
return if Thread.main[:exit] || Thread.current[:reload]
- Formatador.display("Action? [c,e,i,q,r,t,?]? ")
+ Formatador.display("Action? [c,q,r,?]? ")
choice = STDIN.gets.strip
continue = false
Formatador.display_line
Formatador.indent do
case choice
when 'c', 'continue'
continue = true
- when /^e .*/, /^eval .*/
- begin
- value = eval(choice[2..-1], @gestalt.bindings.last)
- if value.nil?
- value = 'nil'
- end
- Formatador.display_line(value)
- rescue => error
- display_error(error)
- end
- when 'i', 'interactive', 'irb'
- Formatador.display_line('Starting interactive session...')
- if @irb.nil?
- require 'irb'
- ARGV.clear # Avoid passing args to IRB
- IRB.setup(nil)
- @irb = IRB::Irb.new(nil)
- IRB.conf[:MAIN_CONTEXT] = @irb.context
- IRB.conf[:PROMPT][:SHINDO] = {}
- end
- for key, value in IRB.conf[:PROMPT][:SIMPLE]
- IRB.conf[:PROMPT][:SHINDO][key] = "#{Formatador.indentation}#{value}"
- end
- @irb.context.prompt_mode = :SHINDO
- @irb.context.workspace = IRB::WorkSpace.new(@gestalt.bindings.last)
- begin
- @irb.eval_input
- rescue SystemExit
- end
when 'q', 'quit', 'exit'
Formatador.display_line("Exiting...")
Thread.main[:exit] = true
when 'r', 'reload'
Formatador.display_line("Reloading...")
Thread.current[:reload] = true
- when 't', 'backtrace', 'trace'
- if @gestalt.calls.empty?
- Formatador.display_line("[red]No methods were called, so no backtrace was captured.[/]")
- else
- @gestalt.display_calls
- end
when '?', 'help'
Formatador.display_lines([
'c - ignore this error and continue',
- 'i - interactive mode',
'q - quit Shindo',
'r - reload and run the tests again',
- 't - display backtrace',
'? - display help'
])
else
View
13 lib/shindo/taciturn.rb
@@ -47,18 +47,5 @@ def display_success(description)
print Formatador.parse("[green]+[/]")
end
- def raises?(expectation, &block)
- value = begin
- instance_eval(&block)
- rescue => error
- error
- end
- [value, value.is_a?(expectation)]
- end
-
- def returns?(expectation, &block)
- [value = instance_eval(&block), value == expectation]
- end
-
end
end
View
10 lib/shindo/verbose.rb
@@ -31,15 +31,5 @@ def display_success(description)
Formatador.display_line("[green]+ #{description}[/]")
end
- def raises?(expectation, &block)
- @gestalt = Gestalt.new({'formatador' => Formatador})
- [value = @gestalt.run(&block), value.is_a?(expectation)]
- end
-
- def returns?(expectation, &block)
- @gestalt = Gestalt.new({'formatador' => Formatador})
- [value = @gestalt.run(&block), value == expectation]
- end
-
end
end
View
1 shindo.gemspec
@@ -49,7 +49,6 @@ Gem::Specification.new do |s|
## List your runtime dependencies here. Runtime dependencies are those
## that are needed for an end user to actually USE your code.
s.add_dependency('formatador', '>=0.0.16')
- s.add_dependency('gestalt', '>=0.0.11')
## List your development dependencies here. Development dependencies are
## those that are only needed during development

0 comments on commit 803b3a0

Please sign in to comment.
Something went wrong with that request. Please try again.