Module: Php::ComposerHooks
- Defined in:
- lib/jekyll-php/composer_hooks.rb
Constant Summary collapse
- DEFAULT_FLAGS =
%w( no-ansi no-dev no-interaction no-plugins no-progress no-scripts optimize-autoloader ).freeze
- CONFIG =
{ "environment" => {"type" => String, "default" => "development"}, "composer" => {"type" => Object, "default" => true}, "composer_output" => {"type" => Object, "default" => false}, "composer_command" => {"type" => String, "default" => "composer install"}, "composer_flags" => {"type" => Array, "default" => DEFAULT_FLAGS} }.freeze
Class Method Summary collapse
- .build_command(site) ⇒ Object
- .composer?(path) ⇒ Boolean
- .get_config(site, key) ⇒ Object
- .production?(site) ⇒ Boolean
Class Method Details
.build_command(site) ⇒ Object
39 40 41 42 |
# File 'lib/jekyll-php/composer_hooks.rb', line 39 def self.build_command(site) command = get_config(site, "composer_command") command << get_config(site, "composer_flags").map {|flag| " --#{flag}"}.join end |
.composer?(path) ⇒ Boolean
35 36 37 |
# File 'lib/jekyll-php/composer_hooks.rb', line 35 def self.composer?(path) File.exists?(File.join(path, "composer.json")) end |
.get_config(site, key) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/jekyll-php/composer_hooks.rb', line 23 def self.get_config(site, key) info = CONFIG[key] value = site.config.key?(key) ? site.config[key] : info["default"] raise Jekyll::Errors::InvalidConfigurationError, "'#{key}' should be set as a(n) #{info["type"]}, but was: #{value.inspect}." unless value.is_a?(info["type"]) value end |
.production?(site) ⇒ Boolean
31 32 33 |
# File 'lib/jekyll-php/composer_hooks.rb', line 31 def self.production?(site) Jekyll.env == "production" || get_config(site, "environment") == "production" end |