simtool 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b3cf4254687f8b6cf1b13ac24cfe430c9ff2b9ed
4
+ data.tar.gz: 63eff77fe85ab973ef5846d852d993bc81cc8056
5
+ SHA512:
6
+ metadata.gz: 502cb3af064f0603b94dafcb9147646f44ac0dc4e50d5c2e67b1e7a14fafe96031d4f76f0f60fc45a8fc0f1f1bb173c853f748201179ac5fcdf6e5ccb281f350
7
+ data.tar.gz: 322c59aeec344db87c41c7135cbfc22fd8d9b33636680b86c7e3aab14e25d552e751285669d26e9e2eef7a94eed245e9ef8f716c1fee49da1e3cfc7d88e596cf
data/LICENSE ADDED
@@ -0,0 +1,10 @@
1
+ Copyright (c) 2015, Hwee-Boon Yar
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+
8
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+
10
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
File without changes
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'commander/import'
5
+
6
+ PHOTO_EXTENSIONS = ['.jpg', '.jpeg', '.tiff', '.png']
7
+
8
+ program :version, '0.0.1'
9
+ program :description, "Import photos to iOS simulator.\n\nThe photos are added to the iOS simulator that is currently running."
10
+
11
+ command :add do |c|
12
+ c.syntax = 'simtool add [options]'
13
+ c.summary = 'Import photos to iOS simulator'
14
+ c.description = "Import photos to iOS simulator.\n\nThe photos are added to the iOS simulator that is currently running."
15
+ c.example 'Add a single photo', '$ simtool add -p ~/Desktop/a-photo.jpg'
16
+ c.example 'Add every photo in a folder', '$ simtool add -p ~/Desktop/important-photos'
17
+ c.option '-p', '--photos PHOTOS_PATH', 'Directory containing the photos to be imported or a path representing a single photo'
18
+ c.action do |args, options|
19
+ say_error 'Specify the directory containing the photos with -p' and abort if options.photos.nil?
20
+ cmd = 'xcode-select -p'
21
+ xcode = `#{cmd}`.chop
22
+ say "xcode: #{xcode}"
23
+ say_error "Can't figure out Xcode to use with `#{cmd}`." and abort unless $?.success?
24
+ simctl = File.join(xcode, 'Platforms/iPhoneSimulator.platform/Developer/usr/bin/simctl')
25
+ say "simctl: #{simctl}"
26
+ cmd = "#{simctl} list devices"
27
+ output = `#{cmd}`
28
+ say_error "Can't list devices with `#{cmd}`." and abort unless $?.success?
29
+ lines = output.split("\n")
30
+ booted = lines.find {|e| e.include? '(Booted)'}
31
+ say_error 'You must be running the iOS simulator you want to import to.' and abort unless booted
32
+ match = Regexp.new(/\((.+?)\)/).match(booted)
33
+ say_error "Can't figure out device_id of simulator" and abort unless match && match.size == 2
34
+ device_id = match[1]
35
+ say "device_id: #{device_id}"
36
+ if PHOTO_EXTENSIONS.any? {|e| options.photos.downcase.end_with? e}
37
+ photos = [options.photos]
38
+ else
39
+ photos = PHOTO_EXTENSIONS.inject([]) {|s, e| s + Dir[File.expand_path(File.join(options.photos, "*#{e}"))]}
40
+ end
41
+ count = 0
42
+ failed_to_import = []
43
+ photos.each do |e|
44
+ cmd = "#{simctl} addphoto #{device_id} #{e}"
45
+ output = `#{cmd}`
46
+ if $?.success?
47
+ count += 1
48
+ else
49
+ failed_to_import << e
50
+ end
51
+ end
52
+ say_ok "Imported #{count} photo#{count==1? '': 's'} successfully."
53
+ unless failed_to_import.empty?
54
+ say_error "Failed to import #{failed_to_import.size} photo#{failed_to_import.size==1? '': 's'}."
55
+ failed_to_import.each do |e|
56
+ say_error e
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1 @@
1
+ require 'simtool/simtool'
File without changes
@@ -0,0 +1,3 @@
1
+ module SimTool
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/simtool/version.rb', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'simtool'
6
+ gem.version = SimTool::VERSION
7
+ gem.licenses = ['BSD']
8
+
9
+ gem.authors = ['Hwee-Boon Yar']
10
+
11
+ gem.description = 'Import photos to iOS simulator.'
12
+ gem.summary = 'Import photos to iOS simulator.'
13
+ gem.homepage = 'http://hboon.com/ios-simtool/'
14
+ gem.email = 'hboon@motionobj.com'
15
+
16
+ gem.add_dependency 'commander', '~> 4.3'
17
+ gem.files = `git ls-files`.split($\)
18
+ gem.executables = ['simtool']
19
+ gem.require_paths = ['lib']
20
+ #gem.test_files = gem.files.grep(%r{^spec/})
21
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simtool
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Hwee-Boon Yar
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: commander
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.3'
27
+ description: Import photos to iOS simulator.
28
+ email: hboon@motionobj.com
29
+ executables:
30
+ - simtool
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE
35
+ - README.md
36
+ - bin/simtool
37
+ - lib/simtool.rb
38
+ - lib/simtool/simtool.rb
39
+ - lib/simtool/version.rb
40
+ - simtool.gemspec
41
+ homepage: http://hboon.com/ios-simtool/
42
+ licenses:
43
+ - BSD
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 2.4.2
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: Import photos to iOS simulator.
65
+ test_files: []