nayutaya-pure-nkf 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,58 @@
1
+
2
+ require "rake/testtask"
3
+ require "lib/pure_nkf/version"
4
+
5
+ NAME = "nayutaya-pure-nkf"
6
+
7
+ task :default => :test
8
+
9
+ Rake::TestTask.new do |test|
10
+ test.libs << "test"
11
+ test.test_files = Dir.glob("test/**/*_test.rb")
12
+ test.verbose = true
13
+ end
14
+
15
+ desc "bump version"
16
+ task :version do
17
+ cur_version = PureNKF::VERSION
18
+ next_version = cur_version.succ
19
+ puts("#{cur_version} -> #{next_version}")
20
+
21
+ filename = File.join(File.dirname(__FILE__), "lib", "pure_nkf", "version.rb")
22
+ File.open(filename, "wb") { |file|
23
+ file.puts(%|# coding: utf-8|)
24
+ file.puts(%||)
25
+ file.puts(%|module PureNKF|)
26
+ file.puts(%| VERSION = "#{next_version}"|)
27
+ file.puts(%|end|)
28
+ }
29
+ end
30
+
31
+ desc "generate gemspec"
32
+ task :gemspec do
33
+ require "erb"
34
+
35
+ src = File.open("#{NAME}.gemspec.erb", "rb") { |file| file.read }
36
+ erb = ERB.new(src, nil, "-")
37
+
38
+ version = PureNKF::VERSION
39
+ date = Time.now.strftime("%Y-%m-%d")
40
+
41
+ files = Dir.glob("**/*").select { |s| File.file?(s) }.reject { |s| /\.gem\z/ =~ s }
42
+ test_files = Dir.glob("test/**").select { |s| File.file?(s) }
43
+
44
+ File.open("#{NAME}.gemspec", "wb") { |file|
45
+ file.write(erb.result(binding))
46
+ }
47
+ end
48
+
49
+ desc "build gem"
50
+ task :build do
51
+ sh "gem build #{NAME}.gemspec"
52
+ end
53
+
54
+ desc "push gem"
55
+ task :push do
56
+ target = "#{NAME}-#{PureNKF::VERSION}.gem"
57
+ sh "gem push #{target}"
58
+ end
data/lib/pure_nkf.rb ADDED
@@ -0,0 +1,4 @@
1
+ # coding: utf-8
2
+
3
+ require "pure_nkf/version"
4
+ require "pure_nkf/core"
@@ -0,0 +1,121 @@
1
+ # coding: utf-8
2
+
3
+ module PureNKF
4
+ Z1_TABLE = [
5
+ # 全角数字
6
+ [/0/, "0"],
7
+ [/1/, "1"],
8
+ [/2/, "2"],
9
+ [/3/, "3"],
10
+ [/4/, "4"],
11
+ [/5/, "5"],
12
+ [/6/, "6"],
13
+ [/7/, "7"],
14
+ [/8/, "8"],
15
+ [/9/, "9"],
16
+ # 全角アルファベット大文字
17
+ [/A/, "A"],
18
+ [/B/, "B"],
19
+ [/C/, "C"],
20
+ [/D/, "D"],
21
+ [/E/, "E"],
22
+ [/F/, "F"],
23
+ [/G/, "G"],
24
+ [/H/, "H"],
25
+ [/I/, "I"],
26
+ [/J/, "J"],
27
+ [/K/, "K"],
28
+ [/L/, "L"],
29
+ [/M/, "M"],
30
+ [/N/, "N"],
31
+ [/O/, "O"],
32
+ [/P/, "P"],
33
+ [/Q/, "Q"],
34
+ [/R/, "R"],
35
+ [/S/, "S"],
36
+ [/T/, "T"],
37
+ [/U/, "U"],
38
+ [/V/, "V"],
39
+ [/W/, "W"],
40
+ [/X/, "X"],
41
+ [/Y/, "Y"],
42
+ [/Z/, "Z"],
43
+ # 全角アルファベット小文字
44
+ [/a/, "a"],
45
+ [/b/, "b"],
46
+ [/c/, "c"],
47
+ [/d/, "d"],
48
+ [/e/, "e"],
49
+ [/f/, "f"],
50
+ [/g/, "g"],
51
+ [/h/, "h"],
52
+ [/i/, "i"],
53
+ [/j/, "j"],
54
+ [/k/, "k"],
55
+ [/l/, "l"],
56
+ [/m/, "m"],
57
+ [/n/, "n"],
58
+ [/o/, "o"],
59
+ [/p/, "p"],
60
+ [/q/, "q"],
61
+ [/r/, "r"],
62
+ [/s/, "s"],
63
+ [/t/, "t"],
64
+ [/u/, "u"],
65
+ [/v/, "v"],
66
+ [/w/, "w"],
67
+ [/x/, "x"],
68
+ [/y/, "y"],
69
+ [/z/, "z"],
70
+ [/0/, "0"],
71
+ # 記号
72
+ [/ /, " "],
73
+ [/!/, "!"],
74
+ [/“/, "\""],
75
+ [/”/, "\""],
76
+ [/#/, "#"],
77
+ [/$/, "$"],
78
+ [/%/, "%"],
79
+ [/&/, "&"],
80
+ [/‘/, "`"],
81
+ [/’/, "'"],
82
+ [/(/, "("],
83
+ [/)/, ")"],
84
+ [/*/, "*"],
85
+ [/+/, "+"],
86
+ [/,/, ","],
87
+ [/-/, "-"], # U+FF0D FULLWIDTH HYPHEN-MINUS
88
+ [/—/, "-"], # U+2014 EM DASH
89
+ [/―/, "-"], # U+2015 HORIZONTAL BAR
90
+ [/−/, "-"], # U+2212 MINUS SIGN
91
+ [/./, "."],
92
+ [///, "/"],
93
+ [/:/, ":"],
94
+ [/;/, ";"],
95
+ [/</, "<"],
96
+ [/〈/, "<"],
97
+ [/=/, "="],
98
+ [/>/, ">"],
99
+ [/〉/, ">"],
100
+ [/?/, "?"],
101
+ [/@/, "@"],
102
+ [/[/, "["],
103
+ [/\/, "\\"],
104
+ [/¥/, "¥"], # U+00A5 YEN SIGN
105
+ [/]/, "]"],
106
+ [/^/, "^"],
107
+ [/_/, "_"],
108
+ [/`/, "`"],
109
+ [/{/, "{"],
110
+ [/}/, "}"],
111
+ [/|/, "|"],
112
+ ].freeze.each { |a| a.freeze }
113
+
114
+ def self.convert_Z1(value)
115
+ value = value.dup
116
+ Z1_TABLE.each { |pattern, replace|
117
+ value.gsub!(pattern, replace)
118
+ }
119
+ return value
120
+ end
121
+ end
@@ -0,0 +1,5 @@
1
+ # coding: utf-8
2
+
3
+ module PureNKF
4
+ VERSION = "0.0.1"
5
+ end
@@ -0,0 +1,38 @@
1
+
2
+ Gem::Specification.new do |s|
3
+ s.specification_version = 2
4
+ s.required_rubygems_version = Gem::Requirement.new(">= 0")
5
+ s.required_ruby_version = Gem::Requirement.new(">= 1.8.6")
6
+
7
+ s.name = "nayutaya-pure-nkf"
8
+ s.version = "0.0.1"
9
+ s.date = "2010-01-19"
10
+
11
+ s.authors = ["Yuya Kato"]
12
+ s.email = "yuyakato@gmail.com"
13
+
14
+ s.summary = "pure-nkf"
15
+ s.description = "pure-nkf"
16
+ s.homepage = "http://github.com/nayutaya/pure-nkf/"
17
+
18
+ s.rubyforge_project = nil
19
+ s.has_rdoc = false
20
+ s.require_paths = ["lib"]
21
+
22
+ s.files = [
23
+ "lib/pure_nkf/core.rb",
24
+ "lib/pure_nkf/version.rb",
25
+ "lib/pure_nkf.rb",
26
+ "nayutaya-pure-nkf.gemspec",
27
+ "nayutaya-pure-nkf.gemspec.erb",
28
+ "Rakefile",
29
+ "README.md",
30
+ "test/core_test.rb",
31
+ "test/test_helper.rb",
32
+ ]
33
+ s.test_files = [
34
+ "test/core_test.rb",
35
+ "test/test_helper.rb",
36
+ ]
37
+ s.extra_rdoc_files = []
38
+ end
@@ -0,0 +1,33 @@
1
+
2
+ Gem::Specification.new do |s|
3
+ s.specification_version = 2
4
+ s.required_rubygems_version = Gem::Requirement.new(">= 0")
5
+ s.required_ruby_version = Gem::Requirement.new(">= 1.8.6")
6
+
7
+ s.name = <%= NAME.dump %>
8
+ s.version = <%= version.dump %>
9
+ s.date = <%= date.dump %>
10
+
11
+ s.authors = ["Yuya Kato"]
12
+ s.email = "yuyakato@gmail.com"
13
+
14
+ s.summary = "pure-nkf"
15
+ s.description = "pure-nkf"
16
+ s.homepage = "http://github.com/nayutaya/pure-nkf/"
17
+
18
+ s.rubyforge_project = nil
19
+ s.has_rdoc = false
20
+ s.require_paths = ["lib"]
21
+
22
+ s.files = [
23
+ <%- files.each { |path| -%>
24
+ <%= path.dump %>,
25
+ <%- } -%>
26
+ ]
27
+ s.test_files = [
28
+ <%- test_files.each { |path| -%>
29
+ <%= path.dump %>,
30
+ <%- } -%>
31
+ ]
32
+ s.extra_rdoc_files = []
33
+ end
data/test/core_test.rb ADDED
@@ -0,0 +1,33 @@
1
+ #! ruby -Ku
2
+ # coding: utf-8
3
+
4
+ require "test_helper"
5
+ require "pure_nkf"
6
+ require "nkf"
7
+
8
+ class CoreTest < Test::Unit::TestCase
9
+ def setup
10
+ @module = PureNKF
11
+ end
12
+
13
+ def test_convert_Z1
14
+ [
15
+ ["0123456789", "0123456789"],
16
+ ["ABCDEFGHIJKLMNOPQRSTUVWXYZ", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"],
17
+ ["abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz"],
18
+ [" ", " "],
19
+ ["!“”#$%&‘’()*+,-./", "!\"\"\#$%&`'()*+,-./"],
20
+ [":;<=>?@", ":;<=>?@"],
21
+ ["[¥]^_`", "[¥]^_`"],
22
+ ["{|}", "{|}"],
23
+ ["—―−", "---"],
24
+ ["〈〉", "<>"],
25
+ ["\", "\\"],
26
+ ].each { |value, expected|
27
+ assert_equal(expected, @module.convert_Z1(value))
28
+ assert_equal(
29
+ NKF.nkf("-w -Z1", value),
30
+ @module.convert_Z1(value))
31
+ }
32
+ end
33
+ end
@@ -0,0 +1,5 @@
1
+ # coding: utf-8
2
+
3
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
4
+
5
+ require "test/unit"
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nayutaya-pure-nkf
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Yuya Kato
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-19 00:00:00 +09:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: pure-nkf
17
+ email: yuyakato@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - lib/pure_nkf/core.rb
26
+ - lib/pure_nkf/version.rb
27
+ - lib/pure_nkf.rb
28
+ - nayutaya-pure-nkf.gemspec
29
+ - nayutaya-pure-nkf.gemspec.erb
30
+ - Rakefile
31
+ - README.md
32
+ - test/core_test.rb
33
+ - test/test_helper.rb
34
+ has_rdoc: true
35
+ homepage: http://github.com/nayutaya/pure-nkf/
36
+ licenses: []
37
+
38
+ post_install_message:
39
+ rdoc_options: []
40
+
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.8.6
48
+ version:
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ requirements: []
56
+
57
+ rubyforge_project:
58
+ rubygems_version: 1.3.5
59
+ signing_key:
60
+ specification_version: 2
61
+ summary: pure-nkf
62
+ test_files:
63
+ - test/core_test.rb
64
+ - test/test_helper.rb