pry-state 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pry-state/printer.rb +14 -7
- data/lib/pry-state/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6eccdad43c0a88648366757e290f56d39cdb6f37
|
4
|
+
data.tar.gz: e21eff3b8a714dc4b43cdbf39c2801a1c3c28f4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a1c0ba046e5dc5b3bf84204b5765f83162cd45b0b3694be2b9b6cf91004129d7cf66ff340e3bde48d25f0c7a6f0f0050b5706ddbcc2ec39ee1b59431c9bbe5a
|
7
|
+
data.tar.gz: d65de01a734669d4dcf44710a3c83d8d5d28a6389174099b01c64ad7a364573bd146464a00c83b48473892c74b52d15ed1fe6ccc5dc090c1c79dcd27520bdcf5
|
data/lib/pry-state/printer.rb
CHANGED
@@ -2,25 +2,32 @@ module Printer
|
|
2
2
|
extend self
|
3
3
|
|
4
4
|
def trunc_and_print var, value, var_color, value_color
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
width = ENV['COLUMNS'] ? ENV['COLUMNS'].to_i : 80
|
6
|
+
# Ratios are 1:3 left:right
|
7
|
+
left_column_width = width / 4
|
8
|
+
left_column_width = left_column_width < 25 ? 25 : left_column_width
|
9
|
+
var_name_adjusted = var.to_s.ljust(left_column_width)
|
10
|
+
# Ensure at least 1 space between left and right columns
|
11
|
+
left_column_text = truncate(var_name_adjusted, left_column_width - 1) + ' '
|
12
|
+
print Pry::Helpers::Text.send(var_color, left_column_text)
|
13
|
+
print stringified_val_or_nil(value, value_color, width - left_column_width)
|
8
14
|
print "\n"
|
9
15
|
end
|
10
16
|
|
11
17
|
private
|
12
18
|
def truncate text, length
|
13
19
|
if text.nil? then return end
|
14
|
-
l = length - "...".
|
20
|
+
l = length - "...".length
|
15
21
|
(text.chars.to_a.size > length ? text.chars.to_a[0...l].join + "..." : text).to_s
|
16
22
|
end
|
17
23
|
|
18
|
-
def
|
24
|
+
def stringified_val_or_nil value, color, length
|
19
25
|
value = stringify_value value
|
20
26
|
if value.empty?
|
21
|
-
|
27
|
+
Pry::Helpers::Text.red 'nil'
|
22
28
|
else
|
23
|
-
|
29
|
+
text = truncate(value, length)
|
30
|
+
Pry::Helpers::Text.send(color, text)
|
24
31
|
end
|
25
32
|
end
|
26
33
|
|
data/lib/pry-state/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-state
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sudhagar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
195
|
version: '0'
|
196
196
|
requirements: []
|
197
197
|
rubyforge_project:
|
198
|
-
rubygems_version: 2.
|
198
|
+
rubygems_version: 2.5.1
|
199
199
|
signing_key:
|
200
200
|
specification_version: 4
|
201
201
|
summary: Shows the state in Pry Session
|