exceptions_tree 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fb18aab90a9fab876a96732f07b7a9115c745c15
4
+ data.tar.gz: b151a192c5a71787246468fb7afd10f8dd847fea
5
+ SHA512:
6
+ metadata.gz: dee5fe6aeb74ceb254c62e7c36e74fabe8842f87ede8be5efd60a41a8e9287fef6d80eeefad9b4860c440d7650d8783622cc3e4535f2ba9b4070fc3e219bb53c
7
+ data.tar.gz: 65c56d21907248660c63a7438bd85ba0cc10c26afcca3358504b0e4c5a80194f68c53a89864cbc65d9dd375de6db23293c8cdde6cf397a43b42e84497167ad0c
data/.gitignore ADDED
@@ -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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in exceptions_tree.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Alan Stebbens <aks@stebbens.org>,<alan.stebbens@procore.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # ExceptionsTree
2
+
3
+ When dealing with errors, ruby developers are encouraged to capture specific
4
+ exceptions, but seeing which exceptions are currently configured (and thus
5
+ possible) is a challenge, especially with exceptions being dynamically
6
+ configured as gems are loaded.
7
+
8
+ The `ExceptionsTree` ruby gem provides adds both a rake task and a script which
9
+ allows developers to see the Exceptions hierarchy configured for the
10
+ application. If the application is based on Rails, this gem uses `railties`
11
+ to tie in the rake task correctly. However, this gem also works fine with ruby
12
+ scripts that are not Rails based.
13
+
14
+ The rake task is done with:
15
+
16
+ bundle exec rake exceptions
17
+
18
+ The script is invoked:
19
+
20
+ display_exceptions
21
+
22
+ The output can be quite long, as many applications have lots of gems that
23
+ insert their own exceptions to the hierarchy. Of course, if you are searching
24
+ for a particular exception, you can pipe the output through `grep` to find it.
25
+ For example:
26
+
27
+ display_exceptions | grep IO # _to find the IO exceptions_
28
+
29
+ ## Installation
30
+
31
+ Add this line to your application's `Gemfile`:
32
+
33
+ ```ruby
34
+ gem 'exceptions_tree'
35
+ ```
36
+
37
+ And then execute:
38
+
39
+ $ bundle
40
+
41
+ Or install it yourself as:
42
+
43
+ $ gem install exceptions_tree
44
+
45
+ ## Usage
46
+
47
+ bundle exec rake exceptions
48
+
49
+ display_exceptions
50
+
51
+ ## Development
52
+
53
+ After checking out the repo, run `bin/setup` to install dependencies. You can
54
+ also run `bin/console` for an interactive prompt that will allow you to
55
+ experiment.
56
+
57
+ To install this gem onto your local machine, run `bundle exec rake install`. To
58
+ release a new version, update the version number in `version.rb`, and then run
59
+ `bundle exec rake release`, which will create a git tag for the version, push
60
+ git commits and tags, and push the `.gem` file to
61
+ [rubygems.org](https://rubygems.org).
62
+
63
+ ## Contributing
64
+
65
+ Bug reports and pull requests are welcome on GitHub at
66
+ https://github.com/[USERNAME]/exceptions_tree. This project is intended to be
67
+ a safe, welcoming space for collaboration, and contributors are expected to
68
+ adhere to the [Contributor Covenant](http://contributor-covenant.org) code of
69
+ conduct.
70
+
71
+ ## License
72
+
73
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
74
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "exceptions_tree"
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,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "exceptions_tree"
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
+ ExceptionsTree.display_exceptions
data/bin/setup ADDED
@@ -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,39 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'exceptions_tree/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "exceptions_tree"
8
+ spec.version = ExceptionsTree::VERSION
9
+ spec.authors = ["Alan Stebbens"]
10
+ spec.email = ["aks@stebbens.org", "alan.stebbens@procore.com"]
11
+
12
+ spec.summary = %q{Adds a rake task to show the currently configured Exception hierarchy.}
13
+ spec.description = %q{\
14
+ Provides `rake task exceptions` or `display_exceptions` script which display the
15
+ currently configured Exceptions hierarchy.
16
+ }
17
+ spec.homepage = "https://github.com/aks/exceptions_tree.git"
18
+ spec.license = "MIT"
19
+
20
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
21
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
22
+ #if spec.respond_to?(:metadata)
23
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
24
+ #else
25
+ # raise "RubyGems 2.0 or newer is required to protect against " \
26
+ # "public gem pushes."
27
+ #end
28
+
29
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
30
+ f.match(%r{^(test|spec|features)/})
31
+ end
32
+ spec.bindir = "bin"
33
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
34
+ spec.require_paths = ["lib"]
35
+
36
+ spec.add_development_dependency "bundler", "~> 1.13"
37
+ spec.add_development_dependency "rake", "~> 10.0"
38
+ #spec.add_development_dependency "pry-byebug" # only when debugging
39
+ end
@@ -0,0 +1,3 @@
1
+ require 'exceptions_tree/version'
2
+ require 'exceptions_tree/display.rb'
3
+ require 'exceptions_tree/railtie.rb' if defined? Rails
@@ -0,0 +1,26 @@
1
+ module ExceptionsTree
2
+
3
+ class <<self
4
+ def display_exceptions
5
+ exception_classes = []
6
+ exception_tree = {}
7
+ ObjectSpace.each_object(Class) do |klass|
8
+ next unless klass.ancestors.include? Exception
9
+ next if exception_classes.include? klass
10
+ next if klass.superclass == SystemCallError # don't want ERRNO
11
+ exception_classes << klass
12
+ klass.ancestors.delete_if {|e| [Object, Kernel].include? e }.
13
+ reverse.inject(exception_tree) {|memo,klass2| memo[klass2] ||= {}}
14
+ end
15
+ show_exception_tree(exception_tree, 0)
16
+ end
17
+
18
+ def show_exception_tree(tree, level)
19
+ tree.keys.sort {|k1, k2| k1.name <=> k2.name}.each do |class_name|
20
+ printf "%s%s\n", (' ' * level), class_name
21
+ show_exception_tree(tree[class_name], level+1)
22
+ end
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,12 @@
1
+ require 'exceptions_tree'
2
+ require 'rails'
3
+
4
+ module ExceptionsTree
5
+ class Railtie < Rails::Railtie
6
+ railtie_name :exceptions_tree
7
+
8
+ rake_tasks do
9
+ load "tasks/exceptions_tree.rake"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module ExceptionsTree
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,5 @@
1
+ # exceptions_tree gem
2
+ desc "Describe the configured exceptions heirarchy"
3
+ task :exceptions do
4
+ ExceptionsTree::display_exceptions
5
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exceptions_tree
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Alan Stebbens
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-11 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.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
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
+ description: "\\\n Provides `rake task exceptions` or `display_exceptions` script
42
+ which display the \n currently configured Exceptions hierarchy.\n "
43
+ email:
44
+ - aks@stebbens.org
45
+ - alan.stebbens@procore.com
46
+ executables:
47
+ - console
48
+ - display_exceptions
49
+ - setup
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - ".gitignore"
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - bin/console
59
+ - bin/display_exceptions
60
+ - bin/setup
61
+ - exceptions_tree.gemspec
62
+ - lib/exceptions_tree.rb
63
+ - lib/exceptions_tree/display.rb
64
+ - lib/exceptions_tree/railtie.rb
65
+ - lib/exceptions_tree/version.rb
66
+ - lib/tasks/exceptions_tree.rake
67
+ homepage: https://github.com/aks/exceptions_tree.git
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.5.1
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Adds a rake task to show the currently configured Exception hierarchy.
91
+ test_files: []