chairs 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/musician.rb +40 -8
  3. data/lib/simctl_parser.rb +27 -0
  4. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46f26fae363f6ab1e45bee1b386604c17e432f9a
4
- data.tar.gz: 09266d8d3551d571ad0aa78c94a90142c30e0dba
3
+ metadata.gz: 68f6133ebe34a5e5bb2083b60209df26ec3a96ef
4
+ data.tar.gz: f34f0a042180bb01da95e44dfe1a980bb5c4d097
5
5
  SHA512:
6
- metadata.gz: 2bf4ffdf43d88cdb0ebe4e42cbe84bd842a04f263cf7b529ab98c46106a1d37d2bc8dc633b2d2f596403c0a551c3c301bc6ab2fc0a4f6e897b3ed8fb1eb22d57
7
- data.tar.gz: beb05e93b995491879f42d03c505fb287f72afaa529e619ca660328bb935fb5cf7f381f1a90ab131d8b5b9ceaa6029baa2e68578008905d8d6f3ae543f1a9c7e
6
+ metadata.gz: 80b0238ba0dae48b3050e8a4e5d13b0ae618d82ee672deae98db7aea250b3f0ae4cb2ef0a87f5daa9cb2ec35fb4a9ea63603e2210a3bcc028c251c5ac659e200
7
+ data.tar.gz: 6d7cbaa34e4639ed59b1cf1dc18cf63221ca9b620aa4696ab40fbdfae86a5c2cc3cef5c94808868ec32722dceb693d49258107110d4e34fa14188bcaf0762ee2
@@ -1,6 +1,6 @@
1
1
  require "rubygems"
2
2
  require File.join(File.dirname(__FILE__), 'pow')
3
-
3
+ require File.join(File.dirname(__FILE__), 'simctl_parser')
4
4
  require "chairs/version"
5
5
 
6
6
  # this command comes in handy for dev
@@ -21,6 +21,7 @@ module Chairs
21
21
  puts ""
22
22
  puts "Musical Chairs - for swapping in/out app data in the iOS Simulator."
23
23
  puts ""
24
+ puts " sync takes the app from the *currently open* sim, and send it to all other sims."
24
25
  puts " pull [name] get documents and support files from latest built app and store as name."
25
26
  puts " push [name] overwrite documents and support files from the latest build in Xcode."
26
27
  puts " rm [name] delete the files for the chair."
@@ -31,7 +32,9 @@ module Chairs
31
32
  end
32
33
 
33
34
  def open
34
- `open "#{ get_app_folder }"`
35
+ setup
36
+ puts "Opening #{ @app_name }"
37
+ `open "#{ @app_folder }"`
35
38
  end
36
39
 
37
40
  def pull
@@ -146,6 +149,34 @@ module Chairs
146
149
 
147
150
  puts "Cleaned"
148
151
  end
152
+
153
+ def sync
154
+ setup
155
+
156
+ simctl = SimctlParser.new
157
+ current_device = simctl.open_device
158
+ get_devices = simctl.get_devices
159
+
160
+ unless current_device
161
+ puts "Couldn't find an active iOS Simulator"
162
+ return
163
+ end
164
+
165
+ print "Migrating #{@app_name} from #{current_device[:name]} to all other devices"
166
+
167
+ os = ""
168
+ get_devices.each do |device|
169
+ next if device[:id] == current_device[:id]
170
+ if device[:os] != os
171
+ os = device[:os]
172
+ print "\n #{os} -> "
173
+ end
174
+
175
+ new_folder = "~/Library/Developer/CoreSimulator/Devices/" + device[:id] + "/data/Applications"
176
+ copy(@app_folder, new_folder, false)
177
+ print "#{ device[:name] }, "
178
+ end
179
+ end
149
180
 
150
181
  protected
151
182
 
@@ -181,12 +212,12 @@ module Chairs
181
212
  app = nil
182
213
 
183
214
  # look through all the installed sims
184
- sims = Pow( Pow("~/Library/Application Support/iPhone Simulator") )
215
+ sims = Pow( Pow("~/Library/Developer/CoreSimulator/Devices") )
185
216
 
186
217
  sims.each do |simulator_folder|
187
218
  next if simulator_folder.class != Pow::Directory
188
219
 
189
- apps = Pow( "#{simulator_folder}/Applications/" )
220
+ apps = Pow( "#{simulator_folder}/data/Applications/" )
190
221
  next unless apps.exists?
191
222
 
192
223
  # look through all the hash folders for apps
@@ -195,7 +226,7 @@ module Chairs
195
226
 
196
227
  # find the app in the folder and compare their modified dates
197
228
  # remember .apps are folders
198
- maybe_app = maybe_app_folder.directories.select{|p|
229
+ maybe_app = maybe_app_folder.directories.select{ |p|
199
230
  p.extension == "app" && p.exists?
200
231
  }.first
201
232
  next unless maybe_app
@@ -234,12 +265,13 @@ module Chairs
234
265
  return ""
235
266
  end
236
267
 
237
- def copy(source, dest)
268
+ def copy(source, dest, verbose=true)
238
269
  source = source.to_s.gsub(" ", "\\ ")
239
270
  dest = dest.to_s.gsub(" ", "\\ ")
240
271
  copy = "cp -R #{source} #{dest}"
241
-
242
- puts copy
272
+ if verbose
273
+ puts copy
274
+ end
243
275
  system copy
244
276
  end
245
277
 
@@ -0,0 +1,27 @@
1
+ class SimctlParser
2
+ def get_devices
3
+ output = `xcrun simctl list`.strip
4
+ output = output.split("== Devices ==").last
5
+ os = ""
6
+ output.lines.map do |line|
7
+ if line.strip.start_with?( "--")
8
+ os = line.gsub("-","").strip
9
+ end
10
+
11
+ if line.strip.length != 0 && line.strip.start_with?( "--") == false
12
+ {
13
+ :name => line.strip.split(" ")[0..-3].join(" "),
14
+ :state => line.strip.split(" ")[-1],
15
+ :id => line.strip.split(" ")[-2][1..-2].strip,
16
+ :os => os
17
+ }
18
+ end
19
+ end.compact
20
+ end
21
+
22
+ def open_device
23
+ get_devices.select do | device |
24
+ device[:state] == "(Booted)"
25
+ end.first
26
+ end
27
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chairs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - orta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-01 00:00:00.000000000 Z
11
+ date: 2015-01-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'Switch the documents directory for the iOS app you''re currently working
14
14
  on using named tags. '
@@ -19,7 +19,7 @@ executables:
19
19
  extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
- - ".gitignore"
22
+ - .gitignore
23
23
  - Gemfile
24
24
  - LICENSE.txt
25
25
  - README.md
@@ -33,6 +33,7 @@ files:
33
33
  - lib/pow/directory.rb
34
34
  - lib/pow/file.rb
35
35
  - lib/pow/pow.rb
36
+ - lib/simctl_parser.rb
36
37
  homepage: http://github.com/orta/muscialchairs
37
38
  licenses:
38
39
  - MIT
@@ -43,19 +44,18 @@ require_paths:
43
44
  - lib
44
45
  required_ruby_version: !ruby/object:Gem::Requirement
45
46
  requirements:
46
- - - ">="
47
+ - - '>='
47
48
  - !ruby/object:Gem::Version
48
49
  version: '0'
49
50
  required_rubygems_version: !ruby/object:Gem::Requirement
50
51
  requirements:
51
- - - ">="
52
+ - - '>='
52
53
  - !ruby/object:Gem::Version
53
54
  version: '0'
54
55
  requirements: []
55
56
  rubyforge_project: chairs
56
- rubygems_version: 2.2.2
57
+ rubygems_version: 2.0.14
57
58
  signing_key:
58
59
  specification_version: 4
59
60
  summary: A gem for swapping in/out document folders in iOS Sims
60
61
  test_files: []
61
- has_rdoc: