Class: Bob::Test::AbstractSCMRepo
- Inherits:
-
Object
- Object
- Bob::Test::AbstractSCMRepo
- Defined in:
- lib/bob/test/scm/abstract.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #add_commit(message, &action) ⇒ Object
- #add_failing_commit ⇒ Object
- #add_successful_commit ⇒ Object
- #commits ⇒ Object
- #destroy ⇒ Object
- #head ⇒ Object
-
#initialize(name, base_dir = Bob.directory) ⇒ AbstractSCMRepo
constructor
A new instance of AbstractSCMRepo.
Constructor Details
#initialize(name, base_dir = Bob.directory) ⇒ AbstractSCMRepo
Returns a new instance of AbstractSCMRepo.
5 6 7 8 |
# File 'lib/bob/test/scm/abstract.rb', line 5 def initialize(name, base_dir=Bob.directory) @name = name @path = File.join(base_dir, @name.to_s) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/bob/test/scm/abstract.rb', line 3 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/bob/test/scm/abstract.rb', line 3 def path @path end |
Instance Method Details
#add_commit(message, &action) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/bob/test/scm/abstract.rb', line 14 def add_commit(, &action) Dir.chdir(path) do yield action commit() end end |
#add_failing_commit ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/bob/test/scm/abstract.rb', line 21 def add_failing_commit add_commit "This commit will fail" do system "echo '#{build_script(false)}' > test" system "chmod +x test" add "test" end end |
#add_successful_commit ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/bob/test/scm/abstract.rb', line 29 def add_successful_commit add_commit "This commit will work" do system "echo '#{build_script(true)}' > test" system "chmod +x test" add "test" end end |
#commits ⇒ Object
37 38 39 |
# File 'lib/bob/test/scm/abstract.rb', line 37 def commits raise NotImplementedError end |
#destroy ⇒ Object
10 11 12 |
# File 'lib/bob/test/scm/abstract.rb', line 10 def destroy FileUtils.rm_r path if File.directory?(path) end |
#head ⇒ Object
41 42 43 |
# File 'lib/bob/test/scm/abstract.rb', line 41 def head commits.last[:identifier] end |