Module: ConfigHelper
- Defined in:
- lib/joe_utils/helpers/config_helper.rb
Instance Method Summary collapse
- #get_list_of_constants(file_content) ⇒ Object
- #is_inside_string? ⇒ Boolean
- #select_config_in_file(file_content, config_name) ⇒ Object
- #sort_json_file(address) ⇒ Object
Instance Method Details
#get_list_of_constants(file_content) ⇒ Object
20 21 22 |
# File 'lib/joe_utils/helpers/config_helper.rb', line 20 def get_list_of_constants(file_content) file_content.match() end |
#is_inside_string? ⇒ Boolean
16 17 18 |
# File 'lib/joe_utils/helpers/config_helper.rb', line 16 def is_inside_string?() end |
#select_config_in_file(file_content, config_name) ⇒ Object
24 25 26 |
# File 'lib/joe_utils/helpers/config_helper.rb', line 24 def select_config_in_file(file_content, config_name) file_content.match() end |
#sort_json_file(address) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/joe_utils/helpers/config_helper.rb', line 6 def sort_json_file(address) json_content = File.open(address, 'r') { |f| f.read } hash = JSON.load(json_content) structure = hash.sort_by { |key, _| key.to_s } hash = {} structure.each {|field| hash[field[0]] = field[1] } File.open(address, 'w+') { |f| f.write(JSON.pretty_generate(hash)) } puts 'File hash content has been sorted.' end |