• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aws / aws-codedeploy-agent / 4600315001

pending completion
4600315001

push

github

GitHub
Updating latest version info for master branch

1129 of 2362 relevant lines covered (47.8%)

2.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

25.53
/lib/instance_agent/plugins/codedeploy/application_specification/mode_info.rb
1
module InstanceAgent
1✔
2
  module Plugins
1✔
3
    module CodeDeployPlugin
1✔
4
      module ApplicationSpecification
1✔
5
        #Helper Class for storing mode of a file
6
        class ModeInfo
1✔
7

8
          attr_reader :mode
1✔
9
          attr_reader :world, :world_readable, :world_writable, :world_executable
1✔
10
          attr_reader :group, :group_readable, :group_writable, :group_executable
1✔
11
          attr_reader :owner, :owner_readable, :owner_writable, :owner_executable
1✔
12
          attr_reader :setuid, :setgid, :sticky
1✔
13
          def initialize(mode)
1✔
14
            mode = mode.to_s
×
15
            while mode.length < 3 do
×
16
              mode = "0" + mode;
×
17
            end
18
            if mode.length > 4
×
19
              raise AppSpecValidationException, "The deployment failed because the length of a permissions mode (#{mode}) in the application specification file is invalid. Permissions modes must be between one and four characters long. Update the permissions section of the AppSpec file, and then try again."
×
20
            end
21
            mode.each_char do |char|
×
22
              if (char.ord < '0'.ord) || (char.ord > '7'.ord)
×
23
                raise AppSpecValidationException, "The deployment failed because the permissions mode (#{mode}) in the application specification file contains an invalid character (#{char}). Update the permissions section of the AppSpec file, and then try again."
×
24
              end
25
            end
26
            @mode = mode
×
27
            mode_array = mode.reverse.chars.entries
×
28

29
            @world = mode_array[0]
×
30
            world_bits = to_bits(@world.to_i, 3)
×
31
            @world_readable = (world_bits[0] == 1)
×
32
            @world_writable = (world_bits[1] == 1)
×
33
            @world_executable = (world_bits[2] == 1)
×
34

35
            @group = mode_array[1]
×
36
            group_bits = to_bits(@group.to_i, 3)
×
37
            @group_readable = (group_bits[0] == 1)
×
38
            @group_writable = (group_bits[1] == 1)
×
39
            @group_executable = (group_bits[2] == 1)
×
40

41
            @owner = mode_array[2]
×
42
            owner_bits = to_bits(@owner.to_i, 3)
×
43
            @owner_readable = (owner_bits[0] == 1)
×
44
            @owner_writable = (owner_bits[1] == 1)
×
45
            @owner_executable = (owner_bits[2] == 1)
×
46

47
            special = (mode_array.length > 3) ? mode_array[3]: '0'
×
48
            special_bits = to_bits(special.to_i, 3)
×
49
            @setuid = (special_bits[0] == 1)
×
50
            @setgid = (special_bits[1] == 1)
×
51
            @sticky = (special_bits[2] == 1)
×
52
          end
53

54
          def to_bits(num, min_size)
1✔
55
            bits = Array.new(min_size, 0)
×
56
            num_bits = num.to_s(2).split("")
×
57
            diff = [0, min_size - num_bits.length].max
×
58
            num_bits.map.with_index {|n,i| bits[i+diff] = n.to_i}
×
59
            bits
×
60
          end
61
        end
62

63
      end
64
    end
65
  end
66
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc