test_for_root 0.0.2

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.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ ./idea/*
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
2
+ require 'test_for_root'
3
+ require 'gemspec'
4
+
5
+
6
+
data/LICENSE.txt ADDED
@@ -0,0 +1,14 @@
1
+ Copyright (c) 2013 Peter Bomars
2
+
3
+ This program is free software: you can redistribute it and/or modify
4
+ it under the terms of the GNU General Public License as published by
5
+ the Free Software Foundation, either version 3 of the License, or
6
+ (at your option) any later version.
7
+
8
+ This program is distributed in the hope that it will be useful,
9
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ GNU General Public License for more details.
12
+
13
+ You should have received a copy of the GNU General Public License
14
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # TestForRoot
2
+
3
+ This gem is a simple file/permissions management tool that tests for super-user permissions and has a basic API to return
4
+ user status at any point.
5
+
6
+ ##Classes
7
+
8
+ TestForRoot::User
9
+ ###Methods
10
+ \#name
11
+ \#groups
12
+ \#member?
13
+ \#uid
14
+
15
+ TestForRoot::Root
16
+
17
+
18
+ ## Installation
19
+
20
+ Add this line to your application's Gemfile:
21
+
22
+ gem 'test_for_root'
23
+
24
+ And then execute:
25
+
26
+ $ bundle
27
+
28
+ Or install it yourself as:
29
+
30
+ $ gem install test_for_root
31
+
32
+ ## Usage
33
+
34
+ TODO: Write usage instructions here
35
+
36
+ ## Contributing
37
+
38
+ 1. Fork it! PLEASE DO!
39
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
40
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
41
+ 4. Push to the branch (`git push origin my-new-feature`)
42
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift File.expand_path("../test_for_root", __FILE__)
2
+
3
+ require 'version'
4
+ require 'user'
5
+
6
+ module TestForRoot
7
+
8
+
9
+ end
@@ -0,0 +1,28 @@
1
+ module TestForRoot
2
+ class User
3
+
4
+ attr_reader :user, :member_of, :user_id
5
+
6
+ def initialize
7
+ @user = `id -un`.chomp
8
+ @member_of = (`groups #{@user}`.chomp.split(":"))[1].split
9
+ @user_id = %x{id -u}.chomp.to_i
10
+ end
11
+
12
+ def name
13
+ @user
14
+ end
15
+
16
+ def groups
17
+ @member_of
18
+ end
19
+
20
+ def member? (group_name)
21
+ @member_of.include? group_name
22
+ end
23
+
24
+ def uid
25
+ @user_id
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module TestForRoot
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'test_for_root'
@@ -0,0 +1,86 @@
1
+ require 'spec_helper'
2
+
3
+ describe TestForRoot do
4
+
5
+
6
+ it 'should have a version number' do
7
+ TestForRoot::VERSION.should_not be_nil
8
+ end
9
+
10
+ describe TestForRoot::User do
11
+ before :each do
12
+ @demo = TestForRoot::User.new
13
+ end
14
+
15
+ context 'it should respond to the various methods' do
16
+ it 'should respond to #name' do
17
+ @demo.should respond_to :name
18
+ end
19
+
20
+
21
+ =begin these don't work
22
+ it 'should respond to #membership' do
23
+
24
+ TestForRoot::User.should respond_to :membership("#{@demo.name}")
25
+
26
+ end
27
+
28
+ it 'should respond to #member?' do
29
+
30
+ TestForRoot::User.should respond_to :member?
31
+
32
+ end
33
+ =end
34
+
35
+ end
36
+
37
+ context "#new" do
38
+ it 'should create a new User object' do
39
+ @demo.should be_an_instance_of TestForRoot::User
40
+ end
41
+
42
+ #it 'should take no parameters' do
43
+ # TestForRoot::User.new(parameter).should raise_error
44
+ #end
45
+ end
46
+
47
+
48
+ context "#name" do
49
+
50
+ it "should return the current username" do
51
+ @demo.name.should eq `id -un`.chomp
52
+ end
53
+ end
54
+
55
+ context "#groups" do
56
+
57
+ it 'should be an array' do
58
+ @demo.groups.should be_a Array
59
+ end
60
+
61
+ it 'should return group membership' do
62
+ @demo.groups.should eq (`groups #{@demo.name}`.chomp.split(":"))[1].split
63
+ end
64
+ end
65
+
66
+ context "#member?" do
67
+
68
+ #it 'should take 1 argument' do
69
+ # @demo.member?.should raise_error
70
+ #end
71
+
72
+ it 'should return true if #name is a member of the supplied group' do
73
+ @demo.member? "#{@demo.name}".should be_true
74
+ end
75
+
76
+ end
77
+
78
+ context '#uid' do
79
+
80
+ it 'should return the $EUID of the program executor' do
81
+ @demo.uid.should == %x{id -u}.chomp.to_i
82
+ end
83
+ end
84
+
85
+ end
86
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'test_for_root/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "test_for_root"
8
+ gem.version = TestForRoot::VERSION
9
+ gem.authors = ["Peter Bomars"]
10
+ gem.email = ["pbomars@gmail.com"]
11
+ gem.description = %q{A gem that tests for root}
12
+ gem.summary = %q{A gem that tests for root on *nix systems with a basic API}
13
+ gem.homepage = "https://github.com/gekken/test_for_root"
14
+ gem.license = "GPLv3"
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_development_dependency "rake"
22
+ gem.add_development_dependency "rspec"
23
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: test_for_root
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Peter Bomars
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: A gem that tests for root
47
+ email:
48
+ - pbomars@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - .rspec
55
+ - Gemfile
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - lib/test_for_root.rb
60
+ - lib/test_for_root/user.rb
61
+ - lib/test_for_root/version.rb
62
+ - spec/spec_helper.rb
63
+ - spec/test_for_root_spec.rb
64
+ - test_for_root.gemspec
65
+ homepage: https://github.com/gekken/test_for_root
66
+ licenses:
67
+ - GPLv3
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 1.8.25
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: A gem that tests for root on *nix systems with a basic API
90
+ test_files:
91
+ - spec/spec_helper.rb
92
+ - spec/test_for_root_spec.rb
93
+ has_rdoc: