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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26b534bc1605227dad77821842bf5c839b29f35b
4
- data.tar.gz: cf118fcb64ca07918db99c924d34056b2387aa81
3
+ metadata.gz: ed8cf60d589d4b695bb7caf6576457d7e0f43b67
4
+ data.tar.gz: a7a109fe5ebe3ef4fac5e0571d8de1a354ed3eb8
5
5
  SHA512:
6
- metadata.gz: 64ffba11aee7a2c6a41b18927be6fc9149f3fbca21b7f709695d747bbb45e150df2285013b90d88c76b56e750f73dd432c74cb28fbe2f4543085d8df849cbab9
7
- data.tar.gz: 21429508ee917377b3dbaab607cee5af63520a28b3430df0786a7537528eec803cd7ce3f2203bbcf7df06570e295e9969fa21ecfd32a2dfa969c900b8208656f
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
- @prompt = "example:#{params[0] || ''}:$ "
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 )
@@ -1,3 +1,3 @@
1
1
  class ShellBase
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
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(@prompt, true).split(" ")
24
+ input = Readline.readline(prompt, true).split(" ")
26
25
  cmd = input.shift
27
26
 
28
27
  begin
@@ -3,7 +3,6 @@ require 'shell_base'
3
3
  describe ShellBase do
4
4
  before do
5
5
  class ExampleShell < ShellBase
6
- prompt "$ "
7
6
  def test
8
7
  puts "Test is success!"
9
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shell-base
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - myun2