Class: Preflight::Settings
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Preflight::Settings
- Defined in:
- lib/preflight/settings.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(project_dir, user_defined_options) ⇒ Settings
constructor
A new instance of Settings.
- #inspect ⇒ Object
- #jetty? ⇒ Boolean
- #jetty_pid_path ⇒ Object
- #jruby? ⇒ Boolean
Constructor Details
#initialize(project_dir, user_defined_options) ⇒ Settings
Returns a new instance of Settings.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/preflight/settings.rb', line 14 def initialize(project_dir, ) contents = {} contents["app_root"] = ["app_root"] || File.(project_dir) contents["app_user"] = ["app_user"] || Etc.getpwuid(File.stat(contents["app_root"]).uid).name contents["java_options"] = ["java_options"] || "-Xmx2048m" contents["https_port"] = ["https_port"] || "4443" contents["http_port"] = ["http_port"] || "4080" contents["jruby_rack"] = ["jruby-rack"] if .key?("jruby-rack") contents["jetty"] = ["jetty"] if .key?("jetty") contents["jruby"] = ["jruby"] if .key?("jruby") contents["max_concurrent_connections"] = ["max_concurrent_connections"] || 20 contents["ruby_version"] = ["ruby_version"] || "1.8" @keys = contents.keys.sort super(contents) end |
Class Method Details
.load_from_project(project_dir) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/preflight/settings.rb', line 7 def self.load_from_project(project_dir) config_file = File.join(project_dir, "config/preflight.yml") raise("#{config_file} not found") unless File.exists?(config_file) yaml = YAML.load(ERB.new(File.read(config_file)).result) Settings.new(project_dir, yaml) end |
Instance Method Details
#inspect ⇒ Object
44 45 46 |
# File 'lib/preflight/settings.rb', line 44 def inspect self.class.name + ":\n" + @keys.map{|k|" #{k.ljust(20)} = #{send(k.to_sym)}"}.join("\n") + "\n" end |
#jetty? ⇒ Boolean
36 37 38 |
# File 'lib/preflight/settings.rb', line 36 def jetty? respond_to?(:jetty) end |
#jetty_pid_path ⇒ Object
40 41 42 |
# File 'lib/preflight/settings.rb', line 40 def jetty_pid_path File.join(app_root, "/vendor/jetty/run/jetty.pid") end |
#jruby? ⇒ Boolean
32 33 34 |
# File 'lib/preflight/settings.rb', line 32 def jruby? respond_to?(:jruby) end |