Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scan and show status in progress bar on launch
- Loading branch information
Showing
8 changed files
with
123 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Launchpad | ||
# Synchronizes the state of the patcher with the view | ||
class UpdateManager | ||
attr_reader :controller, :patcher | ||
|
||
def initialize(controller) | ||
@controller = controller | ||
@patcher = Patcher.new | ||
end | ||
|
||
def scan | ||
patcher.in_sync? ? ready_to_launch : ready_to_update | ||
end | ||
|
||
private | ||
|
||
def ready_to_launch | ||
controller.status.set_text 'Ready' | ||
end | ||
|
||
def ready_to_update | ||
controller.status.set_text 'Update required...' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module Launchpad | ||
# Updates installation directory with the required files | ||
class Patcher | ||
attr_reader :index | ||
|
||
def initialize | ||
@index = Index.new | ||
end | ||
|
||
def in_sync? | ||
index.diff.empty? | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require 'spec_helper' | ||
|
||
describe Launchpad::UpdateManager do | ||
subject { described_class.new controller } | ||
|
||
let(:controller) { double :controller, status: double(set_text: nil) } | ||
|
||
before { allow(Launchpad::Patcher).to receive(:new).and_return patcher } | ||
|
||
describe '#scan' do | ||
before { subject.scan } | ||
|
||
context 'when fils are in sync' do | ||
let(:patcher) { double :patcher, in_sync?: true } | ||
|
||
it 'displays a message that files are synced' do | ||
expect(controller.status).to have_received(:set_text).with 'Ready' | ||
end | ||
end | ||
|
||
context 'when fils are out of sync' do | ||
let(:patcher) { double :patcher, in_sync?: false } | ||
|
||
it 'displays a message that there are files that need syncing' do | ||
expect(controller.status) | ||
.to have_received(:set_text).with 'Update required...' | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'spec_helper' | ||
|
||
describe Launchpad::Patcher do | ||
let(:index) { double :index } | ||
|
||
before { allow(Launchpad::Index).to receive(:new).and_return index } | ||
|
||
describe '#in_sync?' do | ||
context 'when the index reports a diff' do | ||
let(:index) { double diff: [:x, :y, :z] } | ||
|
||
it { is_expected.to_not be_in_sync } | ||
end | ||
|
||
context 'when the index diff is empty' do | ||
let(:index) { double diff: [] } | ||
|
||
it { is_expected.to be_in_sync } | ||
end | ||
end | ||
end |