Class: OneMoreUDID::LocalAgent
- Inherits:
-
Object
- Object
- OneMoreUDID::LocalAgent
- Defined in:
- lib/omudid/local_agent.rb
Instance Method Summary collapse
Instance Method Details
#get_profiles ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/omudid/local_agent.rb', line 39 def get_profiles profiles = [] Dir.glob(File.('~') + '/Library/MobileDevice/Provisioning Profiles/*.mobileprovision') do |file| File.open(file, "r") do |_file| file_contents = _file.read if String.method_defined?(:encode) #file_contents.encode!('UTF-8', 'UTF-8', :invalid => :replace) file_contents.encode!('UTF-16', 'UTF-8', :invalid => :replace, :replace => '') file_contents.encode!('UTF-8', 'UTF-16') end matches = /<key>Name<\/key>\s+<string>([^<]+)<\/string>/.match file_contents profiles << matches[1] end end profiles end |
#install_profile(profile_name, filename) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/omudid/local_agent.rb', line 3 def install_profile(profile_name, filename) Dir.glob(File.('~') + '/Library/MobileDevice/Provisioning Profiles/*.mobileprovision') do |file| delete_file = false File.open(file, "r") do |_file| file_contents = _file.read if String.method_defined?(:encode) #file_contents.encode!('UTF-8', 'UTF-8', :invalid => :replace) file_contents.encode!('UTF-16', 'UTF-8', :invalid => :replace, :replace => '') file_contents.encode!('UTF-8', 'UTF-16') end matches = /<key>Name<\/key>\s+<string>([^<]+)<\/string>/.match file_contents if matches[1] == profile_name delete_file = true end end if delete_file say_warning 'Old profile deleted ('+ file +')' File.delete(file) break end end new_path = File.('~') + '/Library/MobileDevice/Provisioning Profiles/' + filename File.rename(Dir.pwd + '/' + filename, new_path) say_ok 'New profile installed ('+new_path+')' end |