Class: Produce::Service
- Inherits:
-
Object
- Object
- Produce::Service
- Defined in:
- lib/produce/service.rb
Class Method Summary collapse
Instance Method Summary collapse
- #app ⇒ Object
- #disable(options, _args) ⇒ Object
- #enable(options, _args) ⇒ Object
- #update(on, app, options) ⇒ Object
- #valid_services_for(options) ⇒ Object
Class Method Details
.disable(options, args) ⇒ Object
7 8 9 |
# File 'lib/produce/service.rb', line 7 def self.disable(, args) self.new.disable(, args) end |
.enable(options, args) ⇒ Object
3 4 5 |
# File 'lib/produce/service.rb', line 3 def self.enable(, args) self.new.enable(, args) end |
Instance Method Details
#app ⇒ Object
175 176 177 178 179 180 181 182 183 184 |
# File 'lib/produce/service.rb', line 175 def app return @app if @app Helper.log.info "Starting login with user '#{Produce.config[:username]}'" Spaceship.login(Produce.config[:username], nil) Spaceship.select_team Helper.log.info "Successfully logged in" @app ||= Spaceship.app.find(Produce.config[:app_identifier].to_s) end |
#disable(options, _args) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/produce/service.rb', line 23 def disable(, _args) unless app Helper.log.info "[DevCenter] App '#{Produce.config[:app_identifier]}' does not exist".red return end Helper.log.info "[DevCenter] App found '#{app.name}'".green Helper.log.info "Disabling services" disabled = update(false, app, ) Helper.log.info "Done! Disabled #{disabled} services.".green end |
#enable(options, _args) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/produce/service.rb', line 11 def enable(, _args) unless app Helper.log.info "[DevCenter] App '#{Produce.config[:app_identifier]}' does not exist".red return end Helper.log.info "[DevCenter] App found '#{app.name}'".green Helper.log.info "Enabling services" enabled = update(true, app, ) Helper.log.info "Done! Enabled #{enabled} services.".green end |
#update(on, app, options) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/produce/service.rb', line 41 def update(on, app, ) updated = valid_services_for().count if .app_group Helper.log.info "\tApp Groups" if on app.update_service(Spaceship.app_service.app_group.on) else app.update_service(Spaceship.app_service.app_group.off) end end if .associated_domains Helper.log.info "\tAssociated Domains" if on app.update_service(Spaceship.app_service.associated_domains.on) else app.update_service(Spaceship.app_service.associated_domains.off) end end if .data_protection Helper.log.info "\tData Protection" if on case .data_protection when "complete" app.update_service(Spaceship.app_service.data_protection.complete) when "unlessopen" app.update_service(Spaceship.app_service.data_proection.unless_open) when "untilfirstauth" app.update_service(Spaceship.app_service.data_protection.until_first_auth) else raise "Unknown service '#{.data_protection}'. Valid values: 'complete', 'unlessopen', 'untilfirstauth'".red end else app.update_service(Spaceship.app_service.data_protection.off) end end if .healthkit Helper.log.info "\tHealthKit" if on app.update_service(Spaceship.app_service.health_kit.on) else app.update_service(Spaceship.app_service.health_kit.off) end end if .homekit Helper.log.info "\tHomeKit" if on app.update_service(Spaceship.app_service.home_kit.on) else app.update_service(Spaceship.app_service.home_kit.off) end end if .wireless_conf Helper.log.info "\tWireless Accessory Configuration" if on app.update_service(Spaceship.app_service.wireless_accessory.on) else app.update_service(Spaceship.app_service.wireless_accessory.off) end end if .icloud Helper.log.info "\tiCloud" if on case .icloud when "legacy" app.update_service(Spaceship.app_service.icloud.on) app.update_service(Spaceship.app_service.cloud_kit.xcode5_compatible) when "cloudkit" app.update_service(Spaceship.app_service.icloud.on) app.update_service(Spaceship.app_service.cloud_kit.cloud_kit) else raise "Unknown service '#{.icloud}'. Valid values: 'legacy', 'cloudkit'".red end else app.update_service(Spaceship.app_service.icloud.off) end end if .inter_app_audio Helper.log.info "\tInter-App Audio" if on app.update_service(Spaceship.app_service.inter_app_audio.on) else app.update_service(Spaceship.app_service.inter_app_audio.off) end end if .passbook Helper.log.info "\tPassbook" if on app.update_service(Spaceship.app_service.passbook.on) else app.update_service(Spaceship.app_service.passbook.off) end end if .push_notification Helper.log.info "\tPush Notifications" if on app.update_service(Spaceship.app_service.push_notification.on) else app.update_service(Spaceship.app_service.push_notification.off) end end if .vpn_conf Helper.log.info "\tVPN Configuration" if on app.update_service(Spaceship.app_service.vpn_configuration.on) else app.update_service(Spaceship.app_service.vpn_configuration.off) end end updated end |
#valid_services_for(options) ⇒ Object
35 36 37 38 39 |
# File 'lib/produce/service.rb', line 35 def valid_services_for() allowed_keys = [:app_group, :associated_domains, :data_protection, :healthkit, :homekit, :wireless_conf, :icloud, :inter_app_audio, :passbook, :push_notification, :vpn_conf] .__hash__.select { |key, value| allowed_keys.include? key } end |