simpleidn 0.1.0 → 0.1.1

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.
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Input is expected to follow the form found in IdnaMappingTable.txt
4
+ # from The Unicode Consortium
5
+
6
+ puts "# encoding: UTF-8\n\n"
7
+
8
+ map = {}
9
+ ARGF.each do |line|
10
+ # Copy full comment lines to output
11
+ puts line if line[0] == '#'
12
+
13
+ s = line.strip.split('#').first
14
+ next if s.nil?
15
+
16
+ p = s.split(';').map{|s| s.strip}
17
+
18
+ if p[1] == "ignored"
19
+ p[1] = "mapped"
20
+ p[2] = ""
21
+ end
22
+
23
+ next unless p[1] == "mapped" || p[1] == "disallowed_STD3_mapped"
24
+
25
+ dst = p[2].split(/\s+/).map do |hex|
26
+ hex.to_i(16)
27
+ end
28
+ if dst.length == 1
29
+ dst = dst.first
30
+ end
31
+
32
+ if p[0].include?('..')
33
+ a, b = p[0].split('..',2).map{|n|n.to_i(16)}
34
+ (a..b).each do |n|
35
+ map[n] = dst
36
+ end
37
+ else
38
+ src = p[0].to_i(16)
39
+ map[src] = dst
40
+ end
41
+ end
42
+
43
+ # Output final mapping data
44
+ puts
45
+ puts 'module SimpleIDN'
46
+ puts ' UTS64MAPPING = {'
47
+ map.each do |k, v|
48
+ puts " #{k} => #{v},"
49
+ end
50
+ puts ' }'
51
+ puts 'end'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simpleidn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morten Møller Riis
@@ -10,6 +10,20 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2018-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: unf
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.4
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +81,11 @@ files:
67
81
  - README.rdoc
68
82
  - Rakefile
69
83
  - lib/simpleidn.rb
84
+ - lib/simpleidn/uts46mapping.rb
85
+ - lib/simpleidn/version.rb
70
86
  - simpleidn.gemspec
87
+ - tables/IdnaMappingTable.txt
88
+ - tables/generate_mapping_table.rb
71
89
  homepage: https://github.com/mmriis/simpleidn
72
90
  licenses:
73
91
  - MIT