pry-tree 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ca13315ae2ef615bf89a69d4783dae92a0212e0c
4
+ data.tar.gz: c4659234548c96188e0b7dc0edff826167b0c8c7
5
+ SHA512:
6
+ metadata.gz: c5dd41eff1bacbc3713b3076e8ab3cc0f5bc887dc2ebd3836b683e7d3b584db3287ddfafd0878c57f5bff11f29320f8b773ecd175dd743ff360f40ba4bde3df9
7
+ data.tar.gz: ac78990b42260314c4c711b04de46a56d2547e52118ca9b97101b0fc4501f826a881425a60acfb141609f6d0bb18db86648e552201d91981847a4d0b6d1c92e1
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/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.5
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development, :test do
6
+ gem "bundler", "~> 1.10"
7
+ gem "rake", "~> 10.0"
8
+ gem "rspec"
9
+ gem "pry"
10
+ end
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # pry-tree
2
+
3
+ Show the tree of classes and methods in a module.
4
+
5
+ ```
6
+ [1] pry(main)> tree Pry::Helpers
7
+ Helpers
8
+ .new .tablify .tablify_or_one_line .tablify_to_screen_width
9
+ BaseHelpers
10
+ .colorize_code .heading .jruby_19? .mri_20? .new .safe_send .use_ansi_codes? safe_send
11
+ .command_dependencies_met? .highlight .mri? .mri_21? .not_a_real_file? .silence_warnings .windows?
12
+ .find_command .jruby? .mri_19? .mri_2? .rbx? .stagger_output .windows_ansi?
13
+ CommandHelpers
14
+ .absolute_index_number .get_method_or_raise .one_index_number .restrict_to_lines .unindent
15
+ .absolute_index_range .internal_binding? .one_index_range .set_file_and_dir_locals
16
+ .command_error .new .one_index_range_or_number .temp_file
17
+ DocumentationHelpers
18
+ .get_comment_content .process_comment_markup .process_yardoc .strip_comments_from_c_code
19
+ .new .process_rdoc .process_yardoc_tag .strip_leading_whitespace
20
+ OptionsHelpers
21
+ .method_object .method_options .new
22
+ Table
23
+ .new == column_count column_count= columns fits_on_line? items items= rows_to_s to_a to_s
24
+ Text
25
+ .black .bright_black .bright_default .bright_purple .bright_yellow .green .new .purple .white
26
+ .blue .bright_blue .bright_green .bright_red .cyan .indent .no_color .red .with_line_numbers
27
+ .bold .bright_cyan .bright_magenta .bright_white .default .magenta .no_pager .strip_color .yellow
28
+ [2] pry(main)>
29
+ ```
30
+
31
+ ## Installation
32
+
33
+ Install the gem globally or inside the :development group of your gemfile:
34
+
35
+ ```
36
+ gem install 'pry-tree'
37
+ ```
38
+
39
+ Pry will automagically load the plugin.
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/akuhn/pry-sql.
data/Rakefile ADDED
@@ -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
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pry-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
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/lib/pry-tree.rb ADDED
@@ -0,0 +1,58 @@
1
+ require "pry-tree/version"
2
+
3
+ module PryTree
4
+
5
+ def self.call(out, mod, seen = {}, indent = 0)
6
+ return unless Module === mod
7
+ out.print ' ' * indent
8
+ return out.puts '...' if seen[mod]
9
+ seen[mod] = true
10
+ out.print "\e[31m" if mod < Exception
11
+ out.print "\e[34m" unless mod < Exception
12
+ out.print mod.name.split('::').last
13
+ out.print "\e[0m"
14
+ if Class === mod && mod.superclass != Object
15
+ out.print ' < '
16
+ out.print mod.superclass.name.split('::').last
17
+ end
18
+ out.puts ""
19
+
20
+ methods = {
21
+ "." => class_methods = mod.methods(false),
22
+ "\e[0m" => mod.public_instance_methods(false),
23
+ "\e[33m" => mod.protected_instance_methods(false),
24
+ "\e[36m" => private_methods = mod.private_instance_methods(false),
25
+ }
26
+ if private_methods.include? :initialize
27
+ private_methods.delete(:initialize)
28
+ class_methods << :new
29
+ end
30
+ methods = methods.flat_map { |prefix, names| names.map { |name| "#{prefix}#{name}" }}
31
+ methods = methods.sort_by { |name| Pry::Helpers::Text.strip_color(name) }
32
+
33
+ unless methods.empty?
34
+ out.puts Pry::Helpers.tablify_to_screen_width(methods, indent: ' ' * (indent + 2))
35
+ end
36
+ exceptions, constants = mod.constants(false).sort.partition { |name|
37
+ child = mod.const_get(name)
38
+ Module === child && child < Exception
39
+ }
40
+ [*exceptions, *constants].each do |name|
41
+ PryTree.call(out, mod.const_get(name), seen, indent + 2)
42
+ end
43
+ end
44
+
45
+ end
46
+
47
+ Pry::Commands.create_command 'tree' do
48
+
49
+ group 'Context'
50
+ description 'Show the tree of classes and methods in a module.'
51
+ command_options argument_required: true
52
+
53
+ def process
54
+ mod = target.eval(arg_string)
55
+ mod = mod.class unless Module === mod
56
+ _pry_.pager.open { |out| PryTree.call(out, mod) }
57
+ end
58
+ end
@@ -0,0 +1,3 @@
1
+ module PryTree
2
+ VERSION = "0.1.0"
3
+ end
data/pry-tree.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pry-tree/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pry-tree"
8
+ spec.version = PryTree::VERSION
9
+ spec.authors = ["Adrian Kuhn"]
10
+ spec.email = ["akuhn@iam.unibe.ch"]
11
+
12
+ spec.summary = %q{Show tree of classes and methods in a module.}
13
+ spec.homepage = "https://github.com/akuhn/pry-tree"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pry-tree
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Adrian Kuhn
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-02 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - akuhn@iam.unibe.ch
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".rspec"
22
+ - ".travis.yml"
23
+ - Gemfile
24
+ - README.md
25
+ - Rakefile
26
+ - bin/console
27
+ - bin/setup
28
+ - lib/pry-tree.rb
29
+ - lib/pry-tree/version.rb
30
+ - pry-tree.gemspec
31
+ homepage: https://github.com/akuhn/pry-tree
32
+ licenses: []
33
+ metadata: {}
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project:
50
+ rubygems_version: 2.4.6
51
+ signing_key:
52
+ specification_version: 4
53
+ summary: Show tree of classes and methods in a module.
54
+ test_files: []