Class: Poe
- Inherits:
-
Object
- Object
- Poe
- Defined in:
- lib/poe.rb
Constant Summary collapse
- @@hooks =
['build-failed', 'build-worked', 'common.rb']
Instance Method Summary collapse
- #copy_hooks ⇒ Object
- #display_errors ⇒ Object
- #errors ⇒ Object
- #home_dir ⇒ Object
-
#initialize(dir) ⇒ Poe
constructor
A new instance of Poe.
- #run ⇒ Object
- #setup ⇒ Object
- #setup_runner ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(dir) ⇒ Poe
Returns a new instance of Poe.
7 8 9 |
# File 'lib/poe.rb', line 7 def initialize(dir) @dir = dir end |
Instance Method Details
#copy_hooks ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/poe.rb', line 28 def copy_hooks src_dir = File.join(home_dir, '.poe', 'hooks') tgt_dir = File.join(@dir, '.git', 'hooks') @@hooks.each do |h| FileUtils.cp File.join(src_dir, h), tgt_dir end end |
#display_errors ⇒ Object
56 57 58 |
# File 'lib/poe.rb', line 56 def display_errors puts "Dang! something's wrong:\n\t#{errors.join("\n\t")}" end |
#errors ⇒ Object
52 53 54 |
# File 'lib/poe.rb', line 52 def errors @errors ||= [] end |
#home_dir ⇒ Object
42 43 44 |
# File 'lib/poe.rb', line 42 def home_dir File.('~') end |
#run ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/poe.rb', line 11 def run unless valid? display_errors return end setup puts "drop kick => '#@dir'" end |
#setup ⇒ Object
20 21 22 23 24 25 |
# File 'lib/poe.rb', line 20 def setup #copy the hooks copy_hooks #setup the default runner setup_runner end |
#setup_runner ⇒ Object
38 39 40 |
# File 'lib/poe.rb', line 38 def setup_runner `cd #@dir && git config --add cijoe.runner "bundle exec rspec spec"` end |
#valid? ⇒ Boolean
46 47 48 49 50 |
# File 'lib/poe.rb', line 46 def valid? errors << "'#{@dir}' does not exist" unless File.exists?(@dir) errors << "'#{@dir}' is not a git repo" unless File.exists?(File.join(@dir, '.git')) errors.empty? end |