Sha256: 553e8e07ea9f1e2022ac5fc07327d395f95d65abaa72df47eb858fb07b5dbb07

Contents?: true

Size: 1.53 KB

Versions: 39

Compression:

Stored size: 1.53 KB

Contents

# frozen_string_literal: true

# takelage bit clipboard paste
module BitClipboardPaste
  # Backend method for bit paste.
  def bit_clipboard_paste(cid, dir)
    log.debug "Running bit paste \"#{cid}\" to \"#{dir}\""

    return false unless configured? %w[project_root_dir]

    return false unless _bit_clipboard_lib_prepare_workspace

    return false unless _bit_clipboard_paste_cid_exists? cid

    _bit_clipboard_paste_import_cid cid, dir
    _bit_clipbpard_lib_remove_bit_artifacts
    _bit_clipboard_lib_sync_workspace

    log.info "Pasted bit component \"#{cid}\" to directory \"#{dir}\""
    true
  end

  private

  # paste bit component into directory.
  def _bit_clipboard_paste_import_cid(cid, dir)
    cmd_bit_import_cid = format(
      config.active['cmd_bit_clipboard_paste_bit_import_cid'],
      cid: cid,
      dir: dir
    )

    run cmd_bit_import_cid
  end

  # Check if remote component exists.
  def _bit_clipboard_paste_cid_exists?(cid)
    scope = cid.scan(%r{([^/]*).*}).first.first

    log.debug "Checking if scope \"#{scope}\" " \
              "contains component id \"#{cid}\""

    bit_list_scope = _bit_clipboard_paste_cid_exists_list_scope scope

    return true if bit_list_scope.include? "\"id\": \"#{cid}\","

    log.error "No remote component \"#{cid}\""
    false
  end

  # Get components in remote scope.
  def _bit_clipboard_paste_cid_exists_list_scope(scope)
    cmd_bit_list_scope = format(
      config.active['cmd_bit_clipboard_paste_bit_list_scope'],
      scope: scope
    )

    run cmd_bit_list_scope
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
takelage-0.33.1 lib/takelage/bit/clipboard/paste.rb
takelage-0.32.4 lib/takelage/bit/clipboard/paste.rb
takelage-0.32.3 lib/takelage/bit/clipboard/paste.rb
takelage-0.32.1 lib/takelage/bit/clipboard/paste.rb
takelage-0.32.0 lib/takelage/bit/clipboard/paste.rb
takelage-0.31.0 lib/takelage/bit/clipboard/paste.rb
takelage-0.30.6 lib/takelage/bit/clipboard/paste.rb
takelage-0.30.5 lib/takelage/bit/clipboard/paste.rb
takelage-0.30.1 lib/takelage/bit/clipboard/paste.rb
takelage-0.30.0 lib/takelage/bit/clipboard/paste.rb
takelage-0.29.14 lib/takelage/bit/clipboard/paste.rb
takelage-0.29.13 lib/takelage/bit/clipboard/paste.rb
takelage-0.29.11 lib/takelage/bit/clipboard/paste.rb
takelage-0.29.10 lib/takelage/bit/clipboard/paste.rb
takelage-0.29.8 lib/takelage/bit/clipboard/paste.rb
takelage-0.29.6 lib/takelage/bit/clipboard/paste.rb
takelage-0.29.0 lib/takelage/bit/clipboard/paste.rb
takelage-0.28.26 lib/takelage/bit/clipboard/paste.rb
takelage-0.28.24 lib/takelage/bit/clipboard/paste.rb
takelage-0.28.14 lib/takelage/bit/clipboard/paste.rb