Skip to content

Commit 3ad5121

Browse files
committed
Merge branch 'aptx4869-auto-test'
2 parents b7352ce + d3fa114 commit 3ad5121

18 files changed

Lines changed: 385 additions & 76 deletions

.editorconfig

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@ end_of_line = lf
66
charset = utf-8
77
trim_trailing_whitespace = true
88
insert_final_newline = true
9+
tab_width = 2
10+
indent_size = 2
911

1012
[*.js]
1113
indent_style = tab
14+
tab_width = 2
1215

1316
[*.css]
1417
indent_style = space
15-
indent_size = 2
16-
tab_width = 2
1718

1819
[*.coffee]
1920
indent_style = space
20-
indent_size = 2
21-
tab_width = 2
22-

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44

55
# Ignore Node Modules
66
/node_modules/*
7+
/compiled_spec/*
8+
/coverage/*

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: node_js
2+
node_js:
3+
- "0.10"
4+
before_install:
5+
- npm install npm@1.4 -g
6+
before_script:
7+
- npm install -g grunt-cli
8+
script:
9+
- grunt ci
10+
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js

Gruntfile.coffee

Lines changed: 79 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
module.exports = (grunt) ->
2-
require('load-grunt-tasks') grunt
2+
require('load-grunt-tasks') grunt , {
3+
pattern: ['grunt-*', '!grunt-template-jasmine-istanbul']
4+
}
35
grunt.file.readJSON('package.json')
4-
6+
57
# !! Compile configurations
68
License = '/*!Copyright(c) CommentCoreLibrary (//github.com/jabbany/CommentCoreLibrary) - Licensed under the MIT License */'
79
FilterType = "Simple" # "Comment" || "Simple"
@@ -36,14 +38,14 @@ module.exports = (grunt) ->
3638
'src/parsers/AcfunFormat.js'
3739
'src/parsers/BilibiliFormat.js'
3840
]
39-
41+
4042
# !! Below are compile settings
4143
# Dynamically generate the core ts targets
4244
CMP_CORE_TS = { }
4345
CMP_CORE_NAME = [ ]
4446
for target in SRC_CORE_CMP
4547
CMP_CORE_NAME.push ("typescript:" + target)
46-
CMP_CORE_TS[target] =
48+
CMP_CORE_TS[target] =
4749
options:
4850
target: 'es5'
4951
basePath: 'src/core'
@@ -55,29 +57,31 @@ module.exports = (grunt) ->
5557
CMP_KAGEROU_NAME = [ ]
5658
for target,src of SRC_SCRIPTING_KAGEROU
5759
CMP_KAGEROU_NAME.push ('typescript:kagerou_engine_' + target)
58-
CMP_KAGEROU_TS['kagerou_engine_' + target] =
59-
options:
60+
CMP_KAGEROU_TS['kagerou_engine_' + target] =
61+
options:
6062
target: 'es5'
6163
basePath: src.split('/')[0..-1].join('/')
6264
src: src
6365
dest: 'build/scripting/api/' + src.split('/').pop().split('.')[0] + '.js'
64-
66+
6567
# Append Typescript Tasks
6668
ts_config = {}
6769
for key,value of CMP_CORE_TS
6870
ts_config[key] = value
6971
for key,value of CMP_KAGEROU_TS
7072
ts_config[key] = value
71-
73+
7274
# Core concatenated with libraries
7375
# Actual concat ordering does not/should not matter
7476
SRC_CORELIB = SRC_CORE.concat(SRC_PARSER)
7577

78+
grunt.loadNpmTasks('grunt-contrib-coffee')
79+
grunt.loadNpmTasks('grunt-contrib-jasmine')
7680
grunt.initConfig(
7781
clean:
7882
scripting: ['build/scripting']
7983
build: ['build']
80-
84+
8185
# Concat CSS and JS files
8286
# core_only : builds CCL without parsers
8387
# all : builds CCL with everything
@@ -93,18 +97,18 @@ module.exports = (grunt) ->
9397
files:
9498
'build/style.css': CSS
9599
'build/CommentCoreLibrary.js': SRC_CORELIB
96-
100+
97101
# Compile TypeScript
98102
typescript: ts_config
99-
103+
100104
# Copy
101105
copy:
102106
scripting_sandbox:
103107
files:[
104108
{expand: true, cwd:'src/scripting/api/', src: ['*.js'], dest:'build/scripting/api/'},
105109
{expand: true, cwd:'src/scripting/', src: ['OOAPI.js','Worker.js'], dest:'build/scripting/'}
106110
]
107-
111+
108112
# Auto-prefix CSS properties using Can I Use?
109113
autoprefixer:
110114
options:
@@ -130,21 +134,82 @@ module.exports = (grunt) ->
130134
'build/CommentCoreLibrary.min.js': SRC_CORELIB
131135

132136
# Watch files for changes
137+
#
133138
watch:
134139
all:
135140
files: ['src/**/*', '!node_modules']
136141

137142
# Run concat, autoprefixer, cssmin and uglify
138143
tasks: ['build']
144+
145+
jshint:
146+
options:
147+
curly: true,
148+
eqeqeq: true,
149+
immed: true,
150+
latedef: true,
151+
newcap: true,
152+
noarg: true,
153+
sub: true,
154+
undef: true,
155+
boss: true,
156+
eqnull: true,
157+
node: true,
158+
strict: false,
159+
mocha: true
160+
all:
161+
src: ['src/*.js']
162+
163+
# Jasmine test
164+
165+
jasmine:
166+
coverage:
167+
src: 'src/**/*.js'
168+
options:
169+
specs: 'compiled_spec/*spec.js'
170+
helpers: 'spec/*helper.js'
171+
vendor: [
172+
'node_modules/jasmine-jquery/vendor/jquery/jquery.js'
173+
'node_modules/jasmine-jquery/lib/jasmine-jquery.js'
174+
]
175+
template: require('grunt-template-jasmine-istanbul')
176+
templateOptions:
177+
report: 'coverage'
178+
coverage: 'coverage/coverage.json'
179+
ci:
180+
src: 'build/CommentCoreLibrary.js'
181+
options:
182+
specs: 'compiled_spec/*spec.js'
183+
helpers: 'spec/*helper.js'
184+
vendor: [
185+
'node_modules/jasmine-jquery/vendor/jquery/jquery.js'
186+
'node_modules/jasmine-jquery/lib/jasmine-jquery.js'
187+
]
188+
template: require('grunt-template-jasmine-istanbul')
189+
templateOptions:
190+
report:
191+
type: 'lcovonly'
192+
options:
193+
dir: 'coverage'
194+
coverage: 'coverage/coverage.json'
195+
coffee:
196+
glob_to_multiple:
197+
expand: true,
198+
flatten: true,
199+
src: ['spec/**/*.coffee']
200+
dest: 'compiled_spec/'
201+
ext: '.js'
139202
)
140-
203+
141204
# Register special compiles
142205
grunt.registerTask 'compile-ts-kagerou', CMP_KAGEROU_NAME
143206
grunt.registerTask 'compile-ts-core', CMP_CORE_NAME
144-
207+
145208
# Register our tasks
209+
grunt.registerTask 'test', ['coffee', 'jasmine:coverage']
146210
grunt.registerTask 'build-scripting', ['clean:scripting','concat:scripting_host', 'compile-ts-kagerou', 'copy:scripting_sandbox']
147211
grunt.registerTask 'build-core', ['compile-ts-core', 'concat:core_only', 'autoprefixer', 'cssmin', 'uglify:core_only']
148212
grunt.registerTask 'build', ['compile-ts-core', 'concat:all', 'autoprefixer', 'cssmin', 'uglify:all']
213+
grunt.registerTask 'ci', ['build', 'coffee', 'jasmine:ci']
149214
grunt.registerTask 'default', ['clean', 'build', 'build-scripting', 'watch']
150215

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
[![Bower version](https://badge.fury.io/bo/comment-core-library.svg)](http://badge.fury.io/bo/comment-core-library)
44
[![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/)
55
[![License](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
6+
[![Build Status: Linux](https://travis-ci.org/jabbany/CommentCoreLibrary.svg?branch=master)](https://travis-ci.org/jabbany/CommentCoreLibrary)
7+
[![Coverage Status](https://img.shields.io/coveralls/jabbany/CommentCoreLibrary.svg)](https://coveralls.io/r/jabbany/CommentCoreLibrary?branch=master)
68

79
The CommentCoreLibrary is a set of Javascript modules that make up the
810
core controller for comments streaming on top of timed media (video or audio).
@@ -31,6 +33,7 @@ With [npm](https://www.npmjs.org/):
3133
`npm install comment-core-library`
3234

3335
For Rails, installing with [rails-assets](https://rails-assets.org/) is recommended
36+
3437
In Gemfile:
3538
```ruby
3639
# Add https://rails-assets.org as the new gem source

build/CommentCoreLibrary.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@
66
var BinArray = (function(){
77
var BinArray = {};
88
BinArray.bsearch = function(arr, what, how){
9-
if(arr.length == 0) return 0;
10-
if(how(what,arr[0]) < 0) return 0;
11-
if(how(what,arr[arr.length - 1]) >=0) return arr.length;
9+
if(arr.length === 0) {
10+
return 0;
11+
}
12+
if(how(what,arr[0]) < 0) {
13+
return 0;
14+
}
15+
if(how(what,arr[arr.length - 1]) >=0) {
16+
return arr.length;
17+
}
1218
var low =0;
1319
var i = 0;
1420
var count = 0;
@@ -18,15 +24,17 @@ var BinArray = (function(){
1824
count++;
1925
if(how(what,arr[i-1])>=0 && how(what,arr[i])<0){
2026
return i;
21-
}else if(how(what,arr[i-1])<0){
27+
}
28+
if(how(what,arr[i-1])<0){
2229
high = i-1;
2330
}else if(how(what,arr[i])>=0){
2431
low = i;
25-
}else
32+
}else {
2633
console.error('Program Error');
27-
if(count > 1500) console.error('Too many run cycles.');
34+
}
35+
if(count > 1500) { console.error('Too many run cycles.'); }
2836
}
29-
return -1;
37+
return -1; //this line can never been run
3038
};
3139
BinArray.binsert = function(arr, what, how){
3240
var index = BinArray.bsearch(arr,what,how);

build/CommentCoreLibrary.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)