Compare commits

...

8 Commits

Author SHA1 Message Date
David Dollar
a2ba079665 0.19.0 2011-06-27 13:17:54 -04:00
David Dollar
c8d0dba1cb tweaks to template roots, add testing 2011-06-27 13:17:26 -04:00
Michael van Rooijen
e8d2552caa Added the ability to use template configuration files using the '--template [-t]' command line option. This allows you to create a directory on the file system containing your configuration files which Foreman will read from instead of the default templates. 2011-06-26 19:02:51 +02:00
David Dollar
927a57f738 Merge pull request #43 from smith/master
RSpec Warning Fix
2011-06-20 20:35:55 -07:00
Nathan L Smith
f65538c1b1 update rspec to 2.6 2011-06-20 21:58:16 -05:00
Nathan L Smith
470c8043af fix rspec warnings 2011-06-20 21:44:35 -05:00
David Dollar
3e69b27f5f Merge pull request #34 from nz/empty-foreman-file
Gracefully handle the 'garbage in' of an empty .foreman file.
2011-06-03 13:51:29 -07:00
Nick Zadrozny
f4b1e3701b Gracefully handle the 'garbage in' of an empty .foreman file. 2011-06-03 15:48:13 -05:00
9 changed files with 42 additions and 23 deletions

View File

@@ -1,7 +1,7 @@
PATH
remote: .
specs:
foreman (0.18.0)
foreman (0.19.0)
term-ansicolor (~> 1.0.5)
thor (>= 0.13.6)
@@ -28,16 +28,14 @@ GEM
mustache (>= 0.7.0)
rdiscount (>= 1.5.8)
rr (1.0.2)
rspec (2.0.1)
rspec-core (~> 2.0.1)
rspec-expectations (~> 2.0.1)
rspec-mocks (~> 2.0.1)
rspec-core (2.0.1)
rspec-expectations (2.0.1)
diff-lcs (>= 1.1.2)
rspec-mocks (2.0.1)
rspec-core (~> 2.0.1)
rspec-expectations (~> 2.0.1)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
rspec-mocks (~> 2.6.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.6.0)
term-ansicolor (1.0.5)
thor (0.14.6)
@@ -52,4 +50,4 @@ DEPENDENCIES
rcov (~> 0.9.8)
ronn
rr (~> 1.0.2)
rspec (~> 2.0.0)
rspec (~> 2.6.0)

View File

@@ -13,7 +13,7 @@ task :default => :spec
task :release => :man
desc "Run all specs"
Rspec::Core::RakeTask.new(:spec) do |t|
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = 'spec/**/*_spec.rb'
end
@@ -22,7 +22,7 @@ task :rcov => "rcov:build" do
%x{ open coverage/index.html }
end
Rspec::Core::RakeTask.new("rcov:build") do |t|
RSpec::Core::RakeTask.new("rcov:build") do |t|
t.pattern = 'spec/**/*_spec.rb'
t.rcov = true
t.rcov_opts = [ "--exclude", ".bundle", "--exclude", "spec" ]

View File

@@ -25,5 +25,5 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'fakefs', '~> 0.2.1'
gem.add_development_dependency 'rcov', '~> 0.9.8'
gem.add_development_dependency 'rr', '~> 1.0.2'
gem.add_development_dependency 'rspec', '~> 2.0.0'
gem.add_development_dependency 'rspec', '~> 2.6.0'
end

View File

@@ -30,6 +30,7 @@ class Foreman::CLI < Thor
method_option :log, :type => :string, :aliases => "-l"
method_option :port, :type => :numeric, :aliases => "-p"
method_option :user, :type => :string, :aliases => "-u"
method_option :template, :type => :string, :aliases => "-t"
method_option :concurrency, :type => :string, :aliases => "-c",
:banner => '"alpha=5,bar=3"'
@@ -86,7 +87,7 @@ private ######################################################################
def options
original_options = super
return original_options unless File.exists?(".foreman")
defaults = YAML::load_file(".foreman")
defaults = YAML::load_file(".foreman") || {}
Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))
end

View File

@@ -23,8 +23,12 @@ private ######################################################################
puts "[foreman export] %s" % message
end
def export_template(name)
File.read(File.expand_path("../../../../data/export/#{name}", __FILE__))
def export_template(exporter, file, template_root)
if template_root && File.exist?(file_path = File.join(template_root, file))
File.read(file_path)
else
File.read(File.expand_path("../../../../data/export/#{exporter}/#{file}", __FILE__))
end
end
def write_file(filename, contents)

View File

@@ -11,6 +11,7 @@ class Foreman::Export::Upstart < Foreman::Export::Base
app = options[:app] || File.basename(engine.directory)
user = options[:user] || app
log_root = options[:log] || "/var/log/#{app}"
template_root = options[:template]
Dir["#{location}/#{app}*.conf"].each do |file|
say "cleaning up: #{file}"
@@ -19,14 +20,14 @@ class Foreman::Export::Upstart < Foreman::Export::Base
concurrency = Foreman::Utils.parse_concurrency(options[:concurrency])
master_template = export_template("upstart/master.conf.erb")
master_template = export_template("upstart", "master.conf.erb", template_root)
master_config = ERB.new(master_template).result(binding)
write_file "#{location}/#{app}.conf", master_config
process_template = export_template("upstart/process.conf.erb")
process_template = export_template("upstart", "process.conf.erb", template_root)
engine.processes.values.each do |process|
process_master_template = export_template("upstart/process_master.conf.erb")
process_master_template = export_template("upstart", "process_master.conf.erb", template_root)
process_master_config = ERB.new(process_master_template).result(binding)
write_file "#{location}/#{app}-#{process.name}.conf", process_master_config

View File

@@ -1,5 +1,5 @@
module Foreman
VERSION = "0.18.0"
VERSION = "0.19.0"
end

View File

@@ -21,4 +21,19 @@ describe Foreman::Export::Upstart do
File.read("/tmp/init/app-bravo.conf").should == example_export_file("upstart/app-bravo.conf")
File.read("/tmp/init/app-bravo-1.conf").should == example_export_file("upstart/app-bravo-1.conf")
end
context "with alternate templates" do
let(:template_root) { "/tmp/alternate" }
before do
FileUtils.mkdir_p template_root
File.open("#{template_root}/master.conf.erb", "w") { |f| f.puts "alternate_template" }
end
it "can export with alternate template files" do
upstart.export("/tmp/init", :template => template_root)
File.read("/tmp/init/app.conf").should == "alternate_template\n"
end
end
end

View File

@@ -52,7 +52,7 @@ def example_export_file(filename)
data
end
Rspec.configure do |config|
RSpec.configure do |config|
config.color_enabled = true
config.include FakeFS::SpecHelpers
config.mock_with :rr