pry-bloodline 0.0.1

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: 8b63c16b4138e7384bd64c9fac2bf62fd3f72131
4
+ data.tar.gz: 1b73d4e016f2a2b588d5f37f84193680deea3394
5
+ SHA512:
6
+ metadata.gz: 1120823c840f790ad64a0d6248b38e574b177dc4eb899dd01f3a20f4747cc1d89cdea01aa9079e5ed91bcc9df671e38f75305166fdcd7a1b0a65741360b0adc1
7
+ data.tar.gz: 6957354c67e03ffcf51dbd6c0e98bca61265c49cc260ac37276f35306173a6424b6687b09d5cd25ee63353da109be3564b7d71a3f2678fecfebf568d6bb9e1ed
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pry-bloodline.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Ju Liu
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # Pry Bloodline
2
+
3
+ A glorious descendant of a noble lineage of status lines, to be used with Pry.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ group :development, :test do
11
+ gem 'pry-bloodline'
12
+ end
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install pry-bloodline
22
+
23
+ ## Usage
24
+
25
+ Just run:
26
+
27
+ $ rails console
28
+
29
+ Or if you want to use it as your default pry shell, create a `.pryrc` file in your home folder:
30
+
31
+ ```ruby
32
+ require 'pry-bloodline'
33
+
34
+ PryBloodline.setup!
35
+ ```
36
+
37
+ Then:
38
+
39
+ $ pry
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it ( https://github.com/Arkham/pry-bloodline/fork )
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create a new Pull Request
@@ -0,0 +1,24 @@
1
+ require 'pry'
2
+ require 'readline'
3
+ require 'colorize'
4
+
5
+ require 'pry-bloodline/version'
6
+ require 'pry-bloodline/configuration'
7
+ require 'pry-bloodline/setup'
8
+ require 'pry-bloodline/railtie' if defined?(Rails)
9
+
10
+ module PryBloodline
11
+ class << self
12
+ def configuration
13
+ @configuration ||= Configuration.new
14
+ end
15
+
16
+ def configure
17
+ yield(configuration)
18
+ end
19
+
20
+ def setup!
21
+ Setup.new(configuration).setup!
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,57 @@
1
+ module PryBloodline
2
+ class Configuration
3
+
4
+ def self.configuration
5
+ PryBloodline.configuration
6
+ end
7
+
8
+ def self.c
9
+ configuration
10
+ end
11
+
12
+ DEFAULT_LINE_PROC = proc do |object, level, _pry_|
13
+ "[#{_pry_.input_array.size.to_s.bold}]".colorize(c.line_color)
14
+ end
15
+
16
+ DEFAULT_PATH_PROC = proc do |object, level, _pry_|
17
+ _pry_.binding_stack.map.each_with_index do |b, index|
18
+ if index.zero?
19
+ "~"
20
+ else
21
+ Pry.view_clip(b.eval("self"))
22
+ end
23
+ end.join("/").colorize(c.path_color)
24
+ end
25
+
26
+ DEFAULT_SEPARATOR_PROC = proc do
27
+ c.separator.colorize(c.separator_color)
28
+ end
29
+
30
+ DEFAULT_NAME_PROC = proc do
31
+ c.name.colorize(c.name_color)
32
+ end
33
+
34
+ DEFAULTS = {
35
+ name: "pry",
36
+ line_color: :white,
37
+ name_color: :blue,
38
+ path_color: :white,
39
+ separator: "\u00BB",
40
+ separator_color: :red,
41
+ name_proc: DEFAULT_NAME_PROC,
42
+ line_proc: DEFAULT_LINE_PROC,
43
+ path_proc: DEFAULT_PATH_PROC,
44
+ separator_proc: DEFAULT_SEPARATOR_PROC,
45
+ }.freeze
46
+
47
+ DEFAULT_METHODS = DEFAULTS.keys
48
+
49
+ attr_accessor *DEFAULT_METHODS
50
+
51
+ def initialize
52
+ DEFAULTS.each do |sym, value|
53
+ self.send("#{sym}=", value)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,10 @@
1
+ module PryBloodline
2
+ class Railtie < Rails::Railtie
3
+ initializer 'pry-bloodline.initialize' do |app|
4
+ PryBloodline.setup!
5
+ PryBloodline.configure do |c|
6
+ c.name = app.class.parent_name.underscore
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,64 @@
1
+ module PryBloodline
2
+ class Setup
3
+ attr_reader :configuration
4
+
5
+ def initialize(configuration)
6
+ @configuration = configuration
7
+ end
8
+
9
+ def setup!
10
+ Pry.config.prompt = [ prompt, multiline_prompt ]
11
+ end
12
+
13
+ def prompt
14
+ proc do |object, level, _pry_|
15
+ colorize.("#{prompt_without_separator.(object, level, _pry_)} #{separator_proc.()} ")
16
+ end
17
+ end
18
+
19
+ def multiline_prompt
20
+ proc do |object, level, _pry_|
21
+ padding = ' ' * prompt_without_separator.(object, level, _pry_).uncolorize.size
22
+ colorize.("#{padding} #{separator_proc.()} ")
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def prompt_without_separator
29
+ proc do |object, level, _pry_|
30
+ "#{line_proc.(object, level, _pry_)} #{name_proc.()} #{path_proc.(object, level, _pry_)}"
31
+ end
32
+ end
33
+
34
+ def colorize
35
+ proc do |message|
36
+ if color_enabled?
37
+ message
38
+ else
39
+ message.uncolorize
40
+ end
41
+ end
42
+ end
43
+
44
+ def color_enabled?
45
+ Pry.color && colored_prompt?
46
+ end
47
+
48
+ def colored_prompt?
49
+ Readline::VERSION !~ /EditLine/
50
+ end
51
+
52
+ def method_missing(method_sym, *args, &block)
53
+ if configuration.respond_to? method_sym
54
+ configuration.send(method_sym, *args, &block)
55
+ else
56
+ super
57
+ end
58
+ end
59
+
60
+ def respond_to_missing?(method_sym)
61
+ configuration.respond_to? method_sym
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,3 @@
1
+ module PryBloodline
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pry-bloodline/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pry-bloodline"
8
+ spec.version = PryBloodline::VERSION
9
+ spec.authors = ["Ju Liu"]
10
+ spec.email = ["ju.liu@welaika.com"]
11
+ spec.summary = %q{A glorious descendant of a noble lineage of status lines, to be used with Pry.}
12
+ spec.description = %q{A Pry plugin which enables a nice looking prompt, with many customizable components.}
13
+ spec.homepage = "https://github.com/Arkham/pry-bloodline"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "pry", "~> 0.10"
22
+ spec.add_runtime_dependency "colorize", "~> 0.7"
23
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pry-bloodline
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ju Liu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.10'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: colorize
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.7'
41
+ description: A Pry plugin which enables a nice looking prompt, with many customizable
42
+ components.
43
+ email:
44
+ - ju.liu@welaika.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - lib/pry-bloodline.rb
54
+ - lib/pry-bloodline/configuration.rb
55
+ - lib/pry-bloodline/railtie.rb
56
+ - lib/pry-bloodline/setup.rb
57
+ - lib/pry-bloodline/version.rb
58
+ - pry-bloodline.gemspec
59
+ homepage: https://github.com/Arkham/pry-bloodline
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.2.2
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: A glorious descendant of a noble lineage of status lines, to be used with
83
+ Pry.
84
+ test_files: []
85
+ has_rdoc: