Class: Cardigan::Command::OpenCard
- Inherits:
-
Object
- Object
- Cardigan::Command::OpenCard
- Defined in:
- lib/cardigan/command/open_card.rb
Instance Attribute Summary collapse
-
#help ⇒ Object
readonly
Returns the value of attribute help.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Instance Method Summary collapse
- #completion(text) ⇒ Object
- #execute(name) ⇒ Object
-
#initialize(repository, workflow_repository, io) ⇒ OpenCard
constructor
A new instance of OpenCard.
Constructor Details
#initialize(repository, workflow_repository, io) ⇒ OpenCard
Returns a new instance of OpenCard.
7 8 9 10 11 |
# File 'lib/cardigan/command/open_card.rb', line 7 def initialize repository, workflow_repository, io @repository, @workflow_repository, @io = repository, workflow_repository, io @usage = '<card name>' @help = 'Opens the specified card for editing' end |
Instance Attribute Details
#help ⇒ Object (readonly)
Returns the value of attribute help.
5 6 7 |
# File 'lib/cardigan/command/open_card.rb', line 5 def help @help end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
5 6 7 |
# File 'lib/cardigan/command/open_card.rb', line 5 def usage @usage end |
Instance Method Details
#completion(text) ⇒ Object
22 23 24 |
# File 'lib/cardigan/command/open_card.rb', line 22 def completion text @repository.cards.map {|card| card['name'] }.grep(/^#{Regexp.escape(text)}/).sort end |
#execute(name) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/cardigan/command/open_card.rb', line 13 def execute name entry = @repository.cards.find { |entry| entry['name'] == name } original = entry.dup if entry id = entry ? entry.id : UUIDTools::UUID.random_create.to_s entry ||= {'name' => name} Cardigan::EntryContext.new(@io, @workflow_repository, entry).push @repository[id] = entry unless original == entry end |