zarby 0.1.1 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe5948267cd436af9d1cd8639040bee740b642b57f3d79cdb9cf26537508f08e
4
- data.tar.gz: a7989a59ed50492a700bd258d63dedbf4bd8a3e4cb38caea59c1300d3e76453e
3
+ metadata.gz: '094c48a2c426ddb854907fb342840e5360f227b63a272fd8680128573f08e28c'
4
+ data.tar.gz: 3327de7fe14f73baab98e11cf3f7e8c87b2fa6ee2896ce1c877bcdef8ed0a9d9
5
5
  SHA512:
6
- metadata.gz: adaab75a5d8988eb5074068a4746d02fde6267bf2abad0e842eaec851771f9b135fe942001a77467806c911b34fc77ee4b39c3022eb7fe43e3a45a8cfeaaa44d
7
- data.tar.gz: da24b0a4c02b6ca7296cec3caf79292faebb2803eaae4aa3de9ce3545eac4b7f0f4247139be8d264e43b722808050cbb6e8fea29b013d1d823257b43d7b7c705
6
+ metadata.gz: 623c758ff2e50d52939b08f58b414c23297503ab596b4afa0b91f2075b123c42d75f61e0a7501d83ee010e4ce29d7b2c070194596b42d1a2262861b76cca1425
7
+ data.tar.gz: 5764f9b41cb8f31fa3cb171e52fd4265c1295ebca59d73c89fbb563524cbbf12962511159dbdbea404feaaa29ed05f6c648fa247105426155acee5a3970e4b54
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
@@ -7,7 +7,7 @@ module Zarby
7
7
  COMMON_DELIMITERS = ['","', '";"', '":"', '"|"'].freeze
8
8
 
9
9
  def initialize(content:)
10
- @content = content
10
+ @content = content || ""
11
11
  end
12
12
 
13
13
  def self.detect_separator(content)
@@ -6,7 +6,7 @@ module Zarby
6
6
  COMMON_ENCODINGS = %w[UTF-8 Windows-1252 ASCII-8BIT US-ASCII].freeze
7
7
 
8
8
  def initialize(input:)
9
- @input = input
9
+ @input = input || ""
10
10
  end
11
11
 
12
12
  def self.utf8(input)
@@ -15,15 +15,17 @@ module Zarby
15
15
 
16
16
  def utf8
17
17
  output = @input if valid?
18
-
19
18
  COMMON_ENCODINGS.each do |encoding|
20
19
  output ||= convert { @input.encode(encoding) }
21
20
  output ||= convert { @input.force_encoding('UTF-8') } if encoding == 'UTF-8'
21
+ puts output
22
22
  end
23
23
 
24
+ output ||= unpack_pack { @input.unpack("C*").pack("U*") } if output.nil?
25
+
24
26
  # replace any unknown characters with a placeholder: �
25
27
  output ||= convert { @input.encode('UTF-8', invalid: :replace, undef: :replace) }
26
-
28
+ puts output
27
29
  output
28
30
  end
29
31
 
@@ -36,6 +38,13 @@ module Zarby
36
38
  nil
37
39
  end
38
40
 
41
+ def unpack_pack
42
+ string = yield
43
+ string if string.valid_encoding?
44
+ rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError
45
+ nil
46
+ end
47
+
39
48
  def valid?
40
49
  @input.encoding.name == 'UTF-8' && @input.valid_encoding?
41
50
  end
data/lib/zarby/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zarby
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
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/gems/zarby"
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["homepage_uri"] = spec.homepage
19
- spec.metadata["source_code_uri"] = spec.homepage
20
- spec.metadata["changelog_uri"] = "https://github.com/VianneySonneville/zarby/blob/main/CHANGELOG.md"
21
- spec.metadata["github_repo"] = "git@github.com:VianneySonneville/zarby.git"
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zarby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - vianney.sonneville
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-20 00:00:00.000000000 Z
11
+ date: 2023-10-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -17,6 +17,7 @@ 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
@@ -26,15 +27,13 @@ files:
26
27
  - lib/zarby/version.rb
27
28
  - sig/zarby.rbs
28
29
  - zarby.gemspec
29
- homepage: https://rubygems.org/gems/zarby
30
+ homepage: https://guides.rubygems.org
30
31
  licenses:
31
32
  - MIT
32
33
  metadata:
33
- allowed_push_host: https://rubygems.org
34
- homepage_uri: https://rubygems.org/gems/zarby
35
- source_code_uri: https://rubygems.org/gems/zarby
34
+ source_code_uri: https://github.com/VianneySonneville/zarby
36
35
  changelog_uri: https://github.com/VianneySonneville/zarby/blob/main/CHANGELOG.md
37
- github_repo: git@github.com:VianneySonneville/zarby.git
36
+ allowed_push_host: https://rubygems.org
38
37
  post_install_message:
39
38
  rdoc_options: []
40
39
  require_paths:
@@ -50,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
49
  - !ruby/object:Gem::Version
51
50
  version: '0'
52
51
  requirements: []
53
- rubygems_version: 3.2.3
52
+ rubygems_version: 3.3.7
54
53
  signing_key:
55
54
  specification_version: 4
56
55
  summary: String encoding and decoding with Ruby.