Skip to content
This repository has been archived by the owner on Oct 5, 2018. It is now read-only.

Commit

Permalink
gh-57 sync debug info with configuration details
Browse files Browse the repository at this point in the history
  - We now take the value from the config
  - The debug template now takes the value directly
    from the service instead of the model as it will
    reflects changes to the config made elsewhere in the app
  • Loading branch information
holandes22 committed Jul 2, 2017
1 parent 080daa5 commit 90d198d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 15 deletions.
6 changes: 5 additions & 1 deletion app/configuration/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ export default Ember.Service.extend({
return path.join(osHomedir(), 'exercism');
},

getDefaultHomeExercisesDir() {
return path.join(osHomedir(), 'exercism')
},

getDefaults() {
return {
api: 'http://exercism.io',
xapi: 'http://x.exercism.io',
apiKey: null,
dir: this.getHomeExercisesDir(),
dir: this.getDefaultHomeExercisesDir()
};
},

Expand Down
5 changes: 5 additions & 0 deletions app/debug/controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Ember from 'ember';

export default Ember.Controller.extend({
debug: Ember.inject.service()
});
6 changes: 0 additions & 6 deletions app/debug/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@ export default Ember.Route.extend({
return debug.getLatestRelease().then((release) => {
let latestTag = (release && release.tagName)? release.tagName : 'N/A';
return {
arch: debug.arch,
platform: debug.platform,
currentTag: debug.currentTag,
latestTag: latestTag,
homeDir: debug.homeDir,
homeExercisesDir: debug.homeExercisesDir,
configFilePath: debug.configFilePath,
servicesStatus,
};
});
Expand Down
5 changes: 4 additions & 1 deletion app/debug/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ export default Ember.Service.extend({
this.set('arch', os.arch());
this.set('platform', os.platform());
this.set('homeDir', osHomedir());
this.set('homeExercisesDir', this.get('configuration').getHomeExercisesDir());
this.set('configFilePath', this.get('configuration').getHomeConfigFilePath());
},

homeExercisesDir: Ember.computed('configuration.dir', function() {
return this.get('configuration.dir');
}),

getLatestRelease() {
let url = 'https://api.github.com/repos/exercism/gui/releases/latest';

Expand Down
10 changes: 5 additions & 5 deletions app/debug/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

<div class="ui segment">
<div class="ui bulleted relaxed list">
<div class="item">Platform: <strong>{{model.platform}} - {{model.arch}}</strong></div>
<div class="item">Version: <strong>{{model.currentTag}}</strong></div>
<div class="item">Platform: <strong>{{debug.platform}} - {{model.arch}}</strong></div>
<div class="item">Version: <strong>{{debug.currentTag}}</strong></div>
<div class="item">Latest version: <strong>{{model.latestTag}}</strong></div>
<div class="item">Home dir: <strong>{{model.homeDir}}</strong></div>
<div class="item">Exercises dir: <strong>{{model.homeExercisesDir}}</strong></div>
<div class="item">Config file: <strong>{{model.configFilePath}}</strong></div>
<div class="item">Home dir: <strong>{{debug.homeDir}}</strong></div>
<div class="item">Exercises dir: <strong>{{debug.homeExercisesDir}}</strong></div>
<div class="item">Config file: <strong>{{debug.configFilePath}}</strong></div>
</div>
</div>

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/configuration/service-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ test('it returns defaults if config file does not exists', function(assert) {
apiKey: null,
dir: '/home/fake/exercises',
};
service.getHomeExercisesDir = td.function();
td.when(service.getHomeExercisesDir()).thenReturn(expected.dir);
service.getDefaultHomeExercisesDir = td.function();
td.when(service.getDefaultHomeExercisesDir()).thenReturn(expected.dir);
assert.deepEqual(service.readConfigFile(), expected);
});

Expand Down

0 comments on commit 90d198d

Please sign in to comment.