chairs 0.8 → 0.9

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.
Files changed (3) hide show
  1. data/lib/chairs/version.rb +1 -1
  2. data/lib/musician.rb +41 -14
  3. metadata +10 -5
@@ -1,3 +1,3 @@
1
1
  module Chairs
2
- VERSION = "0.8"
2
+ VERSION = "0.9"
3
3
  end
data/lib/musician.rb CHANGED
@@ -3,6 +3,9 @@ require "pow"
3
3
 
4
4
  require "chairs/version"
5
5
 
6
+ # this command comes in handy for dev
7
+ # rm *.gem; gem uninstall chairs -ax;gem build *.gemspec; gem install *.gem;
8
+
6
9
  module Chairs
7
10
 
8
11
  class Musician
@@ -20,6 +23,7 @@ module Chairs
20
23
  puts ""
21
24
  puts " pull [name] get the docs file from most recent app and call it name."
22
25
  puts " push [name] move the named docs to the most recent app doc folder."
26
+ #puts " rm [name] delete the chairs data."
23
27
  puts " open open the app folder in Finder."
24
28
  puts " list list all the current docs in working directory."
25
29
  puts ""
@@ -38,21 +42,22 @@ module Chairs
38
42
 
39
43
  setup
40
44
 
45
+ # validate
41
46
  if Pow("chairs/#{@target_folder}").exists?
42
47
  print "This chair already exists, do you want to overwrite? [Yn] "
43
48
  confirm = STDIN.gets.chomp
44
49
  if confirm.downcase == "y" || confirm == ""
45
- Pow("chairs/#{@target_folder}").delete!
50
+ FileUtils.rm_r( Pow().to_s + "/chairs/#{@target_folder}/")
46
51
  else
47
52
  return
48
53
  end
49
54
  end
50
55
 
51
- puts "Pulling files for #{@app_name}"
52
- puts "From #{@app_folder}/Documents to chairs/#{@target_folder}"
56
+ puts "Pulling files for #{ @app_name }"
57
+ puts "From #{@app_folder} to chairs/#{@target_folder}"
53
58
 
54
- Pow("chairs/#{@target_folder}").create do
55
- copy(Pow("#{@app_folder}/Documents"), Pow())
59
+ Pow("chairs/#{@target_folder}/").create_directory do
60
+ copy(Pow("#{@app_folder}"), Pow())
56
61
  end
57
62
 
58
63
  puts "Done!"
@@ -73,11 +78,11 @@ module Chairs
73
78
  end
74
79
 
75
80
  puts "Pushing files for #{@app_name}"
76
- puts "From chairs/#{@target_folder} to #{@app_folder}/Documents"
81
+ puts "From chairs/#{@target_folder} to #{@app_folder}"
77
82
 
78
- Pow("#{@app_folder}/Documents/").delete! if Pow("#{@app_folder}/Documents/").exists?
83
+ # Pow("#{@app_folder}/Documents/").delete! if Pow("#{@app_folder}/Documents/").exists?
79
84
 
80
- copy(Pow("chairs/#{@target_folder}/Documents/"), Pow("#{@app_folder}/"))
85
+ copy(Pow("chairs/#{@target_folder}/"), Pow("#{@app_folder}/"))
81
86
  puts "Done!"
82
87
  end
83
88
 
@@ -96,7 +101,9 @@ module Chairs
96
101
  end
97
102
 
98
103
  # turn it into a sentence
99
- if folders.length == 1
104
+ if folders.length == 0
105
+ folders = "have no chairs setup."
106
+ elsif folders.length == 1
100
107
  folders = "just " + folders[0]
101
108
  else
102
109
  last = folders.last
@@ -137,10 +144,14 @@ module Chairs
137
144
 
138
145
  # get the most recently used simulator
139
146
  def get_app_folder
147
+ puts "get app folder"
148
+
140
149
  app_folder = nil
150
+ app = nil
141
151
 
142
152
  # look through all the installed sims
143
153
  sims = Pow( Pow("~/Library/Application Support/iPhone Simulator") )
154
+
144
155
  sims.each do |simulator_folder|
145
156
  next if simulator_folder.class != Pow::Directory
146
157
 
@@ -153,12 +164,25 @@ module Chairs
153
164
 
154
165
  # first run
155
166
  app_folder = maybe_app_folder if !app_folder
156
-
157
- # check that we've found the most recently changed
158
- if app_folder.modified_at < maybe_app_folder.modified_at
159
- app_folder = maybe_app_folder
167
+
168
+ # find the app in the folder and compare their modified dates
169
+ # remember .apps are folders
170
+ maybe_app = maybe_app_folder.directories.reject {|p| p.extension != "app"}
171
+ # it returns as an array
172
+ maybe_app = maybe_app[0]
173
+
174
+ if maybe_app && app
175
+ if maybe_app.modified_at > app.modified_at
176
+ app_folder = maybe_app_folder
177
+ app = maybe_app
178
+ end
179
+ else
180
+ # make the first one the thing to beat
181
+ app_folder = maybe_app_folder
182
+ app = maybe_app
160
183
  end
161
184
  end
185
+
162
186
  end
163
187
  app_folder
164
188
  end
@@ -181,7 +205,10 @@ module Chairs
181
205
  end
182
206
 
183
207
  def copy(source, dest)
184
- copy = "rsync -hqr '#{source}' '#{dest}'"
208
+ source = source.to_s.gsub(" ", "\\ ")
209
+ dest = dest.to_s.gsub(" ", "\\ ")
210
+ copy = "cp -R #{source} #{dest}"
211
+
185
212
  puts copy
186
213
  system copy
187
214
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chairs
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.8'
4
+ version: '0.9'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-24 00:00:00.000000000Z
12
+ date: 2012-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pow
16
- requirement: &70336699788200 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70336699788200
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  description: ! 'Switch the documents directory for the iOS app you''re currently working
26
31
  on using named tags. '
27
32
  email:
@@ -60,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
65
  version: '0'
61
66
  requirements: []
62
67
  rubyforge_project: chairs
63
- rubygems_version: 1.8.16
68
+ rubygems_version: 1.8.24
64
69
  signing_key:
65
70
  specification_version: 3
66
71
  summary: A gem for swapping in/out document folders in iOS Sims