File tree Expand file tree Collapse file tree
lib/facter/resolvers/freebsd
spec/facter/resolvers/freebsd Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ def read_swap_memory(fact_name) # rubocop:disable Metrics/AbcSize
2121 @fact_list [ :total_bytes ] = kilobytes_to_bytes ( data . map { |line | line [ 1 ] . to_i } . inject ( :+ ) )
2222 @fact_list [ :used_bytes ] = kilobytes_to_bytes ( data . map { |line | line [ 2 ] . to_i } . inject ( :+ ) )
2323 @fact_list [ :available_bytes ] = kilobytes_to_bytes ( data . map { |line | line [ 3 ] . to_i } . inject ( :+ ) )
24- @fact_list [ :capacity ] = compute_capacity ( @fact_list [ :used_bytes ] , @fact_list [ :total_bytes ] )
24+ @fact_list [ :capacity ] = FilesystemHelper . compute_capacity ( @fact_list [ :used_bytes ] , @fact_list [ :total_bytes ] )
2525 @fact_list [ :encrypted ] = data . map { |line | line [ 0 ] . end_with? ( '.eli' ) } . all?
2626 end
2727
@@ -31,10 +31,6 @@ def read_swap_memory(fact_name) # rubocop:disable Metrics/AbcSize
3131 def kilobytes_to_bytes ( quantity )
3232 ( quantity . to_f * 1024 ) . to_i
3333 end
34-
35- def compute_capacity ( used , total )
36- "#{ format ( '%<value>.2f' , value : ( used / total . to_f * 100 ) ) } %"
37- end
3834 end
3935 end
4036 end
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ def calculate_system_memory(fact_name)
1818 read_available_memory_in_bytes
1919
2020 @fact_list [ :used_bytes ] = @fact_list [ :total_bytes ] - @fact_list [ :available_bytes ]
21- @fact_list [ :capacity ] = compute_capacity ( @fact_list [ :used_bytes ] , @fact_list [ :total_bytes ] )
21+ @fact_list [ :capacity ] = FilesystemHelper . compute_capacity ( @fact_list [ :used_bytes ] , @fact_list [ :total_bytes ] )
2222
2323 @fact_list [ fact_name ]
2424 end
@@ -34,10 +34,6 @@ def read_total_memory_in_bytes
3434
3535 @fact_list [ :total_bytes ] = Facter ::Freebsd ::FfiHelper . sysctl_by_name ( :long , 'hw.physmem' )
3636 end
37-
38- def compute_capacity ( used , total )
39- "#{ format ( '%<value>.2f' , value : ( used / total . to_f * 100 ) ) } %"
40- end
4137 end
4238 end
4339 end
Original file line number Diff line number Diff line change 77 let ( :available_bytes ) { 4_294_967_296 }
88 let ( :total_bytes ) { 4_294_967_296 }
99 let ( :used_bytes ) { 0 }
10- let ( :capacity ) { '0.00 %' }
10+ let ( :capacity ) { '0%' }
1111 let ( :encrypted ) { true }
1212
1313 before do
You can’t perform that action at this time.
0 commit comments