Class: InstanceAgent::CodeDeployPlugin::ApplicationSpecification::ModeInfo
- Inherits:
-
Object
- Object
- InstanceAgent::CodeDeployPlugin::ApplicationSpecification::ModeInfo
- Defined in:
- lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb
Overview
Helper Class for storing mode of a file
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#group_executable ⇒ Object
readonly
Returns the value of attribute group_executable.
-
#group_readable ⇒ Object
readonly
Returns the value of attribute group_readable.
-
#group_writable ⇒ Object
readonly
Returns the value of attribute group_writable.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#owner_executable ⇒ Object
readonly
Returns the value of attribute owner_executable.
-
#owner_readable ⇒ Object
readonly
Returns the value of attribute owner_readable.
-
#owner_writable ⇒ Object
readonly
Returns the value of attribute owner_writable.
-
#setgid ⇒ Object
readonly
Returns the value of attribute setgid.
-
#setuid ⇒ Object
readonly
Returns the value of attribute setuid.
-
#sticky ⇒ Object
readonly
Returns the value of attribute sticky.
-
#world ⇒ Object
readonly
Returns the value of attribute world.
-
#world_executable ⇒ Object
readonly
Returns the value of attribute world_executable.
-
#world_readable ⇒ Object
readonly
Returns the value of attribute world_readable.
-
#world_writable ⇒ Object
readonly
Returns the value of attribute world_writable.
Instance Method Summary collapse
-
#initialize(mode) ⇒ ModeInfo
constructor
A new instance of ModeInfo.
- #to_bits(num, min_size) ⇒ Object
Constructor Details
#initialize(mode) ⇒ ModeInfo
Returns a new instance of ModeInfo.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb', line 14 def initialize(mode) mode = mode.to_s while mode.length < 3 do mode = "0" + mode; end if mode.length > 4 raise AppSpecValidationException, "permission mode length incorrect: #{mode}" end mode.each_char do |char| if (char.ord < '0'.ord) || (char.ord > '7'.ord) raise AppSpecValidationException, "invalid character #{char} in permission mode #{mode}" end end @mode = mode mode_array = mode.reverse.chars.entries @world = mode_array[0] world_bits = to_bits(@world.to_i, 3) @world_readable = (world_bits[0] == 1) @world_writable = (world_bits[1] == 1) @world_executable = (world_bits[2] == 1) @group = mode_array[1] group_bits = to_bits(@group.to_i, 3) @group_readable = (group_bits[0] == 1) @group_writable = (group_bits[1] == 1) @group_executable = (group_bits[2] == 1) @owner = mode_array[2] owner_bits = to_bits(@owner.to_i, 3) @owner_readable = (owner_bits[0] == 1) @owner_writable = (owner_bits[1] == 1) @owner_executable = (owner_bits[2] == 1) special = (mode_array.length > 3) ? mode_array[3]: '0' special_bits = to_bits(special.to_i, 3) @setuid = (special_bits[0] == 1) @setgid = (special_bits[1] == 1) @sticky = (special_bits[2] == 1) end |
Instance Attribute Details
#group ⇒ Object (readonly)
Returns the value of attribute group.
10 11 12 |
# File 'lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb', line 10 def group @group end |
#group_executable ⇒ Object (readonly)
Returns the value of attribute group_executable.
10 11 12 |
# File 'lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb', line 10 def group_executable @group_executable end |
#group_readable ⇒ Object (readonly)
Returns the value of attribute group_readable.
10 11 12 |
# File 'lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb', line 10 def group_readable @group_readable end |
#group_writable ⇒ Object (readonly)
Returns the value of attribute group_writable.
10 11 12 |
# File 'lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb', line 10 def group_writable @group_writable end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
8 9 10 |
# File 'lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb', line 8 def mode @mode end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
11 12 13 |
# File 'lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb', line 11 def owner @owner end |
#owner_executable ⇒ Object (readonly)
Returns the value of attribute owner_executable.
11 12 13 |
# File 'lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb', line 11 def owner_executable @owner_executable end |
#owner_readable ⇒ Object (readonly)
Returns the value of attribute owner_readable.
11 12 13 |
# File 'lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb', line 11 def owner_readable @owner_readable end |
#owner_writable ⇒ Object (readonly)
Returns the value of attribute owner_writable.
11 12 13 |
# File 'lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb', line 11 def owner_writable @owner_writable end |
#setgid ⇒ Object (readonly)
Returns the value of attribute setgid.
12 13 14 |
# File 'lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb', line 12 def setgid @setgid end |
#setuid ⇒ Object (readonly)
Returns the value of attribute setuid.
12 13 14 |
# File 'lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb', line 12 def setuid @setuid end |
#sticky ⇒ Object (readonly)
Returns the value of attribute sticky.
12 13 14 |
# File 'lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb', line 12 def sticky @sticky end |
#world ⇒ Object (readonly)
Returns the value of attribute world.
9 10 11 |
# File 'lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb', line 9 def world @world end |
#world_executable ⇒ Object (readonly)
Returns the value of attribute world_executable.
9 10 11 |
# File 'lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb', line 9 def world_executable @world_executable end |
#world_readable ⇒ Object (readonly)
Returns the value of attribute world_readable.
9 10 11 |
# File 'lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb', line 9 def world_readable @world_readable end |
#world_writable ⇒ Object (readonly)
Returns the value of attribute world_writable.
9 10 11 |
# File 'lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb', line 9 def world_writable @world_writable end |
Instance Method Details
#to_bits(num, min_size) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb', line 55 def to_bits(num, min_size) bits = Array.new(min_size, 0) num_bits = num.to_s(2).split("") diff = [0, min_size - num_bits.length].max num_bits.map.with_index {|n,i| bits[i+diff] = n.to_i} bits end |