foreman 0.44.0 → 0.46.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.
@@ -21,7 +21,7 @@ class Foreman::Engine
21
21
  Foreman::Color.enable($stdout)
22
22
 
23
23
  def initialize(procfile, options={})
24
- @procfile = Foreman::Procfile.new(procfile)
24
+ @procfile = Foreman::Procfile.new(procfile) if File.exists?(procfile)
25
25
  @directory = options[:app_root] || File.expand_path(File.dirname(procfile))
26
26
  @options = options.dup
27
27
  @output_mutex = Mutex.new
@@ -36,6 +36,8 @@ class Foreman::Export::Upstart < Foreman::Export::Base
36
36
  write_file "#{location}/#{app}-#{process.name}-#{num}.conf", process_config
37
37
  end
38
38
  end
39
- end
40
39
 
40
+ FileUtils.mkdir_p(log_root) rescue error "could not create #{log_root}"
41
+ FileUtils.chown(user, nil, log_root) rescue error "could not chown #{log_root} to #{user}"
42
+ end
41
43
  end
@@ -13,8 +13,9 @@ class Foreman::Procfile
13
13
 
14
14
  attr_reader :entries
15
15
 
16
- def initialize(filename)
17
- @entries = parse_procfile(filename)
16
+ def initialize(filename=nil)
17
+ @entries = []
18
+ load(filename) if filename
18
19
  end
19
20
 
20
21
  def [](name)
@@ -25,12 +26,31 @@ class Foreman::Procfile
25
26
  entries.map(&:name)
26
27
  end
27
28
 
28
- private
29
+ def load(filename)
30
+ entries.clear
31
+ parse_procfile(filename)
32
+ end
33
+
34
+ def write(filename)
35
+ File.open(filename, 'w') do |io|
36
+ entries.each do |ent|
37
+ io.puts(ent)
38
+ end
39
+ end
40
+ end
41
+
42
+ def <<(entry)
43
+ entries << Foreman::ProcfileEntry.new(*entry)
44
+ self
45
+ end
46
+
47
+
48
+ protected
29
49
 
30
50
  def parse_procfile(filename)
31
51
  File.read(filename).split("\n").map do |line|
32
52
  if line =~ /^([A-Za-z0-9_]+):\s*(.+)$/
33
- Foreman::ProcfileEntry.new($1, $2)
53
+ self << [ $1, $2 ]
34
54
  end
35
55
  end.compact
36
56
  end
@@ -19,4 +19,8 @@ class Foreman::ProcfileEntry
19
19
  end
20
20
  end
21
21
 
22
+ def to_s
23
+ "#{name}: #{command}"
24
+ end
25
+
22
26
  end
@@ -1,5 +1,5 @@
1
1
  module Foreman
2
2
 
3
- VERSION = "0.44.0"
3
+ VERSION = "0.46.0"
4
4
 
5
5
  end
data/man/foreman.1 CHANGED
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "FOREMAN" "1" "April 2012" "Foreman 0.44.0" "Foreman Manual"
4
+ .TH "FOREMAN" "1" "April 2012" "Foreman 0.45.0" "Foreman Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBforeman\fR \- manage Procfile\-based applications
@@ -12,12 +12,6 @@ describe "Foreman::Engine", :fakefs do
12
12
  end
13
13
 
14
14
  describe "initialize" do
15
- describe "without an existing Procfile" do
16
- it "raises an error" do
17
- lambda { subject }.should raise_error
18
- end
19
- end
20
-
21
15
  describe "with a Procfile" do
22
16
  before { write_procfile }
23
17
 
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+ require 'foreman/procfile_entry'
3
+ require 'pathname'
4
+ require 'tmpdir'
5
+
6
+ describe Foreman::ProcfileEntry do
7
+ subject { described_class.new('alpha', './alpha') }
8
+
9
+ it "stringifies as a Procfile line" do
10
+ subject.to_s.should == 'alpha: ./alpha'
11
+ end
12
+
13
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+ require 'foreman/procfile'
3
+ require 'pathname'
4
+ require 'tmpdir'
5
+
6
+ describe Foreman::Procfile do
7
+ subject { described_class.new }
8
+
9
+ let(:testdir) { Pathname(Dir.tmpdir) }
10
+ let(:procfile) { testdir + 'Procfile' }
11
+
12
+ it "can have a process appended to it" do
13
+ subject << ['alpha', './alpha']
14
+ subject['alpha'].should be_a(Foreman::ProcfileEntry)
15
+ end
16
+
17
+ it "can write itself out to a file" do
18
+ subject << ['alpha', './alpha']
19
+ subject.write(procfile)
20
+ procfile.read.should == "alpha: ./alpha\n"
21
+ end
22
+
23
+ it "can re-read entries from a file" do
24
+ procfile.open('w') { |io| io.puts "gamma: ./radiation", "theta: ./rate" }
25
+ subject << ['alpha', './alpha']
26
+ subject.load(procfile)
27
+ subject.process_names.should have(2).members
28
+ subject.process_names.should include('gamma', 'theta')
29
+ end
30
+
31
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.44.0
4
+ version: 0.46.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-23 00:00:00.000000000 Z
12
+ date: 2012-05-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &70204085019820 !ruby/object:Gem::Requirement
16
+ requirement: &70104163807140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 0.13.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70204085019820
24
+ version_requirements: *70104163807140
25
25
  description: Process manager for applications with multiple components
26
26
  email: ddollar@gmail.com
27
27
  executables:
@@ -75,6 +75,8 @@ files:
75
75
  - spec/foreman/export_spec.rb
76
76
  - spec/foreman/helpers_spec.rb
77
77
  - spec/foreman/process_spec.rb
78
+ - spec/foreman/procfile_entry_spec.rb
79
+ - spec/foreman/procfile_spec.rb
78
80
  - spec/foreman_spec.rb
79
81
  - spec/helper_spec.rb
80
82
  - spec/resources/bin/utf8
@@ -112,12 +114,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
114
  - - ! '>='
113
115
  - !ruby/object:Gem::Version
114
116
  version: '0'
117
+ segments:
118
+ - 0
119
+ hash: -4034722301368458418
115
120
  required_rubygems_version: !ruby/object:Gem::Requirement
116
121
  none: false
117
122
  requirements:
118
123
  - - ! '>='
119
124
  - !ruby/object:Gem::Version
120
125
  version: '0'
126
+ segments:
127
+ - 0
128
+ hash: -4034722301368458418
121
129
  requirements: []
122
130
  rubyforge_project:
123
131
  rubygems_version: 1.8.11