pry-windows 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.
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2013 Conrad Irwin <conrad.irwin@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,34 @@
1
+ This gem makes it somewhat possible to use `utf-8` inside pry under windows.
2
+
3
+ Installation
4
+ ============
5
+
6
+ ### install the gem
7
+
8
+ `gem install pry-windows`
9
+
10
+ ### fix your console font
11
+
12
+ 1. Open `cmd.exe`
13
+ 2. Click the window icon in the title bar
14
+ 3. Go to Properties -> Fonts
15
+ 4. Choose Consolas or Lucidia Console (i.e. anything except Raster fonts)
16
+
17
+ Why?
18
+ ====
19
+
20
+ By default in windows you can only access characters in your home codepage (e.g. [CP437](http://en.wikipedia.org/wiki/Code_page_437)) which makes it hard to play with unicode. This gem makes it a bit easier by changing the codepage to CP65001 (otherwise known as UTF-8) while pry is running. This lets you output utf-8 (assuming you have fixed your font, as above). It also treats strings you type into pry as utf-8 by default.
21
+
22
+ Bugs
23
+ ====
24
+
25
+ It's not possible to type or paste non-ascii characters into `cmd.exe` when it's in `CP65001` mode.
26
+
27
+ If your ruby program exits unexpectedly, you will not be able to run other programs from your console until you fix the problem by running `chcp 437`
28
+
29
+
30
+ Meta-fu
31
+ =======
32
+
33
+ Licensed under the MIT license, bug-reports and pull-requests are welcome.
34
+
@@ -0,0 +1,25 @@
1
+ # The windows cmd.exe cannot handle utf-8 by default because it is set to a locale-specific codepage.
2
+ # This can be fixed by using CP65001 (which is Microsoft's name for utf-8) while pry is running.
3
+ #
4
+ # Unfortunately using CP65001 has a nasty bug whereby you can't run ruby programs from the shell, so
5
+ # we need to undo our change as ruby exits.
6
+ Pry.hooks.add_hook :before_session, :hack_utf8 do |*|
7
+ previous_codepage = `chcp`.scan(/[0-9]+/).first
8
+ `chcp 65001`
9
+ at_exit{ `chcp #{previous_codepage}` }
10
+ end
11
+
12
+ # For some reason `Readline.readline` always returns strings with #<Encoding:ASCII-8BIT>,
13
+ # let's just change that to utf-8 so that everything works more as expected:
14
+ #
15
+ # before this change:
16
+ # [1] pry(main)> "\xC3\xB7".encoding
17
+ # => #<Encoding:ASCII-8BIT>
18
+ #
19
+ # after:
20
+ # [2] pry(main)> "\xC3\xB7".encoding
21
+ # => #<Encoding:UTF-8>
22
+ #
23
+ Pry.hooks.add_hook :after_read, :hack_utf8 do |str, _|
24
+ str.force_encoding('utf-8')
25
+ end
@@ -0,0 +1,19 @@
1
+ Gem::Specification.new do |gem|
2
+ gem.name = 'pry-windows'
3
+ gem.version = '0.1'
4
+
5
+ gem.summary = 'Hacks to make pry work better under windows'
6
+ gem.description = "Makes it easier to get utf-8 support for pry in windows"
7
+
8
+ gem.authors = ['Conrad Irwin']
9
+ gem.email = %w(conrad.irwin@gmail.com)
10
+ gem.homepage = 'http://github.com/ConradIrwin/pry-windows'
11
+
12
+ gem.license = 'MIT'
13
+
14
+ gem.required_ruby_version = '>= 1.8.7'
15
+
16
+ gem.add_dependency 'pry', '>= 0.9.12'
17
+
18
+ gem.files = `git ls-files`.split("\n")
19
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pry-windows
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Conrad Irwin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: pry
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.12
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.9.12
30
+ description: Makes it easier to get utf-8 support for pry in windows
31
+ email:
32
+ - conrad.irwin@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - LICENSE.MIT
38
+ - README.md
39
+ - lib/pry-windows.rb
40
+ - pry-windows.gemspec
41
+ homepage: http://github.com/ConradIrwin/pry-windows
42
+ licenses:
43
+ - MIT
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 1.8.7
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubyforge_project:
62
+ rubygems_version: 1.8.23
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: Hacks to make pry work better under windows
66
+ test_files: []
67
+ has_rdoc: