Class: Remocon::Command::Validate
- Inherits:
-
Object
- Object
- Remocon::Command::Validate
- Includes:
- InterpreterHelper
- Defined in:
- lib/remocon/command/validate_command.rb
Instance Attribute Summary collapse
-
#cmd_opts ⇒ Object
readonly
Returns the value of attribute cmd_opts.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(opts) ⇒ Validate
constructor
A new instance of Validate.
- #require_conditions_file_path ⇒ Object
- #require_parameters_file_path ⇒ Object
- #run ⇒ Object
Methods included from InterpreterHelper
#condition_array, #condition_names, #parameter_hash, #read_conditions, #read_parameters
Constructor Details
Instance Attribute Details
#cmd_opts ⇒ Object (readonly)
Returns the value of attribute cmd_opts.
8 9 10 |
# File 'lib/remocon/command/validate_command.rb', line 8 def cmd_opts @cmd_opts end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/remocon/command/validate_command.rb', line 8 def config @config end |
Instance Method Details
#require_conditions_file_path ⇒ Object
19 20 21 |
# File 'lib/remocon/command/validate_command.rb', line 19 def require_conditions_file_path config.conditions_file_path end |
#require_parameters_file_path ⇒ Object
15 16 17 |
# File 'lib/remocon/command/validate_command.rb', line 15 def require_parameters_file_path config.parameters_file_path end |
#run ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/remocon/command/validate_command.rb', line 23 def run artifact = { conditions: condition_array, parameters: parameter_hash }.skip_nil_values.stringify_values response, body = Tempfile.open do |t| t.write(JSON.pretty_generate(artifact)) t.flush Request.validate(config, t) end if response.kind_of?(Net::HTTPOK) if response.header["etag"] =~ /^.*-0$/ if etag_errors.empty? STDOUT.puts "valid" true else # validation api cannot validate etag STDERR.puts "the latest etag was updated" false end else # https://firebase.google.com/docs/remote-config/use-config-rest#validate_before_publishing STDERR.puts "api server returned 200 but etag is not followed the valid format" false end else STDERR.puts body false end end |