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.
-
#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.
-
#test_fast_command(processes = 4) ⇒ Object
Build the php fast test command.
Constructor Details
#initialize(container_path: nil, local_path: nil, package_file: nil, coverage: nil) ⇒ 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 |
#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
105 106 107 |
# File 'lib/firespring_dev_commands/php.rb', line 105 def check_test_coverage(application:) coverage.check(application:) end |
#install_command ⇒ Object
Build the php install command
72 73 74 75 76 77 |
# File 'lib/firespring_dev_commands/php.rb', line 72 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
80 81 82 83 84 85 |
# File 'lib/firespring_dev_commands/php.rb', line 80 def lint_command lint = base_command lint << 'lint' lint.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s)) lint end |
#lint_fix_command ⇒ Object
Build the php lint fix command
88 89 90 91 92 93 |
# File 'lib/firespring_dev_commands/php.rb', line 88 def lint_fix_command lint_fix = base_command lint_fix << 'lint-fix' lint_fix.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s)) lint_fix end |
#test_command ⇒ Object
Build the php test command
96 97 98 99 100 101 102 |
# File 'lib/firespring_dev_commands/php.rb', line 96 def test_command test = [] test << './vendor/bin/phpunit' test.concat(coverage.) if coverage test.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s)) test end |
#test_fast_command(processes = 4) ⇒ Object
Build the php fast test command
110 111 112 113 114 115 116 |
# File 'lib/firespring_dev_commands/php.rb', line 110 def test_fast_command(processes = 4) test = [] test << './vendor/bin/paratest' test.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s)) test << "-p#{processes}" << '--runner=WrapperRunner' test end |