pry-state 0.1.3

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: ee49672ca3300d999e59c2150c3b1ead8236082a
4
+ data.tar.gz: 6f9b483a4cb8393eed70330e037c665b03357260
5
+ SHA512:
6
+ metadata.gz: 8dafa4dfe231bf5929a6dd852c3af23075a1b62a2e81b824eede720918a93e62d9ff6ba2a3bcdace40495b2ab12371ec83c1f5a24fef00e79c02ede984054e2d
7
+ data.tar.gz: 1b75a93b7b0d219ce4ebed30368fcab24d743aa67afbd1be227a1977f9e48f83f0e908dab545a00a13ec487d9d79c8d52eeb98a4ae6cccf082ebd3afab5a99d0
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.gem
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pry-state.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Sudhagar
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,37 @@
1
+ # Pry::State
2
+
3
+ Pry state is an extension of pry. With pry state you can see the values of the instance and local variables in a pry session.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'pry-state'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install pry-state
20
+
21
+ ## Usage
22
+
23
+ There is no need to edit any configuration. After you have added the dependency in Gemfile, pry-state will add a hook to pry to listen to before_session events.
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ 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` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it ( https://github.com/[my-github-username]/pry-state/fork )
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pry-state"
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-state.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "pry"
2
+ require "pry-state/version"
3
+ require 'pry-state/hook_action'
4
+
5
+
6
+ Pry.hooks.add_hook(:before_session, "pry_state_hook") do |output, binding, pry|
7
+ HookAction.new(binding).act
8
+ end
@@ -0,0 +1,64 @@
1
+ class HookAction
2
+ IGNORABLE_LOCAL_VARS = [:__, :_, :_ex_, :_pry_, :_out_, :_in_, :_dir_, :_file_, :prev_binding]
3
+ IGNORABLE_INSTANCE_VARS = [:@_request, :@_response, :@_routes, :@_prev_instance_state, :@_prev_local_state]
4
+
5
+ def initialize binding
6
+ @binding = binding
7
+ @instance_variables = @binding.eval('instance_variables')
8
+ @local_variables = @binding.eval('local_variables')
9
+ end
10
+
11
+ def act
12
+ (instance_variables - IGNORABLE_INSTANCE_VARS).each do |var|
13
+ eval_and_print var, 'green'
14
+ end
15
+
16
+ (local_variables - IGNORABLE_LOCAL_VARS).each do |var|
17
+ eval_and_print var, 'cyan'
18
+ end
19
+ end
20
+
21
+ private
22
+ attr_reader :binding, :instance_variables, :local_variables
23
+
24
+ def eval_and_print var, color
25
+ var_name_adjusted = var.to_s.ljust(25)
26
+ print Pry::Helpers::Text.send(color, truncate(var_name_adjusted, 25) )
27
+ value = binding.eval(var.to_s)
28
+ print_stringified_val_or_nil value
29
+ end
30
+
31
+ def print_stringified_val_or_nil value
32
+ value = stringify_value value
33
+ if value.empty?
34
+ print Pry::Helpers::Text.red 'nil'
35
+ else
36
+ print truncate(value, 60)
37
+ end
38
+ print "\n"
39
+ end
40
+
41
+ def stringify_value value
42
+ if value.class == String
43
+ "\"#{value}\""
44
+ else
45
+ value.to_s
46
+ end
47
+ end
48
+
49
+ def truncate text, length
50
+ if text.nil? then return end
51
+ l = length - "...".chars.to_a.size
52
+ (text.chars.to_a.size > length ? text.chars.to_a[0...l].join + "..." : text).to_s
53
+ end
54
+
55
+ # def prev_value var
56
+ # prev_binding = binding.eval('@_prev_binding')
57
+ # puts binding
58
+ # puts prev_binding
59
+ # value = prev_binding.eval var.to_s
60
+ # print "prev value of #{var} is #{value.to_s.truncate(20)}"
61
+ # value
62
+ # end
63
+
64
+ end
@@ -0,0 +1,3 @@
1
+ module PryState
2
+ VERSION = '0.1.3'
3
+ end
data/pry-state.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pry-state/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pry-state"
8
+ spec.version = PryState::VERSION
9
+ spec.authors = ["Sudhagar"]
10
+ spec.email = ["sudhagar@isudhagar.in"]
11
+ spec.summary = 'Shows the state in Pry Session'
12
+ spec.description = 'Pry state lets you to see the values of the instance and local variables in a pry session'
13
+ spec.homepage = "https://github.com/SudhagarS/pry-state"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.9"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_runtime_dependency 'pry', '>= 0.9.10', '< 0.11.0'
24
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pry-state
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Sudhagar
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-07-26 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.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
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: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.9.10
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: 0.11.0
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 0.9.10
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.11.0
61
+ description: Pry state lets you to see the values of the instance and local variables
62
+ in a pry session
63
+ email:
64
+ - sudhagar@isudhagar.in
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - ".gitignore"
70
+ - CODE_OF_CONDUCT.md
71
+ - Gemfile
72
+ - LICENSE.txt
73
+ - README.md
74
+ - Rakefile
75
+ - bin/console
76
+ - bin/setup
77
+ - lib/pry-state.rb
78
+ - lib/pry-state/hook_action.rb
79
+ - lib/pry-state/version.rb
80
+ - pry-state.gemspec
81
+ homepage: https://github.com/SudhagarS/pry-state
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.4.5
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: Shows the state in Pry Session
105
+ test_files: []