carrasco 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7dd8ab3b0403998b8a687d65456c0fb2b71db3c1
4
- data.tar.gz: c673f154eddb65b81aa1e34c96be10ecc582b248
3
+ metadata.gz: fbf7a3497241483dd63b3040a8e31a26f4a808a7
4
+ data.tar.gz: 2b648b49eb838a6eb907fee38160dc1ff155115b
5
5
  SHA512:
6
- metadata.gz: 57adb5427db68ea32207a985fef0b913d034c7362be70b0614a4ee052e16cf47a500323c3c15548d5f5729f51e3b76413d1c14781b592e476bcb86e263dc3ae7
7
- data.tar.gz: 3b2941ce20dd9894ff0857da9e75d85acbebffa246b6507c896a9eb90c569607e011ff65a24673fc3f4143550f4e072cbecdd79e5936d812fe95ca62a8f3a36c
6
+ metadata.gz: 022fdb6cdbaf7356029be6eb064b973be7971214cd7c7a4ba8e635051338e80784cc7a82d214208c21e4162e9afa006d56878aa40712d2d90b5e9c3e7b8f3980
7
+ data.tar.gz: c9dff8824189cc55ded4b491e2658151efe6c447d981e935391eb0550b900cec9c27e46b3d7db91985b6ffce94c7c8ed58dea0e3db7a779296564fbe623ed8ad
data/.carrasco.yml CHANGED
@@ -11,8 +11,12 @@ commands:
11
11
  command: ./bin/vendor/phpunit --configuration=tests/phpunit.xml
12
12
 
13
13
  ls:
14
- description: List tmp file
15
- command: ls /tmp/foo/foo
14
+ description: List /tmp folder
15
+ command: ls /tmp
16
+
17
+ ls_with_error:
18
+ description: list folder that does not exist
19
+ command: ls /tmp/file_that_does_not_exist
16
20
 
17
21
  # to be implemented
18
22
  groups:
data/README.md CHANGED
@@ -56,9 +56,10 @@ groups:
56
56
  You can execute:
57
57
 
58
58
  ```bash
59
- carrasco all # all your tasks
60
- carrasco phpunit # phpunit only
61
- carrasco qa # all qa scripts
59
+ bundle exec carrasco # list commands
60
+ bundle exec carrasco all # all your tasks
61
+ bundle exec carrasco phpunit # phpunit only
62
+ bundle exec carrasco qa # all qa scripts
62
63
  ```
63
64
 
64
65
  ## Development
@@ -3,11 +3,12 @@ require "thor/core_ext/hash_with_indifferent_access"
3
3
  module Carrasco
4
4
  class Command
5
5
  attr_reader :command_name, :command, :description, :help
6
+ alias_method :to_s, :command
6
7
 
7
8
  def initialize(command_name, options = {})
8
9
  options = Thor::CoreExt::HashWithIndifferentAccess.new(options)
9
10
  @command_name = command_name
10
- @command = options[:command]
11
+ @command = options[:command] || command_name
11
12
  @help = options[:help] || command_name
12
13
  @description = options[:description] || "description not given"
13
14
  end
@@ -1,5 +1,3 @@
1
- require "thor"
2
-
3
1
  module Carrasco
4
2
  class CommandBuilder
5
3
  def from_config(config)
@@ -17,7 +15,7 @@ module Carrasco
17
15
  klass.desc(command.help, command.description)
18
16
  klass.class_eval do
19
17
  define_method(command.command_name) do
20
- system(command.command)
18
+ execute_command(command)
21
19
  end
22
20
  end
23
21
  end
@@ -0,0 +1,17 @@
1
+ module Carrasco
2
+ class CommandExecuter
3
+ CommandError = Class.new(StandardError)
4
+ def execute(command)
5
+ system(command.to_s)
6
+ $?.exitstatus
7
+ end
8
+
9
+ def execute!(command)
10
+ code = execute(command)
11
+
12
+ unless code == 0
13
+ raise CommandError.new("Command '#{command}' exited with code #{code}")
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ require "thor"
2
+
3
+ module Carrasco
4
+ class Thor < ::Thor
5
+ no_commands do
6
+ def execute_command(command)
7
+ command_executer.execute!(command)
8
+ end
9
+
10
+ def command_executer=(command_executer)
11
+ @@command_executer = command_executer
12
+ end
13
+
14
+ def command_executer
15
+ @@command_executer ||= CommandExecuter.new
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Carrasco
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
data/lib/carrasco.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require "carrasco/version"
2
2
  require "carrasco/command"
3
+ require "carrasco/thor"
3
4
  require "carrasco/command_builder"
5
+ require "carrasco/command_executer"
4
6
 
5
7
  module Carrasco
6
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrasco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Jacobus
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-30 00:00:00.000000000 Z
11
+ date: 2015-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -160,6 +160,8 @@ files:
160
160
  - lib/carrasco.rb
161
161
  - lib/carrasco/command.rb
162
162
  - lib/carrasco/command_builder.rb
163
+ - lib/carrasco/command_executer.rb
164
+ - lib/carrasco/thor.rb
163
165
  - lib/carrasco/version.rb
164
166
  homepage: https://github.com/mjacobus/carrasco
165
167
  licenses: