Skip to content

Commit fecd744

Browse files
committed
Update gemspec
1 parent 6ca4f93 commit fecd744

File tree

4 files changed

+106
-18
lines changed

4 files changed

+106
-18
lines changed

CODE_OF_CONDUCT.md

+13
Original file line numberDiff line numberDiff line change
@@ -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/)

LICENSE.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
The MIT License (MIT)
2+
====================
3+
4+
* Copyright © 2013 David Chelimsky, Myron Marston, Jon Rowe, Sam Phippen, Xavier Shay, Bradley Schaefer
5+
6+
Permission is hereby granted, free of charge, to any person obtaining
7+
a copy of this software and associated documentation files (the
8+
"Software"), to deal in the Software without restriction, including
9+
without limitation the rights to use, copy, modify, merge, publish,
10+
distribute, sublicense, and/or sell copies of the Software, and to
11+
permit persons to whom the Software is furnished to do so, subject to
12+
the following conditions:
13+
14+
The above copyright notice and this permission notice shall be
15+
included in all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+66-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# EncodedString
22

3-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/encoded_string`. To experiment with that code, run `bin/console` for an interactive prompt.
4-
5-
TODO: Delete this and the text above, and describe your gem
3+
EncodedString is a wrapper for a string and a given encoding that handles operations on
4+
strings with different encodings, invalid encodings, have no known conversion method,
5+
or are otherwise incompatible, all without raising excpetions
66

77
## Installation
88

@@ -22,7 +22,63 @@ Or install it yourself as:
2222

2323
## Usage
2424

25-
TODO: Write usage instructions here
25+
```ruby
26+
EncodedString.pick_encoding(str1, str2)
27+
28+
string = "123".force_encoding(EncodedString::UTF_8)
29+
str = "abc".encode('ASCII-8BIT')
30+
str = EncodedString.new(str, target_encoding = string.encoding)
31+
str.source_encoding.to_s
32+
str.split("\n")
33+
str << "123"
34+
str.to_s
35+
```
36+
37+
## About
38+
39+
Encoding Exceptions:
40+
41+
```plain
42+
Raised by Encoding and String methods:
43+
Encoding::UndefinedConversionError:
44+
when a transcoding operation fails
45+
if the String contains characters invalid for the target encoding
46+
e.g. "\x80".encode('UTF-8','ASCII-8BIT')
47+
vs "\x80".encode('UTF-8','ASCII-8BIT', undef: :replace, replace: '<undef>')
48+
# => '<undef>'
49+
Encoding::CompatibilityError
50+
when Encoding.compatibile?(str1, str2) is nil
51+
e.g. utf_16le_emoji_string.split("\n")
52+
e.g. valid_unicode_string.encode(utf8_encoding) << ascii_string
53+
Encoding::InvalidByteSequenceError:
54+
when the string being transcoded contains a byte invalid for
55+
either the source or target encoding
56+
e.g. "\x80".encode('UTF-8','US-ASCII')
57+
vs "\x80".encode('UTF-8','US-ASCII', invalid: :replace, replace: '<byte>')
58+
# => '<byte>'
59+
ArgumentError
60+
when operating on a string with invalid bytes
61+
e.g."\x80".split("\n")
62+
TypeError
63+
when a symbol is passed as an encoding
64+
Encoding.find(:"UTF-8")
65+
when calling force_encoding on an object
66+
that doesn't respond to #to_str
67+
68+
Raised by transcoding methods:
69+
Encoding::ConverterNotFoundError:
70+
when a named encoding does not correspond with a known converter
71+
e.g. 'abc'.force_encoding('UTF-8').encode('foo')
72+
or a converter path cannot be found
73+
e.g. "\x80".force_encoding('ASCII-8BIT').encode('Emacs-Mule')
74+
75+
Raised by byte <-> char conversions
76+
RangeError: out of char range
77+
e.g. the UTF-16LE emoji: 128169.chr
78+
```
79+
80+
See [lib/encoded_string.rb](lib/encoded_string.rb) and
81+
[spec/encoded_string_spec.rb](spec/encoded_string_spec.rb) for more information.
2682

2783
## Development
2884

@@ -32,5 +88,10 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
3288

3389
## Contributing
3490

35-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/encoded_string.
91+
Bug reports and pull requests are welcome on GitHub at https://github.com/bf4/encoded_string. 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.
92+
93+
94+
## License
95+
96+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
3697

encoded_string.gemspec

+4-13
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,13 @@ Gem::Specification.new do |spec|
77
spec.name = "encoded_string"
88
spec.version = EncodedString::VERSION
99
spec.authors = ["Benjamin Fleischer"]
10-
spec.email = ["TODO: Write your email address"]
10+
spec.email = ["[email protected]"]
1111

12-
spec.summary = %q{TODO: Write a short summary, because Rubygems requires one.}
13-
spec.description = %q{TODO: Write a longer description or delete this line.}
14-
spec.homepage = "TODO: Put your gem's website or public repo URL here."
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
12+
spec.summary = %q{Handle string operations without worrying about raising encoding exceptions.}
13+
spec.description = %q{Extracted from rspec-support. See https://github.com/rspec/rspec-support/issues/249.}
14+
spec.homepage = "https://github.com/bf4/encoded_string"
2315

2416
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25-
spec.bindir = "exe"
2617
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
2718
spec.require_paths = ["lib"]
2819

0 commit comments

Comments
 (0)