aris-control 1.1.1 → 1.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3922ebdfa479a051e783e808fed3442b4019e6e
4
- data.tar.gz: d0105e8bbd6c2b2ca5fec3052df6fdf6a8af4e76
3
+ metadata.gz: d9a61dd46a5d85a26cdaca8ea0e1e06b9cbab795
4
+ data.tar.gz: 87daf1c8bd1f7b82d0f425fcc911024a61365ba1
5
5
  SHA512:
6
- metadata.gz: 92c0967e51a656c13287e6304318151de9e651e200d129aadccd3ded6b5b0a2e832fbfb9f372277f0acafab3125514e9a5f3ab36c984a3fed21b0b77eb6a3c3b
7
- data.tar.gz: 5893fc6fb03513b2da0ea994b59577c35eabd66c2aa2cc5817401b89258c74b035b7247160babba3b00cad815e672aac389b8c293d303d7d3489358d44efb597
6
+ metadata.gz: 0a9ce91d47604d931069a34412636284be00818006bafc560338c422457c51cb77000e4e3ba4695183c5cc433685a5e72c0b42a8bfd19f5f0e6106e7270081be
7
+ data.tar.gz: ccc9c11c12d61d0a36ab97ab86d9cccebd264b69dab282cc051276de57eb269df217612881cc032735a88de248f0176881c9de460b2671476aa543aa30b04152
@@ -13,10 +13,18 @@ module ArisControl
13
13
  users
14
14
  end
15
15
 
16
- def add(name:, email:, **opts)
17
- email or raise ArgumentError
18
- user = users[name] || {}
19
- users[name] = user.merge(opts).merge(email: email)
16
+ def add(name, opts = {})
17
+ user = users[name] || {}
18
+ ssh_key = opts[:ssh_key]
19
+ env_vars = opts[:env_vars]
20
+
21
+ _opts = Hash.new.tap do |h|
22
+ h[:email] = opts[:email] || user.fetch(:email)
23
+ h[:ssh_key] = ssh_key if ssh_key
24
+ h[:env_vars] = with_upcased_keys(env_vars) if env_vars
25
+ end
26
+
27
+ users[name] = user.merge(_opts)
20
28
  persistence.store_users(users)
21
29
  end
22
30
 
@@ -28,5 +36,12 @@ module ArisControl
28
36
  def default_persistence
29
37
  ArisControl::Persistence.new
30
38
  end
39
+
40
+ private
41
+
42
+ def with_upcased_keys(hash)
43
+ hash or return
44
+ hash.each_with_object({}) {|(k,v),h| h[k.to_s.upcase] = v }
45
+ end
31
46
  end
32
47
  end
@@ -3,7 +3,7 @@ require 'pp'
3
3
 
4
4
  class ArisControl::Thor < Thor
5
5
  desc 'add/update username', 'Adds/Updates an aris user.'
6
- method_option :email, type: :string, required: true, desc: 'The users email address. Used for web login.'
6
+ method_option :email, type: :string, desc: 'The users email address. Used for web login.'
7
7
  method_option :ssh_key, type: :string, desc: 'The users ssh public key. Used for git access via ssh.'
8
8
  method_option :env_vars, type: :hash, desc: 'The users app env vars. Env vars will be accessible inside the app via ENV[VAR-NAME].'
9
9
  def add(name)
@@ -12,8 +12,8 @@ class ArisControl::Thor < Thor
12
12
  h[:ssh_key] = options[:ssh_key] if options[:ssh_key]
13
13
  h[:env_vars] = options[:env_vars] if options[:env_vars]
14
14
  end
15
- bookkeeper.add(name: name, **opts)
16
- puts "Added/Updated user: #{name}, #{options}"
15
+ bookkeeper.add(name, **opts)
16
+ puts "Added/Updated user: #{name}, #{opts}"
17
17
  puts "-----------------------------"
18
18
  print_current_aris_users
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module ArisControl
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aris-control
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregory Igelmund