fancy_irb 0.6.2 → 0.6.3

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.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010 Jan Lelis
1
+ Copyright (c) 2010-2011 Jan Lelis
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -108,6 +108,6 @@ Feel free to fix a bug or implement a todo ;)
108
108
 
109
109
  Inspired by the irb_rocket gem from genki.
110
110
 
111
- Copyright (c) 2010 Jan Lelis, http://rbjl.net, released under the MIT license.
111
+ Copyright (c) 2010-2011 Jan Lelis, http://rbjl.net, released under the MIT license.
112
112
 
113
113
  J-_-L
data/Rakefile CHANGED
@@ -7,13 +7,14 @@ begin
7
7
  gem.name = "fancy_irb"
8
8
  gem.summary = %q{FancyIrb patches your IRB to create a smooth output experience.}
9
9
  gem.description = %q{FancyIrb patches your IRB to create a smooth output experience.
10
- * Use fancy colors! You can colorize the prompts, irb errors, +stderr+ and +stdout+
10
+ * Use fancy colors! You can colorize the prompts, irb errors, stderr and stdout
11
11
  * Output results as Ruby comment #=> (rocket)
12
12
  * Enhance your output value, using procs}
13
13
  gem.email = "mail@janlelis.de"
14
14
  gem.homepage = "http://github.com/janlelis/fancy_irb"
15
15
  gem.authors = ["Jan Lelis"]
16
16
  gem.add_dependency 'wirble'
17
+ gem.add_dependency 'unicode-display_width'
17
18
  end
18
19
  Jeweler::GemcutterTasks.new
19
20
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.2
1
+ 0.6.3
data/fancy_irb.gemspec CHANGED
@@ -1,36 +1,34 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fancy_irb}
8
- s.version = "0.6.2"
8
+ s.version = "0.6.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jan Lelis"]
12
- s.date = %q{2010-11-10}
12
+ s.date = %q{2011-01-03}
13
13
  s.description = %q{FancyIrb patches your IRB to create a smooth output experience.
14
- * Use fancy colors! You can colorize the prompts, irb errors, +stderr+ and +stdout+
14
+ * Use fancy colors! You can colorize the prompts, irb errors, stderr and stdout
15
15
  * Output results as Ruby comment #=> (rocket)
16
16
  * Enhance your output value, using procs}
17
17
  s.email = %q{mail@janlelis.de}
18
18
  s.extra_rdoc_files = [
19
19
  "LICENSE",
20
- "README.rdoc"
20
+ "README.rdoc"
21
21
  ]
22
22
  s.files = [
23
- ".gitignore",
24
- "LICENSE",
25
- "README.rdoc",
26
- "Rakefile",
27
- "VERSION",
28
- "fancy_irb.gemspec",
29
- "lib/fancy_irb.rb",
30
- "lib/fancy_irb/irb_ext.rb"
23
+ "LICENSE",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "fancy_irb.gemspec",
28
+ "lib/fancy_irb.rb",
29
+ "lib/fancy_irb/irb_ext.rb"
31
30
  ]
32
31
  s.homepage = %q{http://github.com/janlelis/fancy_irb}
33
- s.rdoc_options = ["--charset=UTF-8"]
34
32
  s.require_paths = ["lib"]
35
33
  s.rubygems_version = %q{1.3.7}
36
34
  s.summary = %q{FancyIrb patches your IRB to create a smooth output experience.}
@@ -41,11 +39,14 @@ Gem::Specification.new do |s|
41
39
 
42
40
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
41
  s.add_runtime_dependency(%q<wirble>, [">= 0"])
42
+ s.add_runtime_dependency(%q<unicode-display_width>, [">= 0"])
44
43
  else
45
44
  s.add_dependency(%q<wirble>, [">= 0"])
45
+ s.add_dependency(%q<unicode-display_width>, [">= 0"])
46
46
  end
47
47
  else
48
48
  s.add_dependency(%q<wirble>, [">= 0"])
49
+ s.add_dependency(%q<unicode-display_width>, [">= 0"])
49
50
  end
50
51
  end
51
52
 
@@ -1,5 +1,12 @@
1
1
  module IRB
2
2
  class Irb
3
+ TPUT = {
4
+ :sc => `tput sc`,
5
+ :rc => `tput rc`,
6
+ :cuu1 => `tput cuu1`,
7
+ :cuf1 => `tput cuf1`,
8
+ }
9
+
3
10
  def colorize(string, color)
4
11
  if defined?(Wirble) && color && color_string = Wirble::Colorize::Color.escape( color.to_sym )
5
12
  color_string + string.to_s + Wirble::Colorize::Color.escape( :nothing )
@@ -33,7 +40,7 @@ module IRB
33
40
  # get lengths
34
41
  last_input = @scanner.instance_variable_get( :@line )
35
42
  last_line_without_prompt = last_input.split("\n").last
36
- offset = last_line_without_prompt.size + FancyIrb.real_lengths[:input_prompt] + 1
43
+ offset = last_line_without_prompt.display_size + FancyIrb.real_lengths[:input_prompt] + 1
37
44
  screen_length = `tput cols`.to_i
38
45
  screen_lines = `tput lines`.to_i
39
46
  output_length = FancyIrb.real_lengths[:output]
@@ -44,12 +51,12 @@ module IRB
44
51
  if FancyIrb[:rocket_mode] &&
45
52
  screen_length > offset + rocket_length + output_length &&
46
53
  stdout_lines < screen_lines
47
- print `tput sc` + # save current cursor position
48
- `tput cuu1`*stdout_lines + # move cursor upwards to the original input line
49
- `tput cuf1`*offset + # move cursor rightwards to the original input offset
54
+ print TPUT[:sc] + # save current cursor position
55
+ TPUT[:cuu1]*stdout_lines + # move cursor upwards to the original input line
56
+ TPUT[:cuf1]*offset + # move cursor rightwards to the original input offset
50
57
  rocket + # draw rocket prompt
51
58
  output + # draw output
52
- `tput rc` # return to normal cursor position
59
+ TPUT[:rc] # return to normal cursor position
53
60
  return
54
61
  end
55
62
  end
data/lib/fancy_irb.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'stringio'
2
2
  require 'wirble'
3
+ require 'unicode/display_width'
3
4
 
4
5
  module FancyIrb
5
6
  VERSION = ( File.read File.expand_path( '../VERSION', File.dirname(__FILE__)) ).chomp
@@ -106,8 +107,7 @@ class << FancyIrb
106
107
  def track_height(data)
107
108
  lines = data.to_s.count("\n")
108
109
  long_lines = data.to_s.split("\n").inject(0){ |sum, line|
109
- line_size = (RUBY_VERSION[2] == ?8) ? line.unpack('U*').size : line.size
110
- sum + (line_size / `tput cols`.to_i)
110
+ sum + (line.display_size / `tput cols`.to_i)
111
111
  }
112
112
  @height_counter << lines + long_lines
113
113
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fancy_irb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 2
10
- version: 0.6.2
9
+ - 3
10
+ version: 0.6.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jan Lelis
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-10 00:00:00 +01:00
18
+ date: 2011-01-03 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -32,9 +32,23 @@ dependencies:
32
32
  version: "0"
33
33
  type: :runtime
34
34
  version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: unicode-display_width
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
35
49
  description: |-
36
50
  FancyIrb patches your IRB to create a smooth output experience.
37
- * Use fancy colors! You can colorize the prompts, irb errors, +stderr+ and +stdout+
51
+ * Use fancy colors! You can colorize the prompts, irb errors, stderr and stdout
38
52
  * Output results as Ruby comment #=> (rocket)
39
53
  * Enhance your output value, using procs
40
54
  email: mail@janlelis.de
@@ -46,7 +60,6 @@ extra_rdoc_files:
46
60
  - LICENSE
47
61
  - README.rdoc
48
62
  files:
49
- - .gitignore
50
63
  - LICENSE
51
64
  - README.rdoc
52
65
  - Rakefile
@@ -59,8 +72,8 @@ homepage: http://github.com/janlelis/fancy_irb
59
72
  licenses: []
60
73
 
61
74
  post_install_message:
62
- rdoc_options:
63
- - --charset=UTF-8
75
+ rdoc_options: []
76
+
64
77
  require_paths:
65
78
  - lib
66
79
  required_ruby_version: !ruby/object:Gem::Requirement
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- *.swp
2
- *~
3
- doc
4
- pkg