sidir 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +59 -0
- data/Rakefile +2 -0
- data/bin/sidir +5 -0
- data/lib/sidir.rb +6 -0
- data/lib/sidir/applications_context.rb +104 -0
- data/lib/sidir/browser.rb +39 -0
- data/lib/sidir/cli.rb +19 -0
- data/lib/sidir/context.rb +69 -0
- data/lib/sidir/simulators_context.rb +26 -0
- data/lib/sidir/version.rb +3 -0
- data/sider.gemspec +17 -0
- metadata +62 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Paul Samuels
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Sider
|
2
|
+
|
3
|
+
iOS Simulator directory explorer. This gem is a personal tool intended to make it slightly easier to navigate/manage the iOS Applications directory
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'sider'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install sider
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
sidir is a quick, dirty experiment that attempts to use commands with similar semantics to those in common shells to make them easy to remember. The main reason for sidir is because Applications are stored under unique hashs in the Applications directory, which makes this a pain to navigate in finder especially if you have lots of apps installed in your simulators.
|
22
|
+
|
23
|
+
At which point you'll get a simple prompt
|
24
|
+
|
25
|
+
sidir / >
|
26
|
+
|
27
|
+
Use help to print available commands
|
28
|
+
|
29
|
+
sidir / > help
|
30
|
+
cd <item> - change to directory at <item>
|
31
|
+
ls - list available simulators
|
32
|
+
|
33
|
+
Once you have cd'd into the context of a simulator you'll have more options available
|
34
|
+
|
35
|
+
sidir /5.1 > help
|
36
|
+
cd <item> - open finder at <item>
|
37
|
+
cd .. - move back to simulators
|
38
|
+
ls - list available applications
|
39
|
+
rm - delete the application and all data
|
40
|
+
reset - clean all paths as if the app is freshly installed
|
41
|
+
|
42
|
+
## Contributing
|
43
|
+
|
44
|
+
1. Fork it
|
45
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
46
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
47
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
48
|
+
5. Create new Pull Request
|
49
|
+
|
50
|
+
##Todo
|
51
|
+
|
52
|
+
- Currently the app it's hard coded to load at
|
53
|
+
|
54
|
+
~/Library/Application Support/iPhone Simulator/
|
55
|
+
|
56
|
+
this obviously is less than ideal
|
57
|
+
|
58
|
+
- No tests - this was literally just an experiment
|
59
|
+
- No docs - see above
|
data/Rakefile
ADDED
data/bin/sidir
ADDED
data/lib/sidir.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module Sidir
|
5
|
+
class ApplicationsContext < Context
|
6
|
+
|
7
|
+
attr_reader :simulator
|
8
|
+
|
9
|
+
def directories
|
10
|
+
applications.keys.sort
|
11
|
+
end
|
12
|
+
|
13
|
+
def applications
|
14
|
+
{}.tap do |applications|
|
15
|
+
Dir.glob("*/*.app").entries.delete_if { |dir| dir =~ /^\.{1,2}$/ }.each do |path|
|
16
|
+
applications[File.basename path, '.app'] = File.dirname path
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def traverse_up
|
22
|
+
Dir.chdir '../..'
|
23
|
+
parent_context
|
24
|
+
end
|
25
|
+
|
26
|
+
def traverse_down dir
|
27
|
+
dir.strip!
|
28
|
+
|
29
|
+
unless applications.keys.include? dir
|
30
|
+
puts "No such application :#{dir}"
|
31
|
+
end
|
32
|
+
|
33
|
+
`open #{Shellwords.escape(Dir.pwd + '/' + applications[dir])}`
|
34
|
+
self
|
35
|
+
end
|
36
|
+
|
37
|
+
def rm args
|
38
|
+
app = args.first
|
39
|
+
|
40
|
+
if directories.include? app
|
41
|
+
puts "All data associated with \"#{app}\" will be permanently deleted.\nAre you sure?[yn]"
|
42
|
+
answer = gets.strip
|
43
|
+
if answer == 'y'
|
44
|
+
FileUtils.rm_rf applications[app]
|
45
|
+
puts "#{app} deleted"
|
46
|
+
end
|
47
|
+
else
|
48
|
+
puts "\"#{app}\" not found"
|
49
|
+
end
|
50
|
+
self
|
51
|
+
end
|
52
|
+
|
53
|
+
def reset args
|
54
|
+
app = args.first
|
55
|
+
|
56
|
+
if directories.include? app
|
57
|
+
FileUtils.cd applications[app] do
|
58
|
+
puts "#{Dir.pwd}"
|
59
|
+
|
60
|
+
%w(tmp Documents Library/Caches Library/Preferences).each do |dir|
|
61
|
+
FileUtils.cd dir do
|
62
|
+
Dir.glob('**').each do |path|
|
63
|
+
unless path =~ /com\.apple\..*/
|
64
|
+
puts "cd #{dir}"
|
65
|
+
FileUtils.rm_r(path, verbose: true)
|
66
|
+
puts 'cd -'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
else
|
74
|
+
puts "\"#{app}\" not found"
|
75
|
+
end
|
76
|
+
self
|
77
|
+
end
|
78
|
+
|
79
|
+
def prompt
|
80
|
+
parent_context.prompt + "#{simulator}"
|
81
|
+
end
|
82
|
+
|
83
|
+
def commands
|
84
|
+
super + %w(rm reset)
|
85
|
+
end
|
86
|
+
|
87
|
+
def help args
|
88
|
+
puts <<-help
|
89
|
+
cd <item> - open finder at <item>
|
90
|
+
cd .. - move back to simulators
|
91
|
+
ls - list available applications
|
92
|
+
rm - delete the application and all data
|
93
|
+
reset - clean all paths as if the app is freshly installed
|
94
|
+
help
|
95
|
+
self
|
96
|
+
end
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
def simulator
|
101
|
+
File.basename(File.dirname(Dir.pwd))
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'readline'
|
2
|
+
|
3
|
+
module Sidir
|
4
|
+
class Browser
|
5
|
+
attr_accessor :current_context
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
Dir.chdir File.expand_path("~/Library/Application Support/iPhone Simulator/")
|
9
|
+
@current_context = SimulatorsContext.new nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.start
|
13
|
+
instance = self.new.repl
|
14
|
+
end
|
15
|
+
|
16
|
+
def repl
|
17
|
+
cmd = nil
|
18
|
+
|
19
|
+
Readline.completion_proc = proc do |input|
|
20
|
+
current_context.completions input
|
21
|
+
end
|
22
|
+
|
23
|
+
while cmd != 'exit'
|
24
|
+
line = Readline.readline("sidir #{current_context.prompt} > ", true)
|
25
|
+
args = line.split
|
26
|
+
cmd = args.shift
|
27
|
+
|
28
|
+
break if cmd.nil?
|
29
|
+
|
30
|
+
if current_context.available_command? cmd
|
31
|
+
self.current_context = current_context.execute_command cmd, args
|
32
|
+
else
|
33
|
+
puts "command not recognised :#{cmd}"
|
34
|
+
current_context.help nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/sidir/cli.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Sidir
|
4
|
+
class CLI
|
5
|
+
class << self
|
6
|
+
def parse_options
|
7
|
+
option_parser = OptionParser.new do |opts|
|
8
|
+
executable_name = File.basename($PROGRAM_NAME)
|
9
|
+
opts.banner = "Work with iOS simulator directories: #{executable_name}"
|
10
|
+
end
|
11
|
+
|
12
|
+
option_parser.parse!
|
13
|
+
|
14
|
+
Browser.start
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Sidir
|
2
|
+
class Context
|
3
|
+
attr_accessor :parent_context
|
4
|
+
|
5
|
+
def initialize parent_context
|
6
|
+
self.parent_context = parent_context
|
7
|
+
end
|
8
|
+
|
9
|
+
def execute_command cmd, args
|
10
|
+
send cmd.to_sym, args
|
11
|
+
end
|
12
|
+
|
13
|
+
def traverse_up
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def ls args
|
18
|
+
puts directories
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
def cd args
|
23
|
+
paths = (args.shift || '').split('/')
|
24
|
+
|
25
|
+
context = self
|
26
|
+
|
27
|
+
paths.each do |path|
|
28
|
+
if path == '..'
|
29
|
+
context = traverse_up
|
30
|
+
else
|
31
|
+
context = traverse_down path
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context
|
36
|
+
end
|
37
|
+
|
38
|
+
def prompt
|
39
|
+
'/'
|
40
|
+
end
|
41
|
+
|
42
|
+
def open_path
|
43
|
+
Dir.pwd
|
44
|
+
end
|
45
|
+
|
46
|
+
def available_command? cmd
|
47
|
+
commands.include? cmd
|
48
|
+
end
|
49
|
+
|
50
|
+
def completions input
|
51
|
+
if input.strip == "" || input.nil?
|
52
|
+
directories
|
53
|
+
else
|
54
|
+
directories.grep %r<^#{input}>
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def show args
|
59
|
+
`open #{Shellwords.escape open_path}`
|
60
|
+
self
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def commands
|
66
|
+
%w(ls cd help show)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Sidir
|
2
|
+
class SimulatorsContext < Context
|
3
|
+
def directories
|
4
|
+
Dir.entries('.').delete_if { |dir| dir =~ /^\.{1,2}/ }
|
5
|
+
end
|
6
|
+
|
7
|
+
def traverse_down dir
|
8
|
+
dir.strip!
|
9
|
+
|
10
|
+
unless directories.include? dir
|
11
|
+
puts "No such simulator :#{dir}"
|
12
|
+
end
|
13
|
+
|
14
|
+
Dir.chdir "#{dir}/Applications"
|
15
|
+
ApplicationsContext.new self
|
16
|
+
end
|
17
|
+
|
18
|
+
def help args
|
19
|
+
puts <<-help
|
20
|
+
cd <item> - change to directory at <item>
|
21
|
+
ls - list available simulators
|
22
|
+
help
|
23
|
+
self
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/sider.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/sidir/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Paul Samuels"]
|
6
|
+
gem.email = ["paulio1987@gmail.com"]
|
7
|
+
gem.description = %q{iOS Simulator directory explorer. This gem is a personal tool intended to make it slightly easier to navigate/manage the iOS Applications directory}
|
8
|
+
gem.summary = %q{iOS Simulator directory explorer}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "sidir"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Sidir::VERSION
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sidir
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Paul Samuels
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-19 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: iOS Simulator directory explorer. This gem is a personal tool intended
|
15
|
+
to make it slightly easier to navigate/manage the iOS Applications directory
|
16
|
+
email:
|
17
|
+
- paulio1987@gmail.com
|
18
|
+
executables:
|
19
|
+
- sidir
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- .gitignore
|
24
|
+
- Gemfile
|
25
|
+
- LICENSE
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- bin/sidir
|
29
|
+
- lib/sidir.rb
|
30
|
+
- lib/sidir/applications_context.rb
|
31
|
+
- lib/sidir/browser.rb
|
32
|
+
- lib/sidir/cli.rb
|
33
|
+
- lib/sidir/context.rb
|
34
|
+
- lib/sidir/simulators_context.rb
|
35
|
+
- lib/sidir/version.rb
|
36
|
+
- sider.gemspec
|
37
|
+
homepage: ''
|
38
|
+
licenses: []
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 1.8.24
|
58
|
+
signing_key:
|
59
|
+
specification_version: 3
|
60
|
+
summary: iOS Simulator directory explorer
|
61
|
+
test_files: []
|
62
|
+
has_rdoc:
|