foreman 0.18.0 → 0.19.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.
data/lib/foreman/cli.rb CHANGED
@@ -30,6 +30,7 @@ class Foreman::CLI < Thor
30
30
  method_option :log, :type => :string, :aliases => "-l"
31
31
  method_option :port, :type => :numeric, :aliases => "-p"
32
32
  method_option :user, :type => :string, :aliases => "-u"
33
+ method_option :template, :type => :string, :aliases => "-t"
33
34
  method_option :concurrency, :type => :string, :aliases => "-c",
34
35
  :banner => '"alpha=5,bar=3"'
35
36
 
@@ -86,7 +87,7 @@ private ######################################################################
86
87
  def options
87
88
  original_options = super
88
89
  return original_options unless File.exists?(".foreman")
89
- defaults = YAML::load_file(".foreman")
90
+ defaults = YAML::load_file(".foreman") || {}
90
91
  Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))
91
92
  end
92
93
 
@@ -23,8 +23,12 @@ private ######################################################################
23
23
  puts "[foreman export] %s" % message
24
24
  end
25
25
 
26
- def export_template(name)
27
- File.read(File.expand_path("../../../../data/export/#{name}", __FILE__))
26
+ def export_template(exporter, file, template_root)
27
+ if template_root && File.exist?(file_path = File.join(template_root, file))
28
+ File.read(file_path)
29
+ else
30
+ File.read(File.expand_path("../../../../data/export/#{exporter}/#{file}", __FILE__))
31
+ end
28
32
  end
29
33
 
30
34
  def write_file(filename, contents)
@@ -11,6 +11,7 @@ class Foreman::Export::Upstart < Foreman::Export::Base
11
11
  app = options[:app] || File.basename(engine.directory)
12
12
  user = options[:user] || app
13
13
  log_root = options[:log] || "/var/log/#{app}"
14
+ template_root = options[:template]
14
15
 
15
16
  Dir["#{location}/#{app}*.conf"].each do |file|
16
17
  say "cleaning up: #{file}"
@@ -19,14 +20,14 @@ class Foreman::Export::Upstart < Foreman::Export::Base
19
20
 
20
21
  concurrency = Foreman::Utils.parse_concurrency(options[:concurrency])
21
22
 
22
- master_template = export_template("upstart/master.conf.erb")
23
+ master_template = export_template("upstart", "master.conf.erb", template_root)
23
24
  master_config = ERB.new(master_template).result(binding)
24
25
  write_file "#{location}/#{app}.conf", master_config
25
26
 
26
- process_template = export_template("upstart/process.conf.erb")
27
+ process_template = export_template("upstart", "process.conf.erb", template_root)
27
28
 
28
29
  engine.processes.values.each do |process|
29
- process_master_template = export_template("upstart/process_master.conf.erb")
30
+ process_master_template = export_template("upstart", "process_master.conf.erb", template_root)
30
31
  process_master_config = ERB.new(process_master_template).result(binding)
31
32
  write_file "#{location}/#{app}-#{process.name}.conf", process_master_config
32
33
 
@@ -1,5 +1,5 @@
1
1
  module Foreman
2
2
 
3
- VERSION = "0.18.0"
3
+ VERSION = "0.19.0"
4
4
 
5
5
  end
@@ -21,4 +21,19 @@ describe Foreman::Export::Upstart do
21
21
  File.read("/tmp/init/app-bravo.conf").should == example_export_file("upstart/app-bravo.conf")
22
22
  File.read("/tmp/init/app-bravo-1.conf").should == example_export_file("upstart/app-bravo-1.conf")
23
23
  end
24
+
25
+ context "with alternate templates" do
26
+ let(:template_root) { "/tmp/alternate" }
27
+
28
+ before do
29
+ FileUtils.mkdir_p template_root
30
+ File.open("#{template_root}/master.conf.erb", "w") { |f| f.puts "alternate_template" }
31
+ end
32
+
33
+ it "can export with alternate template files" do
34
+ upstart.export("/tmp/init", :template => template_root)
35
+
36
+ File.read("/tmp/init/app.conf").should == "alternate_template\n"
37
+ end
38
+ end
24
39
  end
data/spec/spec_helper.rb CHANGED
@@ -52,7 +52,7 @@ def example_export_file(filename)
52
52
  data
53
53
  end
54
54
 
55
- Rspec.configure do |config|
55
+ RSpec.configure do |config|
56
56
  config.color_enabled = true
57
57
  config.include FakeFS::SpecHelpers
58
58
  config.mock_with :rr
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: foreman
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.18.0
5
+ version: 0.19.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - David Dollar
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-03 00:00:00 -04:00
13
+ date: 2011-06-27 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -109,7 +109,7 @@ dependencies:
109
109
  requirements:
110
110
  - - ~>
111
111
  - !ruby/object:Gem::Version
112
- version: 2.0.0
112
+ version: 2.6.0
113
113
  type: :development
114
114
  version_requirements: *id009
115
115
  description: Process manager for applications with multiple components