show_me_the_object 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b9b6c369c23ca5882a641c45604fc62d29d68dfa
4
+ data.tar.gz: a51f5fa2e395c61030d5eeb9d3d323299e37440c
5
+ SHA512:
6
+ metadata.gz: 1b386569baa6f1003f1b7119abad0782b8a021b640213d3e8ef3723427b6868fc40163e77897d85ea7944958af45a14284b1a06f88f140fdfb9c5c15e29549c8
7
+ data.tar.gz: 25440ec18d494cba22ff506ea48d8783e08cbdf361b0d36c2f9826f05a6624592964df8cb593ee8d2a983617dba36454dac60682fcd3ca9d5731bc59d0782b06
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.5
5
+ before_install: gem install bundler -v 1.12.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in show_me_the_object.gemspec
4
+ gemspec
@@ -0,0 +1,67 @@
1
+ # ShowMeTheObject
2
+
3
+ When an object raises an exception, have you ever wondered what it's internal
4
+ state looked like?
5
+
6
+ This gem makes it so that exception messages will contain the `#inspect`ed
7
+ version of the object that raised them.
8
+
9
+ For example:
10
+
11
+ ```ruby
12
+ class Test
13
+ def test
14
+ @hello = "World"
15
+ @hash = { one: 1, two: 2 }
16
+
17
+ raise StandardError.new, "Show me the object!:"
18
+ end
19
+ end
20
+
21
+ Test.new.test
22
+ ```
23
+
24
+ The exception will look like:
25
+
26
+ ```
27
+ Show me the object!: (StandardError)
28
+ Raised by:
29
+ #<Test:0x007f846315a600 @hello="World", @hash={:one=>1, :two=>2}>
30
+ ```
31
+
32
+ ## Downsides
33
+
34
+ Currently the backtrace is thrown off, and the first line of the backtrace will
35
+ come from this library. The second line of the backtrace will have the file
36
+ that originally raised the exception.
37
+
38
+ ## Installation
39
+
40
+ Add this line to your application's Gemfile:
41
+
42
+ ```ruby
43
+ gem 'show_me_the_object'
44
+ ```
45
+
46
+ And then execute:
47
+
48
+ $ bundle
49
+
50
+ Or install it yourself as:
51
+
52
+ $ gem install show_me_the_object
53
+
54
+ ## Usage
55
+
56
+ TODO: Write usage instructions here
57
+
58
+ ## Development
59
+
60
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
61
+
62
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
63
+
64
+ ## Contributing
65
+
66
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/show_me_the_object.
67
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "show_me_the_object"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ require "show_me_the_object/version"
2
+ require "show_me_the_object/kernel"
3
+ require "show_me_the_object/exception"
4
+
5
+ Exception.prepend ShowMeTheObject::Exception
@@ -0,0 +1,16 @@
1
+ require 'show_me_the_object'
2
+
3
+ module ShowMeTheObject
4
+ module Exception
5
+ attr_accessor :__raiser
6
+
7
+ def message
8
+ raised_by = if __raiser.respond_to?(:ai)
9
+ __raiser.ai
10
+ else
11
+ __raiser.inspect
12
+ end
13
+ "#{super}\nRaised by: \n#{raised_by}"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ require 'show_me_the_object'
2
+ require 'binding_of_caller'
3
+
4
+ module Kernel
5
+ alias old_raise raise
6
+
7
+ def raise(*args, &block)
8
+ unless caller.first.include?(__FILE__)
9
+ begin
10
+ old_raise(*args)
11
+ rescue Exception => e
12
+ e.__raiser = binding.of_caller(1).eval('self')
13
+ old_raise e
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module ShowMeTheObject
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'show_me_the_object/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "show_me_the_object"
8
+ spec.version = ShowMeTheObject::VERSION
9
+ spec.authors = ["Jake Moffatt"]
10
+ spec.email = ["jakeonrails@gmail.com"]
11
+
12
+ spec.summary = %q{Displays the Ruby object that raised an exception on the console}
13
+ spec.description = %q{Displays the Ruby object that raised an exception on the console}
14
+ spec.homepage = "https://github.com"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
20
+ else
21
+ raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.12"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "rspec", "~> 3.0"
32
+ spec.add_development_dependency "pry-byebug"
33
+ spec.add_development_dependency "awesome_print"
34
+
35
+ spec.add_dependency "binding_of_caller"
36
+ end
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: show_me_the_object
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jake Moffatt
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-08-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: awesome_print
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: binding_of_caller
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Displays the Ruby object that raised an exception on the console
98
+ email:
99
+ - jakeonrails@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - README.md
109
+ - Rakefile
110
+ - bin/console
111
+ - bin/setup
112
+ - lib/show_me_the_object.rb
113
+ - lib/show_me_the_object/exception.rb
114
+ - lib/show_me_the_object/kernel.rb
115
+ - lib/show_me_the_object/version.rb
116
+ - show_me_the_object.gemspec
117
+ homepage: https://github.com
118
+ licenses: []
119
+ metadata:
120
+ allowed_push_host: https://rubygems.org
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.4.8
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: Displays the Ruby object that raised an exception on the console
141
+ test_files: []