Class: Rosette::Core::Commands::SnapshotCommand
- Inherits:
-
GitCommand
- Object
- Command
- GitCommand
- Rosette::Core::Commands::SnapshotCommand
- Includes:
- WithRef, WithRepoName, WithSnapshots
- Defined in:
- lib/rosette/core/commands/git/snapshot_command.rb
Overview
Takes a snapshot and returns a list of phrases. This is different from RepoSnapshotCommand in that it doesn’t return the snapshot hash itself, but instead the phrases contained in the snapshot’s commits.
Instance Attribute Summary collapse
-
#paths ⇒ Array
readonly
The paths to consider when taking the snapshot.
Attributes included from WithRef
Attributes included from WithRepoName
Attributes inherited from Command
Instance Method Summary collapse
-
#execute ⇒ Array<Rosette::Core::Phrase>
Take the snapshot.
-
#set_paths(paths) ⇒ self
Set the paths that will be included in the snapshot.
Methods included from WithRef
#commit_id, #set_commit_id, #set_ref
Methods included from WithRepoName
Methods included from WithSnapshots
Methods inherited from GitCommand
Methods inherited from Command
#initialize, #messages, #valid?, validate, validators
Constructor Details
This class inherits a constructor from Rosette::Core::Commands::Command
Instance Attribute Details
#paths ⇒ Array (readonly)
Returns the paths to consider when taking the snapshot. Any paths that do not exist in this array will not appear in the snapshot.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rosette/core/commands/git/snapshot_command.rb', line 22 class SnapshotCommand < GitCommand attr_reader :paths include WithSnapshots include WithRepoName include WithRef # Set the paths that will be included in the snapshot. # # @param [Array] paths The paths to include in the snapshot. # @return [self] def set_paths(paths) @paths = paths self end # Take the snapshot. # # @return [Array<Rosette::Core::Phrase>] the list of phrases from the # snapshot. def execute snapshot = take_snapshot(get_repo(repo_name), commit_id, paths) datastore.phrases_by_commits(repo_name, snapshot).to_a end end |
Instance Method Details
#execute ⇒ Array<Rosette::Core::Phrase>
Take the snapshot.
42 43 44 45 |
# File 'lib/rosette/core/commands/git/snapshot_command.rb', line 42 def execute snapshot = take_snapshot(get_repo(repo_name), commit_id, paths) datastore.phrases_by_commits(repo_name, snapshot).to_a end |
#set_paths(paths) ⇒ self
Set the paths that will be included in the snapshot.
33 34 35 36 |
# File 'lib/rosette/core/commands/git/snapshot_command.rb', line 33 def set_paths(paths) @paths = paths self end |