rubysl-readline 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +0 -1
  3. data/.travis.yml +8 -0
  4. data/README.md +2 -2
  5. data/Rakefile +0 -1
  6. data/ext/rubysl/readline/extconf.rb +64 -0
  7. data/ext/rubysl/readline/readline.c +537 -0
  8. data/lib/readline.rb +1 -0
  9. data/lib/rubysl/readline.rb +2 -0
  10. data/lib/{rubysl-readline → rubysl/readline}/version.rb +1 -1
  11. data/rubysl-readline.gemspec +20 -18
  12. data/spec/basic_quote_characters_spec.rb +18 -0
  13. data/spec/basic_word_break_characters_spec.rb +18 -0
  14. data/spec/completer_quote_characters_spec.rb +18 -0
  15. data/spec/completer_word_break_characters_spec.rb +18 -0
  16. data/spec/completion_append_character_spec.rb +18 -0
  17. data/spec/completion_case_fold_spec.rb +20 -0
  18. data/spec/completion_proc_spec.rb +24 -0
  19. data/spec/constants_spec.rb +20 -0
  20. data/spec/emacs_editing_mode_spec.rb +11 -0
  21. data/spec/filename_quote_characters_spec.rb +18 -0
  22. data/spec/history/append_spec.rb +30 -0
  23. data/spec/history/delete_at_spec.rb +47 -0
  24. data/spec/history/each_spec.rb +31 -0
  25. data/spec/history/element_reference_spec.rb +42 -0
  26. data/spec/history/element_set_spec.rb +37 -0
  27. data/spec/history/empty_spec.rb +15 -0
  28. data/spec/history/history_spec.rb +11 -0
  29. data/spec/history/length_spec.rb +10 -0
  30. data/spec/history/pop_spec.rb +32 -0
  31. data/spec/history/push_spec.rb +28 -0
  32. data/spec/history/shared/size.rb +14 -0
  33. data/spec/history/shift_spec.rb +32 -0
  34. data/spec/history/size_spec.rb +10 -0
  35. data/spec/history/to_s_spec.rb +11 -0
  36. data/spec/readline_spec.rb +32 -0
  37. data/spec/vi_editing_mode_spec.rb +11 -0
  38. metadata +135 -87
  39. data/lib/rubysl-readline.rb +0 -7
data/lib/readline.rb ADDED
@@ -0,0 +1 @@
1
+ require "rubysl/readline"
@@ -0,0 +1,2 @@
1
+ require "readline/readline"
2
+ require "rubysl/readline/version"
@@ -1,5 +1,5 @@
1
1
  module RubySL
2
2
  module Readline
3
- VERSION = "0.0.1"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
@@ -1,22 +1,24 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/rubysl-readline/version', __FILE__)
1
+ # coding: utf-8
2
+ require './lib/rubysl/readline/version'
3
3
 
4
- Gem::Specification.new do |gem|
5
- gem.authors = ["Brian Shirai"]
6
- gem.email = ["brixen@gmail.com"]
7
- gem.description = %q{Ruby Standard Library - readline}
8
- gem.summary = %q{Ruby Standard Library - readline}
9
- gem.homepage = ""
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "rubysl-readline"
6
+ spec.version = RubySL::Readline::VERSION
7
+ spec.authors = ["Brian Shirai"]
8
+ spec.email = ["brixen@gmail.com"]
9
+ spec.description = %q{Ruby standard library readline.}
10
+ spec.summary = %q{Ruby standard library readline.}
11
+ spec.homepage = "https://github.com/rubysl/rubysl-readline"
12
+ spec.license = "BSD"
10
13
 
11
- gem.files = `git ls-files`.split($\)
12
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
- gem.name = "rubysl-readline"
15
- gem.require_paths = ["lib"]
16
- gem.version = RubySL::Readline::VERSION
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.extensions = ["ext/rubysl/readline/extconf.rb"]
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
17
19
 
18
- gem.add_runtime_dependency "redcard", "~> 1.0"
19
-
20
- gem.add_development_dependency "rake", "~> 10.0"
21
- gem.add_development_dependency "mspec", "~> 1.5"
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "mspec", "~> 1.5"
23
+ spec.add_development_dependency "rubysl-prettyprint", "~> 1.0"
22
24
  end
@@ -0,0 +1,18 @@
1
+ process_is_foreground do
2
+ with_feature :readline do
3
+ require 'readline'
4
+
5
+ describe "Readline.basic_quote_characters" do
6
+ it "returns not nil" do
7
+ Readline.basic_quote_characters.should_not be_nil
8
+ end
9
+ end
10
+
11
+ describe "Readline.basic_quote_characters=" do
12
+ it "returns the passed string" do
13
+ Readline.basic_quote_characters = "test"
14
+ Readline.basic_quote_characters.should == "test"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ process_is_foreground do
2
+ with_feature :readline do
3
+ require 'readline'
4
+
5
+ describe "Readline.basic_word_break_characters" do
6
+ it "returns not nil" do
7
+ Readline.basic_word_break_characters.should_not be_nil
8
+ end
9
+ end
10
+
11
+ describe "Readline.basic_word_break_characters=" do
12
+ it "returns the passed string" do
13
+ Readline.basic_word_break_characters = "test"
14
+ Readline.basic_word_break_characters.should == "test"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ process_is_foreground do
2
+ with_feature :readline do
3
+ require 'readline'
4
+
5
+ describe "Readline.completer_quote_characters" do
6
+ it "returns nil" do
7
+ Readline.completer_quote_characters.should be_nil
8
+ end
9
+ end
10
+
11
+ describe "Readline.completer_quote_characters=" do
12
+ it "returns the passed string" do
13
+ Readline.completer_quote_characters = "test"
14
+ Readline.completer_quote_characters.should == "test"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ process_is_foreground do
2
+ with_feature :readline do
3
+ require 'readline'
4
+
5
+ describe "Readline.completer_word_break_characters" do
6
+ it "returns nil" do
7
+ Readline.completer_word_break_characters.should be_nil
8
+ end
9
+ end
10
+
11
+ describe "Readline.completer_word_break_characters=" do
12
+ it "returns the passed string" do
13
+ Readline.completer_word_break_characters = "test"
14
+ Readline.completer_word_break_characters.should == "test"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ process_is_foreground do
2
+ with_feature :readline do
3
+ require 'readline'
4
+
5
+ describe "Readline.completion_append_character" do
6
+ it "returns not nil" do
7
+ Readline.completion_append_character.should_not be_nil
8
+ end
9
+ end
10
+
11
+ describe "Readline.completion_append_character=" do
12
+ it "returns the first character of the passed string" do
13
+ Readline.completion_append_character = "test"
14
+ Readline.completion_append_character.should == "t"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ process_is_foreground do
2
+ with_feature :readline do
3
+ require 'readline'
4
+
5
+ describe "Readline.completion_case_fold" do
6
+ it "returns nil" do
7
+ Readline.completion_case_fold.should be_nil
8
+ end
9
+ end
10
+
11
+ describe "Readline.completion_case_fold=" do
12
+ it "returns the passed boolean" do
13
+ Readline.completion_case_fold = true
14
+ Readline.completion_case_fold.should == true
15
+ Readline.completion_case_fold = false
16
+ Readline.completion_case_fold.should == false
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,24 @@
1
+ process_is_foreground do
2
+ with_feature :readline do
3
+ require 'readline'
4
+
5
+ describe "Readline.completion_proc" do
6
+ it "returns nil" do
7
+ Readline.completion_proc.should be_nil
8
+ end
9
+ end
10
+
11
+ describe "Readline.completion_proc=" do
12
+ it "returns the passed Proc" do
13
+ proc = Proc.new do |e|
14
+ end
15
+ Readline.completion_proc = proc
16
+ Readline.completion_proc.should == proc
17
+ end
18
+
19
+ it "returns an ArgumentError if not given an Proc or #call" do
20
+ lambda { Readline.completion_proc = "test" }.should raise_error(ArgumentError)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ process_is_foreground do
2
+ with_feature :readline do
3
+ require 'readline'
4
+
5
+ # Note: additional specs for HISTORY are in 'history' subdir.
6
+ describe "Readline::HISTORY" do
7
+ it "is defined" do
8
+ Readline.const_defined?(:HISTORY).should == true
9
+ end
10
+ end
11
+
12
+ describe "Readline::VERSION" do
13
+ it "is defined and is a non-empty String" do
14
+ Readline.const_defined?(:VERSION).should == true
15
+ Readline::VERSION.should be_kind_of(String)
16
+ Readline::VERSION.should_not be_empty
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ process_is_foreground do
2
+ with_feature :readline do
3
+ require 'readline'
4
+
5
+ describe "Readline.emacs_editing_mode" do
6
+ it "returns nil" do
7
+ Readline.emacs_editing_mode.should be_nil
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,18 @@
1
+ process_is_foreground do
2
+ with_feature :readline do
3
+ require 'readline'
4
+
5
+ describe "Readline.filename_quote_characters" do
6
+ it "returns nil" do
7
+ Readline.filename_quote_characters.should be_nil
8
+ end
9
+ end
10
+
11
+ describe "Readline.filename_quote_characters=" do
12
+ it "returns the passed string" do
13
+ Readline.filename_quote_characters = "test"
14
+ Readline.filename_quote_characters.should == "test"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,30 @@
1
+ process_is_foreground do
2
+ with_feature :readline do
3
+ require 'readline'
4
+
5
+ describe "Readline::HISTORY.<<" do
6
+ it "appends the given Object to the history" do
7
+ Readline::HISTORY << "1"
8
+ Readline::HISTORY.size.should == 1
9
+
10
+ Readline::HISTORY << "2"
11
+ Readline::HISTORY.size.should == 2
12
+
13
+ Readline::HISTORY.pop.should == "2"
14
+ Readline::HISTORY.pop.should == "1"
15
+ end
16
+
17
+ it "tries to convert the passed Object to a String using #to_str" do
18
+ obj = mock("Converted to String")
19
+ obj.should_receive(:to_str).and_return("converted")
20
+
21
+ Readline::HISTORY << obj
22
+ Readline::HISTORY.pop.should == "converted"
23
+ end
24
+
25
+ it "raises a TypeError when the passed Object can't be converted to a String" do
26
+ lambda { Readline::HISTORY << mock("Object") }.should raise_error(TypeError)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,47 @@
1
+ process_is_foreground do
2
+ with_feature :readline do
3
+ require 'readline'
4
+
5
+ describe "Readline::HISTORY.delete_at" do
6
+ it "deletes and returns the history entry at the specified index" do
7
+ Readline::HISTORY.push("1", "2", "3")
8
+
9
+ Readline::HISTORY.delete_at(1).should == "2"
10
+ Readline::HISTORY.size.should == 2
11
+
12
+ Readline::HISTORY.delete_at(1).should == "3"
13
+ Readline::HISTORY.size.should == 1
14
+
15
+ Readline::HISTORY.delete_at(0).should == "1"
16
+ Readline::HISTORY.size.should == 0
17
+
18
+
19
+ Readline::HISTORY.push("1", "2", "3", "4")
20
+
21
+ Readline::HISTORY.delete_at(-2).should == "3"
22
+ Readline::HISTORY.size.should == 3
23
+
24
+ Readline::HISTORY.delete_at(-2).should == "2"
25
+ Readline::HISTORY.size.should == 2
26
+
27
+ Readline::HISTORY.delete_at(0).should == "1"
28
+ Readline::HISTORY.size.should == 1
29
+
30
+ Readline::HISTORY.delete_at(0).should == "4"
31
+ Readline::HISTORY.size.should == 0
32
+ end
33
+
34
+ it "raises an IndexError when the given index is greater than the history size" do
35
+ lambda { Readline::HISTORY.delete_at(10) }.should raise_error(IndexError)
36
+ lambda { Readline::HISTORY.delete_at(-10) }.should raise_error(IndexError)
37
+ end
38
+
39
+ it "taints the returned strings" do
40
+ Readline::HISTORY.push("1", "2", "3")
41
+ Readline::HISTORY.delete_at(0).tainted?.should be_true
42
+ Readline::HISTORY.delete_at(0).tainted?.should be_true
43
+ Readline::HISTORY.delete_at(0).tainted?.should be_true
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,31 @@
1
+ process_is_foreground do
2
+ with_feature :readline do
3
+ require 'readline'
4
+
5
+ describe "Readline::HISTORY.each" do
6
+ before(:each) do
7
+ Readline::HISTORY.push("1", "2", "3")
8
+ end
9
+
10
+ after(:each) do
11
+ Readline::HISTORY.pop
12
+ Readline::HISTORY.pop
13
+ Readline::HISTORY.pop
14
+ end
15
+
16
+ it "yields each item in the history" do
17
+ result = []
18
+ Readline::HISTORY.each do |x|
19
+ result << x
20
+ end
21
+ result.should == ["1", "2", "3"]
22
+ end
23
+
24
+ it "yields tainted Objects" do
25
+ Readline::HISTORY.each do |x|
26
+ x.tainted?.should be_true
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,42 @@
1
+ process_is_foreground do
2
+ with_feature :readline do
3
+ require 'readline'
4
+
5
+ describe "Readline::HISTORY.[]" do
6
+ before(:each) do
7
+ Readline::HISTORY.push("1", "2", "3")
8
+ end
9
+
10
+ after(:each) do
11
+ Readline::HISTORY.pop
12
+ Readline::HISTORY.pop
13
+ Readline::HISTORY.pop
14
+ end
15
+
16
+ it "returns tainted objects" do
17
+ Readline::HISTORY[0].tainted?.should be_true
18
+ Readline::HISTORY[1].tainted?.should be_true
19
+ end
20
+
21
+ it "returns the history item at the passed index" do
22
+ Readline::HISTORY[0].should == "1"
23
+ Readline::HISTORY[1].should == "2"
24
+ Readline::HISTORY[2].should == "3"
25
+
26
+ Readline::HISTORY[-1].should == "3"
27
+ Readline::HISTORY[-2].should == "2"
28
+ Readline::HISTORY[-3].should == "1"
29
+ end
30
+
31
+ it "raises an IndexError when there is no item at the passed index" do
32
+ lambda { Readline::HISTORY[-10] }.should raise_error(IndexError)
33
+ lambda { Readline::HISTORY[-9] }.should raise_error(IndexError)
34
+ lambda { Readline::HISTORY[-8] }.should raise_error(IndexError)
35
+
36
+ lambda { Readline::HISTORY[8] }.should raise_error(IndexError)
37
+ lambda { Readline::HISTORY[9] }.should raise_error(IndexError)
38
+ lambda { Readline::HISTORY[10] }.should raise_error(IndexError)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,37 @@
1
+ process_is_foreground do
2
+ with_feature :readline do
3
+ require 'readline'
4
+
5
+ describe "Readline::HISTORY.[]=" do
6
+ before(:each) do
7
+ Readline::HISTORY.push("1", "2", "3")
8
+ end
9
+
10
+ after(:each) do
11
+ Readline::HISTORY.pop
12
+ Readline::HISTORY.pop
13
+ Readline::HISTORY.pop
14
+ end
15
+
16
+ it "returns the new value for the passed index" do
17
+ (Readline::HISTORY[1] = "second test").should == "second test"
18
+ end
19
+
20
+ it "raises an IndexError when there is no item at the passed positive index" do
21
+ lambda { Readline::HISTORY[10] = "test" }.should raise_error(IndexError)
22
+ end
23
+
24
+ it "sets the item at the given index" do
25
+ Readline::HISTORY[0] = "test"
26
+ Readline::HISTORY[0].should == "test"
27
+
28
+ Readline::HISTORY[1] = "second test"
29
+ Readline::HISTORY[1].should == "second test"
30
+ end
31
+
32
+ it "raises an IndexError when there is no item at the passed negative index" do
33
+ lambda { Readline::HISTORY[10] = "test" }.should raise_error(IndexError)
34
+ end
35
+ end
36
+ end
37
+ end