module Dapp::Dapp::Command::Sample::Common

Public Instance Methods

_sample_git_repo() click to toggle source
# File lib/dapp/dapp/command/sample/common.rb, line 29
def _sample_git_repo
  @sample_repo ||= begin
    Dimg::GitRepo::Remote.get_or_create(
      self,
      git_url_to_name(_samples_git_repo_url),
      url: _samples_git_repo_url
    )
  end
end
_sample_list() click to toggle source
# File lib/dapp/dapp/command/sample/common.rb, line 6
def _sample_list
  @sample_list ||= [].tap do |list|
    tree = begin
      latest_commit = _sample_git_repo.latest_branch_commit(_samples_git_repo_branch)
      latest_commit_tree = _sample_git_repo.lookup_commit(latest_commit).tree

      if _samples_dir == '.'
        latest_commit_tree
      else
        begin
          oid = latest_commit_tree.path(_samples_dir)[:oid]
        rescue Rugged::TreeError
          raise Error::Command, code: :samples_directory_not_exist, data: { url: _samples_git_repo_url, path: _samples_dir }
        end

        _sample_git_repo.lookup_object(oid)
      end
    end

    tree.each_tree { |entry| list << entry[:name] }
  end
end
_samples_dir() click to toggle source
# File lib/dapp/dapp/command/sample/common.rb, line 47
def _samples_dir
  options[:samples_dir]
end
_samples_git_repo_branch() click to toggle source
# File lib/dapp/dapp/command/sample/common.rb, line 43
def _samples_git_repo_branch
  options[:samples_branch]
end
_samples_git_repo_url() click to toggle source
# File lib/dapp/dapp/command/sample/common.rb, line 39
def _samples_git_repo_url
  options[:samples_repo]
end