punctuate 1.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c78c7a08c06ce08279076662e83247354725b995
4
+ data.tar.gz: 48360aa794bd0651ea853e72d476bf742b2fee7e
5
+ SHA512:
6
+ metadata.gz: ffe998fb9fe13b20f3a640038c5e6d863d4fcc36e2b79f9ec87679c1455134c4b03e3733194c37fe789fa1b7839251452ba3e7c3ccdcfee48d52e42324a904dd
7
+ data.tar.gz: 6d0298f441c3208d4f502a416b83d1435c560653cd740a3c8297c9d134552d5662685b97265b1fb5ce0cb5f603d01b424773c7076f5bd139448d456af599f82b
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in punctuate.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Victor Ng KP
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,38 @@
1
+ # Punctuate
2
+
3
+ Converts Unicode or non-ASCII punctuation and symbols to nearest ASCII punctuation and symbols. It is based on [default symbols & punctuation mapping table](http://lexsrv3.nlm.nih.gov/LexSysGroup/Projects/lvg/current/docs/designDoc/UDF/unicode/DefaultTables/symbolTable.html) recommended by [Lexical Tools](http://lexsrv3.nlm.nih.gov/LexSysGroup/Projects/lvg/current/docs/designDoc/UDF/unicode/NormOperations/mapSymbolToAscii.html).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'punctuate'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install punctuate
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/victorngkp/punctuate. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
34
+
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "punctuate"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ require "punctuate/version"
2
+ require "punctuate/symbols"
3
+ require "punctuate/punctuation"
4
+
5
+ module Punctuate
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,32 @@
1
+ String.class_eval do
2
+ def punctuate!
3
+ formatted_word = ""
4
+
5
+ self.each_char do |char|
6
+ converted = false
7
+ converted_char = char
8
+
9
+ Punctuate::Symbols::SYMBOLS_MAPPING.each do |character_byte, symbol_bytes_arrays|
10
+ symbol_bytes_arrays.each do |symbol_bytes|
11
+ if (char.bytes == symbol_bytes)
12
+ converted_char = convert_byte_to_character(character_byte)
13
+ converted = true
14
+ break
15
+ end
16
+ end
17
+
18
+ break if converted
19
+ end
20
+
21
+ formatted_word << converted_char
22
+ end
23
+
24
+ return formatted_word
25
+ end
26
+
27
+ private
28
+
29
+ def convert_byte_to_character(character_byte)
30
+ character_byte.split(",").map(&:to_i).pack("c*").force_encoding("utf-8")
31
+ end
32
+ end
@@ -0,0 +1,158 @@
1
+ module Punctuate
2
+ class Symbols
3
+ SYMBOLS_MAPPING = {
4
+ "34" => [ # => \
5
+ [194, 171],
6
+ [194, 187],
7
+ [202, 186],
8
+ [204, 139],
9
+ [204, 142],
10
+ [226, 128, 156],
11
+ [226, 128, 157],
12
+ [226, 128, 158],
13
+ [226, 128, 159],
14
+ [226, 128, 179],
15
+ [226, 128, 182],
16
+ [227, 128, 131],
17
+ [227, 128, 157],
18
+ [227, 128, 158]
19
+ ],
20
+ "45" => [ # => -
21
+ [194, 173],
22
+ [226, 128, 144],
23
+ [226, 128, 145],
24
+ [226, 128, 146],
25
+ [226, 128, 147],
26
+ [226, 128, 148],
27
+ [226, 136, 146]
28
+ ],
29
+ "39" => [ # => '
30
+ [194, 180],
31
+ [202, 185],
32
+ [202, 188],
33
+ [203, 136],
34
+ [204, 129],
35
+ [226, 128, 152],
36
+ [226, 128, 153],
37
+ [226, 128, 155],
38
+ [226, 128, 178]
39
+ ],
40
+ "47" => [ # => /
41
+ [195, 183],
42
+ [204, 184],
43
+ [226, 129, 132],
44
+ [226, 136, 149]
45
+ ],
46
+ "124" => [ # => |
47
+ [199, 128],
48
+ [215, 128],
49
+ [226, 136, 163],
50
+ [226, 157, 152]
51
+ ],
52
+ "33" => [ # => !
53
+ [199, 131],
54
+ [226, 157, 162]
55
+ ],
56
+ "94" => [ # => ^
57
+ [203, 132],
58
+ [203, 134],
59
+ [204, 130],
60
+ [226, 128, 184],
61
+ [226, 140, 131]
62
+ ],
63
+ "96" => [ # => `
64
+ [203, 139],
65
+ [204, 128],
66
+ [226, 128, 181]
67
+ ],
68
+ "95" => [ # => _
69
+ [203, 141],
70
+ [204, 177],
71
+ [204, 178],
72
+ [226, 128, 151]
73
+ ],
74
+ "126" => [ # => ~
75
+ [203, 156],
76
+ [204, 131],
77
+ [226, 129, 147],
78
+ [226, 136, 188],
79
+ [227, 128, 156]
80
+ ],
81
+ "58" => [ # => :
82
+ [214, 137],
83
+ [215, 131],
84
+ [226, 136, 182]
85
+ ],
86
+ "37" => [ # => %
87
+ [217, 170],
88
+ [226, 129, 146]
89
+ ],
90
+ "42" => [ # => *
91
+ [217, 173],
92
+ [226, 129, 142],
93
+ [226, 136, 151],
94
+ [226, 156, 177]
95
+ ],
96
+ "" => [
97
+ [226, 136, 139],
98
+ [226, 129, 160],
99
+ [239, 187, 191]
100
+ ],
101
+ "45,45" => [ # => --
102
+ [226, 128, 149]
103
+ ],
104
+ "124,124" => [ # => ||
105
+ [226, 128, 150]
106
+ ],
107
+ "44" => [ # => ,
108
+ [226, 128, 154]
109
+ ],
110
+ "39,39,39" => [ # => '''
111
+ [226, 128, 180],
112
+ [226, 128, 183]
113
+ ],
114
+ "60" => [ # => <
115
+ [226, 128, 185],
116
+ [226, 140, 169],
117
+ [226, 159, 168],
118
+ [227, 128, 136]
119
+ ],
120
+ "62" => [ # => >
121
+ [226, 128, 186],
122
+ [226, 140, 170],
123
+ [226, 159, 169],
124
+ [227, 128, 137]
125
+ ],
126
+ "63" => [ # => ?
127
+ [226, 128, 189]
128
+ ],
129
+ "92" => [ # => \\
130
+ [226, 131, 165],
131
+ [226, 136, 150]
132
+ ],
133
+ "60,61" => [ # => <=
134
+ [226, 137, 164],
135
+ [226, 137, 166]
136
+ ],
137
+ "62,61" => [ # => >=
138
+ [226, 137, 165],
139
+ [226, 137, 167]
140
+ ],
141
+ "35" => [ # => #
142
+ [226, 153, 175]
143
+ ],
144
+ "91" => [ # => [
145
+ [226, 159, 166]
146
+ ],
147
+ "123" => [ # => {
148
+ [226, 166, 131]
149
+ ],
150
+ "125" => [ # => }
151
+ [226, 166, 132]
152
+ ],
153
+ "93" => [ # => ]
154
+ [227, 128, 155]
155
+ ]
156
+ }
157
+ end
158
+ end
@@ -0,0 +1,3 @@
1
+ module Punctuate
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'punctuate/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "punctuate"
8
+ spec.version = Punctuate::VERSION
9
+ spec.authors = ["Victor Ng KP", "Jack Wong"]
10
+ spec.email = ["khuenping@gmail.com", "jackyhwong91@gmail.com"]
11
+
12
+ spec.summary = %q{Converts Unicode or non-ASCII punctuation and symbols to nearest ASCII punctuation and symbols.}
13
+ spec.homepage = "https://github.com/victorngkp/punctuate"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
+ # delete this section to allow pushing this gem to any host.
18
+ # if spec.respond_to?(:metadata)
19
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
20
+ # else
21
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
+ # end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.10"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "rspec"
32
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: punctuate
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Victor Ng KP
8
+ - Jack Wong
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2016-08-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.10'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.10'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ description:
57
+ email:
58
+ - khuenping@gmail.com
59
+ - jackyhwong91@gmail.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - ".rspec"
66
+ - ".travis.yml"
67
+ - CODE_OF_CONDUCT.md
68
+ - Gemfile
69
+ - LICENSE.txt
70
+ - README.md
71
+ - Rakefile
72
+ - bin/console
73
+ - bin/setup
74
+ - lib/punctuate.rb
75
+ - lib/punctuate/punctuation.rb
76
+ - lib/punctuate/symbols.rb
77
+ - lib/punctuate/version.rb
78
+ - punctuate.gemspec
79
+ homepage: https://github.com/victorngkp/punctuate
80
+ licenses:
81
+ - MIT
82
+ metadata: {}
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.5.1
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: Converts Unicode or non-ASCII punctuation and symbols to nearest ASCII punctuation
103
+ and symbols.
104
+ test_files: []