inspectbang 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +13 -6
  2. data/inspectbang.gemspec +1 -2
  3. data/lib/inspectbang.rb +21 -11
  4. metadata +4 -19
data/README.md CHANGED
@@ -2,9 +2,7 @@ Inspect with a bang!
2
2
  ====================
3
3
 
4
4
 
5
- Easy peasy "puts" style debugging in your browser, for Rails. Use the
6
- `Object#inspect!` method to output an HTML safe representation of the
7
- object in your browser.
5
+ Easy peasy "puts" style debugging in your browser, for Rails and Sinatra.
8
6
 
9
7
 
10
8
  Installation
@@ -14,7 +12,7 @@ Add inspectbang to your Gemfile and run `bundle`:
14
12
 
15
13
  ```ruby
16
14
  group :development do
17
- gem 'inspectbang', '~> 1.0.0'
15
+ gem 'inspectbang', '~> 1.1.0'
18
16
  end
19
17
  ```
20
18
 
@@ -22,8 +20,9 @@ end
22
20
  Usage
23
21
  -----
24
22
 
25
- Just call the `inspect!` method on any object. For example, here's how you
26
- would inspect the form data that was posted to your application:
23
+ Use the `Object#inspect!` method to output an HTML safe representation of
24
+ the object in your browser. For example, here's how you would inspect the
25
+ form data that was posted to your Rails application:
27
26
 
28
27
  ```ruby
29
28
  class SomeController < ApplicationController
@@ -32,3 +31,11 @@ class SomeController < ApplicationController
32
31
  end
33
32
  end
34
33
  ```
34
+
35
+ And here's how you would inspect the request in a Sinatra application:
36
+
37
+ ```ruby
38
+ get '/' do
39
+ request.inspect!
40
+ end
41
+ ```
data/inspectbang.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'inspectbang'
3
- s.version = '1.0.0'
3
+ s.version = '1.1.0'
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.authors = ['Tim Craft']
6
6
  s.email = ['mail@timcraft.com']
@@ -8,6 +8,5 @@ Gem::Specification.new do |s|
8
8
  s.description = 'Inspect with a bang!'
9
9
  s.summary = 'See description'
10
10
  s.files = %w(lib/inspectbang.rb README.md inspectbang.gemspec)
11
- s.add_dependency('rails', ['>= 3.0.3'])
12
11
  s.require_path = 'lib'
13
12
  end
data/lib/inspectbang.rb CHANGED
@@ -1,21 +1,31 @@
1
1
  require 'cgi'
2
2
 
3
3
  module InspectBang
4
- class Exception < StandardError; end
4
+ if defined?(Rails)
5
+ class Exception < StandardError; end
5
6
 
6
- module Method
7
- def inspect!
8
- raise Exception.new(self.inspect)
7
+ module Method
8
+ def inspect!
9
+ raise Exception.new(self.inspect)
10
+ end
9
11
  end
10
- end
11
12
 
12
- class Railtie < Rails::Railtie
13
- initializer 'inspectbang' do |app|
14
- ActionController::Base.rescue_from(Exception) do |exception|
15
- render :text => CGI.escapeHTML(exception.message)
16
- end
13
+ class Railtie < Rails::Railtie
14
+ initializer 'inspectbang' do |app|
15
+ ActionController::Base.rescue_from(Exception) do |exception|
16
+ render :text => CGI.escapeHTML(exception.message)
17
+ end
17
18
 
18
- Object.send(:include, Method)
19
+ Object.send(:include, Method)
20
+ end
19
21
  end
22
+ elsif defined?(Sinatra)
23
+ module Method
24
+ def inspect!
25
+ throw :halt, [200, CGI.escapeHTML(self.inspect)]
26
+ end
27
+ end
28
+
29
+ Object.send(:include, Method)
20
30
  end
21
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inspectbang
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,24 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-30 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: rails
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: 3.0.3
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: 3.0.3
12
+ date: 2012-10-29 00:00:00.000000000 Z
13
+ dependencies: []
30
14
  description: Inspect with a bang!
31
15
  email:
32
16
  - mail@timcraft.com
@@ -62,3 +46,4 @@ signing_key:
62
46
  specification_version: 3
63
47
  summary: See description
64
48
  test_files: []
49
+ has_rdoc: