2pass 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6bc01e1efadcf89aa03153837fe43b43636879457474ed74ec1cc7e8fd23c6db
4
- data.tar.gz: f1bc2a3daaf6925a81106c4eae4b7e5ab54a56a31eaf115bca3672523056db3c
3
+ metadata.gz: 671d7c33b6f4e5e79ef13a88986405674f456dc06e23f5cc7450fb495ecdcb71
4
+ data.tar.gz: 415390e6ac546a6af7678058e1231a4ade807df151dca0b163aa4023da8fe229
5
5
  SHA512:
6
- metadata.gz: aa7041a6501a9214ee30a21482de8fb5251c35731d23e95f3de87dd746f9c85c8bbc3f6cc03dfadf0126e994ea326e40175a7a408434d98f3bd43f1659ce4473
7
- data.tar.gz: 433739132ea8b97032bc3a602da682a655a3a657adaa58d6b32828edd884de102ee2696c1f3f6c01e57b01fd59dc51121c08215f2335c6277e3dcab09f48ca2d
6
+ metadata.gz: f865bb6fac54e13f4ac4c7c917680b0a0ef92194d1a2f1f97cc72333de8215466d4ab598a0a2ddb5360bc61b489c9a0231fa2ec3d53afd98b7e9f15aecb58fb1
7
+ data.tar.gz: e01b0c574e69fcd8096605c7b7a2f383aad580dbbfd72ec6a89701573ee75a182303b5bd6349bc8022a9354e4a4bc042a090435016bba213aca0c37d54fcf5eb
data/2pass.gemspec CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = ["2pass"]
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.required_ruby_version = ">= 3.3"
22
+
21
23
  spec.add_development_dependency "bundler", "~> 2.0"
22
24
  spec.add_development_dependency "rake", "~> 13.0"
23
25
  spec.add_development_dependency "minitest", "~> 5.0"
data/bin/2pass CHANGED
@@ -20,6 +20,9 @@ OptionParser.new do |opts|
20
20
  opts.on("-h", "--help", "Display this help message") do
21
21
  options[:help] = true
22
22
  end
23
+ opts.on("-v", "--version", "Display the version") do
24
+ options[:version] = true
25
+ end
23
26
  end.parse!
24
27
 
25
28
  if options[:help]
@@ -27,6 +30,11 @@ if options[:help]
27
30
  exit
28
31
  end
29
32
 
33
+ if options[:version]
34
+ puts TwoPass::VERSION
35
+ exit
36
+ end
37
+
30
38
  if ARGV.length < 2
31
39
  help_message
32
40
  exit(1)
data/lib/2pass/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module TwoPass
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/2pass.rb CHANGED
@@ -9,61 +9,63 @@ require_relative "2pass/version"
9
9
  module TwoPass
10
10
  VAULT_DIR = "#{Dir.home}/.2pass"
11
11
 
12
- def self.create_symlink(vault_name, target_path)
13
- FileUtils.mkdir_p(VAULT_DIR)
14
- symlink_path = "#{VAULT_DIR}/#{vault_name}.yml"
12
+ class << self
13
+ def create_symlink(vault_name, target_path)
14
+ FileUtils.mkdir_p(VAULT_DIR)
15
+ symlink_path = "#{VAULT_DIR}/#{vault_name}.yml"
15
16
 
16
- if File.exist?(symlink_path)
17
- puts "Symlink already exists: #{symlink_path}"
18
- else
19
- File.symlink(target_path, symlink_path)
20
- puts "Created symlink: #{symlink_path} -> #{target_path}"
17
+ if File.exist?(symlink_path)
18
+ puts "Symlink already exists: #{symlink_path}"
19
+ else
20
+ File.symlink(target_path, symlink_path)
21
+ puts "Created symlink: #{symlink_path} -> #{target_path}"
22
+ end
21
23
  end
22
- end
23
24
 
24
- def self.load_vault(vault_name)
25
- file_path = "#{VAULT_DIR}/#{vault_name}.yml"
26
- return [] unless File.exist?(file_path)
25
+ def load_vault(vault_name)
26
+ file_path = "#{VAULT_DIR}/#{vault_name}.yml"
27
+ return [] unless File.exist?(file_path)
27
28
 
28
- YAML.load_file(file_path, symbolize_names: true) || []
29
- rescue Psych::SyntaxError => e
30
- STDERR.puts "Error parsing YAML file: #{e.message}"
31
- []
32
- end
29
+ YAML.load_file(file_path, symbolize_names: true) || []
30
+ rescue Psych::SyntaxError => e
31
+ STDERR.puts "Error parsing YAML file: #{e.message}"
32
+ []
33
+ end
33
34
 
34
- def self.save_vault(vault_name, data)
35
- FileUtils.mkdir_p(VAULT_DIR)
36
- file_path = "#{VAULT_DIR}/#{vault_name}.yml"
37
- File.write(file_path, YAML.dump(data))
38
- end
35
+ def save_vault(vault_name, data)
36
+ FileUtils.mkdir_p(VAULT_DIR)
37
+ file_path = "#{VAULT_DIR}/#{vault_name}.yml"
38
+ File.write(file_path, YAML.dump(data))
39
+ end
39
40
 
40
- def self.list_content(vault_name)
41
- vault = load_vault(vault_name)
42
- JSON.pretty_generate(vault)
43
- end
41
+ def list_content(vault_name)
42
+ vault = load_vault(vault_name)
43
+ JSON.pretty_generate(vault)
44
+ end
44
45
 
45
- def self.add_secret(vault_name, id, value)
46
- new_secret = {
47
- id: id,
48
- value: value,
49
- uuid: SecureRandom.uuid
50
- }
51
- data = load_vault(vault_name)
52
- existing_entry_id = data.find_index { |hash| hash[:id] == new_secret[:id] }
53
- if existing_entry_id
54
- raise "The secret already exists"
46
+ def add_secret(vault_name, id, value)
47
+ new_secret = {
48
+ id: id,
49
+ value: value,
50
+ uuid: SecureRandom.uuid
51
+ }
52
+ data = load_vault(vault_name)
53
+ existing_entry_id = data.find_index { |hash| hash[:id] == new_secret[:id] }
54
+ if existing_entry_id
55
+ raise "The secret already exists"
56
+ end
57
+ data << new_secret
58
+ save_vault(vault_name, data)
55
59
  end
56
- data << new_secret
57
- save_vault(vault_name, data)
58
- end
59
60
 
60
- def self.get_secret(vault_name, id)
61
- vault = load_vault(vault_name)
62
- entry = vault.find { |hash| hash[:id] == id }
63
- if entry
64
- entry[:value]
65
- else
66
- raise "Entry not found"
61
+ def get_secret(vault_name, id)
62
+ vault = load_vault(vault_name)
63
+ entry = vault.find { |hash| hash[:id] == id }
64
+ if entry
65
+ entry[:value]
66
+ else
67
+ raise "Entry not found"
68
+ end
67
69
  end
68
70
  end
69
71
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: 2pass
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olivier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-31 00:00:00.000000000 Z
11
+ date: 2024-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -99,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
- version: '0'
102
+ version: '3.3'
103
103
  required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  requirements:
105
105
  - - ">="