Class: Bixby::Provision::Base
- Inherits:
-
Object
- Object
- Bixby::Provision::Base
- Extended by:
- Log
- Includes:
- Log, Util::File, ScriptUtil
- Defined in:
- lib/bixby/provision/dsl/base.rb
Direct Known Subclasses
Bundler, Config, DirDSL, FileDSL, Inventory, Meteor, NPM, NTP, NodeJS, Packager::PackagerBase, Ruby, RunControl, SCM, SCM::SCMBase, Service, Services::ServiceBase, System, Variable
Constant Summary collapse
- PATH =
"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Instance Attribute Summary collapse
-
#manifest ⇒ Object
Returns the value of attribute manifest.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
Instance Method Summary collapse
- #get_gid(group) ⇒ Object
- #get_group(gid) ⇒ Object
- #get_uid(user) ⇒ Object
- #get_user(uid) ⇒ Object
-
#initialize(obj = nil) ⇒ Base
constructor
A new instance of Base.
- #tap(&block) ⇒ Object
-
#tempfile(close = false) ⇒ Tempfile
Create a temporary file.
Methods included from Util::File
#chmod, #chown, #sha256sum, #which
Constructor Details
Instance Attribute Details
#manifest ⇒ Object
Returns the value of attribute manifest.
18 19 20 |
# File 'lib/bixby/provision/dsl/base.rb', line 18 def manifest @manifest end |
#proxy ⇒ Object
Returns the value of attribute proxy.
18 19 20 |
# File 'lib/bixby/provision/dsl/base.rb', line 18 def proxy @proxy end |
Instance Method Details
#get_gid(group) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/bixby/provision/dsl/base.rb', line 53 def get_gid(group) return group if group.nil? or group.kind_of? Fixnum return group.to_i if group =~ /^[0-9]+$/ # convert to int, e.g. "500" begin return Etc.getgrnam(group).gid rescue ArgumentError => ex # TODO raise logger.warn("Group '#{group}' was invalid: #{ex.}") end nil end |
#get_group(gid) ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/bixby/provision/dsl/base.rb', line 65 def get_group(gid) begin return Etc.getgrgid(gid).name rescue ArgumentError => ex # TODO raise logger.warn("Group '#{group}' was invalid: #{ex.}") end nil end |
#get_uid(user) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bixby/provision/dsl/base.rb', line 31 def get_uid(user) return user if user.nil? or user.kind_of? Fixnum return user.to_i if user =~ /^[0-9]+$/ # convert to int, e.g. "500" begin return Etc.getpwnam(user).uid rescue ArgumentError => ex # TODO raise logger.warn("Username '#{user}' was invalid: #{ex.}") end nil end |
#get_user(uid) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/bixby/provision/dsl/base.rb', line 43 def get_user(uid) begin return Etc.getpwuid(uid).name rescue ArgumentError => ex # TODO raise logger.warn("Username '#{user}' was invalid: #{ex.}") end nil end |
#tap(&block) ⇒ Object
27 28 29 |
# File 'lib/bixby/provision/dsl/base.rb', line 27 def tap(&block) self.instance_eval(&block) end |
#tempfile(close = false) ⇒ Tempfile
Create a temporary file
80 81 82 83 84 |
# File 'lib/bixby/provision/dsl/base.rb', line 80 def tempfile(close=false) t = Tempfile.new("bixby-provision-") t.close if close t end |