cogy 0.1.1 → 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/CHANGELOG.md +27 -0
- data/LICENSE +1 -1
- data/README.md +166 -32
- data/app/controllers/cogy/cogy_controller.rb +10 -3
- data/lib/cogy/capistrano/cogy.rake +30 -0
- data/lib/cogy/capistrano.rb +15 -1
- data/lib/cogy/command.rb +5 -1
- data/lib/cogy/context.rb +37 -7
- data/lib/cogy/engine.rb +12 -0
- data/lib/cogy/version.rb +1 -1
- data/lib/cogy.rb +43 -40
- data/lib/generators/cogy/templates/cogy_config.rb +7 -4
- data/test/dummy/cogy/builtin_helpers.rb +11 -0
- data/test/dummy/cogy/foo.rb +3 -0
- data/test/dummy/cogy/json_response.rb +7 -0
- data/test/dummy/cogy/templates/pretty-command +5 -0
- data/test/dummy/config/initializers/cogy.rb +7 -4
- data/test/dummy/log/test.log +4846 -0
- data/test/integration/builtin_helpers_test.rb +24 -0
- data/test/integration/command_test.rb +5 -10
- data/test/integration/error_template_test.rb +20 -0
- data/test/integration/inventory_test.rb +18 -4
- data/test/integration/json_response_test.rb +29 -0
- metadata +16 -3
- data/lib/cogy/capistrano/v2/tasks.rb +0 -1
@@ -0,0 +1,24 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module Cogy
|
4
|
+
class BuiltinHelpersTest < ActionDispatch::IntegrationTest
|
5
|
+
include Engine.routes.url_helpers
|
6
|
+
|
7
|
+
setup { @routes = Engine.routes }
|
8
|
+
|
9
|
+
def test_args_helper_overrides_predefined_helpers
|
10
|
+
get "/cogy/cmd/args_overrides/george", cog_argv_1: "hu", cog_argv_0: "haha"
|
11
|
+
assert_equal "hahahu", response.body
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_args_with_empty_arguments
|
15
|
+
get "/cogy/cmd/empty_args/george"
|
16
|
+
assert_equal "true", response.body
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_args
|
20
|
+
get "/cogy/cmd/add/george", cog_argv_0: 1, cog_argv_1: 2
|
21
|
+
assert_equal "3", response.body
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -6,16 +6,6 @@ module Cogy
|
|
6
6
|
|
7
7
|
setup { @routes = Engine.routes }
|
8
8
|
|
9
|
-
def test_error_tmpl_message
|
10
|
-
get "/cogy/cmd/raiser/george"
|
11
|
-
assert response.body.include?("boom")
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_error_tmpl_contenttype
|
15
|
-
get "/cogy/cmd/raiser/george"
|
16
|
-
assert_equal "text/plain", response.content_type.to_s
|
17
|
-
end
|
18
|
-
|
19
9
|
def test_error_response_code
|
20
10
|
get "/cogy/cmd/raiser/george"
|
21
11
|
assert_equal 500, response.status
|
@@ -53,5 +43,10 @@ module Cogy
|
|
53
43
|
|
54
44
|
assert_match(/\[:type, :required\]/, exception.message)
|
55
45
|
end
|
46
|
+
|
47
|
+
def test_args_ordering
|
48
|
+
get "/cogy/cmd/args_order/george", cog_argv_2: 3, cog_argv_1: 2, cog_argv_0: 1
|
49
|
+
assert_equal "123", response.body
|
50
|
+
end
|
56
51
|
end
|
57
52
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module Cogy
|
4
|
+
class ErrorTemplateTest < ActionDispatch::IntegrationTest
|
5
|
+
include Engine.routes.url_helpers
|
6
|
+
|
7
|
+
setup { @routes = Engine.routes }
|
8
|
+
|
9
|
+
def test_error_tmpl_message
|
10
|
+
get "/cogy/cmd/raiser/george"
|
11
|
+
assert response.body.include?("boom")
|
12
|
+
assert response.body.include?("@george")
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_error_tmpl_contenttype
|
16
|
+
get "/cogy/cmd/raiser/george"
|
17
|
+
assert_equal "text/plain", response.content_type.to_s
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -8,8 +8,8 @@ module Cogy
|
|
8
8
|
setup { @routes = Engine.routes }
|
9
9
|
|
10
10
|
def test_valid_yaml
|
11
|
-
with_config(
|
12
|
-
|
11
|
+
with_config(bundle: { name: "hyu", version: "5.0",
|
12
|
+
description: "Yet another bundle" },
|
13
13
|
command_load_paths: ["cogy"]) do |inv|
|
14
14
|
assert_equal "hyu", inv["name"]
|
15
15
|
assert_equal "5.0", inv["version"]
|
@@ -22,13 +22,13 @@ module Cogy
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_bundle_version_lambda
|
25
|
-
with_config(
|
25
|
+
with_config(bundle: { version: -> { 1 + 2 } }) do |inv|
|
26
26
|
assert_equal 3, inv["version"]
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_commands_section
|
31
|
-
with_config(
|
31
|
+
with_config(bundle: { cogy_executable: "/bin/no" }) do |inv|
|
32
32
|
expected = {
|
33
33
|
"executable" => "/bin/no",
|
34
34
|
"description" => "Print a foo",
|
@@ -49,5 +49,19 @@ module Cogy
|
|
49
49
|
get "/cogy/inventory"
|
50
50
|
assert_equal "application/x-yaml", response.content_type
|
51
51
|
end
|
52
|
+
|
53
|
+
def test_template
|
54
|
+
get "/cogy/inventory"
|
55
|
+
|
56
|
+
expected = <<TEMPLATE.strip
|
57
|
+
**foo:** ~$results[0].name~
|
58
|
+
|
59
|
+
~br~
|
60
|
+
|
61
|
+
foo
|
62
|
+
TEMPLATE
|
63
|
+
|
64
|
+
assert_equal expected, fetch_inventory["templates"]["pretty-command"]["body"]
|
65
|
+
end
|
52
66
|
end
|
53
67
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module Cogy
|
4
|
+
class JsonResponseTest < ActionDispatch::IntegrationTest
|
5
|
+
include Engine.routes.url_helpers
|
6
|
+
|
7
|
+
setup { @routes = Engine.routes }
|
8
|
+
|
9
|
+
def test_json_output_and_default_template
|
10
|
+
get "/cogy/cmd/simple_json/george"
|
11
|
+
|
12
|
+
expected = "COG_TEMPLATE: simple_json\n" \
|
13
|
+
"JSON\n" \
|
14
|
+
'{"a":3,"b":4}'
|
15
|
+
|
16
|
+
assert_equal expected, response.body
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_custom_template
|
20
|
+
get "/cogy/cmd/custom_template/hyu"
|
21
|
+
|
22
|
+
expected = "COG_TEMPLATE: foo\n" \
|
23
|
+
"JSON\n" \
|
24
|
+
'{"a":3}'
|
25
|
+
|
26
|
+
assert_equal expected, response.body
|
27
|
+
end
|
28
|
+
end
|
29
|
+
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.
|
4
|
+
version: 0.2.0
|
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-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -102,6 +102,7 @@ executables: []
|
|
102
102
|
extensions: []
|
103
103
|
extra_rdoc_files: []
|
104
104
|
files:
|
105
|
+
- CHANGELOG.md
|
105
106
|
- LICENSE
|
106
107
|
- README.md
|
107
108
|
- Rakefile
|
@@ -111,7 +112,7 @@ files:
|
|
111
112
|
- config/routes.rb
|
112
113
|
- lib/cogy.rb
|
113
114
|
- lib/cogy/capistrano.rb
|
114
|
-
- lib/cogy/capistrano/
|
115
|
+
- lib/cogy/capistrano/cogy.rake
|
115
116
|
- lib/cogy/command.rb
|
116
117
|
- lib/cogy/context.rb
|
117
118
|
- lib/cogy/engine.rb
|
@@ -131,8 +132,11 @@ files:
|
|
131
132
|
- test/dummy/bin/rails
|
132
133
|
- test/dummy/bin/rake
|
133
134
|
- test/dummy/bin/setup
|
135
|
+
- test/dummy/cogy/builtin_helpers.rb
|
134
136
|
- test/dummy/cogy/foo.rb
|
135
137
|
- test/dummy/cogy/fully_fledged.rb
|
138
|
+
- test/dummy/cogy/json_response.rb
|
139
|
+
- test/dummy/cogy/templates/pretty-command
|
136
140
|
- test/dummy/config.ru
|
137
141
|
- test/dummy/config/application.rb
|
138
142
|
- test/dummy/config/boot.rb
|
@@ -159,9 +163,12 @@ files:
|
|
159
163
|
- test/dummy/public/422.html
|
160
164
|
- test/dummy/public/500.html
|
161
165
|
- test/dummy/public/favicon.ico
|
166
|
+
- test/integration/builtin_helpers_test.rb
|
162
167
|
- test/integration/command_test.rb
|
168
|
+
- test/integration/error_template_test.rb
|
163
169
|
- test/integration/helpers_test.rb
|
164
170
|
- test/integration/inventory_test.rb
|
171
|
+
- test/integration/json_response_test.rb
|
165
172
|
- test/support/helpers.rb
|
166
173
|
- test/test_helper.rb
|
167
174
|
homepage: https://github.com/skroutz/cogy
|
@@ -196,8 +203,11 @@ test_files:
|
|
196
203
|
- test/dummy/bin/rails
|
197
204
|
- test/dummy/bin/rake
|
198
205
|
- test/dummy/bin/setup
|
206
|
+
- test/dummy/cogy/builtin_helpers.rb
|
199
207
|
- test/dummy/cogy/foo.rb
|
200
208
|
- test/dummy/cogy/fully_fledged.rb
|
209
|
+
- test/dummy/cogy/json_response.rb
|
210
|
+
- test/dummy/cogy/templates/pretty-command
|
201
211
|
- test/dummy/config/application.rb
|
202
212
|
- test/dummy/config/boot.rb
|
203
213
|
- test/dummy/config/database.yml
|
@@ -226,8 +236,11 @@ test_files:
|
|
226
236
|
- test/dummy/public/favicon.ico
|
227
237
|
- test/dummy/Rakefile
|
228
238
|
- test/dummy/README.rdoc
|
239
|
+
- test/integration/builtin_helpers_test.rb
|
229
240
|
- test/integration/command_test.rb
|
241
|
+
- test/integration/error_template_test.rb
|
230
242
|
- test/integration/helpers_test.rb
|
231
243
|
- test/integration/inventory_test.rb
|
244
|
+
- test/integration/json_response_test.rb
|
232
245
|
- test/support/helpers.rb
|
233
246
|
- test/test_helper.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
puts "foo"
|