Решение на Пета задача от Кристиян Тодоров

Обратно към всички решения

Към профила на Кристиян Тодоров

Резултати

  • 1 точка от тестове
  • 0 бонус точки
  • 1 точка общо
  • 4 успешни тест(а)
  • 26 неуспешни тест(а)

Код

class Hash
def reject_after(reject_key)
new_hash = {}
each_pair do |key, value|
new_hash[key] = value
break if key == reject_key
end
new_hash
end
end
class ObjectStore
require 'digest/sha1'
def initialize
@staging = {}
@commited = {}
@success
@information_message
@count = 0
@branch_hash = {}
@result
@commit_hash = {}
end
def commit_hash
@commit_hash
end
def self.init(&block)
obj = ObjectStore.new
if block_given?
obj.instance_eval &block
end
obj
end
def success?
@success
end
def error?
not success?
end
def commit(note_message)
if @staging.empty?
@success = false
@information_message = "Nothing to commit, working directory clean."
else
@success = true
@information_message = "#{note_message}\n\t#{@count} objects changed"
@commit_message = note_message
@commited.merge!(@staging)
@commit_hash[Digest::SHA1.hexdigest note_message] = @staging
@staging, count = {}, 0
end
self
end
def message
@information_message
end
def files
@commited
end
def result
@result
end
def add(name, value)
@staging[name] = value
@count += 1
@information_message = "Added #{name} to stage."
@result = value
self
end
def remove(name)
if @staging.member?(name)
@staging.delete(name)
@count -= 1
@success = false
@information_message = "Added #{name} for removal."
@result = name
else
@success = true
@information_message = "Object #{name} is not committed."
end
self
end
def checkout(name)
if commit_hash.member?(name)
@committed = commit_hash[name]
@result = commit_hash[name]
@commit_hash = commit_hash.reject_after(name)
@success = true
@information_message = "HEAD is now at #{name}."
else
@information_message, @success = "Commit #{name} does not exist.", false
end
self
end
def branch_hash
@branch_hash
end
def branch
current_branch = self
end
def create(branch_name)
if branch_hash.has_key?(branch_name)
@information_message = "Branch #{branch_name} already exists."
@success = false
else
@branch_hash[branch_name] = branch
@information_message = "Created branch #{branch_name}."
@success = true
end
self
end
end

Лог от изпълнението

FF.FFFFFFFFFFF.FFFFFFFFFFF..FF

Failures:

  1) ObjectStore can add objects
     Failure/Error: expect(repo.add("object", "content")).to be_success("Added object to stage.", "content")
       expected #<ObjectStore:0x007f3cf62ef4c0 @staging={"object"=>"content"}, @commited={}, @count=1, @branch_hash={}, @commit_hash={}, @information_message="Added object to stage.", @result="content"> to be success "Added object to stage." and "content"
     # /tmp/d20160111-5693-64b9c1/spec.rb:23:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  2) ObjectStore can commit objects
     Failure/Error: expect(repo.commit("So cool!")).to be_success("So cool!\n\t2 objects changed", repo.head.result)
     NoMethodError:
       undefined method `head' for #<ObjectStore:0x007f3cf62e8350>
     # /tmp/d20160111-5693-64b9c1/spec.rb:30:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  3) ObjectStore can remove objects
     Failure/Error: expect(repo.remove("object1")).to be_success("Added object1 for removal.", "content1")
       expected #<ObjectStore:0x007f3cf624f240 @staging={}, @commited={"object1"=>"content1", "object2"=>"content2"}, @count=2, @branch_hash={}, @commit_hash={"760af3b5c0afc87ffc251a7d6dcfc22706b198a4"=>{"object1"=>"content1", "object2"=>"content2"}}, @information_message="Object object1 is not committed.", @result="content2", @success=true, @commit_message="So cool!"> to be success "Added object1 for removal." and "content1"
     # /tmp/d20160111-5693-64b9c1/spec.rb:43:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  4) ObjectStore can commit changes which include only removed objects
     Failure/Error: expect(repo.commit("Removed object2")).to be_success("Removed object2\n\t1 objects changed", repo.head.result)
     NoMethodError:
       undefined method `head' for #<ObjectStore:0x007f3cf62415f0>
     # /tmp/d20160111-5693-64b9c1/spec.rb:53:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  5) ObjectStore cannot remove objects that are not committed
     Failure/Error: expect(repo.remove("object2")).to be_error("Object object2 is not committed.")
       expected #<ObjectStore:0x007f3cf623dd10 @staging={}, @commited={"object1"=>"content1"}, @count=1, @branch_hash={}, @commit_hash={"760af3b5c0afc87ffc251a7d6dcfc22706b198a4"=>{"object1"=>"content1"}}, @information_message="Object object2 is not committed.", @result="content1", @success=true, @commit_message="So cool!"> to be error "Object object2 is not committed."
     # /tmp/d20160111-5693-64b9c1/spec.rb:60:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  6) ObjectStore can show head
     Failure/Error: expect(repo.head).to be_success("There we go", last_commit)
     NoMethodError:
       undefined method `head' for #<ObjectStore:0x007f3cf6236858>
     # /tmp/d20160111-5693-64b9c1/spec.rb:69:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  7) ObjectStore cannot show head for empty repository
     Failure/Error: expect(repo.head).to be_error("Branch master does not have any commits yet.")
     NoMethodError:
       undefined method `head' for #<ObjectStore:0x007f3cf6223f78>
     # /tmp/d20160111-5693-64b9c1/spec.rb:74:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  8) ObjectStore can show log of changes for a single commit
     Failure/Error: commit_hash = Digest::SHA1.hexdigest("#{commit.date.strftime("%a %b %d %H:%M %Y %z")}#{commit.message}")
     NoMethodError:
       undefined method `date' for "content2":String
     # /tmp/d20160111-5693-64b9c1/spec.rb:82:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  9) ObjectStore can show log of changes for a single commit
     Failure/Error: commit_hash = Digest::SHA1.hexdigest("#{commit.date.strftime("%a %b %d %H:%M %Y %z")}#{commit.message}")
     NoMethodError:
       undefined method `date' for "content2":String
     # /tmp/d20160111-5693-64b9c1/spec.rb:91:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  10) ObjectStore can show log of changes for multiple commits
     Failure/Error: commit1_hash = Digest::SHA1.hexdigest("#{commit1.date.strftime(time_format)}#{commit1.message}")
     NoMethodError:
       undefined method `date' for "content1":String
     # /tmp/d20160111-5693-64b9c1/spec.rb:105:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  11) ObjectStore shows the log for the current branch only
     Failure/Error: commit1_hash = Digest::SHA1.hexdigest("#{commit1.date.strftime(time_format)}#{commit1.message}")
     NoMethodError:
       undefined method `date' for "content1":String
     # /tmp/d20160111-5693-64b9c1/spec.rb:126:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  12) ObjectStore cannot show log for empty repository
     Failure/Error: expect(repo.log).to be_error("Branch master does not have any commits yet.")
     NoMethodError:
       undefined method `log' for #<ObjectStore:0x007f3cf61d0cd8>
     # /tmp/d20160111-5693-64b9c1/spec.rb:133:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  13) ObjectStore can list branches
     Failure/Error: expect(repo.branch.list).to be_success("  develop\n  feature\n* master")
     NoMethodError:
       undefined method `list' for #<ObjectStore:0x007f3cf61c6aa8>
     # /tmp/d20160111-5693-64b9c1/spec.rb:140:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  14) ObjectStore cannot create branch if already exists
     Failure/Error: expect(repo.branch.create("master")).to be_error("Branch master already exists.")
       expected #<ObjectStore:0x007f3cf61bd548 @staging={}, @commited={}, @count=0, @branch_hash={"master"=>#<ObjectStore:0x007f3cf61bd548 ...>}, @commit_hash={}, @information_message="Created branch master.", @success=true> to be error "Branch master already exists."
     # /tmp/d20160111-5693-64b9c1/spec.rb:150:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  15) ObjectStore can switch branches
     Failure/Error: expect(repo.branch.checkout("develop")).to be_success("Switched to branch develop.")
       expected #<ObjectStore:0x007f3cf61afdf8 @staging={}, @commited={"object1"=>"content1"}, @count=1, @branch_hash={"develop"=>#<ObjectStore:0x007f3cf61afdf8 ...>}, @commit_hash={"1d948d5579c61d4d80112a583877a2e08bf8d6da"=>{"object1"=>"content1"}}, @information_message="Commit develop does not exist.", @result="content1", @success=false, @commit_message="First commit"> to be success "Switched to branch develop."
     # /tmp/d20160111-5693-64b9c1/spec.rb:158:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  16) ObjectStore cannot switch to nonexisting branch
     Failure/Error: expect(repo.branch.checkout("develop")).to be_error("Branch develop does not exist.")
       expected #<ObjectStore:0x007f3cf61a8620 @staging={}, @commited={}, @count=0, @branch_hash={}, @commit_hash={}, @information_message="Commit develop does not exist.", @success=false> to be error "Branch develop does not exist."
     # /tmp/d20160111-5693-64b9c1/spec.rb:168:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  17) ObjectStore can remove branch
     Failure/Error: expect(repo.branch.remove("develop")).to be_success("Removed branch develop.")
       expected #<ObjectStore:0x007f3cf6192370 @staging={}, @commited={}, @count=0, @branch_hash={"develop"=>#<ObjectStore:0x007f3cf6192370 ...>}, @commit_hash={}, @information_message="Object develop is not committed.", @success=true> to be success "Removed branch develop."
     # /tmp/d20160111-5693-64b9c1/spec.rb:174:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  18) ObjectStore cannot remove current branch
     Failure/Error: expect(repo.branch.remove("master")).to be_error("Cannot remove current branch.")
       expected #<ObjectStore:0x007f3cf61722a0 @staging={}, @commited={}, @count=0, @branch_hash={}, @commit_hash={}, @information_message="Object master is not committed.", @success=true> to be error "Cannot remove current branch."
     # /tmp/d20160111-5693-64b9c1/spec.rb:179:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  19) ObjectStore cannot remove nonexisting branch
     Failure/Error: expect(repo.branch.remove("develop")).to be_error("Branch develop does not exist.")
       expected #<ObjectStore:0x007f3cf6168318 @staging={}, @commited={}, @count=0, @branch_hash={}, @commit_hash={}, @information_message="Object develop is not committed.", @success=true> to be error "Branch develop does not exist."
     # /tmp/d20160111-5693-64b9c1/spec.rb:184:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  20) ObjectStore can be initialized with block
     Failure/Error: expect(repo.head).to be_success("Second commit", $second_commit)
     NoMethodError:
       undefined method `head' for #<ObjectStore:0x007f3cf6163a98>
     # /tmp/d20160111-5693-64b9c1/spec.rb:195:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  21) ObjectStore can return objects
     Failure/Error: expect(repo.get("number")).to be_success("Found object number.", 21)
     NoMethodError:
       undefined method `get' for #<ObjectStore:0x007f3cf6161310>
     # /tmp/d20160111-5693-64b9c1/spec.rb:202:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  22) ObjectStore cannot return not committed objects
     Failure/Error: expect(repo.get("string")).to be_error("Object string is not committed.")
     NoMethodError:
       undefined method `get' for #<ObjectStore:0x007f3cf615ee80>
     # /tmp/d20160111-5693-64b9c1/spec.rb:209:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  23) ObjectStore cannot return objects when no commits
     Failure/Error: expect(repo.get("string")).to be_error("Object string is not committed.")
     NoMethodError:
       undefined method `get' for #<ObjectStore:0x007f3cf615c7e8>
     # /tmp/d20160111-5693-64b9c1/spec.rb:214:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  24) ObjectStore can checkout commits
     Failure/Error: expect(repo.checkout(first_commit.hash)).to be_success("HEAD is now at #{first_commit.hash}.", first_commit)
       expected #<ObjectStore:0x007f3cf6152e50 @staging={}, @commited={"number"=>21}, @count=2, @branch_hash={}, @commit_hash={"1d948d5579c61d4d80112a583877a2e08bf8d6da"=>{"number"=>42}, "461d2638f26a54dfb37f51bc222a7e6a6412c1fa"=>{"number"=>21}}, @information_message="Commit 3546227740769576420 does not exist.", @result=21, @success=false, @commit_message="Second commit"> to be success "HEAD is now at 3546227740769576420." and 42
     # /tmp/d20160111-5693-64b9c1/spec.rb:223:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  25) ObjectStore can show the objects in a repo after overwriting an object
     Failure/Error: expect(first_commit.objects).to match_array(["content1"])
     NoMethodError:
       undefined method `objects' for "content1":String
     # /tmp/d20160111-5693-64b9c1/spec.rb:243:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  26) ObjectStore can show the objects of a repo after removing an object
     Failure/Error: expect(first_commit.objects).to match_array(["content1", "content2", "content3"])
     NoMethodError:
       undefined method `objects' for "content3":String
     # /tmp/d20160111-5693-64b9c1/spec.rb:259:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.01976 seconds
30 examples, 26 failures

Failed examples:

rspec /tmp/d20160111-5693-64b9c1/spec.rb:21 # ObjectStore can add objects
rspec /tmp/d20160111-5693-64b9c1/spec.rb:26 # ObjectStore can commit objects
rspec /tmp/d20160111-5693-64b9c1/spec.rb:38 # ObjectStore can remove objects
rspec /tmp/d20160111-5693-64b9c1/spec.rb:46 # ObjectStore can commit changes which include only removed objects
rspec /tmp/d20160111-5693-64b9c1/spec.rb:56 # ObjectStore cannot remove objects that are not committed
rspec /tmp/d20160111-5693-64b9c1/spec.rb:63 # ObjectStore can show head
rspec /tmp/d20160111-5693-64b9c1/spec.rb:72 # ObjectStore cannot show head for empty repository
rspec /tmp/d20160111-5693-64b9c1/spec.rb:77 # ObjectStore can show log of changes for a single commit
rspec /tmp/d20160111-5693-64b9c1/spec.rb:86 # ObjectStore can show log of changes for a single commit
rspec /tmp/d20160111-5693-64b9c1/spec.rb:95 # ObjectStore can show log of changes for multiple commits
rspec /tmp/d20160111-5693-64b9c1/spec.rb:111 # ObjectStore shows the log for the current branch only
rspec /tmp/d20160111-5693-64b9c1/spec.rb:131 # ObjectStore cannot show log for empty repository
rspec /tmp/d20160111-5693-64b9c1/spec.rb:136 # ObjectStore can list branches
rspec /tmp/d20160111-5693-64b9c1/spec.rb:148 # ObjectStore cannot create branch if already exists
rspec /tmp/d20160111-5693-64b9c1/spec.rb:153 # ObjectStore can switch branches
rspec /tmp/d20160111-5693-64b9c1/spec.rb:166 # ObjectStore cannot switch to nonexisting branch
rspec /tmp/d20160111-5693-64b9c1/spec.rb:171 # ObjectStore can remove branch
rspec /tmp/d20160111-5693-64b9c1/spec.rb:177 # ObjectStore cannot remove current branch
rspec /tmp/d20160111-5693-64b9c1/spec.rb:182 # ObjectStore cannot remove nonexisting branch
rspec /tmp/d20160111-5693-64b9c1/spec.rb:187 # ObjectStore can be initialized with block
rspec /tmp/d20160111-5693-64b9c1/spec.rb:198 # ObjectStore can return objects
rspec /tmp/d20160111-5693-64b9c1/spec.rb:205 # ObjectStore cannot return not committed objects
rspec /tmp/d20160111-5693-64b9c1/spec.rb:212 # ObjectStore cannot return objects when no commits
rspec /tmp/d20160111-5693-64b9c1/spec.rb:217 # ObjectStore can checkout commits
rspec /tmp/d20160111-5693-64b9c1/spec.rb:239 # ObjectStore can show the objects in a repo after overwriting an object
rspec /tmp/d20160111-5693-64b9c1/spec.rb:253 # ObjectStore can show the objects of a repo after removing an object

История (1 версия и 0 коментара)

Кристиян обнови решението на 23.11.2015 15:06 (преди над 8 години)

+class Hash
+ def reject_after(reject_key)
+ new_hash = {}
+ each_pair do |key, value|
+ new_hash[key] = value
+ break if key == reject_key
+ end
+ new_hash
+ end
+end
+
+class ObjectStore
+ require 'digest/sha1'
+ def initialize
+ @staging = {}
+ @commited = {}
+ @success
+ @information_message
+ @count = 0
+ @branch_hash = {}
+ @result
+ @commit_hash = {}
+ end
+
+ def commit_hash
+ @commit_hash
+ end
+
+ def self.init(&block)
+ obj = ObjectStore.new
+ if block_given?
+ obj.instance_eval &block
+ end
+ obj
+ end
+
+ def success?
+ @success
+ end
+
+ def error?
+ not success?
+ end
+
+ def commit(note_message)
+ if @staging.empty?
+ @success = false
+ @information_message = "Nothing to commit, working directory clean."
+ else
+ @success = true
+ @information_message = "#{note_message}\n\t#{@count} objects changed"
+ @commit_message = note_message
+ @commited.merge!(@staging)
+ @commit_hash[Digest::SHA1.hexdigest note_message] = @staging
+ @staging, count = {}, 0
+ end
+ self
+ end
+
+ def message
+ @information_message
+ end
+
+ def files
+ @commited
+ end
+
+ def result
+ @result
+ end
+
+ def add(name, value)
+ @staging[name] = value
+ @count += 1
+ @information_message = "Added #{name} to stage."
+ @result = value
+ self
+ end
+
+ def remove(name)
+ if @staging.member?(name)
+ @staging.delete(name)
+ @count -= 1
+ @success = false
+ @information_message = "Added #{name} for removal."
+ @result = name
+ else
+ @success = true
+ @information_message = "Object #{name} is not committed."
+ end
+ self
+ end
+
+ def checkout(name)
+ if commit_hash.member?(name)
+ @committed = commit_hash[name]
+ @result = commit_hash[name]
+ @commit_hash = commit_hash.reject_after(name)
+ @success = true
+ @information_message = "HEAD is now at #{name}."
+ else
+ @information_message, @success = "Commit #{name} does not exist.", false
+ end
+ self
+ end
+
+ def branch_hash
+ @branch_hash
+ end
+
+ def branch
+ current_branch = self
+ end
+
+ def create(branch_name)
+ if branch_hash.has_key?(branch_name)
+ @information_message = "Branch #{branch_name} already exists."
+ @success = false
+ else
+ @branch_hash[branch_name] = branch
+ @information_message = "Created branch #{branch_name}."
+ @success = true
+ end
+ self
+ end
+end