char_size 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/char_size/char_size.c +13 -15
- data/lib/char_size/version.rb +1 -1
- metadata +2 -3
- data/ext/char_size/char_size.h +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5ed68db56f43eea742583e0beea346b72c197d6
|
4
|
+
data.tar.gz: 39050055ae78300950b648c6c1b3cd41a8bef30e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2c2ab26b53ab4e848021c35da15996702c8302839ec2b84c16701927f503a75163e6bad390837122278f16d34dae818a45783d2c4c1d6ef389203cc7fd5a8ea
|
7
|
+
data.tar.gz: 5788bebedae4a24b984da72d8fb7d21b5a82ff514a0276cdf88c859fda4c5e9cc4c17b45a33829beb985e0d10c816aa4d846ed71481c1dcfcfa630ead178a639
|
data/ext/char_size/char_size.c
CHANGED
@@ -1,10 +1,5 @@
|
|
1
|
-
#include <
|
2
|
-
|
3
|
-
static rb_encoding* find_encoding(VALUE encoding_or_name) {
|
4
|
-
rb_encoding* encoding = rb_find_encoding(encoding_or_name);
|
5
|
-
if (encoding == NULL) rb_raise(rb_eArgError, "unknown encoding name - %"PRIsVALUE, encoding_or_name);
|
6
|
-
return encoding;
|
7
|
-
}
|
1
|
+
#include <ruby.h>
|
2
|
+
#include <ruby/encoding.h>
|
8
3
|
|
9
4
|
/*
|
10
5
|
* Gets the minimum character size (in bytes) for an encoding.
|
@@ -14,8 +9,9 @@ static rb_encoding* find_encoding(VALUE encoding_or_name) {
|
|
14
9
|
* CharSize.min("UTF-8") # => 1
|
15
10
|
* CharSize.min(Encoding::UTF_8) # => 1
|
16
11
|
*/
|
17
|
-
static VALUE min(VALUE class, VALUE encoding_or_name)
|
18
|
-
|
12
|
+
static VALUE min(VALUE class, VALUE encoding_or_name)
|
13
|
+
{
|
14
|
+
return INT2NUM(ONIGENC_MBC_MINLEN(rb_to_encoding(encoding_or_name)));
|
19
15
|
}
|
20
16
|
|
21
17
|
/*
|
@@ -26,12 +22,14 @@ static VALUE min(VALUE class, VALUE encoding_or_name) {
|
|
26
22
|
* CharSize.max("UTF-8") # => 6
|
27
23
|
* CharSize.max(Encoding::UTF_8) # => 6
|
28
24
|
*/
|
29
|
-
static VALUE max(VALUE class, VALUE encoding_or_name)
|
30
|
-
|
25
|
+
static VALUE max(VALUE class, VALUE encoding_or_name)
|
26
|
+
{
|
27
|
+
return INT2NUM(ONIGENC_MBC_MAXLEN(rb_to_encoding(encoding_or_name)));
|
31
28
|
}
|
32
29
|
|
33
|
-
void Init_char_size()
|
34
|
-
|
35
|
-
|
36
|
-
|
30
|
+
void Init_char_size()
|
31
|
+
{
|
32
|
+
VALUE CharSize = rb_define_module("CharSize");
|
33
|
+
rb_define_singleton_method(CharSize, "min", min, 1);
|
34
|
+
rb_define_singleton_method(CharSize, "max", max, 1);
|
37
35
|
}
|
data/lib/char_size/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: char_size
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Haines
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -129,7 +129,6 @@ files:
|
|
129
129
|
- bin/setup
|
130
130
|
- char_size.gemspec
|
131
131
|
- ext/char_size/char_size.c
|
132
|
-
- ext/char_size/char_size.h
|
133
132
|
- ext/char_size/extconf.rb
|
134
133
|
- lib/char_size.rb
|
135
134
|
- lib/char_size/rake/char_size.rb.erb
|