diff --git a/.gitignore b/.gitignore index 4c4b4f5..6656715 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,7 @@ -/node_modules/ +/.* +!/.gitignore +!/.travis.yml /bower_components/ -/tmp/ -/dist/ +/node_modules/ /output/ -/coverage/ -public/*.js -.psci_modules -.psci \ No newline at end of file +/public/test.js diff --git a/.travis.yml b/.travis.yml index 0221bb2..7cd7df9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,18 @@ language: node_js -node_js: - - 0.10 +dist: trusty +sudo: required +node_js: 5 install: - - npm install bower gulp -g - - npm install && bower install + - npm install + - npm install -g bower + - bower install script: - - gulp + - npm run build +after_success: +- >- + test $TRAVIS_TAG && + node_modules/.bin/psc-publish > .pursuit.json && + curl -X POST http://pursuit.purescript.org/packages \ + -d @.pursuit.json \ + -H 'Accept: application/json' \ + -H "Authorization: token ${GITHUB_TOKEN}" diff --git a/README.md b/README.md index 6b241d0..cdf9abf 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ -[![Build Status](https://travis-ci.org/cryogenian/purescript-routing.svg?branch=master)](https://travis-ci.org/cryogenian/purescript-routing) - # purescript-routing -Client side routing library +[![Latest release](http://img.shields.io/bower/v/purescript-routing.svg)](https://github.com/slamdata/purescript-routing/releases) +[![Build Status](https://travis-ci.org/slamdata/purescript-routing.svg?branch=master)](https://travis-ci.org/slamdata/purescript-routing) +[![Dependency Status](https://www.versioneye.com/user/projects/56e4cf18df573d00495abcf7/badge.svg?style=flat)](https://www.versioneye.com/user/projects/56e4cf18df573d00495abcf7) + +Client side routing library. ## Installation @@ -10,14 +12,7 @@ Client side routing library bower install purescript-routing ``` -## Documentation +# Module documentation -- [Routing](docs/Routing.md) -- [Routing.Hash](docs/Routing/Hash.md) -- [Routing.Hash.Aff](docs/Routing/Hash/Aff.mfd) -- [Routing.Match](docs/Routing/Match.md) -- [Routing.Match.Class](docs/Routing/Match/Class.md) -- [Routing.Match.Error](docs/Routing/Match/Error.md) -- [Routing.Parser](docs/Routing/Parser.md) -- [Routing.Types](docs/Routing/Types.md) +Module documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-routing). diff --git a/bower.json b/bower.json index 19a861f..9d1409a 100644 --- a/bower.json +++ b/bower.json @@ -9,16 +9,22 @@ "purescript", "routing" ], - "license": "Apache 2.0", + "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "git://github.com/slamdata/purescript-routing.git" + }, "ignore": [ "**/.*", - "node_modules", "bower_components", + "node_modules", + "output", "test", - "tests" + "bower.json", + "package.json" ], "dependencies": { - "purescript-aff": "^0.13.0", + "purescript-aff": "^0.16.0", "purescript-dom": "^0.2.6", "purescript-eff": "^0.1.1", "purescript-either": "^0.2.2", diff --git a/docs/Routing.md b/docs/Routing.md deleted file mode 100644 index 1811b46..0000000 --- a/docs/Routing.md +++ /dev/null @@ -1,55 +0,0 @@ -## Module Routing - -#### `hashChanged` - -``` purescript -hashChanged :: forall e. (String -> String -> Eff e Unit) -> Eff e Unit -``` - -#### `hashes` - -``` purescript -hashes :: forall e. (String -> String -> Eff e Unit) -> Eff e Unit -``` - -#### `matches` - -``` purescript -matches :: forall e a. Match a -> (Maybe a -> a -> Eff e Unit) -> Eff e Unit -``` - -Stream of hash changed, callback called when new hash can be matched -First argument of callback is `Just a` when old hash can be matched -and `Nothing` when it can't. - -#### `matches'` - -``` purescript -matches' :: forall e a. (String -> String) -> Match a -> (Maybe a -> a -> Eff e Unit) -> Eff e Unit -``` - -#### `matchesAff'` - -``` purescript -matchesAff' :: forall e a. (String -> String) -> Match a -> Aff e (Tuple (Maybe a) a) -``` - -#### `matchesAff` - -``` purescript -matchesAff :: forall e a. Match a -> Aff e (Tuple (Maybe a) a) -``` - -#### `matchHash` - -``` purescript -matchHash :: forall a. Match a -> String -> Either String a -``` - -#### `matchHash'` - -``` purescript -matchHash' :: forall a. (String -> String) -> Match a -> String -> Either String a -``` - - diff --git a/docs/Routing/Hash.md b/docs/Routing/Hash.md deleted file mode 100644 index af9096c..0000000 --- a/docs/Routing/Hash.md +++ /dev/null @@ -1,21 +0,0 @@ -## Module Routing.Hash - -#### `setHash` - -``` purescript -setHash :: forall e. String -> Eff (dom :: DOM | e) Unit -``` - -#### `getHash` - -``` purescript -getHash :: forall e. Eff (dom :: DOM | e) String -``` - -#### `modifyHash` - -``` purescript -modifyHash :: forall e. (String -> String) -> Eff (dom :: DOM | e) Unit -``` - - diff --git a/docs/Routing/Hash/Aff.md b/docs/Routing/Hash/Aff.md deleted file mode 100644 index 05ea747..0000000 --- a/docs/Routing/Hash/Aff.md +++ /dev/null @@ -1,15 +0,0 @@ -## Module Routing.Hash.Aff - -#### `modifyHash` - -``` purescript -modifyHash :: forall e. (String -> String) -> Aff (dom :: DOM | e) Unit -``` - -#### `setHash` - -``` purescript -setHash :: forall e. String -> Aff (dom :: DOM | e) Unit -``` - - diff --git a/docs/Routing/Match.md b/docs/Routing/Match.md deleted file mode 100644 index 7e4b2d2..0000000 --- a/docs/Routing/Match.md +++ /dev/null @@ -1,65 +0,0 @@ -## Module Routing.Match - -#### `Match` - -``` purescript -newtype Match a - = Match (Route -> V (Free MatchError) (Tuple Route a)) -``` - -##### Instances -``` purescript -MatchClass Match -Functor Match -Alt Match -Plus Match -Alternative Match -Apply Match -Applicative Match -``` - -#### `unMatch` - -``` purescript -unMatch :: forall a. Match a -> Route -> V (Free MatchError) (Tuple Route a) -``` - -#### `list` - -``` purescript -list :: forall a. Match a -> Match (List a) -``` - -Matches list of matchers. Useful when argument can easy fail (not `str`) -returns `Match Nil` if no matches - -#### `runMatch` - -``` purescript -runMatch :: forall a. Match a -> Route -> Either String a -``` - -#### `eitherMatch` - -``` purescript -eitherMatch :: forall a b. Match (Either a b) -> Match b -``` - -if we match something that can fail then we have to -match `Either a b`. This function converts matching on such -sum to matching on right subpart. Matching on left branch fails. -i.e. -```purescript -data Sort = Asc | Desc -sortOfString :: String -> Either String Sort -sortOfString "asc" = Right Asc -sortOfString "desc" = Right Desc -sortOfString _ = Left "incorrect sort" - -newtype Routing = Routing Sort -routes :: Match Routing -routes = (pure Routing) <*> (eitherMatch (sortOfString <$> var)) - -``` - - diff --git a/docs/Routing/Match/Class.md b/docs/Routing/Match/Class.md deleted file mode 100644 index 70fe645..0000000 --- a/docs/Routing/Match/Class.md +++ /dev/null @@ -1,16 +0,0 @@ -## Module Routing.Match.Class - -#### `MatchClass` - -``` purescript -class (Alternative f) <= MatchClass f where - lit :: String -> f Unit - str :: f String - param :: String -> f String - params :: f (Map String String) - num :: f Number - bool :: f Boolean - fail :: forall a. String -> f a -``` - - diff --git a/docs/Routing/Match/Error.md b/docs/Routing/Match/Error.md deleted file mode 100644 index ca93eb8..0000000 --- a/docs/Routing/Match/Error.md +++ /dev/null @@ -1,23 +0,0 @@ -## Module Routing.Match.Error - -#### `MatchError` - -``` purescript -data MatchError - = UnexpectedPath String - | ExpectedBoolean - | ExpectedNumber - | ExpectedString - | ExpectedQuery - | ExpectedPathPart - | KeyNotFound String - | Fail String -``` - -#### `showMatchError` - -``` purescript -showMatchError :: MatchError -> String -``` - - diff --git a/docs/Routing/Parser.md b/docs/Routing/Parser.md deleted file mode 100644 index a640841..0000000 --- a/docs/Routing/Parser.md +++ /dev/null @@ -1,12 +0,0 @@ -## Module Routing.Parser - -#### `parse` - -``` purescript -parse :: (String -> String) -> String -> Route -``` - -Parse hash string to `Route` with `decoder` function -applied to every hash part (usually `decodeURIComponent`) - - diff --git a/docs/Routing/Types.md b/docs/Routing/Types.md deleted file mode 100644 index c9c2ef0..0000000 --- a/docs/Routing/Types.md +++ /dev/null @@ -1,17 +0,0 @@ -## Module Routing.Types - -#### `RoutePart` - -``` purescript -data RoutePart - = Path String - | Query (Map String String) -``` - -#### `Route` - -``` purescript -type Route = List RoutePart -``` - - diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index 86427fa..0000000 --- a/gulpfile.js +++ /dev/null @@ -1,62 +0,0 @@ -'use strict' - -var gulp = require('gulp'), - purescript = require('gulp-purescript'); - -var sources = [ - 'src/**/*.purs', - 'bower_components/purescript-*/src/**/*.purs' -]; - -var foreigns = [ - 'src/**/*.js', - 'bower_components/purescript-*/src/**/*.js' -]; - -var testSources = [ - 'test/**/*.purs' -]; - -var testForeigns = [ - 'test/**/*.js' -]; - -gulp.task('docs', function() { - return purescript.pscDocs({ - src: sources, - docgen: { - "Routing": "docs/Routing.md", - "Routing.Hash": "docs/Routing/Hash.md", - "Routing.Hash.Aff": "docs/Routing/Hash/Aff.md", - "Routing.Match": "docs/Routing/Match.md", - "Routing.Match.Class": "docs/Routing/Match/Class.md", - "Routing.Match.Error": "docs/Routing/Match/Error.md", - "Routing.Parser": "docs/Routing/Parser.md", - "Routing.Types": "docs/Routing/Types.md" - } - }); -}); - -gulp.task('make', function() { - return purescript.psc({ - src: sources, - ffi: foreigns - }); -}); - -gulp.task('test-make', function() { - return purescript.psc({ - src: sources.concat(testSources), - ffi: foreigns.concat(testForeigns) - }); -}); - -gulp.task('test-bundle', ['test-make'], function() { - return purescript.pscBundle({ - src: 'output/**/*.js', - main: 'Test.Main', - output: 'public/test.js' - }); -}); - -gulp.task("default", ["test-bundle", "docs"]); diff --git a/package.json b/package.json index 78d195f..59f755e 100644 --- a/package.json +++ b/package.json @@ -1,24 +1,13 @@ { - "name": "purescript-routing", - "description": "Routing lib for purescript", "private": true, - "repository": { - "type": "git", - "url": "https://github.com/slamdata/purescript-routing.git" + "scripts": { + "clean": "rimraf output && rimraf .pulp-cache", + "build": "pulp build", + "test": "pulp build --include test --to public/test.js" }, - "keywords": [ - "purescript", - "routing" - ], - "author": "Maxim Zimaliev ", - "license": "Apache 2.0", - "bugs": { - "url": "https://github.com/slamdata/purescript-routing/issues" - }, - "homepage": "https://github.com/slamdata/purescript-routing", - "dependencies": { - "gulp": "^3.9.0", - "gulp-purescript": "^0.8.0", - "purescript": "^0.7.6" + "devDependencies": { + "pulp": "^8.1.0", + "purescript": "^0.7.6", + "rimraf": "^2.5.2" } }