omnomnum 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ext/omnomnum/extconf.rb +51 -0
- data/ext/omnomnum/omnomnum/branchlut/branchlut.c +276 -0
- data/ext/omnomnum/omnomnum/branchlut/branchlut.h +14 -0
- data/ext/omnomnum/omnomnum/dtoa.c +68 -0
- data/ext/omnomnum/omnomnum/dtoa.h +39 -0
- data/ext/omnomnum/omnomnum/grisu2/diy_fp.h +61 -0
- data/ext/omnomnum/omnomnum/grisu2/double.h +121 -0
- data/ext/omnomnum/omnomnum/grisu2/fast_exponent.h +44 -0
- data/ext/omnomnum/omnomnum/grisu2/grisu2.c +120 -0
- data/ext/omnomnum/omnomnum/grisu2/grisu2.h +36 -0
- data/ext/omnomnum/omnomnum/grisu2/k_comp.h +32 -0
- data/ext/omnomnum/omnomnum/grisu2/powers.h +27 -0
- data/ext/omnomnum/omnomnum/grisu2/powers_ten_round64.h +36 -0
- data/ext/omnomnum/omnomnum/grisu2/prettify.h +76 -0
- data/ext/omnomnum/omnomnum/itoa.c +40 -0
- data/ext/omnomnum/omnomnum/itoa.h +40 -0
- data/ext/omnomnum/omnomnum/main.c +87 -0
- data/ext/omnomnum/omnomnum/omnomnum.c +208 -0
- data/ext/omnomnum/omnomnum/omnomnum.h +47 -0
- data/ext/omnomnum/omnomnum/parser.c +3445 -0
- data/ext/omnomnum/omnomnum/parser.h +130 -0
- data/ext/omnomnum/omnomnum/scan.c +55 -0
- data/ext/omnomnum/omnomnum/scan.h +68 -0
- data/ext/omnomnum/omnomnum/scanner.c +4332 -0
- data/ext/omnomnum/omnomnum/scanner.def.c +97 -0
- data/ext/omnomnum/omnomnum/scanner.def.h +105 -0
- data/ext/omnomnum/omnomnum/scanner.h +44 -0
- data/ext/omnomnum/omnomnum/sds.c +1278 -0
- data/ext/omnomnum/omnomnum/sds.h +280 -0
- data/ext/omnomnum/omnomnum/sdsalloc.h +43 -0
- data/ext/omnomnum/omnomnum/test/test_benchmark.c +107 -0
- data/ext/omnomnum/omnomnum/test/test_omnomnum.c +146 -0
- data/ext/omnomnum/omnomnum/test/test_omnomnum.h +6 -0
- data/ext/omnomnum/omnomnum/test/test_util.c +98 -0
- data/ext/omnomnum/omnomnum/util.c +84 -0
- data/ext/omnomnum/omnomnum/util.h +43 -0
- data/ext/omnomnum/ruby_omnomnum.c +96 -0
- data/ext/omnomnum/ruby_omnomnum.h +40 -0
- data/lib/omnomnum.rb +31 -0
- data/lib/omnomnum/omnomnum.so +0 -0
- data/lib/omnomnum/version.rb +32 -0
- metadata +114 -0
@@ -0,0 +1,98 @@
|
|
1
|
+
#if defined (__cplusplus)
|
2
|
+
extern "C" {
|
3
|
+
#endif
|
4
|
+
#include "../util.h"
|
5
|
+
#if defined (__cplusplus)
|
6
|
+
}
|
7
|
+
#endif
|
8
|
+
|
9
|
+
#include <gtest/gtest.h>
|
10
|
+
#include <yaml-cpp/yaml.h>
|
11
|
+
|
12
|
+
#include <iostream>
|
13
|
+
#include <fstream>
|
14
|
+
#include <string>
|
15
|
+
#include <vector>
|
16
|
+
|
17
|
+
using ::testing::InitGoogleTest;
|
18
|
+
|
19
|
+
struct TestCase {
|
20
|
+
std::string input;
|
21
|
+
std::string expect;
|
22
|
+
char remove;
|
23
|
+
};
|
24
|
+
|
25
|
+
std::ostream& operator << (std::ostream &o, const TestCase &test_case) {
|
26
|
+
o << "<TestCase(input=\"" << test_case.input << "\", expect=\"" << test_case.expect << "\")>";
|
27
|
+
return o;
|
28
|
+
}
|
29
|
+
|
30
|
+
void operator >> (const YAML::Node& node, TestCase& test_case) {
|
31
|
+
test_case.input = node[0].as<std::string>();
|
32
|
+
test_case.expect = node[1].as<std::string>();
|
33
|
+
test_case.remove = node[2].as<char>();
|
34
|
+
}
|
35
|
+
|
36
|
+
class Util : public testing::TestWithParam<TestCase> {};
|
37
|
+
|
38
|
+
TEST_P(Util, remove_char_inplace) {
|
39
|
+
const char* input = GetParam().input.c_str();
|
40
|
+
char* modify = (char*)malloc(strlen(input) + 1);
|
41
|
+
strcpy(modify, input);
|
42
|
+
const char* expect = GetParam().expect.c_str();
|
43
|
+
char remove = GetParam().remove;
|
44
|
+
|
45
|
+
size_t modify_len = remove_char_inplace(modify, strlen(modify), remove);
|
46
|
+
|
47
|
+
ASSERT_TRUE(strcmp(expect, modify) == 0) << "expected \"" << expect << "\" given \"" << input << "\", actual \"" << modify << "\"\n";
|
48
|
+
ASSERT_TRUE(strlen(modify) == modify_len) << "expected \"" << strlen(input) << "\" given \"" << modify << "\", actual \"" << modify_len << "\"\n";
|
49
|
+
}
|
50
|
+
|
51
|
+
std::vector<TestCase> ReadTestCasesFromDisk(std::string filename) {
|
52
|
+
YAML::Node doc = YAML::LoadFile(filename);
|
53
|
+
|
54
|
+
std::vector<TestCase> input;
|
55
|
+
for (unsigned i=0; i < doc.size(); i++) {
|
56
|
+
TestCase test_case;
|
57
|
+
doc[i] >> test_case;
|
58
|
+
input.push_back(test_case);
|
59
|
+
}
|
60
|
+
|
61
|
+
return input;
|
62
|
+
}
|
63
|
+
|
64
|
+
INSTANTIATE_TEST_CASE_P(
|
65
|
+
Tests,
|
66
|
+
Util,
|
67
|
+
testing::ValuesIn(ReadTestCasesFromDisk("remove_char_inplace.yml")));
|
68
|
+
|
69
|
+
void printlen(char *value, int len) {
|
70
|
+
int i;
|
71
|
+
for (i = 0; i < len; i++) {
|
72
|
+
if (value[i] != 0) {
|
73
|
+
printf("%c", value[i]);
|
74
|
+
} else {
|
75
|
+
printf("\\0");
|
76
|
+
}
|
77
|
+
}
|
78
|
+
printf("\n");
|
79
|
+
}
|
80
|
+
|
81
|
+
TEST(Util, ReplaceCharInplace) {
|
82
|
+
char input[] = "foo-bar-baz-";
|
83
|
+
const char expect[] = "foo bar baz ";
|
84
|
+
|
85
|
+
replace_char_inplace(input, strlen(input), '-', ' ');
|
86
|
+
|
87
|
+
ASSERT_TRUE(strcmp(expect, input) == 0);
|
88
|
+
}
|
89
|
+
|
90
|
+
TEST(Util, ReplaceTwoByteCharInplace) {
|
91
|
+
char input[] = "foo·bar·baz·";
|
92
|
+
const char expect[] = "foo bar baz ";
|
93
|
+
|
94
|
+
size_t new_len = replace_two_byte_char_inplace((unsigned char*)input, strlen(input), (unsigned char*)"·", ' ');
|
95
|
+
|
96
|
+
ASSERT_TRUE(strcmp(expect, input) == 0);
|
97
|
+
ASSERT_TRUE(strlen(expect) == new_len);
|
98
|
+
}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
/* OmNomNum 0.0.2 -- Gobbles up numbers in strings.
|
2
|
+
*
|
3
|
+
* Copyright (c) 2017, Jesse Buesking <jessebuesking at gmail dot com>
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are met:
|
8
|
+
*
|
9
|
+
* * Redistributions of source code must retain the above copyright notice,
|
10
|
+
* this list of conditions and the following disclaimer.
|
11
|
+
* * Redistributions in binary form must reproduce the above copyright
|
12
|
+
* notice, this list of conditions and the following disclaimer in the
|
13
|
+
* documentation and/or other materials provided with the distribution.
|
14
|
+
* * Neither the name of OmNomNum nor the names of its contributors may be used
|
15
|
+
* to endorse or promote products derived from this software without
|
16
|
+
* specific prior written permission.
|
17
|
+
*
|
18
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
19
|
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
20
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
21
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
22
|
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
23
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26
|
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
*/
|
30
|
+
|
31
|
+
// for size_t
|
32
|
+
#include <stdlib.h>
|
33
|
+
|
34
|
+
// Given a char array and it's length (allowing for strings with nulls), modify
|
35
|
+
// the char array in-place removing the character supplied.
|
36
|
+
size_t remove_char_inplace(char *str, size_t str_len, const unsigned char remove) {
|
37
|
+
size_t orig_index = 0, new_index = 0;
|
38
|
+
for(;orig_index < str_len;) {
|
39
|
+
if (str[orig_index] == remove) {
|
40
|
+
orig_index += 1;
|
41
|
+
} else {
|
42
|
+
str[new_index] = str[orig_index];
|
43
|
+
orig_index += 1;
|
44
|
+
new_index += 1;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
str[new_index] = '\0';
|
49
|
+
return new_index;
|
50
|
+
}
|
51
|
+
|
52
|
+
// Given a char array, it's length (allowing for strings with nulls), a
|
53
|
+
// character to be removed and the character to replace it with, modify the
|
54
|
+
// char array in-place replacing the character.
|
55
|
+
void replace_char_inplace(char *str, size_t str_len, const unsigned char remove, const unsigned char replacement) {
|
56
|
+
size_t index = 0;
|
57
|
+
for(;index < str_len; index++) {
|
58
|
+
if (str[index] == remove) {
|
59
|
+
str[index] = replacement;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
// Given a char array, it's length (allowing for strings with nulls), a two-byte
|
65
|
+
// character to be removed and the character to replace it with, modify the
|
66
|
+
// char array in-place replacing the character. Useful for two-byte UTF-8
|
67
|
+
// characters.
|
68
|
+
size_t replace_two_byte_char_inplace(unsigned char *str, size_t str_len, const unsigned char* remove, const unsigned char replacement) {
|
69
|
+
size_t orig_index = 0, new_index = 0;
|
70
|
+
for(;orig_index < str_len - 1;) {
|
71
|
+
if (str[orig_index] == remove[0] && str[orig_index + 1] == remove[1]) {
|
72
|
+
str[new_index] = replacement;
|
73
|
+
orig_index += 2;
|
74
|
+
new_index += 1;
|
75
|
+
} else {
|
76
|
+
str[new_index] = str[orig_index];
|
77
|
+
orig_index += 1;
|
78
|
+
new_index += 1;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
str[new_index] = '\0';
|
83
|
+
return new_index;
|
84
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
/* OmNomNum 0.0.2 -- Gobbles up numbers in strings.
|
2
|
+
*
|
3
|
+
* Copyright (c) 2017, Jesse Buesking <jessebuesking at gmail dot com>
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are met:
|
8
|
+
*
|
9
|
+
* * Redistributions of source code must retain the above copyright notice,
|
10
|
+
* this list of conditions and the following disclaimer.
|
11
|
+
* * Redistributions in binary form must reproduce the above copyright
|
12
|
+
* notice, this list of conditions and the following disclaimer in the
|
13
|
+
* documentation and/or other materials provided with the distribution.
|
14
|
+
* * Neither the name of OmNomNum nor the names of its contributors may be used
|
15
|
+
* to endorse or promote products derived from this software without
|
16
|
+
* specific prior written permission.
|
17
|
+
*
|
18
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
19
|
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
20
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
21
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
22
|
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
23
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26
|
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
*/
|
30
|
+
|
31
|
+
#ifndef OMNOMNUM_UTIL_H
|
32
|
+
#define OMNOMNUM_UTIL_H
|
33
|
+
|
34
|
+
// for size_t
|
35
|
+
#include <stdlib.h>
|
36
|
+
|
37
|
+
size_t remove_char_inplace(const char *str, size_t str_len, const unsigned char remove);
|
38
|
+
|
39
|
+
void replace_char_inplace(char *str, size_t str_len, const unsigned char remove, const unsigned char replacement);
|
40
|
+
|
41
|
+
size_t replace_two_byte_char_inplace(unsigned char *str, size_t str_len, const unsigned char* remove, const unsigned char replacement);
|
42
|
+
|
43
|
+
#endif
|
@@ -0,0 +1,96 @@
|
|
1
|
+
/* OmNomNum 0.0.2 -- Gobbles up numbers in strings.
|
2
|
+
*
|
3
|
+
* Copyright (c) 2017, Jesse Buesking <jessebuesking at gmail dot com>
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are met:
|
8
|
+
*
|
9
|
+
* * Redistributions of source code must retain the above copyright notice,
|
10
|
+
* this list of conditions and the following disclaimer.
|
11
|
+
* * Redistributions in binary form must reproduce the above copyright
|
12
|
+
* notice, this list of conditions and the following disclaimer in the
|
13
|
+
* documentation and/or other materials provided with the distribution.
|
14
|
+
* * Neither the name of OmNomNum nor the names of its contributors may be used
|
15
|
+
* to endorse or promote products derived from this software without
|
16
|
+
* specific prior written permission.
|
17
|
+
*
|
18
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
19
|
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
20
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
21
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
22
|
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
23
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26
|
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
*/
|
30
|
+
|
31
|
+
#include "ruby_omnomnum.h"
|
32
|
+
#include <ruby/encoding.h>
|
33
|
+
|
34
|
+
VALUE mOmNomNum;
|
35
|
+
VALUE parse_second_symbol;
|
36
|
+
|
37
|
+
ParserState state;
|
38
|
+
int utf8_encoding;
|
39
|
+
|
40
|
+
// for debugging
|
41
|
+
/*int do_print(VALUE key, VALUE val, VALUE in) {*/
|
42
|
+
/*fprintf(*/
|
43
|
+
/*stderr,*/
|
44
|
+
/*"Key %s => Value %d\n", rb_id2name(SYM2ID(key)), RTEST(val));*/
|
45
|
+
|
46
|
+
/*return ST_CONTINUE;*/
|
47
|
+
/*}*/
|
48
|
+
|
49
|
+
static VALUE ruby_omnomnum_normalize(int argc, VALUE *argv, VALUE self)
|
50
|
+
{
|
51
|
+
// the actual string to be normalized
|
52
|
+
VALUE input_string;
|
53
|
+
// hash of optional parameters
|
54
|
+
VALUE opts;
|
55
|
+
|
56
|
+
// takes in:
|
57
|
+
// '1' 1 required argument (string to normalize)
|
58
|
+
// ':' hash of optional arguments
|
59
|
+
rb_scan_args(argc, argv, "1:", &input_string, &opts);
|
60
|
+
|
61
|
+
// if the hash of optional arguments is nil, just set it equal
|
62
|
+
// to the default empty hash we've saved globally.
|
63
|
+
if (NIL_P(opts)) opts = rb_hash_new();
|
64
|
+
|
65
|
+
// for debugging
|
66
|
+
/*rb_hash_foreach(opts, do_print, Qnil);*/
|
67
|
+
|
68
|
+
VALUE ruby_parse_second = rb_hash_aref(opts, parse_second_symbol);
|
69
|
+
if (!NIL_P(ruby_parse_second)) {
|
70
|
+
state.parse_second = RTEST(ruby_parse_second);
|
71
|
+
}
|
72
|
+
|
73
|
+
char *data = StringValuePtr(input_string);
|
74
|
+
size_t data_len = RSTRING_LEN(input_string);
|
75
|
+
|
76
|
+
normalize(data, data_len, &state);
|
77
|
+
|
78
|
+
VALUE _string = rb_str_new(state.result, sdslen(state.result));
|
79
|
+
|
80
|
+
resetParserState(&state);
|
81
|
+
|
82
|
+
rb_enc_associate_index(_string, utf8_encoding);
|
83
|
+
return _string;
|
84
|
+
}
|
85
|
+
|
86
|
+
void Init_omnomnum()
|
87
|
+
{
|
88
|
+
// initialize our global variables
|
89
|
+
parse_second_symbol = ID2SYM(rb_intern("parse_second"));
|
90
|
+
utf8_encoding = rb_enc_find_index("UTF-8");
|
91
|
+
|
92
|
+
initOmNomNum();
|
93
|
+
initParserState(&state);
|
94
|
+
VALUE mOmNomNum = rb_define_module("OmNomNum");
|
95
|
+
rb_define_singleton_method(mOmNomNum, "normalize", ruby_omnomnum_normalize, -1);
|
96
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
/* OmNomNum 0.0.2 -- Gobbles up numbers in strings.
|
2
|
+
*
|
3
|
+
* Copyright (c) 2017, Jesse Buesking <jessebuesking at gmail dot com>
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are met:
|
8
|
+
*
|
9
|
+
* * Redistributions of source code must retain the above copyright notice,
|
10
|
+
* this list of conditions and the following disclaimer.
|
11
|
+
* * Redistributions in binary form must reproduce the above copyright
|
12
|
+
* notice, this list of conditions and the following disclaimer in the
|
13
|
+
* documentation and/or other materials provided with the distribution.
|
14
|
+
* * Neither the name of OmNomNum nor the names of its contributors may be used
|
15
|
+
* to endorse or promote products derived from this software without
|
16
|
+
* specific prior written permission.
|
17
|
+
*
|
18
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
19
|
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
20
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
21
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
22
|
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
23
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26
|
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
*/
|
30
|
+
|
31
|
+
#ifndef RUBY_OMNOMNUM_H
|
32
|
+
#define RUBY_OMNOMNUM_H
|
33
|
+
|
34
|
+
#include <ruby.h>
|
35
|
+
|
36
|
+
#include "omnomnum/omnomnum.h"
|
37
|
+
|
38
|
+
extern VALUE mOmNomNum;
|
39
|
+
|
40
|
+
#endif // RUBY_OMNOMNUM_H
|
data/lib/omnomnum.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# OmNomNum 0.0.2 -- Gobbles up numbers in strings.
|
2
|
+
#
|
3
|
+
# Copyright (c) 2017, Jesse Buesking <jessebuesking at gmail dot com>
|
4
|
+
# All rights reserved.
|
5
|
+
#
|
6
|
+
# Redistribution and use in source and binary forms, with or without
|
7
|
+
# modification, are permitted provided that the following conditions are met:
|
8
|
+
#
|
9
|
+
# * Redistributions of source code must retain the above copyright notice,
|
10
|
+
# this list of conditions and the following disclaimer.
|
11
|
+
# * Redistributions in binary form must reproduce the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer in the
|
13
|
+
# documentation and/or other materials provided with the distribution.
|
14
|
+
# * Neither the name of OmNomNum nor the names of its contributors may be used
|
15
|
+
# to endorse or promote products derived from this software without
|
16
|
+
# specific prior written permission.
|
17
|
+
#
|
18
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
19
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
20
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
21
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
22
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
23
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
|
30
|
+
require 'omnomnum/omnomnum'
|
31
|
+
require 'omnomnum/version'
|
Binary file
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# OmNomNum 0.0.2 -- Gobbles up numbers in strings.
|
2
|
+
#
|
3
|
+
# Copyright (c) 2017, Jesse Buesking <jessebuesking at gmail dot com>
|
4
|
+
# All rights reserved.
|
5
|
+
#
|
6
|
+
# Redistribution and use in source and binary forms, with or without
|
7
|
+
# modification, are permitted provided that the following conditions are met:
|
8
|
+
#
|
9
|
+
# * Redistributions of source code must retain the above copyright notice,
|
10
|
+
# this list of conditions and the following disclaimer.
|
11
|
+
# * Redistributions in binary form must reproduce the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer in the
|
13
|
+
# documentation and/or other materials provided with the distribution.
|
14
|
+
# * Neither the name of OmNomNum nor the names of its contributors may be used
|
15
|
+
# to endorse or promote products derived from this software without
|
16
|
+
# specific prior written permission.
|
17
|
+
#
|
18
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
19
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
20
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
21
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
22
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
23
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
|
30
|
+
module OmNomNum
|
31
|
+
VERSION = "0.0.2"
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omnomnum
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jesse Buesking
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake-compiler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: OmNomNum normalizes numbers in ruby strings.
|
42
|
+
email:
|
43
|
+
- jessebuesking@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions:
|
46
|
+
- ext/omnomnum/extconf.rb
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ext/omnomnum/extconf.rb
|
50
|
+
- ext/omnomnum/omnomnum/branchlut/branchlut.c
|
51
|
+
- ext/omnomnum/omnomnum/branchlut/branchlut.h
|
52
|
+
- ext/omnomnum/omnomnum/dtoa.c
|
53
|
+
- ext/omnomnum/omnomnum/dtoa.h
|
54
|
+
- ext/omnomnum/omnomnum/grisu2/diy_fp.h
|
55
|
+
- ext/omnomnum/omnomnum/grisu2/double.h
|
56
|
+
- ext/omnomnum/omnomnum/grisu2/fast_exponent.h
|
57
|
+
- ext/omnomnum/omnomnum/grisu2/grisu2.c
|
58
|
+
- ext/omnomnum/omnomnum/grisu2/grisu2.h
|
59
|
+
- ext/omnomnum/omnomnum/grisu2/k_comp.h
|
60
|
+
- ext/omnomnum/omnomnum/grisu2/powers.h
|
61
|
+
- ext/omnomnum/omnomnum/grisu2/powers_ten_round64.h
|
62
|
+
- ext/omnomnum/omnomnum/grisu2/prettify.h
|
63
|
+
- ext/omnomnum/omnomnum/itoa.c
|
64
|
+
- ext/omnomnum/omnomnum/itoa.h
|
65
|
+
- ext/omnomnum/omnomnum/main.c
|
66
|
+
- ext/omnomnum/omnomnum/omnomnum.c
|
67
|
+
- ext/omnomnum/omnomnum/omnomnum.h
|
68
|
+
- ext/omnomnum/omnomnum/parser.c
|
69
|
+
- ext/omnomnum/omnomnum/parser.h
|
70
|
+
- ext/omnomnum/omnomnum/scan.c
|
71
|
+
- ext/omnomnum/omnomnum/scan.h
|
72
|
+
- ext/omnomnum/omnomnum/scanner.c
|
73
|
+
- ext/omnomnum/omnomnum/scanner.def.c
|
74
|
+
- ext/omnomnum/omnomnum/scanner.def.h
|
75
|
+
- ext/omnomnum/omnomnum/scanner.h
|
76
|
+
- ext/omnomnum/omnomnum/sds.c
|
77
|
+
- ext/omnomnum/omnomnum/sds.h
|
78
|
+
- ext/omnomnum/omnomnum/sdsalloc.h
|
79
|
+
- ext/omnomnum/omnomnum/test/test_benchmark.c
|
80
|
+
- ext/omnomnum/omnomnum/test/test_omnomnum.c
|
81
|
+
- ext/omnomnum/omnomnum/test/test_omnomnum.h
|
82
|
+
- ext/omnomnum/omnomnum/test/test_util.c
|
83
|
+
- ext/omnomnum/omnomnum/util.c
|
84
|
+
- ext/omnomnum/omnomnum/util.h
|
85
|
+
- ext/omnomnum/ruby_omnomnum.c
|
86
|
+
- ext/omnomnum/ruby_omnomnum.h
|
87
|
+
- lib/omnomnum.rb
|
88
|
+
- lib/omnomnum/omnomnum.so
|
89
|
+
- lib/omnomnum/version.rb
|
90
|
+
homepage: https://github.com/JesseBuesking/ruby_omnomnum
|
91
|
+
licenses:
|
92
|
+
- BSD-3-Clause
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: 1.3.6
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project: omnomnum
|
110
|
+
rubygems_version: 2.5.1
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Gobbles up numbers in strings.
|
114
|
+
test_files: []
|