shell-base 0.1.2 → 0.2.0
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.
- checksums.yaml +4 -4
- data/README.md +4 -5
- data/lib/shell_base/version.rb +1 -1
- data/lib/shell_base.rb +6 -7
- data/spec/shell_base_spec.rb +0 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed8cf60d589d4b695bb7caf6576457d7e0f43b67
|
4
|
+
data.tar.gz: a7a109fe5ebe3ef4fac5e0571d8de1a354ed3eb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89120005b61e65cc602d1b18fc6e8fefb176704d4ced0152e297686ebc94653c920aa3d222a70e6b9040424a319f71b27ef713189ae5efe53ba4a502a2a37bb7
|
7
|
+
data.tar.gz: 164dc852525cab1539ec2d6b601b67edc1e9d8eabb6410dac8efdcf8e7e86107eb58fb3d45d81b290237d000f9d4ec5d1ce2adf8aa944454532d0118353840a5
|
data/README.md
CHANGED
@@ -20,11 +20,12 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
```ruby
|
22
22
|
class ExampleShell < ShellBase
|
23
|
-
prompt "example:$ "
|
24
|
-
|
25
23
|
def hello(*params)
|
26
24
|
puts "hello " + params.join(" ") + "."
|
27
|
-
|
25
|
+
end
|
26
|
+
|
27
|
+
def prompt
|
28
|
+
"example:$ "
|
28
29
|
end
|
29
30
|
end
|
30
31
|
ExampleShell.new
|
@@ -34,8 +35,6 @@ for example implemented `hello` command.
|
|
34
35
|
|
35
36
|
And exit to `exit` command.
|
36
37
|
|
37
|
-
`@prompt` instance variable is prompt string.
|
38
|
-
|
39
38
|
## Contributing
|
40
39
|
|
41
40
|
1. Fork it ( https://github.com/myun2ext/shell-base/fork )
|
data/lib/shell_base/version.rb
CHANGED
data/lib/shell_base.rb
CHANGED
@@ -3,18 +3,17 @@ require 'readline'
|
|
3
3
|
|
4
4
|
class ShellBase
|
5
5
|
class Exit < Exception; end
|
6
|
-
def self.prompt(s)
|
7
|
-
@@default_prompt = s
|
8
|
-
end
|
9
6
|
|
10
7
|
def initialize
|
11
|
-
@prompt = @@default_prompt
|
12
8
|
while readline; end
|
13
9
|
end
|
14
10
|
|
11
|
+
def prompt
|
12
|
+
"$ "
|
13
|
+
end
|
14
|
+
|
15
15
|
def exit
|
16
|
-
puts "bye."
|
17
|
-
raise Exit
|
16
|
+
puts "bye."; raise Exit
|
18
17
|
end
|
19
18
|
|
20
19
|
def method_missing(method_name)
|
@@ -22,7 +21,7 @@ class ShellBase
|
|
22
21
|
end
|
23
22
|
|
24
23
|
def readline
|
25
|
-
input = Readline.readline(
|
24
|
+
input = Readline.readline(prompt, true).split(" ")
|
26
25
|
cmd = input.shift
|
27
26
|
|
28
27
|
begin
|
data/spec/shell_base_spec.rb
CHANGED