guard-rake-vagrant 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .rvmrc
2
+ pkg
3
+ Gemfile.lock
4
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rake'
4
+
5
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1 @@
1
+ Copyright (c) 2014 Salim Afiune
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ guard-rake-vagrant
2
+ ==================
3
+
4
+ Guard Plugin that uses Rake and Vagrant to converge cookbooks and run integration tests.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require 'guard/rake/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'guard-rake-vagrant'
7
+ s.version = Guard::Rake::Vagrant::VERSION
8
+ s.authors = ['Salim Afiune']
9
+ s.email = ['salim@afiunemaya.com.mx']
10
+ s.homepage = 'https://github.com/afiune/guard-rake-vagrant'
11
+ s.summary = %q{Guard Plugin that uses Rake and Vagrant to converge cookbooks and run integration tests}
12
+ s.description = %q{guard-rake-vagrant runs rake tasks from Rakefile automatically but first provisioning a box using Vagrant}
13
+
14
+ s.add_dependency 'guard'
15
+ s.add_dependency 'rake'
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map {|f| File.basename(f) }
20
+ s.require_paths = ['lib']
21
+ end
22
+
data/lib/guard/rake.rb ADDED
@@ -0,0 +1,86 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+ require 'guard/version'
4
+ require 'rake'
5
+
6
+ module Guard
7
+ class Rake < Guard
8
+
9
+ require "guard/rake/vagrant"
10
+
11
+ class << self
12
+ attr_accessor :rakefile_loaded
13
+ end
14
+
15
+ def initialize(watchers=[], options={})
16
+ super
17
+ @options = {
18
+ :run_on_start => true,
19
+ :run_on_all => true,
20
+ :task_args => []
21
+ }.update(options)
22
+ @task = @options[:task]
23
+ end
24
+
25
+ def start
26
+ ::Guard::Rake::Vagrant.up
27
+ UI.info "Starting guard-rake-vagrant #{@task}"
28
+ load_rakefile unless self.class.rakefile_loaded
29
+ run_rake_task if @options[:run_on_start]
30
+ true
31
+ end
32
+
33
+ def stop
34
+ ::Guard::Rake::Vagrant.destroy
35
+ UI.info "Stopping guard-rake-vagrant #{@task}"
36
+ true
37
+ end
38
+
39
+ def reload
40
+ stop
41
+ start
42
+ end
43
+
44
+ def run_all
45
+ run_rake_task if @options[:run_on_all]
46
+ end
47
+
48
+ if ::Guard::VERSION < "1.1"
49
+ def run_on_change(paths)
50
+ ::Guard::Rake::Vagrant.provision
51
+ run_rake_task(paths)
52
+ end
53
+ else
54
+ def run_on_changes(paths)
55
+ ::Guard::Rake::Vagrant.provision
56
+ run_rake_task(paths)
57
+ end
58
+ end
59
+
60
+ def run_rake_task(paths=[])
61
+ UI.info "running #{@task}"
62
+ ::Rake::Task.tasks.each { |t| t.reenable }
63
+ ::Rake::Task[@task].invoke(*@options[:task_args], paths)
64
+
65
+ Notifier.notify(
66
+ "watched files: #{paths}",
67
+ :title => "running rake task: #{@task}",
68
+ :image => :success
69
+ )
70
+ rescue Exception => e
71
+ UI.error "#{self.class.name} failed to run rake task <#{@task}>, exception was:\n\t#{e.class}: #{e.message}"
72
+ UI.debug "\n#{e.backtrace.join("\n")}"
73
+
74
+ Notifier.notify(
75
+ " #{e.class}: #{e.message}", :title => "fail to run rake task: #{@task}", :image => :failed)
76
+ throw :task_has_failed
77
+ end
78
+
79
+ def load_rakefile
80
+ ARGV.clear
81
+ ::Rake.application.init
82
+ ::Rake.application.load_rakefile
83
+ self.class.rakefile_loaded = true
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,3 @@
1
+ guard :rake, :task => 'build' do
2
+ watch(%r{^my_file.rb})
3
+ end
@@ -0,0 +1,60 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+ require "mixlib/shellout"
4
+
5
+ module Guard
6
+ class Rake
7
+ class Vagrant
8
+ class << self
9
+ def up
10
+ UI.info "Guard::Rake::Vagrant box is starting"
11
+ cmd = Mixlib::ShellOut.new("vagrant up", :timeout => 10800)
12
+ cmd.live_stream = STDOUT
13
+ cmd.run_command
14
+
15
+ begin
16
+ cmd.error!
17
+ Notifier.notify('Vagrant box created', :title => 'guard-rake-vagrant', :image => :success)
18
+ rescue Mixlib::ShellOut::ShellCommandFailed => e
19
+ Notifier.notify('Vagrant box create failed', :title => 'guard-rake-vagrant', :image => :failed)
20
+ ::Guard::UI.info("Vagrant box failed with #{e.to_s}")
21
+ throw :task_has_failed
22
+ end
23
+ end
24
+
25
+ def destroy
26
+ ::Guard::UI.info("Guard::Rake::Vagrant is stopping")
27
+ cmd = Mixlib::ShellOut.new("vagrant destroy -f")
28
+ cmd.live_stream = STDOUT
29
+ cmd.run_command
30
+ begin
31
+ cmd.error!
32
+ rescue Mixlib::ShellOut::ShellCommandFailed => e
33
+ ::Guard::UI.info("Vagrant BOX failed #{e.to_s}")
34
+ throw :task_has_failed
35
+ ensure
36
+ # Sometimes, we leave the occasional shell process unreaped!
37
+ Process.waitall
38
+ end
39
+ end
40
+
41
+ def provision
42
+ # Box is running?
43
+ UI.info "Guard::Vagrant provision"
44
+ cmd = Mixlib::ShellOut.new("vagrant provision", :timeout => 10800)
45
+ cmd.live_stream = STDOUT
46
+ cmd.run_command
47
+
48
+ begin
49
+ cmd.error!
50
+ Notifier.notify('Vagrant provisioned', :title => 'guard-vagrant', :image => :success)
51
+ rescue Mixlib::ShellOut::ShellCommandFailed => e
52
+ Notifier.notify('Vagrant provision failed', :title => 'guard-vagrant', :image => :failed)
53
+ ::Guard::UI.info("Vagrant provision failed with #{e.to_s}")
54
+ throw :task_has_failed
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,7 @@
1
+ module Guard
2
+ module Rake
3
+ module Vagrant
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-rake-vagrant
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Salim Afiune
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-03-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: guard
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: guard-rake-vagrant runs rake tasks from Rakefile automatically but first
47
+ provisioning a box using Vagrant
48
+ email:
49
+ - salim@afiunemaya.com.mx
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - LICENSE
57
+ - README.md
58
+ - Rakefile
59
+ - guard-rake-vagrant.gemspec
60
+ - lib/guard/rake.rb
61
+ - lib/guard/rake/templates/Guardfile
62
+ - lib/guard/rake/vagrant.rb
63
+ - lib/guard/rake/version.rb
64
+ homepage: https://github.com/afiune/guard-rake-vagrant
65
+ licenses: []
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 1.8.24
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: Guard Plugin that uses Rake and Vagrant to converge cookbooks and run integration
88
+ tests
89
+ test_files: []