console_runner 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +78 -1
- data/lib/console_runner/version.rb +1 -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: dfc0511852127d604ae309cfc39364d21107e0b6
|
4
|
+
data.tar.gz: 4aad476abc1e57409be5b61925deacc2e30b4354
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c8ce2344ea0ed28c89a0df3c3d46adc04b1a6eda040c39a6b6264e3729a78dc06ad8eec97e7ac29672aaa24a11d9ad7767f0b7ab4eb7a875b46325bc7272064
|
7
|
+
data.tar.gz: 71373f02f65eec0cecf438eb72d4f33bd7c09bb076d7509e7df2ff5dad612b91babbce3d408e321e8afec1c14c6839f421b0108c318ef8cf5998db84ae6fd28b
|
data/README.md
CHANGED
@@ -25,8 +25,85 @@ Or install it yourself as:
|
|
25
25
|
$ gem install console_runner
|
26
26
|
|
27
27
|
## Usage
|
28
|
+
Usage is simple. First of all you need to add `gem 'console_runner'` in your `Gemfile`.
|
29
|
+
Then you need to specify `@runnable` tag in your class and method annotations. For example,
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
# This is basic Ruby class with YARD annotation.
|
33
|
+
# Nothing special here except @runnable tag. This is a `console_runner` tag that
|
34
|
+
# shows that this class can be runnable via bash command line.
|
35
|
+
#
|
36
|
+
# You can mark any method (class method or instance method) with @runnable tag to show you want the method to be executable.
|
37
|
+
# We name class method as *class action* and instance method as *instance action* or just *action*.
|
38
|
+
# Instance action requires #initialize method to be executed first. `console_runner` tool invokes #initialize
|
39
|
+
# method automatically.
|
40
|
+
#
|
41
|
+
# @author Yuri Karpovich
|
42
|
+
#
|
43
|
+
# @runnable This is your "smart" assistant tool.
|
44
|
+
# NOTE: This message will be shown in your tool in --help menu.
|
45
|
+
#
|
46
|
+
# @since 0.1.0
|
47
|
+
class SimpleSiri
|
48
|
+
|
49
|
+
def initialize
|
50
|
+
@name = 'Siri'
|
51
|
+
@age = Random.rand 100
|
52
|
+
end
|
53
|
+
|
54
|
+
# Say something
|
55
|
+
#
|
56
|
+
# @runnable
|
57
|
+
# @return [String]
|
58
|
+
# @param [String] what_to_say ask name or age of Siri
|
59
|
+
def say(what_to_say)
|
60
|
+
case what_to_say.downcase
|
61
|
+
when 'name'
|
62
|
+
puts 'My name is ' + @name
|
63
|
+
when 'age'
|
64
|
+
puts "I'm #{@age} years old"
|
65
|
+
else
|
66
|
+
puts "I don't know".green
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
```
|
72
|
+
|
73
|
+
Then you can run the tool in your console:
|
74
|
+
```bash
|
75
|
+
c_run ruby_class.rb say --help
|
76
|
+
|
77
|
+
This is your "smart" assistant tool.
|
78
|
+
NOTE: This message will be shown in your tool in --help menu.
|
79
|
+
-h, --help Show this message
|
80
|
+
-w, --what-to-say=<s> (Ruby class: String) ask name or age of Siri
|
81
|
+
```
|
82
|
+
|
83
|
+
```bash
|
84
|
+
c_run ruby_class.rb say -w age
|
85
|
+
|
86
|
+
=======================================================
|
87
|
+
Global options:
|
88
|
+
help = false
|
89
|
+
INIT: initialize
|
90
|
+
INIT options:
|
91
|
+
|
92
|
+
Subcommand: say
|
93
|
+
Subcommand options:
|
94
|
+
what_to_say = age
|
95
|
+
=======================================================
|
96
|
+
Start Time: 2017-04-11 21:39:40 +0300
|
97
|
+
I'm 78 years old
|
98
|
+
Finish Time: 2017-04-11 21:39:40 +0300 (Duration: 0.0 minutes)
|
99
|
+
|
100
|
+
```
|
28
101
|
|
29
|
-
|
102
|
+
## ToDo
|
103
|
+
- fix help menu for action: action help text should be displayed.
|
104
|
+
- add tests for class actions
|
105
|
+
- add tests for same methods naming
|
106
|
+
- write good readme
|
30
107
|
|
31
108
|
## Development
|
32
109
|
|