Class: Fixman::Controller
- Inherits:
-
Object
- Object
- Fixman::Controller
- Defined in:
- lib/fixman/controller.rb
Instance Attribute Summary collapse
-
#repos ⇒ Object
readonly
Returns the value of attribute repos.
Class Method Summary collapse
-
.open(conf) ⇒ Object
Controller for the command line interface.
Instance Method Summary collapse
-
#add(input, fixtures_base, extra_repo_info) ⇒ Object
Add a new repository to the collection.
-
#delete(canonical_name) ⇒ Object
Remove repository from the fixtures list.
-
#fetch(groups) ⇒ Object
Download repositories belonging to the at least one of the given groups.
-
#initialize(repos = []) ⇒ Controller
constructor
A new instance of Controller.
- #update(canonical_name, sha = nil) ⇒ Object
- #upgrade(groups) ⇒ Object
Constructor Details
#initialize(repos = []) ⇒ Controller
Returns a new instance of Controller.
9 10 11 |
# File 'lib/fixman/controller.rb', line 9 def initialize(repos = []) @repos = repos end |
Instance Attribute Details
#repos ⇒ Object (readonly)
Returns the value of attribute repos.
7 8 9 |
# File 'lib/fixman/controller.rb', line 7 def repos @repos end |
Class Method Details
.open(conf) ⇒ Object
Controller for the command line interface.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/fixman/controller.rb', line 67 def open(conf) original_ledger = "" controller = begin original_ledger = YAML.load(IO.read conf.fixture_ledger) original_ledger.map! { |entry| YAML.load entry } repos = [] original_ledger.each do |repo_params| repos << Repository.new(repo_params, conf.fixtures_base, conf.extra_repo_info) end Controller.new repos rescue Errno::ENOENT Controller.new end result = yield controller write_ledger controller.repos, original_ledger, conf.fixture_ledger result rescue Git::GitExecuteError => error puts error. exit 1 end |
Instance Method Details
#add(input, fixtures_base, extra_repo_info) ⇒ Object
Add a new repository to the collection.
14 15 16 17 18 |
# File 'lib/fixman/controller.rb', line 14 def add(input, fixtures_base, extra_repo_info) repo = Repository.new input, fixtures_base, extra_repo_info @repos << repo end |
#delete(canonical_name) ⇒ Object
Remove repository from the fixtures list.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fixman/controller.rb', line 21 def delete(canonical_name) repo = find canonical_name if repo @repos.delete repo repo.destroy else fail ArgumentError end end |
#fetch(groups) ⇒ Object
Download repositories belonging to the at least one of the given groups.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fixman/controller.rb', line 33 def fetch(groups) repos = find_by_groups(groups).reject { |repo| repo.fetched? } repos.each do |repo| begin repo.fetch rescue Git::GitExecuteError => error STDERR.puts "Warning: Repository #{repo.canonical_name} could not be fetched." STDERR.puts error. end end end |
#update(canonical_name, sha = nil) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/fixman/controller.rb', line 45 def update(canonical_name, sha = nil) repo = find canonical_name fail ArgumentError unless repo repo.sha = sha || repo.retrieve_head_sha end |
#upgrade(groups) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/fixman/controller.rb', line 52 def upgrade(groups) repos = find_by_groups(groups) repos.each do |repo| begin repo.upgrade rescue Git::GitExecuteError => error STDERR.puts "Warning: Repisotiry #{repo.canonical_name} could not be \" upgraded." STDERR.puts error. end end end |