hanifx 0.1.0 → 0.1.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hanifx.rb +37 -18
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ad418b498d23545f0475b8ae47412e091e40de822e030b5adf9ec0b53823285
4
- data.tar.gz: 9447bece46f00bfce146ade8f86f381785532aabdf7753f416d0aa4ca8827658
3
+ metadata.gz: 3c9d6476712d2c14a259fc8b1ae820c63d3fc9c62405bff8a007b3fba307afd2
4
+ data.tar.gz: 249684d8d687d40e1947d1f992dc99fb933cf86ef007256ea6f245ccb21837c0
5
5
  SHA512:
6
- metadata.gz: 9a4b8935fde52ffaffd7edfb6c9880c28c0c8eac604cdfdaff05e0810f8e2f81bbd8bd212a6cd54924c22dff985bae95940bf9cca37d57f94de7191fc558bd9b
7
- data.tar.gz: fef3535d0ba11dd20d6cf2a5614e81082a5679fa265dc429b00bec7d368b9a4eb597e973ee01253df4249e98cd41bba0c0d13e933a05d445dcedee6601880d51
6
+ metadata.gz: 38a5960cc906ef97b73635eda6748908363bc4f02e57aeef5969f08de7c89a473aff93328a779ca72adab3c43ac305922e8629b2a1c4d077ad0d6d4db22c1dd9
7
+ data.tar.gz: 1a160f531e063ac39e19bca2847bb1156d797c843246764dc78239fd13eb08dc8dd1d3f001874dc75bdbeae1fcc1e0854cf8118a233ca9a2fc22e5259ea393ab
data/lib/hanifx.rb CHANGED
@@ -1,45 +1,64 @@
1
- # lib/hanifx.rb
2
-
3
1
  module Hanifx
4
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
5
3
 
6
4
  # Warning message
7
- def self.warning
5
+ def self.warning(skip: false)
6
+ return if skip
8
7
  puts "[WARNING] Once encoded, this data cannot be decoded. Proceed? (yes/no)"
9
8
  answer = gets.chomp.downcase
10
9
  exit unless answer == "yes"
11
10
  end
12
11
 
13
- # Irreversible encode for text
14
- def self.encode_text(text)
15
- warning
16
- # Simple irreversible algorithm example: char shuffle + unicode offset
17
- text.chars.map { |c| ((c.ord + 7) * 3).to_s(16) }.join("-")
12
+ # Irreversible encode for text (options hash added)
13
+ # options: skip_warning: true/false, verbose: true/false
14
+ def self.encode_text(text, options = {}) # <-- এখানে default hash দিয়েছি
15
+ skip_warning = options[:skip_warning] || false
16
+ verbose = options[:verbose] || false
17
+
18
+ warning(skip: skip_warning)
19
+ encoded = text.chars.map { |c| ((c.ord + 7) * 3).to_s(16) }.join("-")
20
+ puts "[INFO] Text encoded successfully!" if verbose
21
+ encoded
18
22
  end
19
23
 
20
24
  # Irreversible encode for file
21
- def self.encode_file(file_path)
22
- warning
25
+ # options: skip_warning, overwrite, verbose, custom_suffix
26
+ def self.encode_file(file_path, options = {})
27
+ skip_warning = options[:skip_warning] || false
28
+ overwrite = options[:overwrite] || false
29
+ verbose = options[:verbose] || false
30
+ custom_suffix = options[:custom_suffix] || ".hanifx"
31
+
32
+ warning(skip: skip_warning)
23
33
  unless File.exist?(file_path)
24
34
  puts "File not found: #{file_path}"
25
35
  return
26
36
  end
37
+
27
38
  content = File.read(file_path)
28
- encoded = encode_text(content)
29
- File.write(file_path + ".hanifx", encoded)
30
- puts "File encoded successfully: #{file_path}.hanifx"
39
+ encoded = encode_text(content, options)
40
+ target_file = file_path + custom_suffix
41
+
42
+ if File.exist?(target_file) && !overwrite
43
+ puts "File already exists: #{target_file}. Use :overwrite => true to overwrite."
44
+ return
45
+ end
46
+
47
+ File.write(target_file, encoded)
48
+ puts "File encoded successfully: #{target_file}" if verbose
31
49
  end
32
50
 
33
- # Optional: check script safety for GitHub push
34
- def self.check_script(file_path)
51
+ # Check script safety for GitHub push
52
+ # options: verbose
53
+ def self.check_script(file_path, options = {})
54
+ verbose = options[:verbose] || false
35
55
  unless File.exist?(file_path)
36
56
  puts "File not found: #{file_path}"
37
57
  return
38
58
  end
39
- # Basic safety: ensure file can be required without error
40
59
  begin
41
60
  load file_path
42
- puts "Script is safe to run on terminal/GitHub"
61
+ puts "Script is safe to run on terminal/GitHub" if verbose
43
62
  rescue => e
44
63
  puts "Error detected in script: #{e.message}"
45
64
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanifx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hanif