Class: SashimiTanpopo::Provider::Base

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

Direct Known Subclasses

GitHub, GitLab, Local

Instance Method Summary collapse

Constructor Details

#initialize(recipe_paths:, target_dir:, params:, dry_run:, is_colored:, is_update_local:) ⇒ Base

Returns a new instance of Base.

Parameters:

  • recipe_paths (Array<String>)
  • target_dir (String, nil)
  • 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



12
13
14
15
16
17
18
19
# File 'lib/sashimi_tanpopo/provider/base.rb', line 12

def initialize(recipe_paths:, target_dir:, params:, dry_run:, is_colored:, is_update_local:)
  @recipe_paths = recipe_paths
  @target_dir = target_dir || Dir.pwd
  @params = params
  @dry_run = dry_run
  @is_colored = is_colored
  @is_update_local = is_update_local
end

Instance Method Details

#apply_recipe_filesHash<String, { before_content: String, after_content: String, mode: String }>

Apply recipe files

Examples:

Response format

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

Returns:

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

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



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/sashimi_tanpopo/provider/base.rb', line 33

def apply_recipe_files
  all_changed_files = {} # : changed_files

  @recipe_paths.each do |recipe_path|
    changed_files =
      DSL.new.perform(
        recipe_path:     recipe_path,
        target_dir:      @target_dir,
        params:          @params,
        dry_run:         @dry_run,
        is_colored:      @is_colored,
        is_update_local: @is_update_local,
      )

    all_changed_files.merge!(changed_files)
  end

  all_changed_files
end