Skip to content

Commit

Permalink
v2.3.0-beta.4
Browse files Browse the repository at this point in the history
  • Loading branch information
aMarCruz committed Oct 21, 2015
1 parent 89b2118 commit f78c131
Show file tree
Hide file tree
Showing 96 changed files with 515 additions and 655 deletions.
1 change: 1 addition & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ ratings:
- "dist/compiler.js"

exclude_paths:
- "dist/riot.compiler.js"
- "test/**/*"
- "lib/**/*"
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
root: true

env:

###########################################################################
Expand Down Expand Up @@ -76,7 +78,7 @@ rules:
###########################################################################

block-scoped-var: 0 # treat var statements as if they were block scoped
complexity: [1, 10] # specify the maximum cyclomatic complexity allowed in a program
complexity: [1, 8] # specify the maximum cyclomatic complexity allowed in a program
consistent-return: 0 # require return statements to either always or never specify values
curly: 0 # specify curly brace conventions for all control
# statements
Expand Down
25 changes: 5 additions & 20 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ out/
# --------------------
.project
.metadata
*.bak
.classpath
.settings/

Expand All @@ -51,31 +50,17 @@ out/
# --------------------
node_modules
bower_components
make.js
coverage

# these files are generated anyway
dist/
!.eslint*
!.*.yml

!.gitmodules
!.travis.yml

# Logs
logs
**/*.log

# Runtime data
pids
**/*.log
**/*.bak
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov/

# Coverage directory used by tools like istanbul
coverage/

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript
21 changes: 16 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
language: node_js

node_js:
- "0.12.0"
- "4.2"
- "0.12.0"

branches:
only:
- master
- dev

before_install:
npm install coffee-script && npm install babel-core && npm install livescript && npm install typescript-simple && npm install jade && npm install stylus && npm install nib && npm install
install:
- npm i jade
- npm i babel-core
- npm i coffee-script
- npm i livescript
- npm i typescript-simple
- npm i stylus
- npm i nib
- npm i node-sass
- npm i

after_success:
make test-coveralls
after_success: make send-coverage

notifications:
email: false

sudo: false
40 changes: 25 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
# jspp flags
JSPP_FLAGS = -F istanbul --custom-filter "@module\b"
# jspreproc flags
#JSPP_DEBUG = -D DEBUG
JSPP_FLAGS = -F istanbul -F eslint --custom-filter "\s@(module|version)\b" --headers ""
JSPP_RIOT_FLAGS = $(JSPP_FLAGS) -D RIOT
JSPP_NODE_FLAGS = $(JSPP_FLAGS) -D NODE --indent 2s
JSPP_NODE_FLAGS = $(JSPP_FLAGS) -D NODE --indent 2

# Code Climate only accepts the first job of default branch
TESTCOVER = $(TRAVIS_BRANCH) $(TRAVIS_NODE_VERSION)

# Command line paths
ISTANBUL = ./node_modules/.bin/istanbul
ESLINT = ./node_modules/eslint/bin/eslint.js
MOCHA = ./node_modules/mocha/bin/_mocha
COVERALLS = ./node_modules/coveralls/bin/coveralls.js
JSPP = ./node_modules/jspreproc/bin/jspp.js
ESLINT = ./node_modules/eslint/bin/eslint.js
ISTANBUL = ./node_modules/istanbul/lib/cli.js
MOCHA = ./node_modules/mocha/bin/_mocha
JSPP = ./node_modules/jspreproc/bin/jspp.js

# folders
DIST = "./dist/"

test: build
@ $(ISTANBUL) cover $(MOCHA) -- test/runner.js -R spec
# default job
test: build test-mocha

# riot-compiler is for inclusion in riot, it assume tmpl, brackets, and regEx are in the scope
build: eslint
# rebuild all
@ mkdir -p $(DIST)
Expand All @@ -27,16 +30,23 @@ eslint:
# check code style
@ $(ESLINT) -c ./.eslintrc lib

test-coveralls: build
@ RIOT_COV=1 cat ./coverage/lcov.info ./coverage/report-lcov/lcov.info | $(COVERALLS)

test-mocha:
@ $(MOCHA) test/runner.js
@ $(ISTANBUL) cover $(MOCHA) -- test/runner.js

send-coverage:
@ RIOT_COV=1 cat ./coverage/lcov.info | $(COVERALLS)
ifeq ($(TESTCOVER),master 4.2)
@ npm install codeclimate-test-reporter
@ codeclimate-test-reporter < coverage/lcov.info
else
@ echo Send in master 4.2
endif

debug: build
# launching node-inspector
@ node-debug $(MOCHA) test/runner.js

perf: build
@ node --expose-gc test/perf.js

.PHONY: build test eslint test-coveralls debug perf
.PHONY: test build eslint test-mocha send-coverage debug perf
103 changes: 54 additions & 49 deletions dist/compiler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* riot-compiler "0", @license MIT, (c) 2015 Muut Inc. + contributors */

/* riot-compiler 2.3.0-beta.3, @license MIT, (c) 2015 Muut Inc. + contributors */
;(function (root, factory) {

/* istanbul ignore else */
Expand All @@ -14,17 +13,16 @@
}

})(this, function (_tmpl) {
'use strict'

var
brackets = _tmpl.brackets
'use strict' // eslint-disable-line

// lib/parsers.js
var brackets = _tmpl.brackets

/**
* @module parsers
*/
var parsers = (function () {
'use strict'

var _mods = {'none': 'none'}
var _mods = {}

function _try(name) {
if (!(name in _mods)) {
Expand All @@ -38,23 +36,24 @@
return _mods[name]
}

function _get(name) {
var req = name
switch (name) {
case 'es6':
case 'babel':
return _try('babel-core') || _try('babel')
case 'javascript':
return _mods.none
case 'typescript':
req += '-simple'
break
case 'coffee':
case 'coffeescript':
req = 'coffee-script'
break
default:
break
function _get(req) {
switch (req) {
case 'es6':
case 'babel':
// istanbul ignore next: not both
return _try('babel-core') || _try('babel')
case 'none':
case 'javascript':
return 'none'
case 'typescript':
req += '-simple'
break
case 'coffee':
case 'coffeescript':
req = 'coffee-script'
break
default:
break
}
return _try(req)
}
Expand All @@ -72,12 +71,12 @@

var _css = {
stylus: function (tag, css) {
var stylus = _req('stylus'),
nib = _req('nib')
if (nib)
return stylus(css).use(nib()).import('nib').render()
else
return stylus.render(css)
var
stylus = _req('stylus'),
nib = _req('nib')
// istanbul ignore next: not both
return nib ?
stylus(css).use(nib()).import('nib').render() : stylus.render(css)
}
}

Expand Down Expand Up @@ -112,7 +111,9 @@

})()

// lib/core.js
/**
* @module compiler
*/

function _regEx(str, opt) { return new RegExp(str, opt) }

Expand Down Expand Up @@ -157,10 +158,11 @@
}

function parseAttrs(str) {
var list = [],
match,
k, v,
DQ = '"'
var
list = [],
match,
k, v,
DQ = '"'
HTML_ATTR.lastIndex = 0

while (match = HTML_ATTR.exec(str)) {
Expand Down Expand Up @@ -263,17 +265,18 @@

var

JS_RMCOMMS = _regEx(
'(' + brackets.S_QBLOCKS + ')|' + brackets.R_MLCOMMS.source + '|//[^\r\n]*',
'g'),
JS_RMCOMMS = _regEx(
'(' + brackets.S_QBLOCKS + ')|' + brackets.R_MLCOMMS.source + '|//[^\r\n]*',
'g'),

JS_ES6SIGN = /^([ \t]*)([$_A-Za-z][$\w]*)\s*(\([^()]*\)\s*{)/m
JS_ES6SIGN = /^([ \t]*)([$_A-Za-z][$\w]*)\s*(\([^()]*\)\s*{)/m

function riotjs(js) {
var match,
toes5,
parts = [],
pos
var
match,
toes5,
parts = [],
pos

js = js.replace(JS_RMCOMMS, function (m, q) { return q ? m : ' ' })

Expand All @@ -295,9 +298,10 @@
return parts.length ? parts.join('') + js : js

function skipBlock(str) {
var re = _regEx('([{}])|' + brackets.S_QBLOCKS, 'g'),
level = 1,
match
var
re = _regEx('([{}])|' + brackets.S_QBLOCKS, 'g'),
level = 1,
match

while (level && (match = re.exec(str))) {
if (match[1])
Expand Down Expand Up @@ -343,14 +347,15 @@
}

function compileCSS(style, tag, type, scoped) {
// istanbul ignore else

if (type) {
if (type === 'scoped-css') {
scoped = true
}
else if (parsers.css[type]) {
style = parsers.css[type](tag, style)
}
// istanbul ignore else: fallback to nothing
else if (type !== 'css') {
throw new Error('CSS parser not found: "' + type + '"')
}
Expand Down

0 comments on commit f78c131

Please sign in to comment.