freyr 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/Freyrfile CHANGED
@@ -19,3 +19,5 @@ service :sudosleep do
19
19
  start 'sudo sleep 20'
20
20
  proc_match /sleep 20/
21
21
  end
22
+
23
+ group :foo, :sleep, :foobar
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.5.2
@@ -24,11 +24,12 @@ module Freyr
24
24
 
25
25
  total_time = Time.now
26
26
 
27
+ Freyr.logger.debug("attempting to run command") {command.inspect}
28
+
27
29
  pid = spawn(command)
28
30
 
29
- Freyr.logger.debug("attempting to run command") {command.inspect}
30
- str = "\nStarting #{info.name} with #{command.inspect}"
31
- OUT.puts '',"Starting #{info.name} with #{command.inspect}", '='*str.length
31
+ str = "Starting #{info.name} with #{command.inspect}"
32
+ OUT.puts '',str, '='*str.length
32
33
  Process.detach(pid)
33
34
 
34
35
  pid = service.pid_file.wait_for_pid
@@ -83,19 +84,33 @@ module Freyr
83
84
  raise AdminRequired if info.sudo && !Freyr.is_root?
84
85
  end
85
86
 
86
- def chdir
87
- Dir.chdir File.expand_path(info.dir||'/')
87
+ def chdir &blk
88
+ if block_given?
89
+ Dir.chdir(File.expand_path(info.dir),&blk)
90
+ else
91
+ Dir.chdir(File.expand_path(info.dir))
92
+ end
88
93
  end
89
94
 
90
95
  def spawn(command)
91
96
  if info.rvm && RVM.installed?
92
- Freyr.logger.debug('attempting to set rvm') {info.rvm}
93
- if RVM.installed?(info.rvm)
94
- command = "rvm #{info.rvm} exec #{command}"
95
- Freyr.logger.debug('changed command to') {command}
96
- else
97
- abort("must setup rvm correctly, run: rvm --install --create #{info.rvm}")
97
+ Freyr.logger.debug("rvm insalled")
98
+ chdir do
99
+ if File.exist? '.rvmrc'
100
+ Freyr.logger.debug('adding rvmrc to source')
101
+ command = "source .rvmrc && #{command}"
102
+ Freyr.logger.debug('changed command to') {command}
103
+ else
104
+ Freyr.logger.debug('attempting to set rvm') {info.rvm}
105
+ if RVM.installed?(info.rvm)
106
+ command = "rvm #{info.rvm} exec #{command}"
107
+ Freyr.logger.debug('changed command to') {command}
108
+ else
109
+ abort("must setup rvm correctly, run: rvm --install --create #{info.rvm}")
110
+ end
111
+ end
98
112
  end
113
+
99
114
  elsif info.rvm
100
115
  Freyr.logger.debug("rvm not installed so can't switch to") {info.rvm}
101
116
  end
@@ -42,7 +42,7 @@ module Freyr
42
42
  end
43
43
 
44
44
  def wait_for_pid wait = 40, interval=0.2
45
- OUT.puts "Waiting #{wait}s for pid from match of #{@procname}"
45
+ OUT.puts "Waiting #{wait}s for pid from match of #{@procname.inspect}"
46
46
 
47
47
  start = Time.now
48
48
 
@@ -14,22 +14,17 @@ module Freyr
14
14
  end
15
15
 
16
16
  def rubies
17
- @rubies ||= `rvm list`.strip.split("\n").collect do |line|
18
- next unless line =~ /^(\s{3}|=)/
19
- line.strip.sub(/\=\>\s/,'').sub(/\s\[.+\]$/,'')
20
- end.compact
17
+ @rubies ||= `rvm list strings`.chomp.split("\n")
21
18
  end
22
19
 
23
20
  def gemsets_for ruby
24
21
  @gemsets_for ||= Hash.new do |h,ruby|
25
- output = `rvm #{ruby} exec rvm gemset list`.strip.split("\n")
26
- output.shift
22
+ output = `rvm #{ruby} exec rvm gemset list strings`.chomp.split("\n")
27
23
  h[ruby] = output.collect do |line|
28
- next unless line =~ /^(\s{3}|=)/
29
- line.strip.sub(/\=\>\s/,'')
24
+ line.strip.sub(/\s\(.+\)/,'')
30
25
  end.compact
31
26
  end
32
27
  @gemsets_for[ruby]
33
28
  end
34
29
  end
35
- end
30
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freyr
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 1
10
- version: 0.5.1
9
+ - 2
10
+ version: 0.5.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tal Atlas
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-27 00:00:00 Z
18
+ date: 2011-09-28 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rspec