-
Notifications
You must be signed in to change notification settings - Fork 7
/
.irbrc
145 lines (117 loc) · 3.23 KB
/
.irbrc
1
2
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
38
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
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
require 'irb/completion'
require 'irb/ext/save-history'
require 'benchmark'
require 'run_loop'
require 'command_runner'
if RUBY_PLATFORM[/darwin/]
begin
require "dnssd"
rescue LoadError => _
"Skipping dnssd; it is not installed"
end
else
puts "Skipping dnssd on #{RUBY_PLATFORM}"
end
AwesomePrint.irb!
ARGV.concat [ '--readline',
'--prompt-mode',
'simple']
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = '.irb-history'
IRB.conf[:AUTO_INDENT] = true
IRB.conf[:PROMPT][:RUN_LOOP] = {
:PROMPT_I => "run-loop #{RunLoop::VERSION}> ",
:PROMPT_N => "run-loop #{RunLoop::VERSION}> ",
:PROMPT_S => nil,
:PROMPT_C => "> ",
:AUTO_INDENT => false,
:RETURN => "%s\n"
}
IRB.conf[:PROMPT_MODE] = :RUN_LOOP
begin
require 'pry'
Pry.config.history.should_save = false
Pry.config.history.should_load = false
require 'pry-nav'
rescue LoadError => _
end
spec_resources = './spec/resources.rb'
print "require '#{spec_resources}'..."
require spec_resources
puts 'done!'
puts ''
puts '# => Useful Methods <= #'
puts '> xcode => Xcode instance'
puts '> instruments => Instruments instance'
puts '> simctl => Simctl instance'
puts '> default_sim => Default simulator'
puts '> verbose => turn on DEBUG logging'
puts '> quiet => turn off DEBUG logging'
puts "> holmes => Launch an app with DeviceAgent"
puts ''
def xcode
@xcode ||= RunLoop::Xcode.new
end
def instruments
@instruments ||= RunLoop::Instruments.new
end
def simctl
@simctl ||= RunLoop::Simctl.new
end
def default_sim
@default_sim ||= begin
name = RunLoop::Core.default_simulator(xcode)
simctl.simulators.find do |sim|
sim.instruments_identifier == name
end
end
end
def verbose
ENV['DEBUG'] = '1'
end
def quiet
ENV['DEBUG'] = '1'
end
def create_simulator(n, options={})
default_options = {
:name => 'tester',
:type => 'iPhone 6',
:runtime => 'com.apple.CoreSimulator.SimRuntime.iOS-9-0'
}
merged_options = default_options.merge(options)
name = merged_options[:name]
type = merged_options[:type]
runtime = merged_options[:runtime]
n.times do
system('xcrun', "simctl", 'create', name, type, runtime)
end
end
def delete_simulator(name)
simctl.simulators.each do |simulator|
if simulator.name == name
puts "Deleting #{simulator}"
system('xcrun', "simctl", 'delete', simulator.udid)
end
end
true
end
def holmes(options={})
device = RunLoop::Device.detect_device({}, xcode, simctl, instruments)
default_options = {
:app => "com.apple.Preferences",
:device => device.udid,
:xcode => xcode,
:simctl => simctl,
:automator => :device_agent,
:cbx_launcher => :ios_device_manager
}
merged_options = default_options.merge(options)
RunLoop.run(merged_options)
end
verbose
motd=["Let's get this done!", 'Ready to rumble.', 'Enjoy.', 'Remember to breathe.',
'Take a deep breath.', "Isn't it time for a break?", 'Can I get you a coffee?',
'What is a calabash anyway?', 'Smile! You are on camera!', 'Let op! Wild Rooster!',
"Don't touch that button!", "I'm gonna take this to 11.", 'Console. Engaged.',
'Your wish is my command.', 'This console session was created just for you.']
puts "#{motd.sample()}"