diff --git a/app/configuration/service.js b/app/configuration/service.js index 09c7fdd..7cc91b6 100644 --- a/app/configuration/service.js +++ b/app/configuration/service.js @@ -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() }; }, diff --git a/app/debug/controller.js b/app/debug/controller.js new file mode 100644 index 0000000..453e851 --- /dev/null +++ b/app/debug/controller.js @@ -0,0 +1,5 @@ +import Ember from 'ember'; + +export default Ember.Controller.extend({ + debug: Ember.inject.service() +}); diff --git a/app/debug/route.js b/app/debug/route.js index a227ad8..68f574e 100644 --- a/app/debug/route.js +++ b/app/debug/route.js @@ -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, }; }); diff --git a/app/debug/service.js b/app/debug/service.js index cb44ba6..2f74737 100644 --- a/app/debug/service.js +++ b/app/debug/service.js @@ -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'; diff --git a/app/debug/template.hbs b/app/debug/template.hbs index 1e8e6e0..41b5330 100644 --- a/app/debug/template.hbs +++ b/app/debug/template.hbs @@ -2,12 +2,12 @@
-
Platform: {{model.platform}} - {{model.arch}}
-
Version: {{model.currentTag}}
+
Platform: {{debug.platform}} - {{model.arch}}
+
Version: {{debug.currentTag}}
Latest version: {{model.latestTag}}
-
Home dir: {{model.homeDir}}
-
Exercises dir: {{model.homeExercisesDir}}
-
Config file: {{model.configFilePath}}
+
Home dir: {{debug.homeDir}}
+
Exercises dir: {{debug.homeExercisesDir}}
+
Config file: {{debug.configFilePath}}
diff --git a/tests/unit/configuration/service-test.js b/tests/unit/configuration/service-test.js index 94de9fe..45aaebd 100644 --- a/tests/unit/configuration/service-test.js +++ b/tests/unit/configuration/service-test.js @@ -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); });