ruby-bsdconv 10.0.0 → 11.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2b05eed033029fa06160d0f3a36ab6e41d5bf99
4
- data.tar.gz: e98db25abc50cfd0ea3e6266c714f3f0d9f0eecf
3
+ metadata.gz: 0066bb97b35708c2537ce5e757ba9bbcdb507a44
4
+ data.tar.gz: 7e09436a715d04d719d71a9f52c4a29a35f5cc00
5
5
  SHA512:
6
- metadata.gz: 95ebfc61ac166317a0bd57f4545369df61375cd73557a9aa8a1dbc5252213d95c7180895fb9cd89a2789dd8ea2447f9e9875bdcc5e6e53e4692898adf5cbf6c4
7
- data.tar.gz: 5f532a41a2064a6a157514e205c867103be6479728850aed95b39c0ed345994bfe1c5f0d46c05e1b712bec7b551fc22273004724357e7e1e0706b59bd2d850c6
6
+ metadata.gz: 3da4b1f5d9743358fda293bca924e022dfaa394104c6465873063ccdf3e326a4aa4c795911e002549981e1df9ab41257a66ed6178bb20c7f5581bf9434763748
7
+ data.tar.gz: f0cb64891797a31c7b225dd1b148cc17616f2604e28b3802c43f0115f837ee6f2e19ea19e34275ed88385fb014f37f2d0d47c65b709363a6ed04715fbe2c00e8
data/README CHANGED
@@ -1 +1,3 @@
1
+ https://rubygems.org/gems/ruby-bsdconv
2
+
1
3
  see example/* for examples
data/Rakefile CHANGED
@@ -9,10 +9,12 @@ desc 'Generate gemspec'
9
9
  task 'gem:spec' do
10
10
  Gemgem.spec = Gemgem.create do |s|
11
11
  s.name = 'ruby-bsdconv'
12
- s.version = '10.0.0'
12
+ s.version = '11.1.0'
13
13
  s.extensions = 'ext/ruby-bsdconv/extconf.rb'
14
14
  s.authors = ['Buganini Q']
15
+ s.email = 'buganini@gmail.com'
15
16
  s.homepage = 'https://github.com/buganini/ruby-bsdconv'
17
+ s.license = 'BSD'
16
18
  s.summary = 'ruby wrapper for bsdconv'
17
19
  s.description =
18
20
  "#{s.summary}. bsdconv is a BSD licensed charset/encoding converter" \
data/example/example.rb CHANGED
@@ -14,4 +14,4 @@ while $stdin.gets
14
14
  end
15
15
  puts c.conv_chunk_last('')
16
16
 
17
- p c.info
17
+ p c.counter
@@ -1,3 +1,18 @@
1
+ /*
2
+ * Copyright (c) 2011-2013 Kuan-Chung Chiu <buganini@gmail.com>
3
+ *
4
+ * Permission to use, copy, modify, and distribute this software for any
5
+ * purpose with or without fee is hereby granted, provided that the above
6
+ * copyright notice and this permission notice appear in all copies.
7
+ *
8
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
+ * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
13
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
14
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
+ */
1
16
  #include <ruby.h>
2
17
  #ifdef HAVE_RUBY_IO_H /* Ruby 1.9 and later */
3
18
  #include "ruby/io.h"
@@ -23,7 +38,8 @@ static VALUE m_ctl(VALUE, VALUE, VALUE, VALUE);
23
38
  static VALUE m_conv_chunk(VALUE, VALUE);
24
39
  static VALUE m_conv_chunk_last(VALUE, VALUE);
25
40
  static VALUE m_conv_file(VALUE, VALUE, VALUE);
26
- static VALUE m_info(VALUE);
41
+ static VALUE m_counter(int, VALUE *, VALUE);
42
+ static VALUE m_counter_reset(int, VALUE *, VALUE);
27
43
  static VALUE m_nil(VALUE);
28
44
  static VALUE m_inspect(VALUE);
29
45
 
@@ -48,7 +64,8 @@ void Init_bsdconv(){
48
64
  rb_define_method(Bsdconv, "conv_chunk", m_conv_chunk, 1);
49
65
  rb_define_method(Bsdconv, "conv_chunk_last", m_conv_chunk_last, 1);
50
66
  rb_define_method(Bsdconv, "conv_file", m_conv_file, 2);
51
- rb_define_method(Bsdconv, "info", m_info, 0);
67
+ rb_define_method(Bsdconv, "counter", m_counter, -1);
68
+ rb_define_method(Bsdconv, "counter_reset", m_counter_reset, -1);
52
69
  rb_define_method(Bsdconv, "inspect", m_inspect, 0);
53
70
 
54
71
  rb_define_const(Bsdconv, "FROM", INT2NUM(FROM));
@@ -93,6 +110,7 @@ static VALUE m_conv(VALUE self, VALUE str){
93
110
  ins->input.data=RSTRING_PTR(str);
94
111
  ins->input.len=RSTRING_LEN(str);
95
112
  ins->input.flags=0;
113
+ ins->input.next=NULL;
96
114
  ins->flush=1;
97
115
  bsdconv(ins);
98
116
  ret=rb_str_new(ins->output.data, ins->output.len);
@@ -130,6 +148,7 @@ static VALUE m_conv_chunk(VALUE self, VALUE str){
130
148
  ins->input.data=RSTRING_PTR(str);
131
149
  ins->input.len=RSTRING_LEN(str);
132
150
  ins->input.flags=0;
151
+ ins->input.next=NULL;
133
152
  bsdconv(ins);
134
153
  ret=rb_str_new(ins->output.data, ins->output.len);
135
154
  bsdconv_free(ins->output.data);
@@ -144,6 +163,7 @@ static VALUE m_conv_chunk_last(VALUE self, VALUE str){
144
163
  ins->input.data=RSTRING_PTR(str);
145
164
  ins->input.len=RSTRING_LEN(str);
146
165
  ins->input.flags=0;
166
+ ins->input.next=NULL;
147
167
  bsdconv(ins);
148
168
  ret=rb_str_new(ins->output.data, ins->output.len);
149
169
  bsdconv_free(ins->output.data);
@@ -190,6 +210,7 @@ static VALUE m_conv_file(VALUE self, VALUE ifile, VALUE ofile){
190
210
  ins->input.data=in;
191
211
  ins->input.len=fread(in, 1, IBUFLEN, inf);
192
212
  ins->input.flags|=F_FREE;
213
+ ins->input.next=NULL;
193
214
  if(ins->input.len==0){
194
215
  ins->flush=1;
195
216
  }
@@ -207,18 +228,33 @@ static VALUE m_conv_file(VALUE self, VALUE ifile, VALUE ofile){
207
228
  return Qtrue;
208
229
  }
209
230
 
210
- static VALUE m_info(VALUE self){
231
+ static VALUE m_counter(int argc, VALUE *argv, VALUE self){
232
+ struct bsdconv_instance *ins;
233
+ Data_Get_Struct(self, struct bsdconv_instance, ins);
234
+ if(argc!=0){
235
+ bsdconv_counter_t *v=bsdconv_counter(ins, RSTRING_PTR(argv[0]));
236
+ return INT2NUM(*v);
237
+ }else{
238
+ VALUE ret=rb_hash_new();
239
+ struct bsdconv_counter_entry *p=ins->counter;
240
+ while(p){
241
+ rb_hash_aset(ret, rb_str_new2(p->key), INT2FIX(p->val));
242
+ p=p->next;
243
+ }
244
+ return ret;
245
+ }
246
+ }
247
+
248
+ static VALUE m_counter_reset(int argc, VALUE *argv, VALUE self){
211
249
  VALUE ret;
212
250
  struct bsdconv_instance *ins;
213
251
  Data_Get_Struct(self, struct bsdconv_instance, ins);
214
- ret=rb_hash_new();
215
- rb_hash_aset(ret, rb_str_new2("ierr"), INT2FIX(ins->ierr));
216
- rb_hash_aset(ret, rb_str_new2("oerr"), INT2FIX(ins->oerr));
217
- rb_hash_aset(ret, rb_str_new2("score"), rb_float_new(ins->score));
218
- rb_hash_aset(ret, rb_str_new2("full"), INT2FIX(ins->full));
219
- rb_hash_aset(ret, rb_str_new2("half"), INT2FIX(ins->half));
220
- rb_hash_aset(ret, rb_str_new2("ambi"), INT2FIX(ins->ambi));
221
- return ret;
252
+ if(argc!=0){
253
+ bsdconv_counter_reset(ins, RSTRING_PTR(argv[0]));
254
+ }else{
255
+ bsdconv_counter_reset(ins, NULL);
256
+ }
257
+ return Qtrue;
222
258
  }
223
259
 
224
260
  static VALUE m_inspect(VALUE self){
data/ruby-bsdconv.gemspec CHANGED
@@ -1,13 +1,15 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ # stub: ruby-bsdconv 11.1.0 ruby lib
2
3
 
3
4
  Gem::Specification.new do |s|
4
5
  s.name = "ruby-bsdconv"
5
- s.version = "10.0.0"
6
+ s.version = "11.1.0"
6
7
 
7
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
9
  s.authors = ["Buganini Q"]
9
- s.date = "2013-04-24"
10
+ s.date = "2013-09-16"
10
11
  s.description = "ruby wrapper for bsdconv. bsdconv is a BSD licensed charset/encoding converter library with more functionalities than libiconv"
12
+ s.email = "buganini@gmail.com"
11
13
  s.extensions = ["ext/ruby-bsdconv/extconf.rb"]
12
14
  s.files = [
13
15
  ".gitignore",
@@ -22,8 +24,9 @@ Gem::Specification.new do |s|
22
24
  "task/gemgem.rb",
23
25
  "test/test_basic.rb"]
24
26
  s.homepage = "https://github.com/buganini/ruby-bsdconv"
27
+ s.licenses = ["BSD"]
25
28
  s.require_paths = ["lib"]
26
- s.rubygems_version = "2.0.0"
29
+ s.rubygems_version = "2.1.3"
27
30
  s.summary = "ruby wrapper for bsdconv"
28
31
  s.test_files = ["test/test_basic.rb"]
29
32
  end
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-bsdconv
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.0
4
+ version: 11.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Buganini Q
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-24 00:00:00.000000000 Z
11
+ date: 2013-09-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ruby wrapper for bsdconv. bsdconv is a BSD licensed charset/encoding
14
14
  converter library with more functionalities than libiconv
15
- email:
15
+ email: buganini@gmail.com
16
16
  executables: []
17
17
  extensions:
18
18
  - ext/ruby-bsdconv/extconf.rb
@@ -30,7 +30,8 @@ files:
30
30
  - task/gemgem.rb
31
31
  - test/test_basic.rb
32
32
  homepage: https://github.com/buganini/ruby-bsdconv
33
- licenses: []
33
+ licenses:
34
+ - BSD
34
35
  metadata: {}
35
36
  post_install_message:
36
37
  rdoc_options: []
@@ -48,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
48
49
  version: '0'
49
50
  requirements: []
50
51
  rubyforge_project:
51
- rubygems_version: 2.0.0
52
+ rubygems_version: 2.1.3
52
53
  signing_key:
53
54
  specification_version: 4
54
55
  summary: ruby wrapper for bsdconv