cogy 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -3
- data/app/controllers/cogy/cogy_controller.rb +9 -2
- data/app/views/cogy/error.text.erb +5 -0
- data/lib/cogy/version.rb +1 -1
- data/lib/cogy.rb +8 -2
- metadata +3 -3
- data/MIT-LICENSE +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28ec300393c739ebc8a9f7b3d84fb9934e8f9778
|
4
|
+
data.tar.gz: b685e1a2685d49340dbadf54550375a9689d2ac8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90b69b70b3b6a243ff59c6bf7ec4ea8f1c0e8ed6a88a9ea5b0579126c78e34a574379975ebcbdc3ee8a0ff54f40b5609893fcad0ee0bf2b72160712cb6ab7f9e
|
7
|
+
data.tar.gz: a944b9dafce7515bdf84a95547228ba832b11dfc1d02ce40ab16c136005ca7be0930f3022fcc2d384ff9c833cf79211b5897ad39afa2d896416083ac3a314643
|
data/README.md
CHANGED
@@ -93,7 +93,7 @@ Cogy.configure do |config|
|
|
93
93
|
# directory relative to the root of your application.
|
94
94
|
#
|
95
95
|
# Default: ["cogy"]
|
96
|
-
config.command_load_paths = "
|
96
|
+
config.command_load_paths = "cogy"
|
97
97
|
end
|
98
98
|
|
99
99
|
```
|
@@ -127,9 +127,27 @@ on "calc",
|
|
127
127
|
end
|
128
128
|
```
|
129
129
|
|
130
|
-
##
|
130
|
+
## Error template
|
131
131
|
|
132
|
-
|
132
|
+
When a command throws an error, the default error template is rendered, which
|
133
|
+
is the following:
|
134
|
+
|
135
|
+
@<%= @user %>: Command '<%= @cmd %>' returned an error.
|
136
|
+
|
137
|
+
```
|
138
|
+
<%= @exception.class %>:<%= @exception.message %>
|
139
|
+
```
|
140
|
+
|
141
|
+
However it can be overriden in the application by creating a view in
|
142
|
+
`app/views/cogy/error.text.erb`.
|
143
|
+
|
144
|
+
## Authors
|
145
|
+
|
146
|
+
* [Agis Anastasopoulos](https://github.com/agis-)
|
147
|
+
|
148
|
+
## License
|
149
|
+
|
150
|
+
Cogy is licensed under MIT. See [LICENSE](LICENSE).
|
133
151
|
|
134
152
|
|
135
153
|
|
@@ -2,7 +2,7 @@ require_dependency "cogy/application_controller"
|
|
2
2
|
|
3
3
|
module Cogy
|
4
4
|
class CogyController < ApplicationController
|
5
|
-
# GET
|
5
|
+
# GET <mount_path>/cmd/:cmd/:user
|
6
6
|
def command
|
7
7
|
cmd = params[:cmd]
|
8
8
|
args = request.query_parameters.select { |k,_| k !~ /\Acog_opt_/ }.values
|
@@ -10,7 +10,14 @@ module Cogy
|
|
10
10
|
.transform_keys { |k| k.sub("cog_opt_", "") }
|
11
11
|
user = params[:user]
|
12
12
|
|
13
|
-
|
13
|
+
begin
|
14
|
+
render text: Cogy.commands[cmd].run!(args, opts, user)
|
15
|
+
rescue => e
|
16
|
+
@user = user
|
17
|
+
@cmd = cmd
|
18
|
+
@exception = e
|
19
|
+
render "cogy/error"
|
20
|
+
end
|
14
21
|
end
|
15
22
|
|
16
23
|
# GET /inventory
|
data/lib/cogy/version.rb
CHANGED
data/lib/cogy.rb
CHANGED
@@ -59,11 +59,17 @@ module Cogy
|
|
59
59
|
config["commands"][name] = {
|
60
60
|
"executable" => executable_path,
|
61
61
|
"description" => cmd.desc,
|
62
|
-
"arguments" => cmd.formatted_args,
|
63
|
-
"options" => cmd.formatted_opts,
|
64
62
|
"rules" => cmd.rules
|
65
63
|
}
|
66
64
|
|
65
|
+
if !cmd.args.empty?
|
66
|
+
config["commands"][name]["arguments"] = cmd.formatted_args
|
67
|
+
end
|
68
|
+
|
69
|
+
if !cmd.opts.empty?
|
70
|
+
config["commands"][name]["options"] = cmd.formatted_opts
|
71
|
+
end
|
72
|
+
|
67
73
|
if cmd.long_desc
|
68
74
|
config["commands"][name]["long_description"] = cmd.long_desc
|
69
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cogy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Agis Anastasopoulos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -51,11 +51,11 @@ executables: []
|
|
51
51
|
extensions: []
|
52
52
|
extra_rdoc_files: []
|
53
53
|
files:
|
54
|
-
- MIT-LICENSE
|
55
54
|
- README.md
|
56
55
|
- Rakefile
|
57
56
|
- app/controllers/cogy/application_controller.rb
|
58
57
|
- app/controllers/cogy/cogy_controller.rb
|
58
|
+
- app/views/cogy/error.text.erb
|
59
59
|
- config/routes.rb
|
60
60
|
- lib/cogy.rb
|
61
61
|
- lib/cogy/command.rb
|
data/MIT-LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright 2016 Agis Anastasopoulos
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|