Skip to content

Commit

Permalink
Merge branch 'aptx4869-auto-test'
Browse files Browse the repository at this point in the history
  • Loading branch information
jabbany committed Oct 23, 2014
2 parents b7352ce + d3fa114 commit 3ad5121
Show file tree
Hide file tree
Showing 18 changed files with 385 additions and 76 deletions.
8 changes: 3 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
tab_width = 2
indent_size = 2

[*.js]
indent_style = tab
tab_width = 2

[*.css]
indent_style = space
indent_size = 2
tab_width = 2

[*.coffee]
indent_style = space
indent_size = 2
tab_width = 2

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@

# Ignore Node Modules
/node_modules/*
/compiled_spec/*
/coverage/*
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: node_js
node_js:
- "0.10"
before_install:
- npm install npm@1.4 -g
before_script:
- npm install -g grunt-cli
script:
- grunt ci
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
93 changes: 79 additions & 14 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module.exports = (grunt) ->
require('load-grunt-tasks') grunt
require('load-grunt-tasks') grunt , {
pattern: ['grunt-*', '!grunt-template-jasmine-istanbul']
}
grunt.file.readJSON('package.json')

# !! Compile configurations
License = '/*!Copyright(c) CommentCoreLibrary (//github.com/jabbany/CommentCoreLibrary) - Licensed under the MIT License */'
FilterType = "Simple" # "Comment" || "Simple"
Expand Down Expand Up @@ -36,14 +38,14 @@ module.exports = (grunt) ->
'src/parsers/AcfunFormat.js'
'src/parsers/BilibiliFormat.js'
]

# !! Below are compile settings
# Dynamically generate the core ts targets
CMP_CORE_TS = { }
CMP_CORE_NAME = [ ]
for target in SRC_CORE_CMP
CMP_CORE_NAME.push ("typescript:" + target)
CMP_CORE_TS[target] =
CMP_CORE_TS[target] =
options:
target: 'es5'
basePath: 'src/core'
Expand All @@ -55,29 +57,31 @@ module.exports = (grunt) ->
CMP_KAGEROU_NAME = [ ]
for target,src of SRC_SCRIPTING_KAGEROU
CMP_KAGEROU_NAME.push ('typescript:kagerou_engine_' + target)
CMP_KAGEROU_TS['kagerou_engine_' + target] =
options:
CMP_KAGEROU_TS['kagerou_engine_' + target] =
options:
target: 'es5'
basePath: src.split('/')[0..-1].join('/')
src: src
dest: 'build/scripting/api/' + src.split('/').pop().split('.')[0] + '.js'

# Append Typescript Tasks
ts_config = {}
for key,value of CMP_CORE_TS
ts_config[key] = value
for key,value of CMP_KAGEROU_TS
ts_config[key] = value

# Core concatenated with libraries
# Actual concat ordering does not/should not matter
SRC_CORELIB = SRC_CORE.concat(SRC_PARSER)

grunt.loadNpmTasks('grunt-contrib-coffee')
grunt.loadNpmTasks('grunt-contrib-jasmine')
grunt.initConfig(
clean:
scripting: ['build/scripting']
build: ['build']

# Concat CSS and JS files
# core_only : builds CCL without parsers
# all : builds CCL with everything
Expand All @@ -93,18 +97,18 @@ module.exports = (grunt) ->
files:
'build/style.css': CSS
'build/CommentCoreLibrary.js': SRC_CORELIB

# Compile TypeScript
typescript: ts_config

# Copy
copy:
scripting_sandbox:
files:[
{expand: true, cwd:'src/scripting/api/', src: ['*.js'], dest:'build/scripting/api/'},
{expand: true, cwd:'src/scripting/', src: ['OOAPI.js','Worker.js'], dest:'build/scripting/'}
]

# Auto-prefix CSS properties using Can I Use?
autoprefixer:
options:
Expand All @@ -130,21 +134,82 @@ module.exports = (grunt) ->
'build/CommentCoreLibrary.min.js': SRC_CORELIB

# Watch files for changes
#
watch:
all:
files: ['src/**/*', '!node_modules']

# Run concat, autoprefixer, cssmin and uglify
tasks: ['build']

jshint:
options:
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
node: true,
strict: false,
mocha: true
all:
src: ['src/*.js']

# Jasmine test

jasmine:
coverage:
src: 'src/**/*.js'
options:
specs: 'compiled_spec/*spec.js'
helpers: 'spec/*helper.js'
vendor: [
'node_modules/jasmine-jquery/vendor/jquery/jquery.js'
'node_modules/jasmine-jquery/lib/jasmine-jquery.js'
]
template: require('grunt-template-jasmine-istanbul')
templateOptions:
report: 'coverage'
coverage: 'coverage/coverage.json'
ci:
src: 'build/CommentCoreLibrary.js'
options:
specs: 'compiled_spec/*spec.js'
helpers: 'spec/*helper.js'
vendor: [
'node_modules/jasmine-jquery/vendor/jquery/jquery.js'
'node_modules/jasmine-jquery/lib/jasmine-jquery.js'
]
template: require('grunt-template-jasmine-istanbul')
templateOptions:
report:
type: 'lcovonly'
options:
dir: 'coverage'
coverage: 'coverage/coverage.json'
coffee:
glob_to_multiple:
expand: true,
flatten: true,
src: ['spec/**/*.coffee']
dest: 'compiled_spec/'
ext: '.js'
)

# Register special compiles
grunt.registerTask 'compile-ts-kagerou', CMP_KAGEROU_NAME
grunt.registerTask 'compile-ts-core', CMP_CORE_NAME

# Register our tasks
grunt.registerTask 'test', ['coffee', 'jasmine:coverage']
grunt.registerTask 'build-scripting', ['clean:scripting','concat:scripting_host', 'compile-ts-kagerou', 'copy:scripting_sandbox']
grunt.registerTask 'build-core', ['compile-ts-core', 'concat:core_only', 'autoprefixer', 'cssmin', 'uglify:core_only']
grunt.registerTask 'build', ['compile-ts-core', 'concat:all', 'autoprefixer', 'cssmin', 'uglify:all']
grunt.registerTask 'ci', ['build', 'coffee', 'jasmine:ci']
grunt.registerTask 'default', ['clean', 'build', 'build-scripting', 'watch']

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

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

For Rails, installing with [rails-assets](https://rails-assets.org/) is recommended

In Gemfile:
```ruby
# Add https://rails-assets.org as the new gem source
Expand Down
22 changes: 15 additions & 7 deletions build/CommentCoreLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
var BinArray = (function(){
var BinArray = {};
BinArray.bsearch = function(arr, what, how){
if(arr.length == 0) return 0;
if(how(what,arr[0]) < 0) return 0;
if(how(what,arr[arr.length - 1]) >=0) return arr.length;
if(arr.length === 0) {
return 0;
}
if(how(what,arr[0]) < 0) {
return 0;
}
if(how(what,arr[arr.length - 1]) >=0) {
return arr.length;
}
var low =0;
var i = 0;
var count = 0;
Expand All @@ -18,15 +24,17 @@ var BinArray = (function(){
count++;
if(how(what,arr[i-1])>=0 && how(what,arr[i])<0){
return i;
}else if(how(what,arr[i-1])<0){
}
if(how(what,arr[i-1])<0){
high = i-1;
}else if(how(what,arr[i])>=0){
low = i;
}else
}else {
console.error('Program Error');
if(count > 1500) console.error('Too many run cycles.');
}
if(count > 1500) { console.error('Too many run cycles.'); }
}
return -1;
return -1; //this line can never been run
};
BinArray.binsert = function(arr, what, how){
var index = BinArray.bsearch(arr,what,how);
Expand Down
2 changes: 1 addition & 1 deletion build/CommentCoreLibrary.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 3ad5121

Please sign in to comment.