zarby 0.1.0 → 0.1.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/lib/zarby/csv.rb +1 -1
- data/lib/zarby/normalize.rb +43 -0
- data/lib/zarby/version.rb +1 -1
- data/lib/zarby.rb +1 -0
- data/zarby.gemspec +11 -6
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0b346aa22187565e4dc560f912437f47de21d505809e6260bba82dab13e7ba1
|
4
|
+
data.tar.gz: 051f4ae725e23e59d8cca88c3cdf6a3d070dd83445d35c3cca2b530129f7c403
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 874cc0894c30afef80fb52356dec88598b2383633c6a3770a5325e0dd62a37ace0ffcc2a9fa8538580536143360a54a845c375ef523bbe314f22fadb090997d5
|
7
|
+
data.tar.gz: 94d990a09c685429e812077b53dc66c26b4ae83705ce421251dfb9881070f7ec943d5ec2e87fb36505332ebf6aa7ac6121404231d1c2c9af47c9fe86ee7b1a90
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# 0.1.2 / 2023-10-20
|
2
|
+
|
3
|
+
## Enhancements
|
4
|
+
|
5
|
+
* Null safety
|
6
|
+
|
7
|
+
# 0.1.1 / 2023-10-20
|
8
|
+
|
9
|
+
## Enhancements
|
10
|
+
|
11
|
+
* Add class Normalize, this class can force utf-8 string with valide char for bdd
|
12
|
+
|
13
|
+
# 0.1.0 / 2023-09-20
|
14
|
+
|
15
|
+
## Enhancements
|
16
|
+
|
17
|
+
* Add class Csv, this class can auto detect string csv separator
|
data/lib/zarby/csv.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Zarby
|
4
|
+
class Normalize
|
5
|
+
# utf-8 converting from the string's given encoding
|
6
|
+
COMMON_ENCODINGS = %w[UTF-8 Windows-1252 ASCII-8BIT US-ASCII].freeze
|
7
|
+
|
8
|
+
def initialize(input:)
|
9
|
+
@input = input || ""
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.utf8(input)
|
13
|
+
new(input: input).utf8
|
14
|
+
end
|
15
|
+
|
16
|
+
def utf8
|
17
|
+
output = @input if valid?
|
18
|
+
|
19
|
+
COMMON_ENCODINGS.each do |encoding|
|
20
|
+
output ||= convert { @input.encode(encoding) }
|
21
|
+
output ||= convert { @input.force_encoding('UTF-8') } if encoding == 'UTF-8'
|
22
|
+
end
|
23
|
+
|
24
|
+
# replace any unknown characters with a placeholder: �
|
25
|
+
output ||= convert { @input.encode('UTF-8', invalid: :replace, undef: :replace) }
|
26
|
+
|
27
|
+
output
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def convert
|
33
|
+
string = yield
|
34
|
+
string if string.valid_encoding?
|
35
|
+
rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError
|
36
|
+
nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def valid?
|
40
|
+
@input.encoding.name == 'UTF-8' && @input.valid_encoding?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/zarby/version.rb
CHANGED
data/lib/zarby.rb
CHANGED
data/zarby.gemspec
CHANGED
@@ -10,16 +10,21 @@ Gem::Specification.new do |spec|
|
|
10
10
|
|
11
11
|
spec.summary = "String encoding and decoding with Ruby."
|
12
12
|
# spec.description = "TODO: Write a longer description or delete this line."
|
13
|
-
spec.homepage = "https://rubygems.org
|
13
|
+
spec.homepage = "https://guides.rubygems.org"
|
14
14
|
spec.required_ruby_version = ">= 2.6.0"
|
15
15
|
spec.licenses = ['MIT']
|
16
|
-
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
17
16
|
|
18
|
-
spec.metadata
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
spec.metadata = {
|
18
|
+
"source_code_uri" => "https://github.com/VianneySonneville/zarby",
|
19
|
+
"changelog_uri" => "https://github.com/VianneySonneville/zarby/blob/main/CHANGELOG.md"
|
20
|
+
}
|
21
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
22
22
|
|
23
|
+
# spec.metadata["homepage_uri"] = spec.homepage
|
24
|
+
# spec.metadata["source_code_uri"] = spec.homepage
|
25
|
+
# spec.metadata["changelog_uri"] = "https://github.com/VianneySonneville/zarby/blob/main/CHANGELOG.md"
|
26
|
+
# spec.metadata["github_repo"] = "git@github.com:VianneySonneville/zarby.git"
|
27
|
+
# spec.metadata["source_code_link"] = "git@github.com:VianneySonneville/zarby.git"
|
23
28
|
# Specify which files should be added to the gem when it is released.
|
24
29
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
30
|
spec.files = Dir.chdir(__dir__) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zarby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vianney.sonneville
|
@@ -17,23 +17,23 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- CHANGELOG.md
|
20
21
|
- LICENSE
|
21
22
|
- README.md
|
22
23
|
- Rakefile
|
23
24
|
- lib/zarby.rb
|
24
25
|
- lib/zarby/csv.rb
|
26
|
+
- lib/zarby/normalize.rb
|
25
27
|
- lib/zarby/version.rb
|
26
28
|
- sig/zarby.rbs
|
27
29
|
- zarby.gemspec
|
28
|
-
homepage: https://rubygems.org
|
30
|
+
homepage: https://guides.rubygems.org
|
29
31
|
licenses:
|
30
32
|
- MIT
|
31
33
|
metadata:
|
32
|
-
|
33
|
-
homepage_uri: https://rubygems.org/gems/zarby
|
34
|
-
source_code_uri: https://rubygems.org/gems/zarby
|
34
|
+
source_code_uri: https://github.com/VianneySonneville/zarby
|
35
35
|
changelog_uri: https://github.com/VianneySonneville/zarby/blob/main/CHANGELOG.md
|
36
|
-
|
36
|
+
allowed_push_host: https://rubygems.org
|
37
37
|
post_install_message:
|
38
38
|
rdoc_options: []
|
39
39
|
require_paths:
|