Skip to content

Commit 68cbf41

Browse files
committed
initial
0 parents  commit 68cbf41

6 files changed

+151
-0
lines changed

.editorconfig

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[*]
2+
indent_style = space
3+
insert_final_newline = true
4+
indent_size = 2
5+
trim_trailing_whitespace = true

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Andy Davidoff
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# datamuse
2+
3+
- `cpp +/ nim-1.0` [![Build Status](https://travis-ci.org/disruptek/datamuse.svg?branch=master)](https://travis-ci.org/disruptek/datamuse)
4+
- `arc +/ cpp +/ nim-1.3` [![Build Status](https://travis-ci.org/disruptek/datamuse.svg?branch=devel)](https://travis-ci.org/disruptek/datamuse)
5+
6+
An interface to the datamuse API.
7+
8+
## Installation
9+
```
10+
$ nimble install datamuse
11+
```
12+
13+
## Usage
14+
```nim
15+
import std/asyncdispatch
16+
17+
import rest
18+
import datamuse
19+
20+
var
21+
call = newDataMuseCall {"rel_rhy": rhyme}
22+
let
23+
request = newRecallable(call)
24+
response = request.retried
25+
echo waitfor response.body
26+
```
27+
28+
## Documentation
29+
See [the documentation for the datamuse module](https://disruptek.github.io/datamuse/datamuse.html) as generated directly from the source.
30+
31+
## Tests
32+
```
33+
$ nimble test
34+
```
35+
36+
## License
37+
MIT

datamuse.nim

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import std/uri
2+
import std/asyncdispatch
3+
import std/httpclient
4+
import std/options
5+
6+
import rest
7+
import cutelog
8+
import bump
9+
10+
const
11+
datamuseUrl = "https://api.datamuse.com/words".parseUri
12+
13+
proc newDataMuseCall*(args: openArray[tuple[key, val: string]];
14+
name = "datamuse"): RestCall =
15+
result = RestCall(name: name, meth: HttpGet, url: datamuseUrl ? args)
16+
17+
proc name(rhyme = "") =
18+
19+
var
20+
call = newDataMuseCall {"rel_rhy": rhyme}
21+
let
22+
request = newRecallable(call)
23+
response = request.retried
24+
debug waitfor response.body
25+
26+
when isMainModule:
27+
import cligen
28+
29+
let
30+
logger = newCuteConsoleLogger()
31+
addHandler(logger)
32+
33+
# find the version
34+
const
35+
version = projectVersion()
36+
if version.isSome:
37+
clCfg.version = $version.get
38+
else:
39+
clCfg.version = "(unknown version)"
40+
41+
dispatchCf name, cmdName = "name", cf = clCfg
42+
when false:
43+
dispatchCf name, cmdName = "name", cf = clCfg,
44+
usage = "Options(opt-arg sep :|=|spc):\n$options",
45+
help = {
46+
"patch": "increment the patch version field",
47+
"minor": "increment the minor version field",
48+
"major": "increment the major version field",
49+
"dry-run": "just report the projected version",
50+
"commit": "also commit any other unstaged changes",
51+
"v": "prefix the version tag with an ugly `v`",
52+
"nimble": "specify the nimble file to modify",
53+
"folder": "specify the location of the nimble file",
54+
"release": "also use `hub` to issue a GitHub release",
55+
"log-level": "specify Nim logging level",
56+
"manual": "manually set the new version to #.#.#",
57+
}

datamuse.nim.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--out:muse
2+
--define:ssl

datamuse.nimble

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version = "0.0.1"
2+
author = "disruptek"
3+
description = "generate random names"
4+
license = "MIT"
5+
requires "nim >= 1.0.0"
6+
requires "cligen < 1.0.0"
7+
requires "https://github.com/disruptek/cutelog < 2.0.0"
8+
requires "https://github.com/disruptek/rest < 2.0.0"
9+
requires "https://github.com/disruptek/bump < 2.0.0"
10+
11+
bin = @["muse"]
12+
13+
proc execCmd(cmd: string) =
14+
echo "execCmd:" & cmd
15+
exec cmd
16+
17+
proc execTest(test: string) =
18+
execCmd "nim c -f -r " & test
19+
execCmd "nim c -d:release -r " & test
20+
execCmd "nim c -d:danger -r " & test
21+
execCmd "nim cpp -r " & test
22+
execCmd "nim cpp -d:danger -r " & test
23+
when NimMajor >= 1 and NimMinor >= 1:
24+
execCmd "nim c --useVersion:1.0 -d:danger -r " & test
25+
execCmd "nim c --gc:arc -r " & test
26+
execCmd "nim cpp --gc:arc -r " & test
27+
28+
task test, "run tests for travis":
29+
execTest("tests/tmuse.nim")

0 commit comments

Comments
 (0)