idn_ffi 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,11 @@ require File.join(File.dirname(__FILE__), %w{ idn_ffi idn_lib } )
3
3
  require File.join(File.dirname(__FILE__), %w{ idn_ffi methods } )
4
4
 
5
5
  module IDNFFI
6
+
7
+ IDNA_ALLOW_UNASSIGNED = 0x0001 # Don't reject strings containing unassigned Unicode code points.
8
+ IDNA_USE_STD3_ASCII_RULES = 0x0002 # Validate strings according to STD3 rules (i.e., normal host name rules).
9
+
6
10
  extend IDNFFI::Methods
7
11
 
8
12
  class Error < Exception; end
9
- end
13
+ end
@@ -1,14 +1,10 @@
1
1
  module IDNFFI::Methods
2
2
 
3
- # flags
4
- IDNA_ALLOW_UNASSIGNED = 0x0001 # Don't reject strings containing unassigned Unicode code points.
5
- IDNA_USE_STD3_ASCII_RULES = 0x0002 # Validate strings according to STD3 rules (i.e., normal host name rules).
6
-
7
- def to_ascii(str, flags = IDNA_ALLOW_UNASSIGNED)
3
+ def to_ascii(str, flags = IDNFFI::IDNA_ALLOW_UNASSIGNED)
8
4
  transform(:idna_to_ascii_8z, str, flags)
9
5
  end
10
6
 
11
- def to_unicode(str, flags = IDNA_ALLOW_UNASSIGNED)
7
+ def to_unicode(str, flags = IDNFFI::IDNA_ALLOW_UNASSIGNED)
12
8
  transform(:idna_to_unicode_8z8z, str, flags)
13
9
  end
14
10
 
@@ -16,29 +12,16 @@ private
16
12
 
17
13
  UTF8 = "UTF-8"
18
14
 
19
- if RUBY_VERSION >= "1.9"
20
- def transform(method, str, flags)
21
- return unless str
22
- pointer = FFI::MemoryPointer.new :pointer
23
- int = IDNFFI::Lib.send(method, str, pointer, flags)
24
- raise IDNFFI::Error, "bad answer from libidn #{ind}, http://www.gnu.org/software/libidn/reference/libidn-idna.html#IDNA-SUCCESS:CAPS" if int != 0
25
- strptr = pointer.read_pointer()
26
- result = strptr.read_string()
27
- pointer.free
28
- result.force_encoding(UTF8)
29
- result
30
- end
31
- else
32
- def transform(method, str, flags)
33
- return unless str
34
- pointer = FFI::MemoryPointer.new :pointer
35
- int = IDNFFI::Lib.send(method, str, pointer, flags)
36
- raise IDNFFI::Error, "bad answer from libidn #{ind}, http://www.gnu.org/software/libidn/reference/libidn-idna.html#IDNA-SUCCESS:CAPS" if int != 0
37
- strptr = pointer.read_pointer()
38
- result = strptr.read_string()
39
- pointer.free
40
- result
41
- end
15
+ def transform(method, str, flags)
16
+ return unless str
17
+ pointer = FFI::MemoryPointer.new :pointer
18
+ int = IDNFFI::Lib.send(method, str, pointer, flags)
19
+ raise IDNFFI::Error, "bad answer from libidn #{int}, http://www.gnu.org/software/libidn/reference/libidn-idna.html#IDNA-SUCCESS:CAPS" if int != 0
20
+ strptr = pointer.read_pointer()
21
+ result = strptr.read_string()
22
+ pointer.free
23
+ result.force_encoding(UTF8) if result.respond_to?(:force_encoding)
24
+ result
42
25
  end
43
26
 
44
27
  end
@@ -1,3 +1,3 @@
1
1
  module IDNFFI
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,75 +1,71 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: idn_ffi
3
- version: !ruby/object:Gem::Version
4
- hash: 25
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Konstantin Makarchev
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-11-30 00:00:00 +04:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
23
- none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 3
28
- segments:
29
- - 0
30
- version: "0"
31
- prerelease: false
32
- type: :runtime
33
- requirement: *id001
12
+ date: 2013-01-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
34
15
  name: ffi
35
- - !ruby/object:Gem::Dependency
36
- version_requirements: &id002 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
37
17
  none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- hash: 3
42
- segments:
43
- - 0
44
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
45
23
  prerelease: false
46
- type: :development
47
- requirement: *id002
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
48
31
  name: rake
49
- - !ruby/object:Gem::Dependency
50
- version_requirements: &id003 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
51
33
  none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- hash: 3
56
- segments:
57
- - 0
58
- version: "0"
59
- prerelease: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
60
38
  type: :development
61
- requirement: *id003
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
62
47
  name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
63
62
  description: LibIdn FFI ruby binding
64
- email:
63
+ email:
65
64
  - kostya27@gmail.com
66
65
  executables: []
67
-
68
66
  extensions: []
69
-
70
67
  extra_rdoc_files: []
71
-
72
- files:
68
+ files:
73
69
  - .gitignore
74
70
  - Gemfile
75
71
  - LICENSE
@@ -82,40 +78,36 @@ files:
82
78
  - lib/idn_ffi/version.rb
83
79
  - spec/idn_spec.rb
84
80
  - spec/test_vectors.rb
85
- has_rdoc: true
86
81
  homepage: https://github.com/kostya/idn_ffi
87
82
  licenses: []
88
-
89
83
  post_install_message:
90
84
  rdoc_options: []
91
-
92
- require_paths:
85
+ require_paths:
93
86
  - lib
94
- required_ruby_version: !ruby/object:Gem::Requirement
87
+ required_ruby_version: !ruby/object:Gem::Requirement
95
88
  none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- hash: 3
100
- segments:
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ segments:
101
94
  - 0
102
- version: "0"
103
- required_rubygems_version: !ruby/object:Gem::Requirement
95
+ hash: 515023181
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
97
  none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- hash: 3
109
- segments:
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ segments:
110
103
  - 0
111
- version: "0"
104
+ hash: 515023181
112
105
  requirements: []
113
-
114
106
  rubyforge_project:
115
- rubygems_version: 1.4.2
107
+ rubygems_version: 1.8.24
116
108
  signing_key:
117
109
  specification_version: 3
118
110
  summary: LibIdn FFI ruby binding
119
- test_files:
111
+ test_files:
120
112
  - spec/idn_spec.rb
121
113
  - spec/test_vectors.rb