cogy 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d68c05583565f05400bafb31ec6487ed3ed72d2
4
- data.tar.gz: a693a5479f2ea5c0a74ebcca4d17a1ea5ac7e5b5
3
+ metadata.gz: a8aa6c2ef3205ba369337329ccb410e7e04721f8
4
+ data.tar.gz: 8ee9376fa3a2b06846fdd32f5807753824639efc
5
5
  SHA512:
6
- metadata.gz: 115ffd20c179abbdf00324759778b7ad5945213c91f6724b5e41e0f3f0f860ebd0c1c9412b5380d7bdbebd3f47876f3c22468cc52ae75f4abad235a4b55786c5
7
- data.tar.gz: 02c5c9aec2d01c167a6b29e027b787988d627e27692ea24370c45491b7a0f8b0583631d0b4955eb143d6dea9ceca3c0b1a9a30359f7f9b091508ee492c710c33
6
+ metadata.gz: 163f6aaf64c9d1c5e596371d81980d537122bb930a04674d8dca06a5c4411aa59a9be42e260275724899e8d39f8d9b428789edb4cd0564c217b373c17eb11694
7
+ data.tar.gz: cf617969c35eb9c9abc90f7d2534f79c76671ae9f3cf239e45452e0e74e271ae8661906e0bb680afe8d4ea46d1dd67524ade46d38209deb29fd4c03c9c95322e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.5.0 (2017-01-25)
6
+
7
+ ### Changed
8
+
9
+ - The `COGY_BACKEND` env. variable is now shipped from Cogy, so you don't have
10
+ to set it in the Relays anymore ([#37](https://github.com/skroutz/cogy/issues/37)).
11
+ This has the side-effect of `Cogy.cogy_endpoint` configuration being *required*
12
+ if you use the Capistrano tasks, since they use it instead of the old,
13
+ Capistrano-specific setting.
14
+
5
15
  ## 0.4.0 (2016-12-05)
6
16
 
7
17
  This release requires the [cogy-bundle](https://github.com/skroutz/cogy-bundle)
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  [![Build Status](https://api.travis-ci.org/skroutz/cogy.svg?branch=master)](https://travis-ci.org/skroutz/cogy)
4
4
  [![Gem Version](https://badge.fury.io/rb/cogy.svg)](https://badge.fury.io/rb/cogy)
5
- [![Inline docs](http://inch-ci.org/github/skroutz/cogy.svg)](http://inch-ci.org/github/skroutz/cogy)
6
5
 
7
6
  Cogy integrates [Cog](https://operable.io/) with Rails
8
7
  in a way that writing & deploying commands from your application is a breeze.
@@ -13,13 +12,13 @@ Refer to the [Changelog](CHANGELOG.md) to see what's changed between releases.
13
12
 
14
13
  ## Features
15
14
 
16
- - Write commands inside your Rails app, using Ruby (see [_Usage_](#usage))
17
- - The bundle config is generated automatically
15
+ - Define commands from your Rails app (see [_Usage_](#usage))
16
+ - Bundle config is generated automatically
18
17
  - Commands are installed _automatically_ when you deploy (see [_Deployment_](#deployment))
19
- - Support for JSON responses and Templates (see [_Returning JSON to COG_](#returning-json-to-cog))
20
- - Customizable error templates (see [_Error template_](#error-template))
18
+ - Supports JSON responses and Cog Templates (see [_Returning JSON to COG_](#returning-json-to-cog))
19
+ - Customizable error template (see [_Error template_](#error-template))
21
20
 
22
- ...and more on the way!
21
+ ...and [more on the way](https://github.com/skroutz/cogy/issues?q=is%3Aopen+is%3Aissue+label%3Afeature)!
23
22
 
24
23
  ## Why
25
24
 
@@ -73,7 +72,7 @@ Take a look at the relevant [diagrams](diagrams/) for a detailed illustration.
73
72
 
74
73
  ## Requirements
75
74
 
76
- * [cogy bundle v0.3.0+](https://github.com/skroutz/cogy-bundle)
75
+ * [cogy bundle v0.4.0+](https://github.com/skroutz/cogy-bundle)
77
76
  * Ruby 2.1+
78
77
  * Rails 4.2 (support for Rails 5 is on the way)
79
78
 
@@ -189,7 +188,7 @@ Info on how Cog handles JSON can be found in the [official documentation](https:
189
188
 
190
189
  ### Templates
191
190
 
192
- Templates are defined in their own files under `templates/` inside any of
191
+ [Templates](https://cog-book.operable.io/#_templates) are defined in their own files under `templates/` inside any of
193
192
  the [command load paths](#Configuration). For example:
194
193
 
195
194
  ```
@@ -272,6 +271,10 @@ Cogy.configure do |config|
272
271
 
273
272
  # The path in the Relay where the cogy command executable is located.
274
273
  cogy_executable: "/cogcmd/cogy"
274
+
275
+ # The endpoint where Cogy is reachable at. This depends on where you've
276
+ # mounted the Cogy engine at.
277
+ cogy_endpoint: "http://www.example.com/cogy"
275
278
  }
276
279
 
277
280
  # Paths in your application where the files that define the commands live in.
@@ -350,33 +353,26 @@ is the following:
350
353
  It can be overriden in the application by creating a view in
351
354
  `app/views/cogy/error.text.erb`.
352
355
 
353
- ## Installation Trigger
356
+ ## Testing commands
354
357
 
355
- In order to automate the process of installing the new bundle versions
356
- (eg. after a new command is added), you must create a [Cog Trigger](https://cog-book.operable.io/#_developing_a_trigger)
357
- that will perform the installation, which will be called when you deploy your
358
- app.
359
-
360
- The trigger will look this:
358
+ We don't yet provide means to write tests for the commands, but you can easily
359
+ test them by executing a request to your development server:
361
360
 
362
361
  ```shell
363
- $ cogctl triggers
364
- Name ID Enabled Pipeline
365
- ReleaseUrlTrigger d10df83b-a737-4fc4-8d9b-bf9627412d0a true cogy:install --url $body.url > chat://#general
362
+ $ curl -XPOST --data "COG_ARGV_0=foo" http://localhost:3000/cogy/foo
366
363
  ```
367
364
 
368
- It essentially uses the [cogy bundle](https://github.com/skroutz/cogy-bundle)
369
- and installs the bundle config which is served by your application
370
- (ie. http://your-app.com/cogy/inventory).
365
+ In the request body you may pass the complete or any part of the
366
+ [Cog environment](https://cog-book.operable.io/#_command_environment_variables) you need.
371
367
 
372
- See [_Deployment_](#deployment) on information about how this trigger is
373
- invoked.
368
+ This is essentially what the [cogy executable](https://github.com/skroutz/cogy-bundle)
369
+ also does.
374
370
 
375
371
  ## Deployment
376
372
 
377
- Cogy provides integration with Capistrano 2 and 3.
373
+ Cogy provides integration with Capistrano 2 & 3.
378
374
 
379
- There is the just one task, `cogy:notify_cog`, which just executes the
375
+ There is just one task, `cogy:notify_cog`, which executes the
380
376
  [installation Trigger](#installation-trigger).
381
377
 
382
378
  The task should run
@@ -386,10 +382,9 @@ example, it should run after the built-in `deploy:restart` task.
386
382
 
387
383
  The following options need to be set:
388
384
 
385
+ * `Cogy.cogy_endpoint`: See [*Configuration*](#Configuration).
389
386
  * `cogy_release_trigger_url`: This is the URL of the Cog Trigger that will
390
387
  install the newly deployed bundle (ie. `!cogy:install`).
391
- * `cogy_endpoint`: Where the Cogy Engine is mounted at.
392
- For example `http://myapp.com/cogy`.
393
388
 
394
389
  You can also configure the timeout value for the request to the Trigger by
395
390
  setting the `cogy_trigger_timeout` option (default: 7).
@@ -405,7 +400,6 @@ Add the following in `config/deploy.rb`:
405
400
  require "cogy/capistrano"
406
401
 
407
402
  set :cogy_release_trigger_url, "<TRIGGER-INVOCATION-URL>"
408
- set :cogy_endpoint, "<COGY-MOUNT-POINT>"
409
403
 
410
404
  after "deploy:restart", "cogy:notify_cog"
411
405
  ```
@@ -424,11 +418,32 @@ Then configure the task and hook it:
424
418
  # in config/deploy.rb
425
419
 
426
420
  set :cogy_release_trigger_url, "<TRIGGER-INVOCATION-URL>"
427
- set :cogy_endpoint, "<COGY-MOUNT-POINT>"
428
421
 
429
422
  after "<app-restart-task>", "cogy:notify_cog"
430
423
  ```
431
424
 
425
+ ### Installation Trigger
426
+
427
+ In order to automate the process of installing the new bundle versions
428
+ (eg. after a new command is added), you must create a [Cog Trigger](https://cog-book.operable.io/#_developing_a_trigger)
429
+ that will perform the installation, which will be called when you deploy your
430
+ app.
431
+
432
+ The trigger will look this:
433
+
434
+ ```shell
435
+ $ cogctl triggers
436
+ Name ID Enabled Pipeline
437
+ ReleaseUrlTrigger d10df83b-a737-4fc4-8d9b-bf9627412d0a true cogy:install --url $body.url > chat://#general
438
+ ```
439
+
440
+ It essentially uses the [cogy bundle](https://github.com/skroutz/cogy-bundle)
441
+ and installs the bundle config which is served by your application
442
+ (ie. http://your-app.com/cogy/inventory).
443
+
444
+ See [_Deployment_](#deployment) on information about how this trigger is
445
+ invoked.
446
+
432
447
  ## Development
433
448
 
434
449
  Running the tests and RuboCop:
@@ -6,11 +6,11 @@ namespace :cogy do
6
6
  require "json"
7
7
 
8
8
  trigger_url = fetch(:cogy_release_trigger_url)
9
- cogy_endpoint = fetch(:cogy_endpoint)
9
+ cogy_endpoint = Cogy.cogy_endpoint
10
10
 
11
11
  begin
12
12
  raise ":cogy_release_trigger_url must be set" if trigger_url.nil?
13
- raise ":cogy_endpoint must be set" if cogy_endpoint.nil?
13
+ raise "Cogy.cogy_endpoint must be set" if cogy_endpoint.nil?
14
14
 
15
15
  Timeout.timeout(fetch(:cogy_trigger_timeout) || 7) do
16
16
  url = URI(trigger_url)
data/lib/cogy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cogy
2
- VERSION = "0.4.0".freeze
2
+ VERSION = "0.5.0".freeze
3
3
  end
data/lib/cogy.rb CHANGED
@@ -45,6 +45,11 @@ module Cogy
45
45
  @@command_load_paths = ["cogy"]
46
46
  mattr_accessor :command_load_paths
47
47
 
48
+ # The endpoint where the Cogy engine is reachable at.
49
+ # For example "http://www.example.com/cogy"
50
+ @@cogy_endpoint = nil
51
+ mattr_accessor :cogy_endpoint
52
+
48
53
  # Initializes a new {Command} and registers it. All the options passed are
49
54
  # used when generating the bundle config in {Cogy.bundle_config}.
50
55
  #
@@ -129,6 +134,12 @@ module Cogy
129
134
  if cmd.examples
130
135
  config["commands"][name]["examples"] = cmd.examples
131
136
  end
137
+
138
+ if Cogy.cogy_endpoint
139
+ config["commands"][name]["env_vars"] = {
140
+ "COGY_BACKEND" => Cogy.cogy_endpoint
141
+ }
142
+ end
132
143
  end
133
144
 
134
145
  config["templates"] = templates if !templates.empty?
@@ -8,4 +8,5 @@ Cogy.configure do |config|
8
8
  #}
9
9
  #
10
10
  #config.command_load_paths = ["cogy"]
11
+ #config.cogy_endpoint = "http://www.example.com/cogy"
11
12
  end
@@ -7,6 +7,7 @@ Cogy.configure do |c|
7
7
  }
8
8
 
9
9
  c.command_load_paths = ["cogy"]
10
+ c.cogy_endpoint = "http://www.example.com/cogy"
10
11
 
11
12
  c.helper(:foo) { env["cog_foo"] }
12
13
  c.helper(:bar) { |text| text.titleize }