israkel 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'json', '~> 1.7.6'
4
+ gem 'rake', '~> 0.9.0'
5
+
6
+ group :development do
7
+ gem 'jeweler', '~> 1.8.4'
8
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,21 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.8.4)
6
+ bundler (~> 1.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rdoc
10
+ json (1.7.6)
11
+ rake (0.9.6)
12
+ rdoc (3.12)
13
+ json (~> 1.4)
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ jeweler (~> 1.8.4)
20
+ json (~> 1.7.6)
21
+ rake (~> 0.9.0)
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # ISRakel
2
+
3
+ This gem is a collection of rake tasks for maintaining common tasks
4
+ for the iPhone Simulator on Mac OS like ...
5
+
6
+ * Change preferences of the iPhone Simulator
7
+ * Change the language of the iPhone Simulator
8
+ * Reset the iPhone Simulator
9
+ * Start the iPhone Simulator
10
+ * Stop the iPhone Simulator
11
+
12
+ ## Example Usage
13
+
14
+ You will need to install the gem:
15
+
16
+ gem install israkel
17
+
18
+ and then require the gem in your projects rake file
19
+
20
+ require 'israkel'
21
+
22
+ and finally load the rake tasks
23
+
24
+ ISRakel::Tasks.new
25
+
26
+ You can also change the default prefix `simulator`:
27
+
28
+ ISRakel::Tasks.new do |r|
29
+ r.name = 'ios'
30
+ end
31
+
32
+ ## Edit (global) Preferences
33
+
34
+ There are binary plist files that you can edit with your custom rake
35
+ tasks to change some settings:
36
+
37
+ i = ISRakel::Tasks.new
38
+ desc "Change keyboard preferences"
39
+ task :set_keyboard_preferences do
40
+ i.edit_preferences do |p|
41
+ puts p
42
+ p.merge!({
43
+ :KeyboardAutocapitalization => false,
44
+ :KeyboardAutocorrection => false,
45
+ :KeyboardCapsLock => false,
46
+ :KeyboardCheckSpelling => false,
47
+ :KeyboardPeriodShortcut => false,
48
+ })
49
+ puts p
50
+ end
51
+ end
52
+
53
+ There's a second method called `edit_global_preferences` which works
54
+ the same, just edits a different file.
55
+
56
+ ## Feedback
57
+
58
+ Please raise issues if you find problems or have a feature request.
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ $:.unshift "#{File.dirname(__FILE__)}/lib"
2
+ require 'jeweler'
3
+ require 'israkel'
4
+
5
+ Jeweler::Tasks.new do |gem|
6
+ gem.name = 'israkel'
7
+ gem.homepage = 'http://github.com/plu/israkel'
8
+ gem.license = 'MIT'
9
+ gem.summary = %Q{Collection of common rake tasks for the iPhone Simulator.}
10
+ gem.description = %Q{Collection of common rake tasks for the iPhone Simulator like start/stop and some more.}
11
+ gem.email = 'plu@pqpq.de'
12
+ gem.authors = ['Johannes Plunien']
13
+ end
14
+ Jeweler::RubygemsDotOrgTasks.new
15
+
16
+ i = ISRakel::Tasks.new
17
+ desc "Change keyboard preferences"
18
+ task :set_keyboard_preferences do
19
+ i.edit_preferences do |p|
20
+ puts p
21
+ p.merge!({
22
+ :KeyboardAutocapitalization => false,
23
+ :KeyboardAutocorrection => false,
24
+ :KeyboardCapsLock => false,
25
+ :KeyboardCheckSpelling => false,
26
+ :KeyboardPeriodShortcut => false,
27
+ })
28
+ puts p
29
+ end
30
+ end
31
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/israkel.gemspec ADDED
@@ -0,0 +1,52 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "israkel"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Johannes Plunien"]
12
+ s.date = "2013-01-11"
13
+ s.description = "Collection of common rake tasks for the iPhone Simulator like start/stop and some more."
14
+ s.email = "plu@pqpq.de"
15
+ s.extra_rdoc_files = [
16
+ "README.md"
17
+ ]
18
+ s.files = [
19
+ "Gemfile",
20
+ "Gemfile.lock",
21
+ "README.md",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "israkel.gemspec",
25
+ "lib/israkel.rb",
26
+ "lib/israkel/tasks.rb"
27
+ ]
28
+ s.homepage = "http://github.com/plu/israkel"
29
+ s.licenses = ["MIT"]
30
+ s.require_paths = ["lib"]
31
+ s.rubygems_version = "1.8.24"
32
+ s.summary = "Collection of common rake tasks for the iPhone Simulator."
33
+
34
+ if s.respond_to? :specification_version then
35
+ s.specification_version = 3
36
+
37
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
38
+ s.add_runtime_dependency(%q<json>, ["~> 1.7.6"])
39
+ s.add_runtime_dependency(%q<rake>, ["~> 0.9.0"])
40
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
41
+ else
42
+ s.add_dependency(%q<json>, ["~> 1.7.6"])
43
+ s.add_dependency(%q<rake>, ["~> 0.9.0"])
44
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
45
+ end
46
+ else
47
+ s.add_dependency(%q<json>, ["~> 1.7.6"])
48
+ s.add_dependency(%q<rake>, ["~> 0.9.0"])
49
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
50
+ end
51
+ end
52
+
@@ -0,0 +1,107 @@
1
+ require 'fileutils'
2
+ require 'json'
3
+ require 'rake'
4
+ require 'rake/tasklib'
5
+
6
+ module ISRakel
7
+ class Tasks < ::Rake::TaskLib
8
+ include ::Rake::DSL if defined?(::Rake::DSL)
9
+
10
+ attr_accessor :name, :sdk_version
11
+
12
+ def initialize(name = :simulator)
13
+ @name = name
14
+ @sdk_version = ENV['IOS_SDK_VERSION'] || '6.0'
15
+
16
+ yield self if block_given?
17
+
18
+ # Make sure all external commands are in the PATH.
19
+ xcode_path
20
+
21
+ define_reset_task
22
+ define_set_language_task
23
+ define_start_task
24
+ define_stop_task
25
+ end
26
+
27
+ def edit_global_preferences(&block)
28
+ edit_file( File.join(simulator_preferences_path, '.GlobalPreferences.plist'), &block )
29
+ end
30
+
31
+ def edit_preferences(&block)
32
+ edit_file( File.join(simulator_preferences_path, 'com.apple.Preferences.plist'), &block )
33
+ end
34
+
35
+ private
36
+
37
+ def edit_file(file)
38
+ content = plist_to_hash(file)
39
+ yield content
40
+ hash_to_plist(content, file)
41
+ end
42
+
43
+ def define_reset_task
44
+ desc "Reset content and settings of the iPhone Simulator"
45
+ task "#{name}:reset" do
46
+ rm_rf simulator_support_path
47
+ end
48
+ end
49
+
50
+ def define_set_language_task
51
+ desc "Set the system language (via IOS_LANG environment variable)"
52
+ task "#{name}:set_language" do
53
+ language = ENV['IOS_LANG']
54
+ if language.nil?
55
+ fail "You must set the IOS_LANG environment variable"
56
+ end
57
+ edit_global_preferences do |p|
58
+ unless p['AppleLanguages'].include?(language)
59
+ fail "#{language} is not a valid language"
60
+ end
61
+ p['AppleLanguages'].unshift(language).uniq!
62
+ end
63
+ end
64
+ end
65
+
66
+ def define_start_task
67
+ desc "Start the iPhone Simulator"
68
+ task "#{name}:start" do
69
+ sh 'open', '-g', simulator_path
70
+ end
71
+ end
72
+
73
+ def define_stop_task
74
+ desc "Stop the iPhone Simulator"
75
+ task "#{name}:stop" do
76
+ sh 'killall', '-m', '-KILL', 'iPhone Simulator' do |ok, res|
77
+ end
78
+ end
79
+ end
80
+
81
+ def hash_to_plist(hash, path)
82
+ cmd = IO.popen(['plutil', '-convert', 'binary1', '-o', path, '-'], 'w')
83
+ cmd.puts hash.to_json
84
+ end
85
+
86
+ def plist_to_hash(path)
87
+ JSON.parse( IO.popen(['plutil', '-convert', 'json', '-o', '-', path]) {|f| f.read} )
88
+ end
89
+
90
+ def simulator_path
91
+ @simulator_path ||= File.join(xcode_path, 'Platforms', 'iPhoneSimulator.platform', 'Developer', 'Applications', 'iPhone Simulator.app')
92
+ end
93
+
94
+ def simulator_preferences_path
95
+ File.join(simulator_support_path, 'Library', 'Preferences')
96
+ end
97
+
98
+ def simulator_support_path
99
+ @simulator_support_path ||= File.join(ENV['HOME'], 'Library', 'Application Support', 'iPhone Simulator', sdk_version)
100
+ end
101
+
102
+ def xcode_path
103
+ @xcode_path ||= `xcode-select --print-path`.chomp
104
+ end
105
+
106
+ end
107
+ end
data/lib/israkel.rb ADDED
@@ -0,0 +1 @@
1
+ require 'israkel/tasks'
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: israkel
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Johannes Plunien
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.7.6
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.7.6
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.9.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.9.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: jeweler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.8.4
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.8.4
62
+ description: Collection of common rake tasks for the iPhone Simulator like start/stop
63
+ and some more.
64
+ email: plu@pqpq.de
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files:
68
+ - README.md
69
+ files:
70
+ - Gemfile
71
+ - Gemfile.lock
72
+ - README.md
73
+ - Rakefile
74
+ - VERSION
75
+ - israkel.gemspec
76
+ - lib/israkel.rb
77
+ - lib/israkel/tasks.rb
78
+ homepage: http://github.com/plu/israkel
79
+ licenses:
80
+ - MIT
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ segments:
92
+ - 0
93
+ hash: 1776053137443745317
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 1.8.24
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: Collection of common rake tasks for the iPhone Simulator.
106
+ test_files: []