readline-ng 0.0.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -4,7 +4,7 @@
4
4
  # development environment upon cd'ing into the directory
5
5
 
6
6
  # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7
- environment_id="ruby-1.9.3-p125"
7
+ environment_id="ruby-1.9.3-p327"
8
8
 
9
9
  #
10
10
  # Uncomment following line if you want options to be set only for given project.
@@ -0,0 +1,30 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ readline-ng (0.1.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.1.3)
10
+ metaclass (0.0.1)
11
+ mocha (0.12.3)
12
+ metaclass (~> 0.0.1)
13
+ rake (0.9.2.2)
14
+ rspec (2.11.0)
15
+ rspec-core (~> 2.11.0)
16
+ rspec-expectations (~> 2.11.0)
17
+ rspec-mocks (~> 2.11.0)
18
+ rspec-core (2.11.1)
19
+ rspec-expectations (2.11.2)
20
+ diff-lcs (~> 1.1.3)
21
+ rspec-mocks (2.11.2)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ mocha
28
+ rake
29
+ readline-ng!
30
+ rspec
@@ -7,8 +7,8 @@ module ReadlineNG
7
7
  n = ::ReadlineNG::ChunkedString.new
8
8
 
9
9
  VERSION_MAJOR = 0
10
- VERSION_MINOR = 0
11
- VERSION_PATCH = 9
10
+ VERSION_MINOR = 2
11
+ VERSION_PATCH = 0
12
12
  VERSION = "#{VERSION_MAJOR}.#{VERSION_MINOR}.#{VERSION_PATCH}"
13
13
 
14
14
  CONTROL_BS = "\x08"
@@ -58,10 +58,8 @@ module ReadlineNG
58
58
  end
59
59
 
60
60
  def wait(n)
61
- (n * polling_resolution).times do
62
- tick
63
- sleep 1.0/polling_resolution
64
- end
61
+ to_read, _, _ = IO.select([STDIN], [], [], n)
62
+ tick unless to_read.empty?
65
63
  end
66
64
 
67
65
  def puts_above(string)
@@ -101,8 +99,12 @@ module ReadlineNG
101
99
  # TODO This method is getting monolithic, think about how to modularise it
102
100
  case c
103
101
  when "\r"
104
- @lines += [@buf]
105
- reset
102
+ if @buf[@index-1] == ?\\
103
+ @buf[@index-1] = "\n"
104
+ else
105
+ @lines += [@buf]
106
+ reset
107
+ end
106
108
  when CONTROL_INT
107
109
  raise Interrupt
108
110
  when KB_BS
@@ -83,6 +83,16 @@ describe ReadlineNG do
83
83
  @reader.get_line.should == "'''"
84
84
  end
85
85
 
86
+ it "should insert a newline from a trailing backslash" do
87
+ STDIN.stub(:read_nonblock).and_return("rawr", ?\\, "\r", "thing", "\r")
88
+ @reader.get_line.should == "rawr\nthing"
89
+ end
90
+
91
+ it "Shouldn't explode if you backspace beyond the start of the line" do
92
+ STDIN.stub(:read_nonblock).and_return("rawr", "\x7F"*14, "rawr\r")
93
+ @reader.get_line.should == "rawr"
94
+ end
95
+
86
96
  # TODO it "should erase the displayed line when input is terminated" do
87
97
 
88
98
  end
metadata CHANGED
@@ -1,71 +1,75 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: readline-ng
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 9
9
- version: 0.0.9
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Rich Healey
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2012-05-12 00:00:00 +10:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-01-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rspec
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- version: "0"
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
30
22
  type: :development
31
- version_requirements: *id001
32
- - !ruby/object:Gem::Dependency
33
- name: mocha
34
23
  prerelease: false
35
- requirement: &id002 !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- segments:
40
- - 0
41
- version: "0"
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: mocha
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
42
38
  type: :development
43
- version_requirements: *id002
44
- - !ruby/object:Gem::Dependency
45
- name: rake
46
39
  prerelease: false
47
- requirement: &id003 !ruby/object:Gem::Requirement
48
- requirements:
49
- - - ">="
50
- - !ruby/object:Gem::Version
51
- segments:
52
- - 0
53
- version: "0"
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
54
  type: :development
55
- version_requirements: *id003
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
56
62
  description: Essentially, readline++
57
- email:
63
+ email:
58
64
  - richo@psych0tik.net
59
65
  executables: []
60
-
61
66
  extensions: []
62
-
63
67
  extra_rdoc_files: []
64
-
65
- files:
68
+ files:
66
69
  - .rvmrc
67
70
  - .travis.yml
68
71
  - Gemfile
72
+ - Gemfile.lock
69
73
  - Gemfile.travis
70
74
  - README.md
71
75
  - Rakefile
@@ -74,35 +78,29 @@ files:
74
78
  - readline-ng.gemspec
75
79
  - readline.rb
76
80
  - spec/readline-ng_spec.rb
77
- has_rdoc: true
78
81
  homepage: http://github.com/richo/readline-ng
79
82
  licenses: []
80
-
81
83
  post_install_message:
82
84
  rdoc_options: []
83
-
84
- require_paths:
85
+ require_paths:
85
86
  - lib
86
- required_ruby_version: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- segments:
91
- - 0
92
- version: "0"
93
- required_rubygems_version: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- segments:
98
- - 0
99
- version: "0"
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
100
99
  requirements: []
101
-
102
100
  rubyforge_project:
103
- rubygems_version: 1.3.6
101
+ rubygems_version: 1.8.24
104
102
  signing_key:
105
103
  specification_version: 3
106
104
  summary: Essentially, readline++
107
- test_files:
105
+ test_files:
108
106
  - spec/readline-ng_spec.rb