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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6828b103b20f4146b1d1dab950c3406ead00ce81
4
- data.tar.gz: bb140e077caeb3f704a9fa1b599c08891a971c54
3
+ metadata.gz: f5ed68db56f43eea742583e0beea346b72c197d6
4
+ data.tar.gz: 39050055ae78300950b648c6c1b3cd41a8bef30e
5
5
  SHA512:
6
- metadata.gz: 36fc67ddacafe8ee708b52dded407224dd5c9126e8ef3608b66ae6022f85ee9a50eedafcefab021c82baaa44a01ab3398d5b4ff3144720f0a722aff561c650f4
7
- data.tar.gz: eeb92cc7a3322cb1363aba9a5416d1ba1227e509691874042de5ced26a79a973774506bd7c47fb3fd48ea3fd409bcde6148af6d4a463347ad7e8821bc6d71071
6
+ metadata.gz: a2c2ab26b53ab4e848021c35da15996702c8302839ec2b84c16701927f503a75163e6bad390837122278f16d34dae818a45783d2c4c1d6ef389203cc7fd5a8ea
7
+ data.tar.gz: 5788bebedae4a24b984da72d8fb7d21b5a82ff514a0276cdf88c859fda4c5e9cc4c17b45a33829beb985e0d10c816aa4d846ed71481c1dcfcfa630ead178a639
@@ -1,10 +1,5 @@
1
- #include <char_size.h>
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
- return INT2NUM(ONIGENC_MBC_MINLEN(find_encoding(encoding_or_name)));
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
- return INT2NUM(ONIGENC_MBC_MAXLEN(find_encoding(encoding_or_name)));
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
- VALUE CharSize = rb_define_module("CharSize");
35
- rb_define_singleton_method(CharSize, "min", min, 1);
36
- rb_define_singleton_method(CharSize, "max", max, 1);
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
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CharSize
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
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.0
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-22 00:00:00.000000000 Z
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
@@ -1,6 +0,0 @@
1
- #pragma once
2
-
3
- #include <ruby.h>
4
- #include <ruby/encoding.h>
5
-
6
- #include <char_size.h>