symbol_lookup 1.1.0 → 1.2.0
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.
- data/ext/symbol_lookup/SymbolLookup.c +48 -5
- metadata +17 -18
- checksums.yaml +0 -7
@@ -1,12 +1,40 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2013, Matthew Kerwin
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
6
|
+
* modification, are permitted provided that the following conditions are met:
|
7
|
+
*
|
8
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
* list of conditions and the following disclaimer.
|
10
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
* this list of conditions and the following disclaimer in the documentation
|
12
|
+
* and/or other materials provided with the distribution.
|
13
|
+
*
|
14
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
15
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
16
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
17
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
18
|
+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
19
|
+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
20
|
+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
21
|
+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
22
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
23
|
+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
24
|
+
*/
|
25
|
+
|
1
26
|
#include "ruby.h"
|
2
27
|
|
3
28
|
/*
|
4
29
|
* call-seq:
|
30
|
+
* Symbol.find str => Symbol or nil
|
5
31
|
* Symbol[str] => Symbol or nil
|
6
32
|
*
|
7
33
|
* Returns an extant symbol, which is the .to_sym of +str+, or
|
8
34
|
* nil if no such symbol exists.
|
9
35
|
*
|
36
|
+
* Symbol.find('Object') #=> :Object
|
37
|
+
* Symbol.find('none such') #=> nil
|
10
38
|
* Symbol['Object'] #=> :Object
|
11
39
|
* Symbol['none such'] #=> nil
|
12
40
|
*/
|
@@ -23,14 +51,14 @@ sym_lookup(VALUE cls, VALUE str)
|
|
23
51
|
|
24
52
|
/*
|
25
53
|
* call-seq:
|
26
|
-
* str.interned
|
54
|
+
* str.interned? -> symbol
|
27
55
|
*
|
28
56
|
* Returns the <code>Symbol</code> corresponding to <i>str</i>, returning
|
29
57
|
* nil if it did not previously exist. See <code>Symbol[str]</code>.
|
30
58
|
*
|
31
59
|
* x = :banana
|
32
|
-
* "banana".interned
|
33
|
-
* "mango".interned
|
60
|
+
* "banana".interned? #=> :banana
|
61
|
+
* "mango".interned? #=> nil
|
34
62
|
*
|
35
63
|
*/
|
36
64
|
|
@@ -44,6 +72,18 @@ str_interned(VALUE str)
|
|
44
72
|
}
|
45
73
|
return Qnil;
|
46
74
|
}
|
75
|
+
VALUE
|
76
|
+
str_interned_dep(VALUE str)
|
77
|
+
{
|
78
|
+
rb_warn("String#interned is deprecated; use #interned? instead");
|
79
|
+
return str_interned(str);
|
80
|
+
}
|
81
|
+
VALUE
|
82
|
+
sym_interned_dep(VALUE sym)
|
83
|
+
{
|
84
|
+
rb_warn("Symbol#interned is deprecated; use #interned? instead");
|
85
|
+
return sym;
|
86
|
+
}
|
47
87
|
|
48
88
|
/*
|
49
89
|
* call-seq:
|
@@ -74,9 +114,12 @@ str_to_existing_sym(VALUE str)
|
|
74
114
|
|
75
115
|
void Init_symbol_lookup() {
|
76
116
|
rb_define_singleton_method(rb_cSymbol, "[]", sym_lookup, 1);
|
77
|
-
|
117
|
+
rb_define_singleton_method(rb_cSymbol, "find", sym_lookup, 1);
|
118
|
+
rb_define_method(rb_cSymbol, "interned", sym_interned_dep, 0);
|
119
|
+
rb_define_alias(rb_cSymbol, "interned?", "intern");
|
78
120
|
rb_define_alias(rb_cSymbol, "to_existing_sym", "to_sym");
|
79
121
|
|
80
|
-
rb_define_method(rb_cString, "interned",
|
122
|
+
rb_define_method(rb_cString, "interned", str_interned_dep, 0);
|
123
|
+
rb_define_method(rb_cString, "interned?", str_interned, 0);
|
81
124
|
rb_define_method(rb_cString, "to_existing_sym", str_to_existing_sym, 0);
|
82
125
|
}
|
metadata
CHANGED
@@ -1,22 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: symbol_lookup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Matthew Kerwin
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2014-02-26 00:00:00.000000000 Z
|
12
13
|
dependencies: []
|
13
|
-
description:
|
14
|
-
A gemified version of the Symbol[str] method proposed in https://bugs.ruby-lang.org/issues/7854
|
15
|
-
|
16
|
-
Version 1.1.0 defines:
|
17
|
-
- Symbol[str] => Symbol or nil
|
18
|
-
- String#interned => Symbol or nil
|
19
|
-
- String#to_existing_sym => Symbol or exception
|
14
|
+
description: A gemified version of the Symbol.find(str) method
|
20
15
|
email: matthew@kerwin.net.au
|
21
16
|
executables: []
|
22
17
|
extensions:
|
@@ -27,12 +22,11 @@ files:
|
|
27
22
|
- ext/symbol_lookup/extconf.rb
|
28
23
|
homepage: http://rubygems.org/gems/symbol_lookup
|
29
24
|
licenses:
|
30
|
-
-
|
31
|
-
metadata: {}
|
25
|
+
- ISC
|
32
26
|
post_install_message:
|
33
27
|
rdoc_options:
|
34
28
|
- --title
|
35
|
-
- Symbol
|
29
|
+
- Symbol.find
|
36
30
|
- --main
|
37
31
|
- Symbol
|
38
32
|
- --line-numbers
|
@@ -41,19 +35,24 @@ rdoc_options:
|
|
41
35
|
require_paths:
|
42
36
|
- lib
|
43
37
|
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
44
39
|
requirements:
|
45
|
-
- - '>='
|
40
|
+
- - ! '>='
|
46
41
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.0
|
42
|
+
version: '2.0'
|
43
|
+
- - <
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '2.2'
|
48
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
49
48
|
requirements:
|
50
|
-
- - '>='
|
49
|
+
- - ! '>='
|
51
50
|
- !ruby/object:Gem::Version
|
52
51
|
version: '0'
|
53
52
|
requirements: []
|
54
53
|
rubyforge_project:
|
55
|
-
rubygems_version:
|
54
|
+
rubygems_version: 1.8.23.2
|
56
55
|
signing_key:
|
57
|
-
specification_version:
|
58
|
-
summary: Symbol
|
56
|
+
specification_version: 3
|
57
|
+
summary: Symbol.find
|
59
58
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 8552cbf7c041894da45719e3a1251a4e274455d7
|
4
|
-
data.tar.gz: d4d3dcea61bd3241be9e8cecbf396eecbc434be2
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 2a062b1bab8390e5656bb68f62cad16dad05b4f00d9dc8513674a83a396c3fa555f1a9dd150aaf2fe7002f6d97d0c7db65221805142d4cb1b7e94ae1c6cfd145
|
7
|
-
data.tar.gz: 78ae46266ac6c34f1e8e229191a676b5c08a7bde9a62e34d0400f4f531d10c5b3952082104e1d375fb479eeaccd6880520c59d1154cab2f33624dd3c0596ff41
|