Class: MockVersion::WorkingCopy

Inherits:
Object
  • Object
show all
Defined in:
lib/mockversion/working_copy.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo_path, path) ⇒ WorkingCopy

Returns a new instance of WorkingCopy.



14
15
16
17
# File 'lib/mockversion/working_copy.rb', line 14

def initialize(repo_path, path)
  @repo_path = repo_path
  @path = path
end

Class Method Details

.create(repo_path, path) ⇒ Object



6
7
8
# File 'lib/mockversion/working_copy.rb', line 6

def self.create(repo_path, path)
  new(repo_path, path).save
end

.loadObject



10
11
12
# File 'lib/mockversion/working_copy.rb', line 10

def self.load
  YAML.load_file(".svn/working_copy.yml")
end

Instance Method Details

#add(path) ⇒ Object



19
20
21
22
# File 'lib/mockversion/working_copy.rb', line 19

def add(path)
  staged_files << path
  save
end

#commit(message) ⇒ Object



24
25
26
27
28
# File 'lib/mockversion/working_copy.rb', line 24

def commit(message)
  puts "committing to: #{@repo_path}"
  repo = Repository.load_from_path(@repo_path)
  repo.create_new_revision
end

#saveObject



34
35
36
37
# File 'lib/mockversion/working_copy.rb', line 34

def save
  FileUtils.makedirs("#{@path}/.svn")
  File.open("#{@path}/.svn/working_copy.yml", "w") { |file| file.puts to_yaml }
end

#staged_filesObject



30
31
32
# File 'lib/mockversion/working_copy.rb', line 30

def staged_files
  @staged_files ||= []
end