aris-control 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bcc9b2350949da64d9361170d4408babe8dd77fd
4
+ data.tar.gz: 20d3cce981bceddaf96070f3ec30f6b43a89ff3d
5
+ SHA512:
6
+ metadata.gz: eb4410226c47d6e7ee8f0d13b53cff492609ac255d6cc6353a72ad042db2963b0118beeac5d82e7239e64aa3edb67a8892e4db49c8fc0730716e29e4d86574d7
7
+ data.tar.gz: d95e36bb4ff59644b9f9d946b0c45e8ae6663bd60adbcdcbd8eec2407bdb8b735df5fcf564a9679b3dea40df747126e110f25a43fa37648af3b8a1f20943004e
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format doc
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,6 @@
1
+ # Aris-Control
2
+ A little CLI util for managing the aris service. Aris is currently a private project opensource-based
3
+ heroku-like solution which I use for my work at [HTW](http://www.htw-berlin.de).
4
+
5
+ # License
6
+ http://grekko.mit-license.org/
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler/gem_tasks'
2
+
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'aris-control/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'aris-control'
8
+ spec.version = ArisControl::VERSION
9
+ spec.authors = ["Gregory Igelmund"]
10
+ spec.email = ["gregory.igelmund@gmail.com"]
11
+
12
+ spec.summary = 'Aris utility'
13
+ spec.description = 'Manage aris users from the command line. Add, delete or list them.'
14
+ spec.homepage = 'https://github.com/grekko/aris-control'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'bin'
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.require_paths = %w(lib)
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.10'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'rspec', '~> 3.3'
25
+ spec.add_development_dependency 'byebug', '~> 6.0'
26
+ spec.add_dependency 'thor', '~> 0.19'
27
+ end
data/bin/aris-control ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/aris-control'
3
+
4
+ ArisControl::Thor.start
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require_relative '../lib/aris-control'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
@@ -0,0 +1,33 @@
1
+ require_relative 'persistence'
2
+
3
+ module ArisControl
4
+ ModificationError = Class.new(StandardError)
5
+
6
+ class Bookkeeper
7
+ attr_reader :persistence, :users
8
+
9
+ def initialize(persistence = default_persistence)
10
+ @persistence = persistence
11
+ @users = persistence.load_users
12
+ end
13
+
14
+ def list
15
+ users
16
+ end
17
+
18
+ def add(name:, email:, **opts)
19
+ raise ArisControl::ModificationError if users.has_key?(name)
20
+ users[name] = opts.merge(email: email)
21
+ persistence.store_users(users)
22
+ end
23
+
24
+ def delete(name)
25
+ users.delete(name)
26
+ persistence.store_users(users)
27
+ end
28
+
29
+ def default_persistence
30
+ ArisControl::Persistence.new
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,32 @@
1
+ require 'yaml'
2
+ require 'pathname'
3
+
4
+ module ArisControl
5
+ class Persistence
6
+ attr_reader :config_file_path, :users_file_path
7
+
8
+ def initialize(config = default_config)
9
+ @config = config
10
+ @config_file_path = Pathname.new config[:config_file_path]
11
+ @users_file_path = Pathname.new config[:users_file_path]
12
+ end
13
+
14
+ def store_users(users)
15
+ users ||= {}
16
+ IO.binwrite(users_file_path, YAML.dump(users))
17
+ users
18
+ end
19
+
20
+ def load_users
21
+ store_users({}) unless users_file_path.exist?
22
+ YAML.load(IO.binread(users_file_path)) || {}
23
+ end
24
+
25
+ def default_config
26
+ {
27
+ config_file_path: '/opt/aris/config/aris.cfg',
28
+ users_file_path: '/opt/aris/config/users.yml',
29
+ }
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,38 @@
1
+ require 'thor'
2
+ require 'pp'
3
+
4
+ class ArisControl::Thor < Thor
5
+ desc 'add username email', 'Adds a new aris user'
6
+ method_option :ssh_key, type: :string, desc: 'The users ssh public key for git access'
7
+ def add(name, email)
8
+ bookkeeper.add(name: name, email: email, **options.dup)
9
+ puts "Added user: #{name}, #{email}"
10
+ puts "-----------------------------"
11
+ print_current_aris_users
12
+ end
13
+
14
+ desc 'delete name', 'Deletes aris user'
15
+ def delete(name)
16
+ bookkeeper.delete(name)
17
+ puts "Removed user: #{name}"
18
+ puts "-----------------------------"
19
+ print_current_aris_users
20
+ end
21
+
22
+ desc 'list', 'Lists current aris-users'
23
+ def list
24
+ print_current_aris_users
25
+ end
26
+
27
+ private
28
+
29
+ def print_current_aris_users
30
+ puts "Current aris user database"
31
+ puts "-----------------------------"
32
+ pp bookkeeper.list
33
+ end
34
+
35
+ def bookkeeper
36
+ @bookkeeper ||= ArisControl::Bookkeeper.new
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module ArisControl
2
+ VERSION = '1.0.0'
3
+ end
File without changes
@@ -0,0 +1,6 @@
1
+ module ArisControl
2
+ end
3
+
4
+ require_relative './aris-control/persistence'
5
+ require_relative './aris-control/bookkeeper'
6
+ require_relative './aris-control/thor'
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aris-control
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Gregory Igelmund
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '6.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '6.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: thor
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.19'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.19'
83
+ description: Manage aris users from the command line. Add, delete or list them.
84
+ email:
85
+ - gregory.igelmund@gmail.com
86
+ executables:
87
+ - aris-control
88
+ - console
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - ".rspec"
94
+ - Gemfile
95
+ - README.md
96
+ - Rakefile
97
+ - aris-control.gemspec
98
+ - bin/aris-control
99
+ - bin/console
100
+ - lib/aris-control-thor.rb
101
+ - lib/aris-control.rb
102
+ - lib/aris-control/bookkeeper.rb
103
+ - lib/aris-control/persistence.rb
104
+ - lib/aris-control/thor.rb
105
+ - lib/aris-control/version.rb
106
+ homepage: https://github.com/grekko/aris-control
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.4.8
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Aris utility
130
+ test_files: []