Class: Openbox::Runtime
- Inherits:
-
Object
- Object
- Openbox::Runtime
- Defined in:
- lib/openbox/runtime.rb
Overview
Detection application runtime
Instance Method Summary collapse
-
#groups ⇒ Array<Symbol>
Groups to detect.
-
#has?(*names) ⇒ TrueClass|FalseClass
Check for rubygmes exists.
-
#initialize(dependencies = []) ⇒ Runtime
constructor
A new instance of Runtime.
-
#rails? ⇒ TrueClass|FalseClass
Check for Rails environment.
-
#select(*names) ⇒ Array<Bundler::Dependency>
Select desired rubygems.
Constructor Details
#initialize(dependencies = []) ⇒ Runtime
Returns a new instance of Runtime.
13 14 15 |
# File 'lib/openbox/runtime.rb', line 13 def initialize(dependencies = []) @dependencies = dependencies end |
Instance Method Details
#groups ⇒ Array<Symbol>
Groups to detect
50 51 52 |
# File 'lib/openbox/runtime.rb', line 50 def groups @groups ||= [:default, ENV['RAILS_ENV'], ENV['RACK_ENV']].compact.map(&:to_sym) end |
#has?(*names) ⇒ TrueClass|FalseClass
Check for rubygmes exists
41 42 43 |
# File 'lib/openbox/runtime.rb', line 41 def has?(*names) select(*names).any? end |
#rails? ⇒ TrueClass|FalseClass
Check for Rails environment
22 23 24 |
# File 'lib/openbox/runtime.rb', line 22 def rails? has?('rails') end |
#select(*names) ⇒ Array<Bundler::Dependency>
Select desired rubygems
31 32 33 34 |
# File 'lib/openbox/runtime.rb', line 31 def select(*names) @dependencies .select { |dep| names.include?(dep.name) && (dep.groups & groups).any? } end |