robeaux 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 372cf8d1ac133936d4ecb9ccaab33108218c6938
4
- data.tar.gz: ce7fe45bcdb904a62d3f88ffeace434b387640a0
3
+ metadata.gz: fb64bdd58fcc2541db81dc55c3a21750db37af3f
4
+ data.tar.gz: e873c183975f9dd68f66a1dc975eec90894da0f0
5
5
  SHA512:
6
- metadata.gz: e9581241e3fc08b54d496c075ce3bcbc565df3d64d9a1c2f41b3a1f1c3c127473c20fca73fac34edb6083348b01b6d3f6ae94ee9ad7b966161317d5c9d5fddf2
7
- data.tar.gz: 115f733c314dd79045ab4a6663b6b235e40eb4f379d3b834f7cae6524926c7e09e7a07353aac9671ef4178a27226d30ef52b0eeead7caa02a7650d2b3a89e2c1
6
+ metadata.gz: 863dc02ee4c0e0905b537d4f0fe676ca5c0d85556437478688565e99b32b3037a0230cfe69d7d407d9fa5158c31540a0ab8284ec9f1c457b33ac753461bafe0b
7
+ data.tar.gz: 77ae747880626efcbfdeb149ce4c1a18d4f7134a446033d6a3d66640d37ceeb5a042e3b00c24b556c5315baa90e014d91ac00781aca11aa51c1458ac71ae3ab8
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ /node_modules/
data/Makefile CHANGED
@@ -1,10 +1,9 @@
1
1
  VERSION := $(shell node -e "console.log(require('./package.json').version)")
2
2
 
3
- .PHONY: default release
3
+ .PHONY: test release
4
4
 
5
- # to prevent a release attempt every time someone runs 'make'
6
- default:
7
- @echo "Default Make Task"
5
+ test:
6
+ @./node_modules/karma/bin/karma start ./test/karma.conf.js --no-auto-watch --single-run
8
7
 
9
8
  release:
10
9
  @git tag -m "$(VERSION)" v$(VERSION)
data/README.markdown CHANGED
@@ -60,6 +60,8 @@ Then, just run `make release`. It'll take care of:
60
60
 
61
61
  ## Releases
62
62
 
63
+ - 0.2.0 - Update for CPP-IO API spec
64
+
63
65
  - 0.1.1 - Remove dependency on Google WebFonts
64
66
 
65
67
  - 0.1.0 - Full rewrite. Supports Server-Sent-Events.
@@ -22,7 +22,7 @@ var DeviceCommandsCtrl = function DeviceCommandsCtrl($scope, $http) {
22
22
  command = $scope.command,
23
23
  params = parseParams($scope.device.params);
24
24
 
25
- var url ='/robots/' + robot + "/devices/" + device + "/commands/" + command;
25
+ var url ='/api/robots/' + robot + "/devices/" + device + "/commands/" + command;
26
26
 
27
27
  $http.post(url, params).success(function(data) {
28
28
  if (data.result) {
@@ -9,7 +9,7 @@ var DeviceEventsCtrl = function DeviceEventsCtrl($scope, $filter) {
9
9
  device = $scope.device.name,
10
10
  event = $scope.eventName;
11
11
 
12
- var uri = "/robots/" + robot + "/devices/" + device + "/events/" + event;
12
+ var uri = "/api/robots/" + robot + "/devices/" + device + "/events/" + event;
13
13
  var $device = $scope.device;
14
14
  var source = new EventSource(uri);
15
15
 
@@ -1,6 +1,6 @@
1
1
  var IndexCtrl = function IndexCtrl($scope, $http, $location) {
2
- $http.get("/robots").success(function(data) {
3
- $scope.robots = data;
2
+ $http.get("/api/robots").success(function(data) {
3
+ $scope.robots = data.robots;
4
4
  });
5
5
 
6
6
  $scope.details = function (robot) {
@@ -7,7 +7,6 @@ var RobotCommandsCtrl = function RobotCommandsCtrl($scope, $http) {
7
7
  };
8
8
 
9
9
  $scope.addParam = function(last) {
10
- console.log("HEY");
11
10
  if (!last) { return; }
12
11
  $scope.robot.params.push({ name: '', value: '', type: 'string' });
13
12
  };
@@ -22,7 +21,7 @@ var RobotCommandsCtrl = function RobotCommandsCtrl($scope, $http) {
22
21
  command = $scope.command,
23
22
  params = parseParams($scope.robot.params);
24
23
 
25
- var url ='/robots/' + robot + "/commands/" + command;
24
+ var url ='/api/robots/' + robot + "/commands/" + command;
26
25
 
27
26
  $http.post(url, params).success(function(data) {
28
27
  if (data.result) {
@@ -1,6 +1,6 @@
1
1
  var RobotCtrl = function RobotCtrl($scope, $http, $routeParams) {
2
- $http.get("/robots/" + $routeParams.robot).success(function(data) {
3
- $scope.robot = data;
2
+ $http.get("/api/robots/" + $routeParams.robot).success(function(data) {
3
+ $scope.robot = data.robot;
4
4
 
5
5
  $scope.robot.params = [ { name: '', value: '', type: 'string' } ];
6
6
  $scope.robot.results = [];
data/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "robeaux",
3
- "version": "0.1.1",
4
- "description": "An AngularJS interface for the Cylon.js API",
3
+ "version": "0.2.0",
4
+ "description": "An AngularJS interface for the CPPP-IO API spec",
5
5
  "homepage": "http://cylonjs.com",
6
- "bugs": "https://github.com/hybridgroup/cylon/issues",
7
-
6
+ "bugs": "https://github.com/hybridgroup/robeaux/issues",
8
7
  "author": "The Hybrid Group <cylonjs@hybridgroup.com>",
9
-
10
8
  "repository": {
11
9
  "type": "git",
12
10
  "url": "https://github.com/hybridgroup/robeaux"
13
11
  },
14
-
15
- "license": "Apache 2.0"
12
+ "license": "Apache 2.0",
13
+ "devDependencies": {
14
+ "karma": "~0.12.16",
15
+ "karma-phantomjs-launcher": "~0.1",
16
+ "karma-jasmine": "~0.1.5"
17
+ }
16
18
  }
data/partials/robot.html CHANGED
@@ -55,7 +55,7 @@
55
55
  <span class="name">{{device.name}}</span>
56
56
 
57
57
  <div class="details">
58
- <span>{{device.connection.name}}</span>
58
+ <span>{{device.connection}}</span>
59
59
  </div>
60
60
  </div>
61
61
  </div>
data/robeaux.gemspec CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "robeaux"
5
- s.version = "0.1.1"
5
+ s.version = "0.2.0"
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ["Ron Evans", "Adrian Zankich", "Ari Lerner", "Mario Ricalde", "Daniel Fischer", "Andrew Stewart"]
8
8
  s.email = ["artoo@hybridgroup.com"]
9
9
  s.homepage = "https://github.com/hybridgroup/robeaux"
10
- s.summary = %q{Angular-based front end for universal robot API}
11
- s.description = %q{Angular-based front end for universal robot API}
10
+ s.summary = %q{Angular-based front end for the CPPP-IO API spec}
11
+ s.description = %q{Angular-based front end for the CPPP-IO API spec}
12
12
  s.license = 'Apache 2.0'
13
13
 
14
14
  s.rubyforge_project = "robeaux"
@@ -0,0 +1,80 @@
1
+ // Karma configuration
2
+ // Generated on Tue Jul 01 2014 13:33:46 GMT-0700 (PDT)
3
+
4
+ module.exports = function(config) {
5
+ config.set({
6
+
7
+ // base path that will be used to resolve all patterns (eg. files, exclude)
8
+ basePath: '../',
9
+
10
+ // frameworks to use
11
+ // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
12
+ frameworks: ['jasmine'],
13
+
14
+ // list of files / patterns to load in the browser
15
+ files: [
16
+ 'js/vendor/angular.min.js',
17
+ 'js/vendor/angular-route.min.js',
18
+ 'test/vendor/angular-mocks.js',
19
+ 'test/vendor/jquery.js',
20
+ 'test/vendor/jasmine-jquery.js',
21
+ 'js/app.js',
22
+ 'js/router.js',
23
+ 'js/*.js',
24
+ 'js/**/*.js',
25
+ 'test/main.js',
26
+
27
+ {pattern: 'test/support/robots.json', watched: true, served: true, included: false},
28
+ {pattern: 'test/support/myRobot.json', watched: true, served: true, included: false},
29
+ {pattern: 'test/support/myDevice.json', watched: true, served: true, included: false}
30
+ ],
31
+
32
+
33
+
34
+ // list of files to exclude
35
+ exclude: [
36
+
37
+ ],
38
+
39
+
40
+ // preprocess matching files before serving them to the browser
41
+ // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
42
+ preprocessors: {
43
+
44
+ },
45
+
46
+
47
+ // test results reporter to use
48
+ // possible values: 'dots', 'progress'
49
+ // available reporters: https://npmjs.org/browse/keyword/karma-reporter
50
+ reporters: ['progress'],
51
+
52
+
53
+ // web server port
54
+ port: 9000,
55
+
56
+
57
+ // enable / disable colors in the output (reporters and logs)
58
+ colors: true,
59
+
60
+
61
+ // level of logging
62
+ // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
63
+ logLevel: config.LOG_INFO,
64
+
65
+
66
+ // enable / disable watching file and executing tests whenever any file changes
67
+ autoWatch: true,
68
+
69
+
70
+ // start these browsers
71
+ // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
72
+ browsers: ['PhantomJS'],
73
+
74
+
75
+ // Continuous Integration mode
76
+ // if true, Karma captures browsers, runs the tests and exits
77
+ singleRun: true
78
+
79
+ });
80
+ };
data/test/main.js ADDED
@@ -0,0 +1,248 @@
1
+ describe('IndexCtrl', function() {
2
+ var $scope, $rootScope, $httpBackend, $timeout, testController;
3
+ beforeEach(inject(function($injector) {
4
+ $timeout = $injector.get('$timeout');
5
+ $httpBackend = $injector.get('$httpBackend');
6
+ $rootScope = $injector.get('$rootScope');
7
+ $scope = $rootScope.$new();
8
+
9
+ var $controller = $injector.get('$controller');
10
+
11
+ testController = function() {
12
+ return $controller('IndexCtrl', {
13
+ '$scope': $scope
14
+ });
15
+ };
16
+ }));
17
+
18
+ afterEach(function() {
19
+ $httpBackend.verifyNoOutstandingExpectation();
20
+ $httpBackend.verifyNoOutstandingRequest();
21
+ });
22
+
23
+ it('IndexCtrl should get array of robots', function() {
24
+ var controller = testController();
25
+ jasmine.getJSONFixtures().fixturesPath='base/test/support';
26
+ var data = loadJSONFixtures('robots.json')['robots.json'];
27
+ $httpBackend.expect('GET', '/api/robots').respond(data);
28
+ $httpBackend.flush();
29
+ expect($scope.robots).toEqual(data.robots);
30
+ });
31
+ });
32
+
33
+ describe('RobotCtrl', function() {
34
+ beforeEach(module('robeaux'));
35
+ var $scope, $rootScope, $httpBackend, $timeout, $routeParams, testController;
36
+ beforeEach(inject(function($injector) {
37
+ $timeout = $injector.get('$timeout');
38
+ $httpBackend = $injector.get('$httpBackend');
39
+ $rootScope = $injector.get('$rootScope');
40
+ $routeParams = $injector.get('$routeParams');
41
+ $scope = $rootScope.$new();
42
+
43
+ var $controller = $injector.get('$controller');
44
+
45
+ testController = function() {
46
+ return $controller('RobotCtrl', {
47
+ '$scope': $scope
48
+
49
+ });
50
+ };
51
+ var controller = testController();
52
+
53
+ jasmine.getJSONFixtures().fixturesPath='base/test/support';
54
+ $httpBackend.expect('GET', '/api/robots/' + $routeParams.robot).respond(loadJSONFixtures('myRobot.json')['myRobot.json']);
55
+ $httpBackend.flush();
56
+
57
+ }));
58
+
59
+ afterEach(function() {
60
+ $httpBackend.verifyNoOutstandingExpectation();
61
+ $httpBackend.verifyNoOutstandingRequest();
62
+ });
63
+
64
+ it('RobotCtrl should get robot data', function() {
65
+ var data = loadJSONFixtures('myRobot.json')['myRobot.json'];
66
+ data.robot.params = [ { name: '', value: '', type: 'string' } ];
67
+ data.robot.results = [];
68
+ expect($scope.robot).toEqual(data.robot);
69
+ });
70
+
71
+ it('RobotCtrl should select device', function (){
72
+ var robotArray= [{"name": "robo1"},{"name":"robo2"}];
73
+ $scope.robot = robotArray;
74
+ $scope.select($scope.robot[1]);
75
+ expect($scope.robot[1]).toEqual($scope.device);
76
+ expect($scope.robot[0]).toNotEqual($scope.device);
77
+ });
78
+
79
+
80
+ it('RobotCtrl should keep device selected', function (){
81
+ var robotArray= [{"name": "robo1"},{"name":"robo2"}];
82
+ $scope.robot = robotArray;
83
+ $scope.select($scope.robot);
84
+ expect($scope.selected($scope.robot)).toBeTruthy();
85
+ });
86
+ });
87
+
88
+
89
+
90
+ describe('parseParams', function(){
91
+
92
+ beforeEach(module('robeaux'));
93
+
94
+
95
+ it('should set param name to value', function(){
96
+ var form = [
97
+ { 'name': 'bool', 'value': 'TRUE', 'type': 'boolean' },
98
+ { 'name': 'boole', 'value': 'sadg', 'type': 'boolean' },
99
+ { 'name': 'str', 'value': 'isOn', 'type': 'string' },
100
+ { 'name': 'num', 'value': 100, 'type': 'number' }
101
+ ];
102
+ var params = parseParams(form);
103
+ expect(params['num']).toEqual(100);
104
+ expect(params['bool']).toEqual(true);
105
+ expect(params['boole']).toEqual(false);
106
+ expect(params['str']).toEqual('isOn');
107
+ });
108
+
109
+ it('should set empty params to true', function(){
110
+ var form = [
111
+ { 'name': '', 'value': '', 'type': 'boolean' },
112
+ { 'name': '21', 'value': '12','type': 'boolean' },
113
+ ];
114
+
115
+ expect(paramsAreEmpty([form[1]])).toEqual(false);
116
+ expect(paramsAreEmpty([form[0]])).toEqual(true);
117
+ });
118
+
119
+ });
120
+
121
+ describe('RobotCommandsCtrl', function() {
122
+ beforeEach(module('robeaux'));
123
+ var $scope, $rootScope, $httpBackend, $timeout, testController;
124
+ var $injector = angular.injector(['robeaux', 'ng']);
125
+ beforeEach(inject(function($injector) {
126
+ $timeout = $injector.get('$timeout');
127
+ $httpBackend = $injector.get('$httpBackend');
128
+ $rootScope = $injector.get('$rootScope');
129
+ $scope = $rootScope.$new();
130
+
131
+ var $controller = $injector.get('$controller');
132
+
133
+ testController = function() {
134
+ return $controller('RobotCommandsCtrl', {
135
+ '$scope': $scope
136
+ });
137
+ };
138
+ var controller = testController();
139
+
140
+ jasmine.getJSONFixtures().fixturesPath='base/test/support';
141
+ var data = loadJSONFixtures('myRobot.json')['myRobot.json'];
142
+ $scope.robot = data.robot;
143
+ }));
144
+
145
+ afterEach(function() {
146
+ $httpBackend.verifyNoOutstandingExpectation();
147
+ $httpBackend.verifyNoOutstandingRequest();
148
+ });
149
+
150
+ it('RobotCommandsCtrl command should be an empty string', function (){
151
+ $scope.command = "";
152
+ expect($scope.isDisabled()).toBe(true);
153
+ });
154
+
155
+ it('RobotCommandsCtrl should add params if last', function (){
156
+ expect($scope.robot.params.length).toBe(1)
157
+ $scope.addParam($scope.robot);
158
+ expect($scope.robot.params.length).toBe(2)
159
+ });
160
+
161
+ it('RobotCommandsCtrl command should be an empty string', function (){
162
+ expect($scope.robot.params.length).toBe(2)
163
+ $scope.removeParam($scope.robot);
164
+ expect($scope.robot.params.length).toBe(1)
165
+ });
166
+
167
+ it('RobotCommandsCtrl should get robot command results', function (){
168
+ $scope.robot.name = "myRobot";
169
+ $scope.command = "relax";
170
+ $scope.robot.params= [{'name': 'relax', 'value':'true', 'type':'string'}];
171
+ var params = {'relax': 'true'};
172
+ var data= {'result': "myRobot says relax"};
173
+
174
+ $scope.submit();
175
+ $httpBackend.expectPOST('/api/robots/myRobot/commands/relax', params).respond(data);
176
+ $httpBackend.flush();
177
+ expect($scope.robot.results).toEqual([{'result': "myRobot says relax"}])
178
+ });
179
+ });
180
+
181
+ describe('DeviceCommandsCtrl', function() {
182
+ beforeEach(module('robeaux'));
183
+ var $scope, $rootScope, $httpBackend, $timeout, testController;
184
+ beforeEach(inject(function($injector) {
185
+ $timeout = $injector.get('$timeout');
186
+ $httpBackend = $injector.get('$httpBackend');
187
+ $rootScope = $injector.get('$rootScope');
188
+ $scope = $rootScope.$new();
189
+
190
+ var $controller = $injector.get('$controller');
191
+
192
+ testController = function() {
193
+ return $controller('DeviceCommandsCtrl', {
194
+ '$scope': $scope
195
+ });
196
+ };
197
+ var controller = testController();
198
+
199
+ jasmine.getJSONFixtures().fixturesPath='base/test/support';
200
+
201
+ var data = loadJSONFixtures('myDevice.json')['myDevice.json'];
202
+
203
+ $scope.device = data[0];
204
+ $scope.device.results = [];
205
+ $scope.device.params = [{ name: '', value: '', type: 'string' }];
206
+ }));
207
+
208
+ afterEach(function() {
209
+ $httpBackend.verifyNoOutstandingExpectation();
210
+ $httpBackend.verifyNoOutstandingRequest();
211
+ });
212
+
213
+ it('DeviceCommandsCtrl command should be an empty string', function (){
214
+ $scope.command = "";
215
+ expect($scope.isDisabled()).toBe(true);
216
+ });
217
+
218
+ it('DeviceCommandsCtrl should add params if last', function (){
219
+ expect($scope.device.params.length).toBe(1)
220
+ $scope.addParam($scope.device);
221
+ expect($scope.device.params.length).toBe(2)
222
+ });
223
+
224
+ it('DeviceCommandsCtrl command should be an empty string', function (){
225
+ $scope.device.params = [
226
+ { name: '', value: '', type: 'string' },
227
+ { name: '', value: '', type: 'string' }
228
+ ];
229
+ $scope.removeParam($scope.device);
230
+ expect($scope.device.params.length).toBe(1)
231
+ });
232
+
233
+ it('DeviceCommandsCtrl command should be an empty string', function (){
234
+ $scope.robot = {'name':"myRobot"};
235
+ $scope.device.name = "led";
236
+ $scope.command = "brightness";
237
+ $scope.device.params = [{'name': 'brightness', 'value': 255, 'type':'string'}];
238
+ var params = {'brightness': 255};
239
+ var data= {'result': "brightness is 255"};
240
+
241
+ $scope.submit();
242
+ $httpBackend.expectPOST('/api/robots/myRobot/devices/led/commands/brightness', params).respond(data);
243
+ $httpBackend.flush();
244
+ expect($scope.device.results[0]).toEqual({'result': "brightness is 255"})
245
+ });
246
+
247
+ });
248
+
@@ -0,0 +1,15 @@
1
+ [
2
+ {
3
+ "commands": [ "isOn", "turnOn", "turnOff", "toggle", "brightness" ],
4
+ "connection": "arduino",
5
+ "driver": "Led",
6
+ "name": "led",
7
+ "pin": 3
8
+ }, {
9
+ "commands": [ "isPressed" ],
10
+ "connection": "arduino",
11
+ "driver": "Button",
12
+ "name": "button",
13
+ "pin": 2
14
+ }
15
+ ]
@@ -0,0 +1,31 @@
1
+ {
2
+ "robot": {
3
+ "name": "myRobot",
4
+
5
+ "connections": [
6
+ {
7
+ "adaptor": "Adaptor",
8
+ "name": "arduino",
9
+ "port": "/dev/ttyACM0"
10
+ }
11
+ ],
12
+
13
+ "devices": [
14
+ {
15
+ "commands": [ "isOn", "turnOn", "turnOff", "toggle", "brightness" ],
16
+ "connection": "arduino",
17
+ "driver": "Led",
18
+ "name": "led",
19
+ "pin": 13
20
+ }, {
21
+ "commands": [ "isPressed" ],
22
+ "connection": "arduino",
23
+ "driver": "Button",
24
+ "name": "button",
25
+ "pin": 2
26
+ }
27
+ ],
28
+
29
+ "commands": []
30
+ }
31
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "robots": [
3
+ {
4
+ "name": "myRobot",
5
+
6
+ "connections": [
7
+ {
8
+ "adaptor": "Adaptor",
9
+ "name": "arduino",
10
+ "port": "/dev/ttyACM0"
11
+ }
12
+ ],
13
+
14
+ "devices": [
15
+ {
16
+ "commands": [ "isOn", "turnOn", "turnOff", "toggle", "brightness" ],
17
+ "connection": "arduino",
18
+ "driver": "Led",
19
+ "name": "led",
20
+ "pin": 13
21
+ }, {
22
+ "commands": [ "isPressed" ],
23
+ "connection": "arduino",
24
+ "driver": "Button",
25
+ "name": "button",
26
+ "pin": 2
27
+ }
28
+ ],
29
+
30
+ "commands": []
31
+ }
32
+ ]
33
+ }