Move proquint from Godeps to gx
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
Jakub Sztandera committed
May 19, 2016 at 12:33 UTC
f96bf86fe4dbf632d1c7e88eba9ddeb1a9368df7
5 files changed
+11
-138
Godeps/Godeps.json
-4
@@ -9,10 +9,6 @@
9
"ImportPath": "bazil.org/fuse",
10
"Rev": "e4fcc9a2c7567d1c42861deebeb483315d222262"
11
},
12
- {
13
- "ImportPath": "github.com/bren2010/proquint",
14
- "Rev": "5958552242606512f714d2e93513b380f43f9991"
15
- },
12
{
13
"ImportPath": "github.com/briantigerchow/pubsub",
14
"Rev": "39ce5f556423a4c7223b370fa17a3bbd75b2d197"
Godeps/_workspace/src/github.com/bren2010/proquint/README.md
deleted
-6
@@ -1,6 +0,0 @@
1
-Proquint
2
--------
3
-
4
-Golang implementation of [Proquint Pronounceable Identifiers](https://github.com/deoxxa/proquint).
5
-
6
-
Godeps/_workspace/src/github.com/bren2010/proquint/proquint.go
deleted
-123
@@ -1,123 +0,0 @@
1
-/*
2
-Copyright (c) 2014 Brendan McMillion
3
-
4
-Permission is hereby granted, free of charge, to any person obtaining a copy
5
-of this software and associated documentation files (the "Software"), to deal
6
-in the Software without restriction, including without limitation the rights
7
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
-copies of the Software, and to permit persons to whom the Software is
9
-furnished to do so, subject to the following conditions:
10
-
11
-The above copyright notice and this permission notice shall be included in
12
-all copies or substantial portions of the Software.
13
-
14
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
-THE SOFTWARE.
21
-*/
22
-
23
-package proquint
24
-
25
-import (
26
- "bytes"
27
- "strings"
28
- "regexp"
29
-)
30
-
31
-var (
32
- conse = [...]byte{'b', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n',
33
- 'p', 'r', 's', 't', 'v', 'z'}
34
- vowse = [...]byte{'a', 'i', 'o', 'u'}
35
-
36
- consd = map[byte] uint16 {
37
- 'b' : 0, 'd' : 1, 'f' : 2, 'g' : 3,
38
- 'h' : 4, 'j' : 5, 'k' : 6, 'l' : 7,
39
- 'm' : 8, 'n' : 9, 'p' : 10, 'r' : 11,
40
- 's' : 12, 't' : 13, 'v' : 14, 'z' : 15,
41
- }
42
-
43
- vowsd = map[byte] uint16 {
44
- 'a' : 0, 'i' : 1, 'o' : 2, 'u' : 3,
45
- }
46
-)
47
-
48
-/**
49
-* Tests if a given string is a Proquint identifier
50
-*
51
-* @param {string} str The candidate string.
52
-*
53
-* @return {bool} Whether or not it qualifies.
54
-* @return {error} Error
55
-*/
56
-func IsProquint(str string) (bool, error) {
57
- exp := "^([abdfghijklmnoprstuvz]{5}-)*[abdfghijklmnoprstuvz]{5}$"
58
- ok, err := regexp.MatchString(exp, str)
59
-
60
- return ok, err
61
-}
62
-
63
-/**
64
-* Encodes an arbitrary byte slice into an identifier.
65
-*
66
-* @param {[]byte} buf Slice of bytes to encode.
67
-*
68
-* @return {string} The given byte slice as an identifier.
69
-*/
70
-func Encode(buf []byte) string {
71
- var out bytes.Buffer
72
-
73
- for i := 0; i < len(buf); i = i + 2 {
74
- var n uint16 = (uint16(buf[i]) * 256) + uint16(buf[i + 1])
75
-
76
- var (
77
- c1 = n & 0x0f
78
- v1 = (n >> 4) & 0x03
79
- c2 = (n >> 6) & 0x0f
80
- v2 = (n >> 10) & 0x03
81
- c3 = (n >> 12) & 0x0f
82
- )
83
-
84
- out.WriteByte(conse[c1])
85
- out.WriteByte(vowse[v1])
86
- out.WriteByte(conse[c2])
87
- out.WriteByte(vowse[v2])
88
- out.WriteByte(conse[c3])
89
-
90
- if (i + 2) < len(buf) {
91
- out.WriteByte('-')
92
- }
93
- }
94
-
95
- return out.String()
96
-}
97
-
98
-/**
99
-* Decodes an identifier into its corresponding byte slice.
100
-*
101
-* @param {string} str Identifier to convert.
102
-*
103
-* @return {[]byte} The identifier as a byte slice.
104
-*/
105
-func Decode(str string) []byte {
106
- var (
107
- out bytes.Buffer
108
- bits []string = strings.Split(str, "-")
109
- )
110
-
111
- for i := 0; i < len(bits); i++ {
112
- var x uint16 = consd[bits[i][0]] +
113
- (vowsd[bits[i][1]] << 4) +
114
- (consd[bits[i][2]] << 6) +
115
- (vowsd[bits[i][3]] << 10) +
116
- (consd[bits[i][4]] << 12)
117
-
118
- out.WriteByte(byte(x >> 8))
119
- out.WriteByte(byte(x))
120
- }
121
-
122
- return out.Bytes()
123
-}
namesys/proquint.go
+1
-1
@@ -3,8 +3,8 @@ package namesys
3
import (
4
"errors"
5
6
- proquint "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/bren2010/proquint"
6
path "github.com/ipfs/go-ipfs/path"
7
+ proquint "gx/ipfs/QmYnf27kzqR2cxt6LFZdrAFJuQd6785fTkBvMuEj9EeRxM/proquint"
8
context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
9
)
10
package.json
+10
-4
@@ -75,18 +75,24 @@
75
"hash": "QmcyaFHbyiZfoX5GTpcqqCPYmbjYNAhRDekXSJPFHdYNSV",
76
"name": "go.uuid",
77
"version": "1.0.0"
78
- },
79
- {
78
+ },
79
+ {
80
"author": "steakknife",
81
"hash": "QmeWQMDa5dSdP4n8WDeoY5z8L2EKVqF4ZvK4VEHsLqXsGu",
82
"name": "hamming",
83
"version": "0.0.10"
84
- },
85
- {
84
+ },
85
+ {
86
"author": "cenk",
87
"hash": "QmPJUtEJsm5YLUWhF6imvyCH8KZXRJa9Wup7FDMwTy5Ufz",
88
"name": "backoff",
89
"version": "1.0.0"
90
+ },
91
+ {
92
+ "author": "Bren2010",
93
+ "hash": "QmYnf27kzqR2cxt6LFZdrAFJuQd6785fTkBvMuEj9EeRxM",
94
+ "name": "proquint",
95
+ "version": "0.0.0"
96
}
97
],
98
"gxVersion": "0.4.0",