Class: Dev::Php
- Defined in:
- lib/firespring_dev_commands/php.rb,
lib/firespring_dev_commands/php/audit.rb
Overview
Class containing methods related to php applicatio
Defined Under Namespace
Constant Summary collapse
- DEFAULT_PATH =
The default path of the application inside the container
'/usr/src/app'.freeze
- DEFAULT_PACKAGE_FILE =
The default name of the php package file
'composer.json'.freeze
Instance Attribute Summary collapse
-
#container_path ⇒ Object
Returns the value of attribute container_path.
-
#coverage ⇒ Object
Returns the value of attribute coverage.
-
#local_path ⇒ Object
Returns the value of attribute local_path.
-
#package_file ⇒ Object
Returns the value of attribute package_file.
Class Method Summary collapse
-
.config {|@config| ... } ⇒ Object
(also: configure)
Instantiates a new top level config object if one hasn’t already been created Yields that config object to any given block Returns the resulting config object.
Instance Method Summary collapse
-
#audit_command ⇒ Object
Build the command which can be use to perform a security audit report.
-
#audit_fix_command ⇒ Object
Build the command to fix any security vulnerabilities that were found.
-
#base_command ⇒ Object
The base npm command that is the starting point for all subsequent commands.
-
#check_test_coverage(application:) ⇒ Object
Run the check to ensure code coverage meets the desired threshold.
-
#initialize(container_path: nil, local_path: nil, package_file: nil, coverage: nil) ⇒ Php
constructor
A new instance of Php.
-
#install_command ⇒ Object
Build the php install command.
-
#lint_command ⇒ Object
Build the php lint command.
-
#lint_fix_command ⇒ Object
Build the php lint fix command.
-
#test_command ⇒ Object
Build the php test command.
Constructor Details
#initialize(container_path: nil, local_path: nil, package_file: nil, coverage: nil) ⇒ Php
Returns a new instance of Php.
36 37 38 39 40 41 42 |
# File 'lib/firespring_dev_commands/php.rb', line 36 def initialize(container_path: nil, local_path: nil, package_file: nil, coverage: nil) @container_path = container_path || self.class.config.container_path @local_path = local_path || self.class.config.local_path @package_file = package_file || self.class.config.package_file @coverage = coverage || Dev::Coverage::None.new raise 'coverage must be an instance of the base class' unless @coverage.is_a?(Dev::Coverage::Base) end |
Instance Attribute Details
#container_path ⇒ Object
Returns the value of attribute container_path.
34 35 36 |
# File 'lib/firespring_dev_commands/php.rb', line 34 def container_path @container_path end |
#coverage ⇒ Object
Returns the value of attribute coverage.
34 35 36 |
# File 'lib/firespring_dev_commands/php.rb', line 34 def coverage @coverage end |
#local_path ⇒ Object
Returns the value of attribute local_path.
34 35 36 |
# File 'lib/firespring_dev_commands/php.rb', line 34 def local_path @local_path end |
#package_file ⇒ Object
Returns the value of attribute package_file.
34 35 36 |
# File 'lib/firespring_dev_commands/php.rb', line 34 def package_file @package_file end |
Class Method Details
.config {|@config| ... } ⇒ Object Also known as: configure
Instantiates a new top level config object if one hasn’t already been created Yields that config object to any given block Returns the resulting config object
24 25 26 27 28 |
# File 'lib/firespring_dev_commands/php.rb', line 24 def config @config ||= Config.new yield(@config) if block_given? @config end |
Instance Method Details
#audit_command ⇒ Object
Build the command which can be use to perform a security audit report
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/firespring_dev_commands/php.rb', line 50 def audit_command audit = base_command audit << 'audit' audit << '--no-interaction' audit << '--no-cache' audit << '--format' << 'json' audit.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s)) audit << '2>&1' << '||' << 'true' # Run the command as part of a shell script ['sh', '-c', audit.join(' ')] end |
#audit_fix_command ⇒ Object
Build the command to fix any security vulnerabilities that were found
64 65 66 |
# File 'lib/firespring_dev_commands/php.rb', line 64 def audit_fix_command raise 'not implemented' end |
#base_command ⇒ Object
The base npm command that is the starting point for all subsequent commands
45 46 47 |
# File 'lib/firespring_dev_commands/php.rb', line 45 def base_command ['composer', '--working-dir', container_path] end |
#check_test_coverage(application:) ⇒ Object
Run the check to ensure code coverage meets the desired threshold
102 103 104 |
# File 'lib/firespring_dev_commands/php.rb', line 102 def check_test_coverage(application:) coverage.check(application:) end |
#install_command ⇒ Object
Build the php install command
69 70 71 72 73 74 |
# File 'lib/firespring_dev_commands/php.rb', line 69 def install_command install = base_command install << 'install' install.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s)) install end |
#lint_command ⇒ Object
Build the php lint command
77 78 79 80 81 82 |
# File 'lib/firespring_dev_commands/php.rb', line 77 def lint_command lint = base_command lint << 'run' << 'lint' << '--' lint.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s)) lint end |