kender 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Nzk3MTdmZGNmYTE2OGYwYmQ4Y2U4MTA0ODJhNmM4MGY1ZmM3OTlkZA==
4
+ NTljY2QzNWNkY2E0MDBkNDc5YmNkY2FlZjE1M2ZiMDQyMmRkYmM0ZQ==
5
5
  data.tar.gz: !binary |-
6
- N2EyNjU4MjU1NGI4ZjQ2OGEyZTExMDY5NDI2YmRiMjQ4NTIyOGFlNQ==
6
+ MDk1YmEyZTExY2UzMWI5ODk3ODZiZGI5ODA1ZDMyZDQ3ZDdhY2EyYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YmM3Nzg5NTFkYzhlYTlmMGUwOGE5YTAwNzZkMzk3ZGIyZThmODM4YzEzMWJi
10
- ZDQ1NGNjMzBkN2QzN2QxNzMzYWE2ZWQzNWIwOGFhZGYzNTVmMWMwMDBmYTc1
11
- ZDU0MDYwOGIwYzQ3ZGY2MDYyOTQ5ZGY3NjcwNThkYjU0NWJiNDQ=
9
+ NTk2YmY3M2E5NDY2NzY1ZDY1NGIwMzMxNWI5ZmUzZmI4OTc1NmM0OWMzNGFm
10
+ YzJiZmU0YjI4MzMwMzEyZWJkMjNmMjkwM2ZjOWJmMzA3ZGU4OWEyMDcxNmEw
11
+ MGY3YTA1NTA4ZmM4NDZlNjYyMGFjODJmNGY3MmIyNjgzMWUwYzE=
12
12
  data.tar.gz: !binary |-
13
- M2RkNzNhNDhhYjI0OTE4MDljNjBlNGFmMTRiZDA5Nzg0ZjYyMjNmNzQzZWQ4
14
- MzcyOTBjZWVjYWZmY2NlN2FiNGEwNzkyODg2Yjg1NTJjODc1MGZmNmNiYmNj
15
- NDhkN2NhOTNiYjQ2ZjdmNWIzN2IwZDdkOGNkNDMyY2FmZGI0YzU=
13
+ M2QzOTQ0NWNlYjYyYTFhYTdiYTdhZWQ1YzVjNjVlMjRiZTg0ZTM0ZDZhNmJh
14
+ ZTljMWVlNTkwOTA2MWZkNjBiNjBmZDQ1YzIwYzhjZjE5NWEwN2E3NTkwYjU2
15
+ MTQ2NDQzMzhkNDEyODQzNTM4ODdiMGViZTYyZTg1MzQyY2ZkYzg=
@@ -0,0 +1,61 @@
1
+ module Kender
2
+ # This class abstracts the shell commands we use
3
+ class Command
4
+
5
+ def initialize(command)
6
+ @command = command
7
+ end
8
+
9
+ def name
10
+ self.class.name.split("::").last.downcase.to_sym
11
+ end
12
+
13
+ def task_name
14
+ "ci:#{name}"
15
+ end
16
+
17
+ # by default all the commands are available
18
+ def available?
19
+ true
20
+ end
21
+
22
+ def execute
23
+ if !run(@command).success?
24
+ raise RuntimeError, "Command failed: #{@command}"
25
+ end
26
+ end
27
+
28
+ def run(command)
29
+ system(command)
30
+ $?
31
+ end
32
+
33
+
34
+ class << self
35
+
36
+ def commands
37
+ @commands ||= []
38
+ end
39
+
40
+ #TODO: if I store objects instead of classes it seems that the @command
41
+ #become nil, WHY?!?
42
+ def inherited(klass)
43
+ commands << klass
44
+ end
45
+
46
+ def all_tasks
47
+ all.map{|c| c.task_name }
48
+ end
49
+
50
+ def all
51
+ commands.map(&:new).select { |c| c.available? }
52
+ end
53
+
54
+ end
55
+ end
56
+ end
57
+
58
+ require_relative 'commands/brakeman'
59
+ require_relative 'commands/shamus'
60
+ require_relative 'commands/cucumber'
61
+ require_relative 'commands/rspec'
@@ -0,0 +1,15 @@
1
+ module Kender
2
+ class Brakeman < Command
3
+
4
+ def initialize
5
+ # Make warnings fail the build with the '--exit-on-warn' switch.
6
+ command = 'bundle exec brakeman --quiet --exit-on-warn'
7
+ super(command)
8
+ end
9
+
10
+ def available?
11
+ defined?(::Brakeman)
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ module Kender
2
+ class Cucumber < Command
3
+
4
+ def initialize
5
+ command = 'bundle exec cucumber'
6
+ super(command)
7
+ end
8
+
9
+ # we run cucumber when we are not running Shamus
10
+ def available?
11
+ #this is slow as bundle exec can prove to be quite slow in old rubies
12
+ return false if ENV['VALIDATE_PROJECT']
13
+ `bundle exec cucumber --version`
14
+ $?.success?
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module Kender
2
+ class Rspec < Command
3
+
4
+ def initialize
5
+ command = 'bundle exec rspec'
6
+ super(command)
7
+ end
8
+
9
+ # we run cucumber when we are not running Shamus
10
+ def available?
11
+ #this is slow as bundle exec can prove to be quite slow in old rubies
12
+ return false if ENV['VALIDATE_PROJECT']
13
+ `bundle exec rspec --version`
14
+ $?.success?
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ module Kender
2
+ class Shamus < Command
3
+
4
+ def initialize
5
+ command = 'bundle exec shamus'
6
+ super(command)
7
+ end
8
+
9
+ # we only run shamus if the we are told so
10
+ def available?
11
+ #this is slow as bundle exec can prove to be quite slow in old rubies
12
+ return false if !ENV['VALIDATE_PROJECT']
13
+ `bundle exec shamus --help`
14
+ $?.success?
15
+ end
16
+ end
17
+ end
@@ -1,5 +1,6 @@
1
1
  require 'kender/configuration'
2
2
  require 'kender/github'
3
+ require 'kender/command'
3
4
 
4
5
  desc "Configure and run continuous integration tests then clean up"
5
6
  task :ci => ['ci:status:pending'] do
@@ -26,24 +27,29 @@ namespace :ci do
26
27
  task :config => ['ci:env', 'config:all', 'db:create', 'db:migrate']
27
28
 
28
29
  desc "Run continuous integration tests with the current configuration"
29
- task :run => ['ci:env', 'ci:shamus', 'ci:brakeman']
30
+ task :run => ['ci:env'] + Kender::Command.all_tasks
30
31
 
31
32
  desc "Destroy resources created externally for the continuous integration run, e.g. drops databases"
32
33
  task :clean => ['ci:env', 'db:drop']
33
34
 
34
35
  task :env do
35
- ENV['RAILS_ENV'] ||= 'test'
36
- end
37
-
38
- task :shamus do
39
- sh('bundle exec shamus')
36
+ if defined?(Rails)
37
+ # Default to the 'test' environment unless otherwise specified. This
38
+ # ensures that 'db:*' tasks are run on the correct (default) database for
39
+ # later tasks like 'spec'.
40
+ ENV['RAILS_ENV'] ||= 'test'
41
+ Rails.env = ENV['RAILS_ENV']
42
+ else
43
+ ENV['RACK_ENV'] ||= 'test'
44
+ end
40
45
  end
41
46
 
42
- task :brakeman do
43
- # Make warnings fail the build with the '--exit-on-warn' switch.
44
- sh('bundle exec brakeman --quiet --exit-on-warn')
47
+ Kender::Command.all.each do |command|
48
+ task command.name do
49
+ command.execute
50
+ end
45
51
  end
46
-
52
+
47
53
  namespace :status do
48
54
 
49
55
  config = Kender::Configuration.new
@@ -1,3 +1,3 @@
1
1
  module Kender
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kender
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Smith
@@ -20,6 +20,11 @@ extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
22
  - lib/kender.rb
23
+ - lib/kender/command.rb
24
+ - lib/kender/commands/brakeman.rb
25
+ - lib/kender/commands/cucumber.rb
26
+ - lib/kender/commands/rspec.rb
27
+ - lib/kender/commands/shamus.rb
23
28
  - lib/kender/configuration.rb
24
29
  - lib/kender/github.rb
25
30
  - lib/kender/railtie.rb