Class: SashimiTanpopo::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/sashimi_tanpopo/dsl.rb

Defined Under Namespace

Classes: EvalContext

Instance Method Summary collapse

Instance Method Details

#evaluate(recipe_body:, recipe_path:, target_dir:, params:, dry_run:, is_colored:, is_update_local:) ⇒ Hash<String, { before_content: String, after_content: String, mode: String }>

Apply recipe file for unit test

Examples:

Response format

{
  "path/to/changed-file.txt" => {
    before_content: "foo",
    after_content:  "bar",
    mode:           "100644",
  }
}

Parameters:

  • recipe_body (String)
  • recipe_path (String)
  • target_dir (String)
  • params (Hash<Symbol, String>)
  • dry_run (Boolean)
  • is_colored (Boolean)

    Whether show color diff

  • is_update_local (Boolean)

    Whether update local file in update_file

Returns:

  • (Hash<String, { before_content: String, after_content: String, mode: String }>)

    changed files (key: file path, value: Hash)



56
57
58
59
60
# File 'lib/sashimi_tanpopo/dsl.rb', line 56

def evaluate(recipe_body:, recipe_path:, target_dir:, params:, dry_run:, is_colored:, is_update_local:)
  context = EvalContext.new(params: params, dry_run: dry_run, is_colored: is_colored, target_dir: target_dir, is_update_local: is_update_local)
  InstanceEval.new(recipe_body: recipe_body, recipe_path: recipe_path, target_dir: target_dir, context: context).call
  context.changed_files
end

#perform(recipe_path:, target_dir:, params:, dry_run:, is_colored:, is_update_local:) ⇒ Hash<String, { before_content: String, after_content: String, mode: String }>

Apply recipe file

Examples:

Response format

{
  "path/to/changed-file.txt" => {
    before_content: "foo",
    after_content:  "bar",
    mode:           "100644",
  }
}

Parameters:

  • recipe_path (String)
  • target_dir (String)
  • params (Hash<Symbol, String>)
  • dry_run (Boolean)
  • is_colored (Boolean)

    Whether show color diff

  • is_update_local (Boolean)

    Whether update local file in update_file

Returns:

  • (Hash<String, { before_content: String, after_content: String, mode: String }>)

    changed files (key: file path, value: Hash)



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/sashimi_tanpopo/dsl.rb', line 24

def perform(recipe_path:, target_dir:, params:, dry_run:, is_colored:, is_update_local:)
  evaluate(
    recipe_body:     File.read(recipe_path),
    recipe_path:     recipe_path,
    target_dir:      target_dir,
    params:          params,
    dry_run:         dry_run,
    is_colored:      is_colored,
    is_update_local: is_update_local,
  )
end