coolline 0.0.1pre

Sign up to get free protection for your applications and to get access to all the features.
data/test/helpers.rb ADDED
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift File.expand_path(File.join("../lib"), File.dirname(__FILE__))
2
+
3
+ require 'riot'
4
+ require 'coolline'
5
+
6
+ Riot.reporter = Riot::PrettyDotMatrixReporter
7
+
8
+ TestDir = File.dirname(__FILE__)
9
+
10
+ def path_to(file)
11
+ File.join(TestDir, file)
12
+ end
@@ -0,0 +1,85 @@
1
+ require File.expand_path("helpers.rb", File.dirname(__FILE__))
2
+
3
+ context "a newly created history" do
4
+ setup do
5
+ Coolline::History.new(path_to("history"), 10)
6
+ end
7
+
8
+ asserts(:size).equals 0
9
+ asserts(:max_size).equals 10
10
+
11
+ context "after inserting a new-line" do
12
+ hookup do
13
+ topic << "1"
14
+ end
15
+
16
+ asserts(:size).equals 1
17
+ asserts(:max_size).equals 10
18
+
19
+ asserts(:[], 0).equals "1"
20
+
21
+ context "and many others" do
22
+ hookup do
23
+ 2.upto(11) { |n| topic << n.to_s }
24
+ end
25
+
26
+ asserts(:size).equals 10
27
+ asserts(:max_size).equals 10
28
+
29
+ 2.upto(11) do |n|
30
+ asserts(:[], n - 2).equals n.to_s
31
+ end
32
+ end
33
+ end
34
+
35
+ teardown do
36
+ File.delete path_to("history")
37
+ end
38
+ end
39
+
40
+ context "an history from an existing file" do
41
+ setup do
42
+ open(path_to("history"), 'w') do |io|
43
+ io.puts((1..13).to_a)
44
+ end
45
+
46
+ Coolline::History.new(path_to("history"), 15)
47
+ end
48
+
49
+ asserts(:size).equals 13
50
+ asserts(:max_size).equals 15
51
+
52
+ 1.upto(13) do |n|
53
+ asserts(:[], n - 1).equals n.to_s
54
+ end
55
+
56
+ asserts("search for 3") { topic.search(/3/).to_a }.equals [["13",12], ["3",2]]
57
+ asserts("search for 3 before last line") {
58
+ topic.search(/3/, -2).to_a
59
+ }.equals [["3",2]]
60
+
61
+ teardown do
62
+ File.delete path_to("history")
63
+ end
64
+ end
65
+
66
+ context "an history from a huge existing file" do
67
+ setup do
68
+ open(path_to("history"), 'w') do |io|
69
+ io.puts((1..20).to_a)
70
+ end
71
+
72
+ Coolline::History.new(path_to("history"), 15)
73
+ end
74
+
75
+ asserts(:size).equals 15
76
+ asserts(:max_size).equals 15
77
+
78
+ 6.upto(20) do |n|
79
+ asserts(:[], n - 6).equals n.to_s
80
+ end
81
+
82
+ teardown do
83
+ File.delete path_to("history")
84
+ end
85
+ end
data/test/run_all.rb ADDED
@@ -0,0 +1,5 @@
1
+ require File.expand_path("helpers.rb", File.dirname(__FILE__))
2
+
3
+ Dir.glob(File.join(File.dirname(__FILE__), "**/*_test.rb")) do |file|
4
+ load file
5
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coolline
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1pre
5
+ prerelease: 5
6
+ platform: ruby
7
+ authors:
8
+ - Mon ouie
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: riot
16
+ requirement: &19279600 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *19279600
25
+ description: ! 'A readline-like library that allows to change how the input
26
+
27
+ is displayed.
28
+
29
+ '
30
+ email: mon.ouie@gmail.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - lib/coolline/handler.rb
36
+ - lib/coolline/history.rb
37
+ - lib/coolline/editor.rb
38
+ - lib/coolline/coolline.rb
39
+ - lib/coolline/version.rb
40
+ - lib/coolline.rb
41
+ - test/helpers.rb
42
+ - test/editor_test.rb
43
+ - test/run_all.rb
44
+ - test/history_test.rb
45
+ - repl.rb
46
+ - .gemtest
47
+ homepage: http://github.com/Mon-Ouie/coolline
48
+ licenses: []
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>'
63
+ - !ruby/object:Gem::Version
64
+ version: 1.3.1
65
+ requirements: []
66
+ rubyforge_project:
67
+ rubygems_version: 1.8.10
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Sounds like readline, smells like readline, but isn't readline
71
+ test_files: []