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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d9c096643610ea450443b943aeafa6e730800fb
4
- data.tar.gz: 6c722c16fc8973bf43e74ad7185775a998fe298a
3
+ metadata.gz: 6eccdad43c0a88648366757e290f56d39cdb6f37
4
+ data.tar.gz: e21eff3b8a714dc4b43cdbf39c2801a1c3c28f4c
5
5
  SHA512:
6
- metadata.gz: c35e182ba770bdde0f3dad0cf8349eeae50c2f0b2f601e54bc5028325375fa1636ba1dfbf98d989d66e80fe3806dfaf10e8ef3bc0ba74f6ac393977d36141dec
7
- data.tar.gz: 559d8707f6d1a3e913925986767cb782400a276cc8eea6c07bbb9d6cd2e46c962f3f6466db225342b0273232e63870ab3e172e383a9b9e37202bfe542c608fdd
6
+ metadata.gz: 7a1c0ba046e5dc5b3bf84204b5765f83162cd45b0b3694be2b9b6cf91004129d7cf66ff340e3bde48d25f0c7a6f0f0050b5706ddbcc2ec39ee1b59431c9bbe5a
7
+ data.tar.gz: d65de01a734669d4dcf44710a3c83d8d5d28a6389174099b01c64ad7a364573bd146464a00c83b48473892c74b52d15ed1fe6ccc5dc090c1c79dcd27520bdcf5
@@ -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
- var_name_adjusted = var.to_s.ljust(25)
6
- print Pry::Helpers::Text.send(var_color, truncate(var_name_adjusted, 25) )
7
- print_stringified_val_or_nil value, value_color
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 - "...".chars.to_a.size
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 print_stringified_val_or_nil value, color
24
+ def stringified_val_or_nil value, color, length
19
25
  value = stringify_value value
20
26
  if value.empty?
21
- print Pry::Helpers::Text.red 'nil'
27
+ Pry::Helpers::Text.red 'nil'
22
28
  else
23
- print Pry::Helpers::Text.send(color, truncate(value, 60) )
29
+ text = truncate(value, length)
30
+ Pry::Helpers::Text.send(color, text)
24
31
  end
25
32
  end
26
33
 
@@ -1,3 +1,3 @@
1
1
  module PryState
2
- VERSION = '0.1.7'
2
+ VERSION = '0.1.8'
3
3
  end
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.7
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: 2015-09-23 00:00:00.000000000 Z
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.4.5
198
+ rubygems_version: 2.5.1
199
199
  signing_key:
200
200
  specification_version: 4
201
201
  summary: Shows the state in Pry Session