cinatra 0.4.0 → 0.4.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.
- data/README.markdown +60 -0
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/lib/cinatra.rb +7 -5
- data/test/test_cinatra.rb +8 -0
- metadata +6 -6
- data/README.rdoc +0 -27
data/README.markdown
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
Cinatra
|
2
|
+
=======
|
3
|
+
|
4
|
+
Cinatra is a library for command based console application.
|
5
|
+
It is like Sinatra.
|
6
|
+
|
7
|
+
Feature
|
8
|
+
-----
|
9
|
+
|
10
|
+
* Easy to define commands
|
11
|
+
* Easy to run
|
12
|
+
* Completion for commands
|
13
|
+
* Similar to Sinatra :)
|
14
|
+
|
15
|
+
Usage
|
16
|
+
-----
|
17
|
+
|
18
|
+
require 'cinatra'
|
19
|
+
|
20
|
+
command 'todos' do |arg|
|
21
|
+
show_todos
|
22
|
+
end
|
23
|
+
|
24
|
+
sub command:
|
25
|
+
|
26
|
+
require 'cinatra'
|
27
|
+
|
28
|
+
command 'todo add' do |arg|
|
29
|
+
TODOS << arg
|
30
|
+
end
|
31
|
+
|
32
|
+
Run
|
33
|
+
-----
|
34
|
+
|
35
|
+
% ruby app.rb
|
36
|
+
|
37
|
+
Default Commands
|
38
|
+
-----
|
39
|
+
|
40
|
+
help:
|
41
|
+
|
42
|
+
> help
|
43
|
+
help Show help
|
44
|
+
exit Exit
|
45
|
+
...
|
46
|
+
|
47
|
+
exit:
|
48
|
+
|
49
|
+
> exit
|
50
|
+
%
|
51
|
+
|
52
|
+
Installation
|
53
|
+
-----
|
54
|
+
|
55
|
+
gem install cinatra
|
56
|
+
|
57
|
+
Copyright
|
58
|
+
-----
|
59
|
+
|
60
|
+
Copyright (c) 2009 jugyo. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -5,8 +5,8 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "cinatra"
|
8
|
-
gem.summary = %Q{
|
9
|
-
gem.description = %Q{Cinatra is a
|
8
|
+
gem.summary = %Q{Cinatra is a library for command based console application.}
|
9
|
+
gem.description = %Q{Cinatra is a library for command based console application. It is like Sinatra. :)}
|
10
10
|
gem.email = "jugyo.org@gmail.com"
|
11
11
|
gem.homepage = "http://github.com/jugyo/cinatra"
|
12
12
|
gem.authors = ["jugyo"]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.1
|
data/lib/cinatra.rb
CHANGED
@@ -36,16 +36,20 @@ class Cinatra
|
|
36
36
|
return if line.empty?
|
37
37
|
command_name, command_arg = resolve_command_name_and_arg(line)
|
38
38
|
unless command_name
|
39
|
-
puts "Error: Command not found
|
39
|
+
puts "Error: Command not found: #{line}"
|
40
40
|
else
|
41
41
|
begin
|
42
42
|
get_command(command_name).call(command_arg)
|
43
43
|
rescue Exception => e
|
44
|
-
puts e.message
|
44
|
+
puts "Error: #{e.message}\n #{e.backtrace.join("\n ")}"
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
def completion(text)
|
50
|
+
commands.keys.map {|i| i.to_s }.grep(/^#{Regexp.quote(text)}/)
|
51
|
+
end
|
52
|
+
|
49
53
|
def start
|
50
54
|
stty_save = `stty -g`.chomp
|
51
55
|
trap("INT") do
|
@@ -57,9 +61,7 @@ class Cinatra
|
|
57
61
|
end
|
58
62
|
|
59
63
|
Readline.basic_word_break_characters= "\t\n\"\\'`><=;|&{("
|
60
|
-
Readline.completion_proc = lambda
|
61
|
-
Cinatra.commands.keys.map {|i| i.to_s }.grep(/#{Regexp.quote(text)}/)
|
62
|
-
end
|
64
|
+
Readline.completion_proc = lambda {|text| completion(text) }
|
63
65
|
|
64
66
|
while !exiting && buf = Readline.readline('> ', true)
|
65
67
|
call(buf)
|
data/test/test_cinatra.rb
CHANGED
@@ -68,6 +68,14 @@ class TestCinatra < Test::Unit::TestCase
|
|
68
68
|
Cinatra.add_command('test foo', &@block_foo)
|
69
69
|
end
|
70
70
|
|
71
|
+
should "do completion" do
|
72
|
+
assert_equal ['test', 'test foo'], @instance.completion('')
|
73
|
+
assert_equal ['test', 'test foo'], @instance.completion('test')
|
74
|
+
assert_equal ['test foo'], @instance.completion('test ')
|
75
|
+
assert_equal [], @instance.completion('test b')
|
76
|
+
assert_equal [], @instance.completion('foo')
|
77
|
+
end
|
78
|
+
|
71
79
|
should "call command 'test'" do
|
72
80
|
mock(@block).call('bar')
|
73
81
|
Cinatra.call('test bar')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jugyo
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-02 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: "0"
|
34
34
|
version:
|
35
|
-
description: Cinatra is a
|
35
|
+
description: Cinatra is a library for command based console application. It is like Sinatra. :)
|
36
36
|
email: jugyo.org@gmail.com
|
37
37
|
executables: []
|
38
38
|
|
@@ -40,11 +40,11 @@ extensions: []
|
|
40
40
|
|
41
41
|
extra_rdoc_files:
|
42
42
|
- LICENSE
|
43
|
-
- README.
|
43
|
+
- README.markdown
|
44
44
|
files:
|
45
45
|
- .gitignore
|
46
46
|
- LICENSE
|
47
|
-
- README.
|
47
|
+
- README.markdown
|
48
48
|
- Rakefile
|
49
49
|
- VERSION
|
50
50
|
- examples/sleep.rb
|
@@ -80,7 +80,7 @@ rubyforge_project:
|
|
80
80
|
rubygems_version: 1.3.5
|
81
81
|
signing_key:
|
82
82
|
specification_version: 3
|
83
|
-
summary:
|
83
|
+
summary: Cinatra is a library for command based console application.
|
84
84
|
test_files:
|
85
85
|
- test/helper.rb
|
86
86
|
- test/test_cinatra.rb
|
data/README.rdoc
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
= Cinatra
|
2
|
-
|
3
|
-
Cinatra is a Sinatra like command base app library.
|
4
|
-
|
5
|
-
== Usage
|
6
|
-
|
7
|
-
require 'cinatra'
|
8
|
-
|
9
|
-
command 'sleep' do |arg|
|
10
|
-
sleep arg.to_f
|
11
|
-
end
|
12
|
-
|
13
|
-
command 'exit' do
|
14
|
-
Cinatra.exit
|
15
|
-
end
|
16
|
-
|
17
|
-
== Run
|
18
|
-
|
19
|
-
ruby app.rb
|
20
|
-
|
21
|
-
== Installation
|
22
|
-
|
23
|
-
gem install cinatra
|
24
|
-
|
25
|
-
== Copyright
|
26
|
-
|
27
|
-
Copyright (c) 2009 jugyo. See LICENSE for details.
|