guard-bacon 1.0.0

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.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in guard-bacon.gemspec
4
+ gemspec
@@ -0,0 +1,2 @@
1
+
2
+ A guard to automatically run bacon specs on file changes.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "guard/guard-bacon/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "guard-bacon"
7
+ s.version = Guard::Guard::VERSION
8
+ s.authors = ["Julien Ammous"]
9
+ s.email = ["schmurfy@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Guard for bacon}
12
+ s.description = %q{Run your bacon specs on file change}
13
+
14
+ s.rubyforge_project = "guard-bacon"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_runtime_dependency "guard"
20
+ s.add_runtime_dependency "schmurfy-bacon", "~> 1.2"
21
+ end
@@ -0,0 +1,92 @@
1
+ # encoding: utf-8
2
+
3
+ require 'bacon'
4
+ require 'guard'
5
+ require 'guard/guard'
6
+ require 'guard/guard-bacon/version'
7
+
8
+ module Guard
9
+ class Bacon < Guard
10
+
11
+ def initialize(watchers= [], options= {})
12
+ super
13
+ if options[:output]
14
+ puts "Bacon: Using output #{options[:output]}."
15
+ ::Bacon.extend(::Bacon::const_get(options[:output]))
16
+ end
17
+
18
+ if options[:backtrace]
19
+ puts "Bacon: Limiting backtrace to #{options[:backtrace]} lines."
20
+ ::Bacon.backtrace_size = options[:backtrace]
21
+ end
22
+ end
23
+
24
+ def start
25
+ puts "Guard::Bacon started."
26
+ true
27
+ end
28
+
29
+ # Called on Ctrl-C signal (when Guard quits)
30
+ def stop
31
+ true
32
+ end
33
+
34
+ # Called on Ctrl-Z signal
35
+ def reload
36
+ true
37
+ end
38
+
39
+ # Called on Ctrl-\ signal
40
+ # This method should be principally used for long action like running all specs/tests/...
41
+ def run_all
42
+ Dir["specs/**/*_spec.rb"].each do |path|
43
+ run_spec(path)
44
+ end
45
+
46
+ true
47
+ end
48
+
49
+ def run_spec(path)
50
+ if File.exists?(path)
51
+ pid = Kernel.fork do
52
+ puts "\n●●➤ Running spec: #{path}"
53
+ counters = ::Bacon.run_file(path)
54
+ # system "bundle exec bacon -o TestUnit #{path}"
55
+ # {:installed_summary=>1, :specifications=>19, :depth=>0, :requirements=>30, :failed=>2, :errors => 1}
56
+
57
+ all_specs = counters[:specifications]
58
+ failed = counters[:failed].to_i + counters[:errors].to_i
59
+
60
+ if failed > 0
61
+ Notifier.notify("Specs: #{failed} Failures (#{all_specs} specs)",
62
+ :image => :failed,
63
+ :title => File.basename(path)
64
+ )
65
+ else
66
+ Notifier.notify("Specs: OK (#{all_specs} specs)",
67
+ :image => :success,
68
+ :title => File.basename(path)
69
+ )
70
+ end
71
+ end
72
+
73
+ Process.wait(pid)
74
+ else
75
+ puts "spec not found: #{path}"
76
+ end
77
+ end
78
+
79
+ def file_changed(path)
80
+ run_spec(path)
81
+ puts ""
82
+ end
83
+
84
+ # Called on file(s) modifications
85
+ def run_on_change(paths)
86
+ paths.each do |path|
87
+ file_changed(path)
88
+ end
89
+ end
90
+
91
+ end
92
+ end
@@ -0,0 +1,9 @@
1
+
2
+ # parameters:
3
+ # output => the formatted to use
4
+ # backtrace => number of lines, nil = everything
5
+ guard 'bacon', :output => "BetterOutput", :backtrace => 4 do
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "specs/lib/#{m[1]}_spec.rb" }
7
+ watch(%r{specs/.+\.rb$})
8
+ end
9
+
@@ -0,0 +1,5 @@
1
+ module Guard
2
+ class Guard
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-bacon
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Julien Ammous
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-08 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: guard
16
+ requirement: &70227182227140 !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: *70227182227140
25
+ - !ruby/object:Gem::Dependency
26
+ name: schmurfy-bacon
27
+ requirement: &70227182226040 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '1.2'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70227182226040
36
+ description: Run your bacon specs on file change
37
+ email:
38
+ - schmurfy@gmail.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - .gitignore
44
+ - Gemfile
45
+ - README.md
46
+ - Rakefile
47
+ - guard-bacon.gemspec
48
+ - lib/guard/bacon.rb
49
+ - lib/guard/guard-bacon/templates/Guardfile
50
+ - lib/guard/guard-bacon/version.rb
51
+ homepage: ''
52
+ licenses: []
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project: guard-bacon
71
+ rubygems_version: 1.8.11
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Guard for bacon
75
+ test_files: []