cogy 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +20 -0
- data/README.md +140 -52
- data/Rakefile +4 -14
- data/app/controllers/cogy/cogy_controller.rb +26 -5
- data/app/views/cogy/error.text.erb +1 -1
- data/lib/cogy/command.rb +33 -16
- data/lib/cogy/context.rb +52 -0
- data/lib/cogy/engine.rb +2 -8
- data/lib/cogy/invocation.rb +37 -0
- data/lib/cogy/version.rb +1 -1
- data/lib/cogy.rb +111 -20
- data/lib/generators/cogy/config_generator.rb +15 -0
- data/lib/generators/cogy/install_generator.rb +25 -0
- data/lib/generators/cogy/templates/cogy_config.rb +8 -0
- data/lib/generators/cogy/templates/cogy_folder_readme.md +4 -0
- data/lib/generators/cogy/templates/command_file.rb +8 -0
- data/test/dummy/cogy/foo.rb +24 -0
- data/test/dummy/cogy/fully_fledged.rb +14 -0
- data/test/dummy/config/application.rb +3 -4
- data/test/dummy/config/environments/development.rb +4 -4
- data/test/dummy/config/environments/test.rb +1 -1
- data/test/dummy/config/initializers/cogy.rb +10 -0
- data/test/dummy/config/routes.rb +2 -1
- data/test/dummy/log/development.log +84 -0
- data/test/dummy/log/test.log +18184 -0
- data/test/integration/command_test.rb +47 -0
- data/test/integration/helpers_test.rb +19 -0
- data/test/integration/inventory_test.rb +54 -0
- data/test/support/helpers.rb +30 -0
- data/test/test_helper.rb +4 -10
- metadata +71 -13
- data/lib/cogy/handler.rb +0 -14
- data/test/cogy_test.rb +0 -7
- data/test/dummy/app/assets/javascripts/application.js +0 -13
- data/test/dummy/app/assets/stylesheets/application.css +0 -15
- data/test/integration/navigation_test.rb +0 -8
@@ -0,0 +1,47 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module Cogy
|
4
|
+
class CommandTest < 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
|
+
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
|
+
def test_error_response_code
|
20
|
+
get "/cogy/cmd/raiser/george"
|
21
|
+
assert_equal 500, response.status
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_calc_command
|
25
|
+
get "/cogy/cmd/calc/george", cog_opt_op: "+", cog_argv_0: 1, cog_argv_1: 2
|
26
|
+
assert_equal "Hello george, the answer is: 3", response.body
|
27
|
+
|
28
|
+
get "/cogy/cmd/calc/george", cog_opt_op: "/", cog_argv_0: 10, cog_argv_1: 5
|
29
|
+
assert_equal "Hello george, the answer is: 2", response.body
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_command_not_found
|
33
|
+
get "/cogy/cmd/idontexist/foo"
|
34
|
+
assert_equal 404, response.status
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_cogy_env
|
38
|
+
get "/cogy/cmd/print_env/george", cogy_foo: "bar"
|
39
|
+
assert_equal "bar", response.body
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_rails_url_helpers
|
43
|
+
get "/cogy/cmd/rails_url_helpers/george"
|
44
|
+
assert_equal "http://dummy.com/baz /baz", response.body
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module Cogy
|
4
|
+
class HelpersTest < ActionDispatch::IntegrationTest
|
5
|
+
include Engine.routes.url_helpers
|
6
|
+
|
7
|
+
setup { @routes = Engine.routes }
|
8
|
+
|
9
|
+
def test_custom_helpers_can_access_default_helpers
|
10
|
+
get "/cogy/cmd/foohelper/george", cogy_foo: "bar"
|
11
|
+
assert_equal "bar", response.body
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_custom_helper_with_arguments
|
15
|
+
get "/cogy/cmd/titleize/george"
|
16
|
+
assert_equal "This Should Be Titleized", response.body
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "yaml"
|
3
|
+
|
4
|
+
module Cogy
|
5
|
+
class InventoryTest < ActionDispatch::IntegrationTest
|
6
|
+
include Engine.routes.url_helpers
|
7
|
+
|
8
|
+
setup { @routes = Engine.routes }
|
9
|
+
|
10
|
+
def test_valid_yaml
|
11
|
+
with_config(bundle_name: "hyu", bundle_version: "5.0",
|
12
|
+
bundle_description: "Yet another bundle",
|
13
|
+
command_load_paths: ["cogy"]) do |inv|
|
14
|
+
assert_equal "hyu", inv["name"]
|
15
|
+
assert_equal "5.0", inv["version"]
|
16
|
+
assert_equal "Yet another bundle", inv["description"]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_cog_bundle_version
|
21
|
+
assert_equal 4, fetch_inventory["cog_bundle_version"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_bundle_version_lambda
|
25
|
+
with_config(bundle_version: -> { 1 + 2 }) do |inv|
|
26
|
+
assert_equal 3, inv["version"]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_commands_section
|
31
|
+
with_config(executable_path: "/bin/no") do |inv|
|
32
|
+
expected = {
|
33
|
+
"executable" => "/bin/no",
|
34
|
+
"description" => "Print a foo",
|
35
|
+
"rules" => ["allow"]
|
36
|
+
}
|
37
|
+
|
38
|
+
assert_equal expected, inv["commands"]["say_foo"]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_without_commands
|
43
|
+
without_commands do
|
44
|
+
refute_includes fetch_inventory.keys, "commands"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_content_type
|
49
|
+
get "/cogy/inventory"
|
50
|
+
assert_equal "application/x-yaml", response.content_type
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'active_support/test_case'
|
2
|
+
|
3
|
+
class ActiveSupport::TestCase
|
4
|
+
def fetch_inventory
|
5
|
+
get "/cogy/inventory"
|
6
|
+
YAML.load(response.body)
|
7
|
+
end
|
8
|
+
|
9
|
+
def with_config(opts={})
|
10
|
+
old = {}
|
11
|
+
|
12
|
+
opts.each do |k, v|
|
13
|
+
old[k] = Cogy.send(k)
|
14
|
+
Cogy.send("#{k}=", v)
|
15
|
+
end
|
16
|
+
|
17
|
+
yield fetch_inventory
|
18
|
+
|
19
|
+
old.each do |k, v|
|
20
|
+
Cogy.send("#{k}=", v)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def without_commands
|
25
|
+
old = Cogy.commands
|
26
|
+
Cogy.commands = {}
|
27
|
+
yield
|
28
|
+
Cogy.commands = old
|
29
|
+
end
|
30
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -2,20 +2,14 @@
|
|
2
2
|
ENV["RAILS_ENV"] = "test"
|
3
3
|
|
4
4
|
require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
|
5
|
-
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
|
6
|
-
ActiveRecord::Migrator.migrations_paths << File.expand_path('../../db/migrate', __FILE__)
|
7
5
|
require "rails/test_help"
|
6
|
+
require "minitest/spec"
|
7
|
+
|
8
|
+
require "minitest/reporters"
|
9
|
+
Minitest::Reporters.use!(Minitest::Reporters::DefaultReporter.new)
|
8
10
|
|
9
11
|
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
10
12
|
# to be shown.
|
11
13
|
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|
12
14
|
|
13
|
-
# Load support files
|
14
15
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
15
|
-
|
16
|
-
# Load fixtures from the engine
|
17
|
-
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
|
18
|
-
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
19
|
-
ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
|
20
|
-
ActiveSupport::TestCase.fixtures :all
|
21
|
-
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.1.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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -44,13 +44,57 @@ dependencies:
|
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
|
-
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: pry-byebug
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: minitest-reporters
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: yard
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
description: Cogy integrates Cog with Rails in a way that writing and deploying commands
|
90
|
+
from your application is a breeze.
|
48
91
|
email:
|
49
92
|
- agis.anast@gmail.com
|
50
93
|
executables: []
|
51
94
|
extensions: []
|
52
95
|
extra_rdoc_files: []
|
53
96
|
files:
|
97
|
+
- LICENSE
|
54
98
|
- README.md
|
55
99
|
- Rakefile
|
56
100
|
- app/controllers/cogy/application_controller.rb
|
@@ -59,15 +103,18 @@ files:
|
|
59
103
|
- config/routes.rb
|
60
104
|
- lib/cogy.rb
|
61
105
|
- lib/cogy/command.rb
|
106
|
+
- lib/cogy/context.rb
|
62
107
|
- lib/cogy/engine.rb
|
63
|
-
- lib/cogy/
|
108
|
+
- lib/cogy/invocation.rb
|
64
109
|
- lib/cogy/version.rb
|
110
|
+
- lib/generators/cogy/config_generator.rb
|
111
|
+
- lib/generators/cogy/install_generator.rb
|
112
|
+
- lib/generators/cogy/templates/cogy_config.rb
|
113
|
+
- lib/generators/cogy/templates/cogy_folder_readme.md
|
114
|
+
- lib/generators/cogy/templates/command_file.rb
|
65
115
|
- lib/tasks/cogy_tasks.rake
|
66
|
-
- test/cogy_test.rb
|
67
116
|
- test/dummy/README.rdoc
|
68
117
|
- test/dummy/Rakefile
|
69
|
-
- test/dummy/app/assets/javascripts/application.js
|
70
|
-
- test/dummy/app/assets/stylesheets/application.css
|
71
118
|
- test/dummy/app/controllers/application_controller.rb
|
72
119
|
- test/dummy/app/helpers/application_helper.rb
|
73
120
|
- test/dummy/app/views/layouts/application.html.erb
|
@@ -75,6 +122,8 @@ files:
|
|
75
122
|
- test/dummy/bin/rails
|
76
123
|
- test/dummy/bin/rake
|
77
124
|
- test/dummy/bin/setup
|
125
|
+
- test/dummy/cogy/foo.rb
|
126
|
+
- test/dummy/cogy/fully_fledged.rb
|
78
127
|
- test/dummy/config.ru
|
79
128
|
- test/dummy/config/application.rb
|
80
129
|
- test/dummy/config/boot.rb
|
@@ -85,6 +134,7 @@ files:
|
|
85
134
|
- test/dummy/config/environments/test.rb
|
86
135
|
- test/dummy/config/initializers/assets.rb
|
87
136
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
137
|
+
- test/dummy/config/initializers/cogy.rb
|
88
138
|
- test/dummy/config/initializers/cookies_serializer.rb
|
89
139
|
- test/dummy/config/initializers/filter_parameter_logging.rb
|
90
140
|
- test/dummy/config/initializers/inflections.rb
|
@@ -94,12 +144,16 @@ files:
|
|
94
144
|
- test/dummy/config/locales/en.yml
|
95
145
|
- test/dummy/config/routes.rb
|
96
146
|
- test/dummy/config/secrets.yml
|
147
|
+
- test/dummy/log/development.log
|
97
148
|
- test/dummy/log/test.log
|
98
149
|
- test/dummy/public/404.html
|
99
150
|
- test/dummy/public/422.html
|
100
151
|
- test/dummy/public/500.html
|
101
152
|
- test/dummy/public/favicon.ico
|
102
|
-
- test/integration/
|
153
|
+
- test/integration/command_test.rb
|
154
|
+
- test/integration/helpers_test.rb
|
155
|
+
- test/integration/inventory_test.rb
|
156
|
+
- test/support/helpers.rb
|
103
157
|
- test/test_helper.rb
|
104
158
|
homepage: https://github.com/skroutz/cogy
|
105
159
|
licenses:
|
@@ -124,11 +178,8 @@ rubyforge_project:
|
|
124
178
|
rubygems_version: 2.2.5
|
125
179
|
signing_key:
|
126
180
|
specification_version: 4
|
127
|
-
summary:
|
181
|
+
summary: Develop & deploy Cog commands from your Rails app
|
128
182
|
test_files:
|
129
|
-
- test/cogy_test.rb
|
130
|
-
- test/dummy/app/assets/javascripts/application.js
|
131
|
-
- test/dummy/app/assets/stylesheets/application.css
|
132
183
|
- test/dummy/app/controllers/application_controller.rb
|
133
184
|
- test/dummy/app/helpers/application_helper.rb
|
134
185
|
- test/dummy/app/views/layouts/application.html.erb
|
@@ -136,6 +187,8 @@ test_files:
|
|
136
187
|
- test/dummy/bin/rails
|
137
188
|
- test/dummy/bin/rake
|
138
189
|
- test/dummy/bin/setup
|
190
|
+
- test/dummy/cogy/foo.rb
|
191
|
+
- test/dummy/cogy/fully_fledged.rb
|
139
192
|
- test/dummy/config/application.rb
|
140
193
|
- test/dummy/config/boot.rb
|
141
194
|
- test/dummy/config/database.yml
|
@@ -145,6 +198,7 @@ test_files:
|
|
145
198
|
- test/dummy/config/environments/test.rb
|
146
199
|
- test/dummy/config/initializers/assets.rb
|
147
200
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
201
|
+
- test/dummy/config/initializers/cogy.rb
|
148
202
|
- test/dummy/config/initializers/cookies_serializer.rb
|
149
203
|
- test/dummy/config/initializers/filter_parameter_logging.rb
|
150
204
|
- test/dummy/config/initializers/inflections.rb
|
@@ -155,6 +209,7 @@ test_files:
|
|
155
209
|
- test/dummy/config/routes.rb
|
156
210
|
- test/dummy/config/secrets.yml
|
157
211
|
- test/dummy/config.ru
|
212
|
+
- test/dummy/log/development.log
|
158
213
|
- test/dummy/log/test.log
|
159
214
|
- test/dummy/public/404.html
|
160
215
|
- test/dummy/public/422.html
|
@@ -162,5 +217,8 @@ test_files:
|
|
162
217
|
- test/dummy/public/favicon.ico
|
163
218
|
- test/dummy/Rakefile
|
164
219
|
- test/dummy/README.rdoc
|
165
|
-
- test/integration/
|
220
|
+
- test/integration/command_test.rb
|
221
|
+
- test/integration/helpers_test.rb
|
222
|
+
- test/integration/inventory_test.rb
|
223
|
+
- test/support/helpers.rb
|
166
224
|
- test/test_helper.rb
|
data/lib/cogy/handler.rb
DELETED
data/test/cogy_test.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
-
// listed below.
|
3
|
-
//
|
4
|
-
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
-
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
-
//
|
7
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// compiled file.
|
9
|
-
//
|
10
|
-
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
-
// about supported directives.
|
12
|
-
//
|
13
|
-
//= require_tree .
|
@@ -1,15 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
-
* listed below.
|
4
|
-
*
|
5
|
-
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
-
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
-
*
|
8
|
-
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
-
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
-
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
-
* file per style scope.
|
12
|
-
*
|
13
|
-
*= require_tree .
|
14
|
-
*= require_self
|
15
|
-
*/
|