chairs 0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +20 -0
- data/Rakefile +1 -0
- data/bin/chairs +8 -0
- data/chairs.gemspec +21 -0
- data/lib/chairs/version.rb +3 -0
- data/lib/musician.rb +170 -0
- metadata +66 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Art.sy
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/chairs
ADDED
data/chairs.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "chairs/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "chairs"
|
7
|
+
s.version = Chairs::VERSION
|
8
|
+
s.authors = ["orta"]
|
9
|
+
s.email = ["orta.therox@gmail.com"]
|
10
|
+
s.homepage = "http://github.com/orta/muscialchairs"
|
11
|
+
s.summary = %q{A gem for swapping in/out document folders in iOS Sims}
|
12
|
+
s.description = %q{Switch the documents directory for the iOS app you're currently working on using named tags. }
|
13
|
+
|
14
|
+
s.rubyforge_project = "chairs"
|
15
|
+
|
16
|
+
s.add_dependency 'pow'
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
data/lib/musician.rb
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "pow"
|
3
|
+
|
4
|
+
require "chairs/version"
|
5
|
+
|
6
|
+
module Chairs
|
7
|
+
|
8
|
+
class Musician
|
9
|
+
|
10
|
+
def initialize(args)
|
11
|
+
# find a command
|
12
|
+
@params = args
|
13
|
+
command = @params[0].to_sym rescue :help
|
14
|
+
commands.include?(command) ? send(command.to_sym) : help
|
15
|
+
end
|
16
|
+
|
17
|
+
def help
|
18
|
+
puts ""
|
19
|
+
puts "Musical Chairs - for swapping in/out document folders in iOS Sims."
|
20
|
+
puts ""
|
21
|
+
puts " pull [name] get the docs file from most recent app and call it name."
|
22
|
+
puts " push [name] move the named docs to the most recent app doc folder."
|
23
|
+
puts " list list all the current docs in working directory."
|
24
|
+
puts ""
|
25
|
+
puts " ./"
|
26
|
+
end
|
27
|
+
|
28
|
+
def pull
|
29
|
+
unless @params[1]
|
30
|
+
puts "Chairs needs a name for the target."
|
31
|
+
return
|
32
|
+
end
|
33
|
+
|
34
|
+
setup
|
35
|
+
|
36
|
+
puts "Switching files from #{@app_folder}/Documents to"
|
37
|
+
puts "chairs/#{@target_folder} for #{@app_name}."
|
38
|
+
|
39
|
+
Pow("chairs/#{@target_folder}").create do
|
40
|
+
Pow("#{@app_folder}/Documents").copy_to(Pow())
|
41
|
+
end
|
42
|
+
|
43
|
+
puts "Done!"
|
44
|
+
end
|
45
|
+
|
46
|
+
def push
|
47
|
+
unless @params[1]
|
48
|
+
puts "Chairs needs a name for the target."
|
49
|
+
return
|
50
|
+
end
|
51
|
+
|
52
|
+
setup
|
53
|
+
|
54
|
+
unless Pow("chairs/#{@target_folder}").exists?
|
55
|
+
puts "You don't have a folder for #{@target_folder}."
|
56
|
+
list
|
57
|
+
return
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
puts "Moving files from chairs/#{@target_folder} to"
|
62
|
+
puts "#{@app_folder}/Documents for #{@app_name}."
|
63
|
+
|
64
|
+
Pow("chairs/#{@target_folder}/Documents/").copy_to(Pow("#{@app_folder}/"))
|
65
|
+
|
66
|
+
puts "Done!"
|
67
|
+
end
|
68
|
+
|
69
|
+
def list
|
70
|
+
unless Pow("chairs/").exists?
|
71
|
+
puts "You haven't used chairs yet."
|
72
|
+
return
|
73
|
+
end
|
74
|
+
|
75
|
+
folders = []
|
76
|
+
@target_folder = @params[1]
|
77
|
+
Pow("chairs/").each do |doc|
|
78
|
+
filename = File.basename(doc)
|
79
|
+
folders << filename if doc.directory?
|
80
|
+
end
|
81
|
+
|
82
|
+
# turn it into a sentence
|
83
|
+
if folders.length == 1
|
84
|
+
folders = "just " + folders[0]
|
85
|
+
else
|
86
|
+
last = folders.last
|
87
|
+
folders = "have " + folders[0..-2].join(", ") + " and #{last}."
|
88
|
+
end
|
89
|
+
puts "Currently you #{ folders }."
|
90
|
+
end
|
91
|
+
|
92
|
+
protected
|
93
|
+
|
94
|
+
def setup
|
95
|
+
check_for_gitignore
|
96
|
+
|
97
|
+
@target_folder = @params[1]
|
98
|
+
@app_folder = get_app_folder()
|
99
|
+
@app_name = get_app_name()
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
def check_for_gitignore
|
104
|
+
gitignore = Pow(".gitignore")
|
105
|
+
|
106
|
+
# if the folder already exists, don't ask twice
|
107
|
+
# but surely everyone'll add it to the gitignore on first pull
|
108
|
+
if gitignore.exists? && ( Pow("chairs/").exists? == false )
|
109
|
+
gitignore_line = "\nchairs/\n"
|
110
|
+
file = File.open(gitignore, "a")
|
111
|
+
reader = File.read(gitignore)
|
112
|
+
|
113
|
+
unless reader.include?(gitignore_line)
|
114
|
+
puts "You don't have chairs/ in your .gitignore would you like chairs to add it? [Yn]"
|
115
|
+
confirm = STDIN.gets.chomp
|
116
|
+
file << gitignore_line if confirm && confirm.downcase == "y"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
# get the most recently used simulator
|
122
|
+
def get_app_folder
|
123
|
+
app_folder = nil
|
124
|
+
|
125
|
+
# look through all the installed sims
|
126
|
+
sims = Pow( Pow("~/Library/Application Support/iPhone Simulator") )
|
127
|
+
sims.each do |simulator_folder|
|
128
|
+
next if simulator_folder.class != Pow::Directory
|
129
|
+
|
130
|
+
apps = Pow( "#{simulator_folder}/Applications/" )
|
131
|
+
next unless apps.exists?
|
132
|
+
|
133
|
+
# look through all the hash folders for apps
|
134
|
+
apps.each do |maybe_app_folder|
|
135
|
+
next unless maybe_app_folder.directory?
|
136
|
+
|
137
|
+
# first run
|
138
|
+
app_folder = maybe_app_folder if !app_folder
|
139
|
+
|
140
|
+
# check that we've found the most recently changed
|
141
|
+
if app_folder.modified_at < maybe_app_folder.modified_at
|
142
|
+
app_folder = maybe_app_folder
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
app_folder
|
147
|
+
end
|
148
|
+
|
149
|
+
def get_app_name
|
150
|
+
# grab the app name
|
151
|
+
# look in the app's folder for a .app
|
152
|
+
app_folder = get_app_folder
|
153
|
+
Pow(app_folder).each do |app_folder_files|
|
154
|
+
if app_folder_files.directory?
|
155
|
+
|
156
|
+
# and use the name of that
|
157
|
+
filename = File.basename app_folder_files
|
158
|
+
if filename.include? ".app"
|
159
|
+
return filename
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
return ""
|
164
|
+
end
|
165
|
+
|
166
|
+
def commands
|
167
|
+
(public_methods - Object.public_methods).sort.map{ |c| c.to_sym}
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chairs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.6'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- orta
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-23 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: pow
|
16
|
+
requirement: &70351506730900 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70351506730900
|
25
|
+
description: ! 'Switch the documents directory for the iOS app you''re currently working
|
26
|
+
on using named tags. '
|
27
|
+
email:
|
28
|
+
- orta.therox@gmail.com
|
29
|
+
executables:
|
30
|
+
- chairs
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- Gemfile
|
36
|
+
- LICENSE.txt
|
37
|
+
- Rakefile
|
38
|
+
- bin/chairs
|
39
|
+
- chairs.gemspec
|
40
|
+
- lib/chairs/version.rb
|
41
|
+
- lib/musician.rb
|
42
|
+
homepage: http://github.com/orta/muscialchairs
|
43
|
+
licenses: []
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project: chairs
|
62
|
+
rubygems_version: 1.8.16
|
63
|
+
signing_key:
|
64
|
+
specification_version: 3
|
65
|
+
summary: A gem for swapping in/out document folders in iOS Sims
|
66
|
+
test_files: []
|