Class: ISRakel::Tasks
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- ISRakel::Tasks
- Includes:
- Rake::DSL
- Defined in:
- lib/israkel/tasks.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#sdk_version ⇒ Object
Returns the value of attribute sdk_version.
Instance Method Summary collapse
- #allow_gps_access(bundle_id) ⇒ Object
- #edit_global_preferences(&block) ⇒ Object
- #edit_preferences(&block) ⇒ Object
-
#initialize(name = :simulator) {|_self| ... } ⇒ Tasks
constructor
A new instance of Tasks.
- #set_language(language) ⇒ Object
- #simulator_path ⇒ Object
- #simulator_preferences_path ⇒ Object
- #simulator_support_path ⇒ Object
Constructor Details
#initialize(name = :simulator) {|_self| ... } ⇒ Tasks
Returns a new instance of Tasks.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/israkel/tasks.rb', line 13 def initialize(name = :simulator) @name = name yield self if block_given? define_allow_gps_access_task define_reset_task define_set_language_task define_start_task define_stop_task end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
11 12 13 |
# File 'lib/israkel/tasks.rb', line 11 def name @name end |
#sdk_version ⇒ Object
Returns the value of attribute sdk_version.
11 12 13 |
# File 'lib/israkel/tasks.rb', line 11 def sdk_version @sdk_version end |
Instance Method Details
#allow_gps_access(bundle_id) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/israkel/tasks.rb', line 25 def allow_gps_access(bundle_id) directory = File.join(simulator_support_path, 'Library', 'Caches', 'locationd') FileUtils.mkdir_p(directory) unless Dir.exists?(directory) edit_file( File.join(directory, 'clients.plist') ) do |content| content.merge!({ bundle_id => { :Authorized => true, :BundleId => bundle_id, :Executable => "", :Registered => "", :Whitelisted => false, } }) end end |
#edit_global_preferences(&block) ⇒ Object
41 42 43 |
# File 'lib/israkel/tasks.rb', line 41 def edit_global_preferences(&block) edit_file( File.join(simulator_preferences_path, '.GlobalPreferences.plist'), &block ) end |
#edit_preferences(&block) ⇒ Object
45 46 47 |
# File 'lib/israkel/tasks.rb', line 45 def edit_preferences(&block) edit_file( File.join(simulator_preferences_path, 'com.apple.Preferences.plist'), &block ) end |
#set_language(language) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/israkel/tasks.rb', line 53 def set_language(language) edit_global_preferences do |p| unless p['AppleLanguages'].include?(language) fail "#{language} is not a valid language" end p['AppleLanguages'].unshift(language).uniq! end end |
#simulator_path ⇒ Object
62 63 64 |
# File 'lib/israkel/tasks.rb', line 62 def simulator_path @simulator_path ||= File.join(xcode_path, 'Platforms', 'iPhoneSimulator.platform', 'Developer', 'Applications', 'iPhone Simulator.app') end |
#simulator_preferences_path ⇒ Object
66 67 68 |
# File 'lib/israkel/tasks.rb', line 66 def simulator_preferences_path File.join(simulator_support_path, 'Library', 'Preferences') end |
#simulator_support_path ⇒ Object
70 71 72 |
# File 'lib/israkel/tasks.rb', line 70 def simulator_support_path @simulator_support_path ||= File.join(ENV['HOME'], 'Library', 'Application Support', 'iPhone Simulator', sdk_version) end |