Skip to content

Commit 9173d3c

Browse files
author
David Chase
committed
Release 3.0.0
1 parent a068d81 commit 9173d3c

File tree

14 files changed

+411
-71433
lines changed

14 files changed

+411
-71433
lines changed

README.md

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,22 @@
11
# ramtuary
2-
Ramda + Ramda Fantasy + Sanctuary REPL
2+
JavaScript functional REPL
33

4-
~~This is basically a clone of the [ramda repl](https://github.com/ramda/ramda.github.io/tree/master/repl) with a new skin.~~
4+
[![builtwith](https://img.shields.io/badge/built--with-rollup-e94c43.svg?style=flat-square)](http://rollupjs.org)
5+
[![builtwith](https://img.shields.io/badge/es6--with-bublé-0074D9.svg?style=flat-square)](http://buble.surge.sh/#)
6+
[![builtwith](https://img.shields.io/badge/repl--with-codemirror-d30707.svg?style=flat-square)](https://codemirror.net)
57

6-
~~With some additions of [ramda fantasy](https://github.com/ramda/ramda-fantasy) and [sanctuary](https://github.com/plaid/sanctuary) for moar fun.~~
8+
## Usage
9+
This REPL includes different libraries such as
710

8-
Ramtuary is now the ramda [repl](ramdajs.com/repl/).
11+
- [Ramda](https://github.com/ramda/ramda) - available with prefix `R` or without
12+
- [Sanctuary](https://github.com/sanctuary-js/sanctuary) - available with prefix `S`
13+
- [Ramda Fantasy](https://github.com/ramda/ramda-fantasy) - available `Either, Future, Identity, IO, Maybe, Reader, Tuple `
14+
- [Tcomb](https://github.com/gcanti/tcomb) - available as `tcomb`
915

10-
Inlcudes [ramda](https://github.com/ramda/ramda), [ramda fantasy](https://github.com/ramda/ramda-fantasy) and [sanctuary](https://github.com/plaid/sanctuary)
16+
## Todo
17+
- [ ] Add examples
18+
- [ ] Add info for available libraries
1119

12-
Uses [Babel](babeljs.io) and latest version of [CodeMirror](codemirror.net) under the hood
20+
### Please note
21+
If you are looking for the original REPL, it is now part of Ramda REPL [here](http://ramdajs.com/repl/)
1322

14-
Supports es6 and even es7 (`console::console.log`)
15-
16-
[Try it out](http://davidchase.github.io/ramtuary/)
17-
18-
## usage
19-
20-
The following variables are available globally:
21-
22-
`R` for Ramda
23-
24-
`S` for Sanctuary
25-
26-
`Either, Future, Identity, IO, Maybe, Reader, Tuple` for Ramda Fantasy
27-
28-
Use <kbd>Tab</kbd> for auto-completion
29-
30-
Examples located in this [folder](examples)
31-
32-
## todo / features
33-
- [x] add `console.log` capturing for output
34-
- [x] update to latest [codemirror](https://github.com/codemirror/CodeMirror) for moar features
35-
- [x] switch to babel
36-
- [x] support auto-completion
37-
- [x] match brackets
38-
- [ ] remove jquery dependency
39-
- [ ] refactor/code cleanup (could always use a bit of that)

create-examples.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import fs from 'fs';
2-
import R from 'ramda';
3-
import vfs from 'vinyl-fs';
4-
import through2 from 'through2';
1+
const fs = require('fs');
2+
const R = require('ramda');
3+
const vfs = require('vinyl-fs');
4+
const through2 = require('through2');
55

66
const src = './examples/**/*.js';
77
const dest = './examples/example.json';
@@ -31,4 +31,4 @@ const flush = function flush(callback) {
3131
callback();
3232
};
3333

34-
stream.pipe(through2(options, transform, flush)).pipe(fs.createWriteStream(dest));
34+
stream.pipe(through2(options, transform, flush)).pipe(fs.createWriteStream(dest));

examples/example.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,7 @@
33
{
44
"category": "fantasy",
55
"title": "futures",
6-
"code": "const log = console::console.log;\nconst error = console::console.error;\n\nconst url = 'http://reqr.es/api/users?page=3';\n\nconst xhr = function(url) {\n return new Future(function(rej, res) {\n const oReq = new XMLHttpRequest();\n oReq.addEventListener(\"load\", res, false);\n oReq.addEventListener(\"error\", rej, false);\n oReq.addEventListener(\"abort\", rej, false);\n oReq.open(\"get\", url, true);\n oReq.send();\n });\n};\n\nconst f = R.compose(R.map(S.parseJson), R.map(R.path(['target', 'response'])), xhr)(url);\n\nf.fork(error, R.map(log)); //=> Object {page: \"3\", per_page: 3, total: 12, total_pages: 4, data: Array[3]}"
7-
}
8-
],
9-
"function": [
10-
{
11-
"category": "function",
12-
"title": "compose",
13-
"code": "const f = R.compose(R.inc, R.negate, Math.pow);\n\nf(3, 4);"
14-
},
15-
{
16-
"category": "function",
17-
"title": "useWith",
18-
"code": "const double = y => y * 2;\nconst square = x => x * x;\nconst add = (a, b) => a + b;\n// Adds any number of arguments together\nconst addAll = (...args) => R.reduce(add, 0, args);\n\n// Basic example\nconst addDoubleAndSquare = R.useWith(addAll, double, square);\n\n//≅ addAll(double(10), square(5));\naddDoubleAndSquare(10, 5); //=> 45"
6+
"code": "const log = console.log.bind(console);\nconst error = console.error.bind(console);\n\nconst url = 'http://reqres.in/api/users?page=3';\n\nconst xhr = function(url) {\n return new Future(function(rej, res) {\n const oReq = new XMLHttpRequest();\n oReq.addEventListener(\"load\", res, false);\n oReq.addEventListener(\"error\", rej, false);\n oReq.addEventListener(\"abort\", rej, false);\n oReq.open(\"get\", url, true);\n oReq.send();\n });\n};\n\nconst f = R.compose(R.map(S.parseJson), R.map(R.path(['target', 'response'])), xhr)(url);\n\nf.fork(error, R.map(log)); //=> Object {page: \"3\", per_page: 3, total: 12, total_pages: 4, data: Array[3]}\n"
197
}
208
],
219
"list": [
@@ -30,6 +18,18 @@
3018
"code": "const double = x => x * 2;\n\nR.map(double, [1, 2, 3]);"
3119
}
3220
],
21+
"function": [
22+
{
23+
"category": "function",
24+
"title": "compose",
25+
"code": "const f = R.compose(R.inc, R.negate, Math.pow);\n\nf(3, 4);"
26+
},
27+
{
28+
"category": "function",
29+
"title": "useWith",
30+
"code": "const double = y => y * 2;\nconst square = x => x * x;\nconst add = (a, b) => a + b;\n// Adds any number of arguments together\nconst addAll = (...args) => R.reduce(add, 0, args);\n\n// Basic example\nconst addDoubleAndSquare = R.useWith(addAll, double, square);\n\n//≅ addAll(double(10), square(5));\naddDoubleAndSquare(10, 5); //=> 45"
31+
}
32+
],
3333
"object": [
3434
{
3535
"category": "object",

examples/fantasy/futures.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const log = console::console.log;
2-
const error = console::console.error;
1+
const log = console.log.bind(console);
2+
const error = console.error.bind(console);
33

4-
const url = 'http://reqr.es/api/users?page=3';
4+
const url = 'http://reqres.in/api/users?page=3';
55

66
const xhr = function(url) {
77
return new Future(function(rej, res) {
@@ -16,4 +16,4 @@ const xhr = function(url) {
1616

1717
const f = R.compose(R.map(S.parseJson), R.map(R.path(['target', 'response'])), xhr)(url);
1818

19-
f.fork(error, R.map(log)); //=> Object {page: "3", per_page: 3, total: 12, total_pages: 4, data: Array[3]}
19+
f.fork(error, R.map(log)); //=> Object {page: "3", per_page: 3, total: 12, total_pages: 4, data: Array[3]}

index.html

Lines changed: 16 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,10 @@
3737
</head>
3838

3939
<body>
40-
<div class="github-fork-ribbon-wrapper right">
41-
<div class="github-fork-ribbon">
42-
<a href="https://github.com/davidchase/ramtuary" target="blank">Fork me on GitHub</a>
43-
</div>
44-
</div>
45-
<!-- Fixed navbar -->
46-
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
40+
41+
<div class="nav" role="navigation">
4742
<nav class="top-nav"></nav>
48-
<div class="container col-lg-12">
43+
<div class="col-lg-12">
4944
<div class="navbar-header">
5045
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
5146
<span class="sr-only">Toggle navigation</span>
@@ -57,60 +52,22 @@
5752
</div>
5853
<div class="navbar-collapse collapse">
5954
<ul class="nav navbar-nav">
60-
<li><a data-toggle="modal" data-target="#about-modal">About</a></li>
61-
<li class="dropdown" id="examples_menu">
62-
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Examples <b class="caret"></b></a>
63-
<ul id="examples" class="dropdown-menu"></ul>
64-
</li>
55+
<li><button id="mkurl" class="btn btn-default btn-sm">Make Short URL:</button><input id="urlout" type="text" class="urltext" /></li>
6556
</ul>
6657
</div><!--/.nav-collapse -->
6758
</div>
6859
</div>
6960

70-
<div class="modal fade" id="about-modal" tabindex="-1" role="dialog" aria-labelledby="about" aria-hidden="true">
71-
<div class="modal-dialog">
72-
<div class="modal-content">
73-
<div class="modal-header">
74-
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
75-
<h4 class="modal-title" id="myModalLabel">About</h4>
76-
</div>
77-
<div class="modal-body">
78-
<p>
79-
Inspired by <a href="https://github.com/ramda/ramda.github.io/tree/master/repl">Ramda repl</a>
80-
this repl uses <a href="https://babeljs.io/">Babel</a>, and the lastest <a href="http://codemirror.net/">CodeMirror</a> for es6 and even es7 fun with ramda, ramda-fantasy and sanctuary.
81-
</p>
82-
<p>
83-
The "Examples" menu contains sample code you can play around with from the <a href="http://ramdajs.com/docs/">ramda docs</a>
84-
</p>
85-
<p>
86-
The "Reset" button clears the repl and repl
87-
history.
88-
</p>
89-
</div>
90-
<div class="modal-footer">
91-
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
92-
</div>
93-
</div><!-- /.modal-content -->
94-
</div><!-- /.modal-dialog -->
95-
</div><!-- /.modal -->
96-
97-
<div class="container col-lg-12 theme-showcase">
98-
99-
<div class="page-header">
100-
<h1>Ramtuary REPL
101-
<button class="btn btn-danger" type="reset">Reset</button>
102-
<button id="mkurl" class="btn btn-primary">Make Short URL:</button><input id="urlout" type="text" class="urltext" />
103-
</h1>
104-
<a href="http://ramdajs.com/" target="_blank">Ramda</a> + <a href="https://github.com/ramda/ramda-fantasy" target="_blank">Ramda Fantasy</a> + <a href="https://github.com/plaid/sanctuary" target="_blank">Sanctuary</a>
105-
</div>
61+
<div class="col-lg-12 theme-showcase">
62+
10663
<div class="row">
10764
<div class="col-md-6">
10865
<div class="panel panel-primary">
10966
<div class="panel-heading">
11067
<h3 class="panel-title">Input</h3>
11168
</div>
11269
<div class="panel-body">
113-
<textarea class="input" rows="20" cols="50"></textarea>
70+
<textarea class="input" rows="80" cols="50"></textarea>
11471
</div>
11572
</div>
11673
</div>
@@ -120,27 +77,28 @@ <h3 class="panel-title">Input</h3>
12077
<h3 class="panel-title output">Output</h3>
12178
<button class="btn btn-link btn-xs clear-console" type="button">Clear Output</button>
12279
</div>
123-
<div class="panel-body">
80+
<div class="panel-body yield">
81+
<textarea class="results" rows="80" cols="50"></textarea>
12482
<pre class="error"></pre>
12583
<pre class="console-log"></pre>
126-
<pre class="eval"></pre>
12784
</div>
12885
</div>
12986
</div>
13087
</div>
13188

13289
</div> <!-- /container -->
90+
<a href="https://git.io/vrb8q" class="github-corner"><svg width="66" height="66" viewBox="0 0 250 250" style="fill:#53506b; color:#fff; position: absolute; top: 0; border: 0; right: 0;"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
13391

134-
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.6.0/codemirror.min.js"></script>
92+
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.6.0/codemirror.js"></script>
13593
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.6.0/addon/edit/closebrackets.min.js"></script>
13694
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.6.0/addon/hint/show-hint.min.js"></script>
13795
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.6.0/addon/hint/javascript-hint.min.js"></script>
13896
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.6.0/mode/javascript/javascript.min.js"></script>
139-
<script src="//wzrd.in/standalone/ramda@latest"></script>
140-
<script src="//wzrd.in/standalone/sanctuary@latest"></script>
141-
<script src="//wzrd.in/standalone/ramda-fantasy@latest"></script>
142-
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
143-
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>
97+
<script src="https://wzrd.in/standalone/ramda@latest"></script>
98+
<script src="https://wzrd.in/standalone/sanctuary@latest"></script>
99+
<script src="https://wzrd.in/standalone/tcomb@latest"></script>
100+
<script src="https://wzrd.in/standalone/ramda-fantasy@latest"></script>
101+
<script src="https://wzrd.in/standalone/buble@latest"></script>
144102

145103
<script src="lib/js/main.js"></script>
146104
<script src="lib/js/bundle.js"></script>

lib/css/repl.css

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
html, body {
44
margin: 0;
5-
padding-top: 30px;
6-
padding-bottom: 30px;
5+
padding: 0;
6+
height: calc(100vh - 190px);
77
}
88

99
.output-wrapper {
@@ -16,8 +16,6 @@ html.hide-output .output-wrapper {
1616
display: none;
1717
}
1818

19-
html.hide-output .CodeMirror {
20-
}
2119

2220
.eval, .source-map {
2321
background-color: white;
@@ -60,3 +58,11 @@ body.dark, body.dark h1 {
6058
vertical-align: middle;
6159
margin-left: 6px;
6260
}
61+
62+
.input, .results {
63+
display:none;
64+
}
65+
66+
#mkurl {
67+
margin: 10px 0;
68+
}

lib/css/terminal.css

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
margin-left: 12px;
1919
}
2020
.top-nav {
21-
background: #6F377D;
21+
background: #53506b;
2222
height:15px;
2323
}
2424

@@ -77,4 +77,36 @@ button.btn.btn-danger {
7777
.navbar.navbar-inverse.navbar-fixed-top {
7878
background-color: #282a36;
7979
background-image: none;
80-
}
80+
}
81+
82+
.error span.cm-variable {
83+
color: red;
84+
}
85+
86+
.error span.cm-string {
87+
color: red;
88+
}
89+
90+
.error span.cm-number {
91+
color: red;
92+
}
93+
94+
.error span.cm-operator {
95+
color: red;
96+
}
97+
98+
.error span.cm-property {
99+
color: red;
100+
}
101+
102+
.error span.cm-keyword {
103+
color: red;
104+
}
105+
106+
.navbar-brand {
107+
color: #53506b;
108+
}
109+
110+
.btn.btn-link.btn-xs.clear-console {
111+
color: #939294;
112+
}

0 commit comments

Comments
 (0)