From 9e42dfb253ea9ff94680fb8107181da776d429eb Mon Sep 17 00:00:00 2001 From: David Dollar Date: Wed, 3 Nov 2010 14:05:01 -0700 Subject: [PATCH] change back to Procfile --- data/example/{Pstypes => Procfile} | 0 lib/foreman/cli.rb | 20 ++++++++++---------- lib/foreman/engine.rb | 14 +++++++------- spec/foreman/cli_spec.rb | 16 ++++++++-------- spec/foreman/engine_spec.rb | 14 +++++++------- spec/spec_helper.rb | 4 ++-- 6 files changed, 34 insertions(+), 34 deletions(-) rename data/example/{Pstypes => Procfile} (100%) diff --git a/data/example/Pstypes b/data/example/Procfile similarity index 100% rename from data/example/Pstypes rename to data/example/Procfile diff --git a/lib/foreman/cli.rb b/lib/foreman/cli.rb index 05289a1..19ccf86 100644 --- a/lib/foreman/cli.rb +++ b/lib/foreman/cli.rb @@ -5,7 +5,7 @@ require "thor" class Foreman::CLI < Thor - class_option :psfile, :type => :string, :aliases => "-f", :desc => "Default: Psfile" + class_option :procfile, :type => :string, :aliases => "-f", :desc => "Default: Procfile" desc "start [PROCESS]", "Start the application, or a specific process" @@ -14,7 +14,7 @@ class Foreman::CLI < Thor :banner => '"alpha=5,bar=3"' def start(process=nil) - check_psfile! + check_procfile! if process engine.execute(process, options) @@ -33,7 +33,7 @@ class Foreman::CLI < Thor :banner => '"alpha=5,bar=3"' def export(format, location=nil) - check_psfile! + check_procfile! formatter = case format when "upstart" then Foreman::Export::Upstart @@ -49,16 +49,16 @@ class Foreman::CLI < Thor private ###################################################################### - def check_psfile! - error("#{psfile} does not exist.") unless File.exist?(psfile) + def check_procfile! + error("#{procfile} does not exist.") unless File.exist?(procfile) end def engine - @engine ||= Foreman::Engine.new(psfile) + @engine ||= Foreman::Engine.new(procfile) end - def psfile - options[:psfile] || "Psfile" + def procfile + options[:procfile] || "Procfile" end private ###################################################################### @@ -68,8 +68,8 @@ private ###################################################################### exit 1 end - def psfile_exists?(psfile) - File.exist?(psfile) + def procfile_exists?(procfile) + File.exist?(procfile) end end diff --git a/lib/foreman/engine.rb b/lib/foreman/engine.rb index 83c8044..52c8ef9 100644 --- a/lib/foreman/engine.rb +++ b/lib/foreman/engine.rb @@ -8,21 +8,21 @@ require "fileutils" class Foreman::Engine - attr_reader :psfile + attr_reader :procfile attr_reader :directory extend Term::ANSIColor COLORS = [ cyan, yellow, green, magenta, red ] - def initialize(psfile) - @psfile = read_psfile(psfile) - @directory = File.expand_path(File.dirname(psfile)) + def initialize(procfile) + @procfile = read_procfile(procfile) + @directory = File.expand_path(File.dirname(procfile)) end def processes @processes ||= begin - psfile.split("\n").inject({}) do |hash, line| + procfile.split("\n").inject({}) do |hash, line| next if line.strip == "" name, command = line.split(" ", 2) process = Foreman::Process.new(name, command) @@ -144,8 +144,8 @@ private ###################################################################### $0 = title end - def read_psfile(psfile) - File.read(psfile) + def read_procfile(procfile) + File.read(procfile) end def watch_for_termination diff --git a/spec/foreman/cli_spec.rb b/spec/foreman/cli_spec.rb index aec3b10..a1b8305 100644 --- a/spec/foreman/cli_spec.rb +++ b/spec/foreman/cli_spec.rb @@ -5,17 +5,17 @@ describe "Foreman::CLI" do subject { Foreman::CLI.new } describe "start" do - describe "with a non-existent Psfile" do + describe "with a non-existent Procfile" do it "prints an error" do - mock_error(subject, "Psfile does not exist.") do + mock_error(subject, "Procfile does not exist.") do dont_allow.instance_of(Foreman::Engine).start subject.start end end end - describe "with a Psfile" do - before(:each) { write_psfile } + describe "with a Procfile" do + before(:each) { write_procfile } it "runs successfully" do dont_allow(subject).error @@ -26,17 +26,17 @@ describe "Foreman::CLI" do end describe "export" do - describe "with a non-existent Psfile" do + describe "with a non-existent Procfile" do it "prints an error" do - mock_error(subject, "Psfile does not exist.") do + mock_error(subject, "Procfile does not exist.") do dont_allow.instance_of(Foreman::Engine).export subject.export("testapp") end end end - describe "with a Psfile" do - before(:each) { write_psfile } + describe "with a Procfile" do + before(:each) { write_procfile } describe "with an invalid formatter" do it "prints an error" do diff --git a/spec/foreman/engine_spec.rb b/spec/foreman/engine_spec.rb index c5febfa..17075b8 100644 --- a/spec/foreman/engine_spec.rb +++ b/spec/foreman/engine_spec.rb @@ -2,18 +2,18 @@ require "spec_helper" require "foreman/engine" describe "Foreman::Engine" do - subject { Foreman::Engine.new("Psfile") } + subject { Foreman::Engine.new("Procfile") } describe "initialize" do - describe "without an existing Psfile" do + describe "without an existing Procfile" do it "raises an error" do lambda { subject }.should raise_error end end - describe "with a Psfile" do + describe "with a Procfile" do it "reads the processes" do - write_psfile + write_procfile subject.processes["alpha"].command.should == "./alpha" subject.processes["bravo"].command.should == "./bravo" end @@ -22,7 +22,7 @@ describe "Foreman::Engine" do describe "start" do it "forks the processes" do - write_psfile + write_procfile mock(subject).fork(subject.processes["alpha"], {}) mock(subject).fork(subject.processes["bravo"], {}) mock(subject).watch_for_termination @@ -30,7 +30,7 @@ describe "Foreman::Engine" do end it "handles concurrency" do - write_psfile + write_procfile mock(subject).fork_individual(subject.processes["alpha"], 1, 5000) mock(subject).fork_individual(subject.processes["alpha"], 2, 5001) mock(subject).fork_individual(subject.processes["bravo"], 1, 5100) @@ -41,7 +41,7 @@ describe "Foreman::Engine" do describe "execute" do it "runs the processes" do - write_psfile + write_procfile mock(subject).fork(subject.processes["alpha"], {}) mock(subject).watch_for_termination subject.execute("alpha") diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cb86e0f..b8fe97f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -24,8 +24,8 @@ def write_foreman_config(app) end end -def write_psfile(psfile="Psfile") - File.open(psfile, "w") do |file| +def write_procfile(procfile="Procfile") + File.open(procfile, "w") do |file| file.puts "alpha ./alpha" file.puts "bravo ./bravo" end