53 Commits

Author SHA1 Message Date
Thibault Jouan
99710b0df9 Implement Remote::FS#sftp 2013-09-26 00:28:40 +00:00
Thibault Jouan
d240df0281 Add Remote::FS class 2013-09-26 00:28:40 +00:00
Thibault Jouan
e51adbdefa Bump version to 0.1.2 2013-09-26 00:20:39 +00:00
Thibault Jouan
e676eb40d6 Transform Tests class in a module 2013-09-23 21:44:50 +00:00
Thibault Jouan
8247f3a973 Bump version to 0.1.1 2013-08-20 03:53:38 +00:00
Thibault Jouan
5d3173977f Bump version to 0.1.0 2013-08-20 03:16:45 +00:00
Thibault Jouan
04afc82a29 Implement `has_env' condition keyword 2013-08-20 03:03:17 +00:00
Thibault Jouan
b0ea7d876e Implement Remote#environment:
Build and return a Remote::Environment instance, with the output of
`env` command execution.
2013-08-20 03:03:07 +00:00
Thibault Jouan
513ba4eedb Implement basic Remote::Environment class:
Represent a registry for remote environment variables, will follow an
API similar to Hash except the constructor. Currently only #has_key? is
implemented.
2013-08-20 02:13:54 +00:00
Thibault Jouan
ed99c191e0 Build conditions with DSL evaluated tests:
In Condition:

  * Modify constructor to accepts tests and a default return value;
  * Implement #met?;
  * Modify #! so that it return the negated value returned by #met?.

  In Condition::DSL:

  * Modify .evaluate to build the condition with tests and the value
    returned by a the evaluated condition block.

  Add a basic Test base class, with env and arguments as attributes.

  Add some spec helpers to build some easily testable kind of Test
instances (as test doubles).
2013-08-18 00:29:36 +00:00
Thibault Jouan
00a11e159f Use instance_eval in Condition::DSL#evaluate:
Use instance_eval so that the assigned block is evaluated inside the
DSL sandbox instance, giving access to all required methods and instance
variables.
2013-08-18 00:29:36 +00:00
Thibault Jouan
3a0ce82799 Improve Condition DSL framework:
Add the necessary API so that we can implement new tests easily as new
standalone classes.

  In Condition::DSL:

* Add #tests accessor;
* Modify constructor so that it accepts the env;
* Implement .define_test(keyword, class) method.
2013-08-18 00:29:36 +00:00
Thibault Jouan
639bdc1c73 Implement basic condition DSL framework for tests:
Instead of interrupting task evaluation when condition is not met,
allow the whole task to be evaluated (including condition and
evaluation) so that the interpreter will get all tasks actions (whether
condition is met or not) and be able to query the condition.

* Modify Interpreter#process_task: test if task condition is met before
  applying the actions;
* Implement condition handling in Task and Task::DSL;
* Implement Condition and Condition::DSL (useless as they are, but
  needed to implement later test keywords as part of the condition DSL.
2013-08-18 00:29:14 +00:00
Thibault Jouan
e4a4211a7b Rename Worker class as Interpreter 2013-08-16 19:30:51 +00:00
Thibault Jouan
5a4c8c02bc Fix coding standards in Task class 2013-08-15 22:35:10 +00:00
Thibault Jouan
d4d5222261 Refactor task DSL usages:
Remove most of task evaluation code from Task class, rely on
Task::DSL.evaluate to get an evaluated task.

* Task: remove #evaluate, change constructor prototype to accept actions
  instead of a block, implement .evaluate(name, env &block);
* Implement Task::DSL.evaluate method;
* Recipe::DSL: remove tasks evaluation from#evaluate, modify #task to
  use Task.evaluate to return the new task to be rigstered.
2013-08-15 22:28:16 +00:00
Thibault Jouan
a675c9c910 Implement `echo' task action 2013-08-14 23:43:36 +00:00
Thibault Jouan
f0e144cebd Refactor and simplify recipe DSL evaluation usages:
Remove most of recipe evaluation code in Recipe class, and rely on
Recipe::DSL to get evaluated recipes.

* Remove Recipe#evaluate call from CLI, rely on
  Recipe.evaluate_from_file to get the evaluated recipe;
* Implement Recipe.evaluate_from_file(filepath, env);
* Implement Recipe::DSL.evaluate(code, env);
* Remove code and filepath accessor on Recipe;
* Remove Recipe.from_file and Recipe#evaluate methods;
* Move task evaluations in Recipe::DSL#evaluate;
* Modify Recipe constructor so that it accepts tasks as argument.
2013-08-14 19:48:43 +00:00
Thibault Jouan
53db841b2d Remove Env#current_recipe attribute 2013-08-13 01:36:33 +00:00
Thibault Jouan
a5d9ca26f4 Remove error handling for evaluation errors 2013-08-13 00:42:14 +00:00
Thibault Jouan
0904fa1fc9 Implement Worker class:
* Move recipe processing code in the worker;
* Refactor CLI and use the the worker;
* Implement Recipe#tasks and remove tasks application during evaluation,
  tasks are now applied by the worker after all evaluations are done.
2013-08-10 14:47:02 +00:00
Thibault Jouan
825bdec74d Improve `sh' task action error handling:
Handle exit status code in Remote#execute.
2013-08-07 23:39:49 +00:00
Thibault Jouan
f10914c7d7 Implement basic `sh' task action feature:
* Executes a command on the remote host;
* Forwards remote standard output.
2013-08-07 16:16:40 +00:00
Thibault Jouan
0148854843 Make DSL specific method private in Task#DSL 2013-08-07 01:14:44 +00:00
Thibault Jouan
9875a4ae7b Make remote available to env 2013-08-05 20:05:58 +00:00
Thibault Jouan
ace5bfb3fa Add basic Remote#execute implementation 2013-08-05 20:03:13 +00:00
Thibault Jouan
6e1ba269eb Implement Remote class 2013-08-05 19:58:17 +00:00
Thibault Jouan
0cccbc8dde Add Env#output with $stdout as default 2013-08-04 21:29:13 +00:00
Thibault Jouan
e6c14f1903 Implement basic task actions API:
* Add Action base class;
* Implement Task::DSL.define_action(keyword, klass);
* Add Task::DSL#actions accessor;
* Apply task DSL actions when Task instances are evaluated.
2013-08-04 20:30:54 +00:00
Thibault Jouan
8e455fc4d5 Improve Env constructor 2013-08-04 15:45:08 +00:00
Thibault Jouan
a3bba6d4da Implement target recipe keyword feature 2013-08-03 23:42:47 +00:00
Thibault Jouan
a6e27edfd2 Add env recipe keyword feature 2013-08-03 23:42:41 +00:00
Thibault Jouan
c4fc9828db Improve error reporting during recipe evaluation
* Report invalid action usages from tasks;
* Implement backtrace cleaning in CLI;
* Extract error class declarations in a new errors file;
* Replace raise with fail keyword in task DSL class.
2013-08-01 20:31:39 +00:00
Thibault Jouan
ace6a4ad2b Implement Task::DSL#evaluate:
So that the env is available from the task DSL.
2013-08-01 00:01:20 +00:00
Thibault Jouan
0aa043b61a Remove host argument:
Currently the idea is to later implement a -h (or -t) option to the
command, and/or a `target' recipe keyword. Another option might be to
use the target/host key when the key/value registry will be implemented
and made available to the recipe and task DSLs.
2013-08-01 00:01:20 +00:00
Thibault Jouan
2acb57254f Fix a few coding standards issues:
* Remove extra empty lines before private keyword usages.

  specs:

  * Fix one long line;
  * use proc keyword instead of Proc.new.
2013-08-01 00:01:20 +00:00
Thibault Jouan
3792f60a5c Improve source recipe keyword feature:
* Improve error reporting from sourced recipe;
* Extract cucumber feature from recipe one.
2013-08-01 00:01:19 +00:00
Thibault Jouan
b1c99dbeeb Extract task DSL code and spec 2013-08-01 00:01:19 +00:00
Thibault Jouan
2939123574 Extract recipe DSL code and spec 2013-08-01 00:01:19 +00:00
Thibault Jouan
e12dd5c0e7 Implement recipe error reporting feature 2013-08-01 00:01:15 +00:00
Thibault Jouan
f6d9dd2c90 Change ConditionNotMetError superclass 2013-07-30 15:57:03 +00:00
Thibault Jouan
a1e92893ad Refactor CLI#run! method 2013-07-30 15:19:34 +00:00
Thibault Jouan
10bfe17c56 Remove extra #each call in Recipe#evaluate 2013-07-30 14:48:07 +00:00
Thibault Jouan
d199ba56fd Add Env class 2013-07-30 14:47:56 +00:00
Thibault Jouan
30e1930719 Implement Recipe::DSL#evaluate method:
Move recipe DSL evaluation in a dedicated #evaluate method, instead of
evaluating the code during the DSL instantiation.
2013-07-30 14:46:27 +00:00
Thibault Jouan
37e17d1030 Implement Recipe#filepath method:
Returns the filepath of the recipe when it is built from a file.
2013-07-30 14:46:27 +00:00
Thibault Jouan
d146566411 Implement tasks condition feature 2013-07-28 22:56:08 +00:00
Thibault Jouan
baaa957e9e Implement task evaluation feature 2013-07-28 19:18:53 +00:00
Thibault Jouan
c7295fb977 Implement source keyword feature for recipes 2013-07-28 18:38:00 +00:00
Thibault Jouan
8e4f670fbf Introduce Recipe::DSL to eval recipe DSL code 2013-07-28 18:08:16 +00:00