chairs 0.94 → 1.0

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/chairs.gemspec CHANGED
@@ -13,7 +13,6 @@ Gem::Specification.new do |s|
13
13
 
14
14
  s.rubyforge_project = "chairs"
15
15
 
16
- s.add_dependency 'pow'
17
16
  s.files = `git ls-files`.split("\n")
18
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
data/lib/musician.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require "rubygems"
2
- require "pow"
2
+ require_relative "pow"
3
3
 
4
4
  require "chairs/version"
5
5
 
@@ -19,7 +19,7 @@ module Chairs
19
19
 
20
20
  def help
21
21
  puts ""
22
- puts "Musical Chairs - for swapping in/out app version in the iOS Simulator."
22
+ puts "Musical Chairs - for swapping in/out app data in the iOS Simulator."
23
23
  puts ""
24
24
  puts " pull [name] get documents and support files from latest built app and store as name."
25
25
  puts " push [name] overwrite documents and support files from the latest build in Xcode."
@@ -130,6 +130,19 @@ module Chairs
130
130
  list
131
131
  end
132
132
  end
133
+
134
+ def clean
135
+ setup
136
+
137
+ puts "Deleting App directory"
138
+ target_path = Pow(@app_folder).to_s.gsub(" ", "\\ ")
139
+
140
+ command = "rm -r #{target_path}"
141
+ puts command
142
+ system command
143
+
144
+ puts "Cleaned"
145
+ end
133
146
 
134
147
  protected
135
148
 
@@ -139,7 +152,6 @@ module Chairs
139
152
  @target_folder = @params[1]
140
153
  @app_folder = get_app_folder()
141
154
  @app_name = get_app_name()
142
-
143
155
  end
144
156
 
145
157
  def check_for_gitignore
@@ -217,6 +229,7 @@ module Chairs
217
229
  end
218
230
  end
219
231
  end
232
+
220
233
  return ""
221
234
  end
222
235
 
@@ -229,7 +242,6 @@ module Chairs
229
242
  system copy
230
243
  end
231
244
 
232
-
233
245
  def commands
234
246
  (public_methods - Object.public_methods).sort.map{ |c| c.to_sym}
235
247
  end
data/lib/pow.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'fileutils'
2
+
3
+ require File.dirname(__FILE__) + '/pow/pow'
4
+ require File.dirname(__FILE__) + '/pow/directory'
5
+ require File.dirname(__FILE__) + '/pow/file'
6
+
7
+ module Pow
8
+ VERSION = '0.2.2'
9
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2007 Corey Johnson
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 NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,108 @@
1
+ module Pow
2
+
3
+ # Pow object representing a directory. Inherits from Pow::Base
4
+ class Directory < Base
5
+ include Enumerable
6
+
7
+ def initialize(path, mode=nil, &block) #:nodoc:
8
+ super
9
+ open(&block) if block_given?
10
+ end
11
+
12
+ def open(mode=nil, &block) #:nodoc:
13
+ raise PowError, "'#{path}' does not exist!" unless exists?
14
+
15
+ begin
16
+ former_dir = Dir.pwd
17
+ Dir.chdir self.to_s
18
+ block.call self
19
+ ensure
20
+ Dir.chdir(former_dir)
21
+ end
22
+ end
23
+
24
+ def create(&block) #:nodoc:
25
+ create_directory(&block)
26
+ end
27
+
28
+ # Deletes an empty directory
29
+ def delete
30
+ raise PowError, "Can not delete '#{path}'. It must be empty before you delete it!" unless children.empty?
31
+ Dir.rmdir path
32
+ end
33
+
34
+ # Recurslivly deletes the directory, DANGER! DANGER!
35
+ def delete!
36
+ FileUtils.rm_r path
37
+ end
38
+
39
+ def copy_to(dest)
40
+ FileUtils.cp_r(path, dest.to_s)
41
+ end
42
+ alias_method :cp, :copy_to
43
+
44
+ def copy_to!(dest)
45
+ Pow(dest).parent.create_directory
46
+ FileUtils.cp_r(path, dest.to_s)
47
+ end
48
+ alias_method :cp!, :copy_to!
49
+
50
+ def move_to(dest)
51
+ if FileUtils.mv(path.to_s, dest.to_s)
52
+ self.path = dest
53
+ end
54
+ end
55
+ alias_method :mv, :move_to
56
+
57
+ def empty?
58
+ children.empty?
59
+ end
60
+
61
+ # ===============
62
+ # = My Children =
63
+ # ===============
64
+
65
+ # A wrapper for Dir.glob, returns files & directories found by expanding pattern.
66
+ def glob(pattern, *flags)
67
+ Dir[::File.join(to_s, pattern), *flags].collect {|path| Pow(path)}
68
+ end
69
+
70
+ # Returns all the files in the directory
71
+ def files
72
+ children(:no_dirs => true)
73
+ end
74
+
75
+ # Returns all the directories in the directory
76
+ def directories
77
+ children(:no_files => true)
78
+ end
79
+ alias_method :dirs, :directories
80
+
81
+ # Returns all files and directories in the directory.
82
+ #
83
+ # ==== Parameters
84
+ # options<Hash>:: [:no_dirs, :no_files] (defaults to :no_dirs => true, :no_files => true)
85
+ def children(options={})
86
+ options = {:no_dirs => false, :no_files => false}.merge(options)
87
+
88
+ children = []
89
+ Dir.foreach(path) do |child|
90
+ child_path = ::File.join(path, child)
91
+
92
+ next if child == '.'
93
+ next if child == '..'
94
+ next if (::File.file?(child_path) and options[:no_files])
95
+ next if (::File.directory?(child_path) and options[:no_dirs])
96
+ children << Pow(child_path)
97
+ end
98
+
99
+ children
100
+ end
101
+
102
+ # Yields the child paths to an each block.
103
+ def each(&block)
104
+ raise PowError, "'#{path.realpath}' does not exist!" unless exists?
105
+ children.each(&block)
106
+ end
107
+ end
108
+ end
data/lib/pow/file.rb ADDED
@@ -0,0 +1,63 @@
1
+ module Pow
2
+
3
+ # Pow object representing a file. Inherits from Pow::Base
4
+ class File < Base
5
+ def initialize(path, mode="r+", &block) #:nodoc:
6
+ super
7
+ open(mode, &block) if block_given?
8
+ end
9
+
10
+ def open(mode="r", &block) #:nodoc:
11
+ Kernel.open(path.to_s, mode, &block)
12
+ end
13
+
14
+ def create(&block) #:nodoc:
15
+ create_file(&block)
16
+ end
17
+
18
+ # Opens the file, optionally seeks to the given offset, then returns length bytes (defaulting to the rest of the file). read ensures the file is closed before returning.
19
+ # Alias for IO.read
20
+ def read(length=nil, offset=nil)
21
+ ::File.read(path.to_s, length, offset)
22
+ end
23
+
24
+ def write(string)
25
+ open("w") {|f| f.write string}
26
+ end
27
+
28
+ def delete
29
+ ::File.delete(path)
30
+ end
31
+
32
+ def empty?
33
+ ::File.size(path) == 0
34
+ end
35
+
36
+ def copy_to(dest)
37
+ FileUtils.cp(path.to_s, dest.to_s)
38
+ Pow(dest)
39
+ end
40
+ alias_method :cp, :copy_to
41
+
42
+ # Will create the directory path if it does not already exist.
43
+ def copy_to!(dest)
44
+ Pow(dest).parent.create_directory
45
+ copy_to(dest)
46
+ end
47
+ alias_method :cp!, :copy_to!
48
+
49
+ def move_to(dest)
50
+ if FileUtils.mv(path.to_s, dest.to_s)
51
+ self.path = dest.path
52
+ end
53
+ end
54
+ alias_method :mv, :move_to
55
+
56
+ # Will create the directory path if it does not already exist.
57
+ def move_to!(dest)
58
+ Pow(dest).parent.create_directory
59
+ move_to(dest)
60
+ end
61
+ alias_method :mv!, :move_to!
62
+ end
63
+ end
data/lib/pow/pow.rb ADDED
@@ -0,0 +1,214 @@
1
+ class PowError < StandardError; end
2
+
3
+ # Path based in current working directory
4
+ def Pow(*args, &block)
5
+ Pow::Base.open(*args, &block)
6
+ end
7
+
8
+ # Path based in the current file's directory
9
+ def Pow!(*args, &block)
10
+ file_path = ::File.dirname(caller[0])
11
+ Pow(file_path, *args, &block)
12
+ end
13
+
14
+ module Pow
15
+ class Base
16
+ attr_accessor :path
17
+
18
+ def self.open(*paths, &block) #:nodoc:
19
+ paths.collect! {|path| path.to_s}
20
+ path = ::File.join(paths)
21
+
22
+ klass = if ::File.directory?(path)
23
+ Directory
24
+ elsif ::File.file?(path)
25
+ File
26
+ else
27
+ self
28
+ end
29
+
30
+ klass.new(path, &block)
31
+ end
32
+
33
+ # Returns the path to the current working directory as a Pow::Dir object.
34
+ def self.working_directory
35
+ Pow(Dir.getwd)
36
+ end
37
+ class <<self; alias_method :cwd, :working_directory; end
38
+
39
+ def initialize(path, mode=nil, &block)
40
+ self.path = ::File.expand_path(path)
41
+ end
42
+
43
+ def open(mode="r", &block)
44
+ create(mode, &block)
45
+ end
46
+
47
+ def write(string)
48
+ create_file.write(string)
49
+ end
50
+
51
+ def copy_to(dest)
52
+ path_must_exist
53
+ end
54
+ alias_method :cp, :copy_to
55
+
56
+ def copy_to!(dest)
57
+ path_must_exist
58
+ end
59
+ alias_method :cp!, :copy_to!
60
+
61
+ def move_to(dest)
62
+ path_must_exist
63
+ end
64
+ alias_method :mv, :move_to
65
+
66
+ def move_to!(dest)
67
+ path_must_exist
68
+ end
69
+ alias_method :mv!, :move_to!
70
+
71
+ def rename_to(new_name)
72
+ move_to(parent / new_name)
73
+ end
74
+
75
+ def permissions=(mode)
76
+ mode = mode.to_s.to_i(8) # convert from octal
77
+ FileUtils.chmod(mode, path)
78
+ end
79
+
80
+ def permissions
81
+ ("%o" % ::File.stat(path.to_s).mode)[2..-1].to_i # Forget about the first two numbers
82
+ end
83
+
84
+ def size
85
+ ::File.size(path)
86
+ end
87
+
88
+ def accessed_at
89
+ ::File.atime(path)
90
+ end
91
+ alias_method :atime, :accessed_at
92
+
93
+ def changed_at
94
+ ::File.ctime(path)
95
+ end
96
+ alias_method :ctime, :changed_at
97
+
98
+ def modified_at
99
+ ::File.mtime(path)
100
+ end
101
+ alias_method :mtime, :modified_at
102
+
103
+ # String representation of the expanded path
104
+ def to_s
105
+ path
106
+ end
107
+ alias_method :to_str, :to_s
108
+
109
+ # Shortcut to combine paths
110
+ # tmp = Pow("tmp")
111
+ # readme_path = tmp["subdir", :README]
112
+ def [](*paths, &block)
113
+ Pow(path, *paths, &block)
114
+ end
115
+
116
+ # Shortcut to append info onto a Pow object
117
+ # tmp = Pow("tmp")
118
+ # readme_path = tmp/"subdir"/"README"
119
+ def /(name=nil)
120
+ self.class.open(path, name)
121
+ end
122
+
123
+ # Compares the path string
124
+ def ==(other)
125
+ other.to_s == self.to_s
126
+ end
127
+
128
+ def eql?(other)
129
+ other.eql? self.to_s
130
+ end
131
+
132
+ # Regex match on the basename for the path
133
+ # path = Pow("/tmp/a_file.txt")
134
+ # path =~ /file/ #=> 2
135
+ # path =~ /tmp/ #=> nil
136
+ def =~(pattern)
137
+ name =~ pattern
138
+ end
139
+
140
+ # Sort based on name
141
+ def <=>(other)
142
+ name <=> other
143
+ end
144
+
145
+ # Returns the last component of the filename given, can optionally exclude the extension
146
+ #
147
+ # ==== Parameters
148
+ # with_extension<Boolean>
149
+ def name(with_extension=true)
150
+ ::File.basename path, (with_extension ? "" : ".#{extension}")
151
+ end
152
+
153
+ # Returns the extension (the portion of file name in path after the period).
154
+ def extension
155
+ ::File.extname(path)[1..-1] # Gets rid of the dot
156
+ end
157
+
158
+ def exists?
159
+ ::File.exist? path
160
+ end
161
+ alias_method :exist?, :exists?
162
+
163
+ def directory?
164
+ ::File.directory?(path)
165
+ end
166
+ alias_method :is_directory?, :directory?
167
+
168
+ def file?
169
+ ::File.file?(path)
170
+ end
171
+ alias_method :is_file?, :file?
172
+
173
+ # Returns the path the is one level up from the current path
174
+ def parent
175
+ Pow(::File.dirname(path))
176
+ end
177
+
178
+ def empty?
179
+ true
180
+ end
181
+
182
+ # Creates a new path. If there is a . in the name, then assume it is a file
183
+ # Block returns a file object when a file is created
184
+ def create(mode="a+", &block)
185
+ name =~ /\./ ? create_file(mode, &block) : create_directory(&block)
186
+ end
187
+
188
+ def create_file(mode="a+", &block)
189
+ FileUtils.mkdir_p(::File.dirname(self.to_s))
190
+ file = File.new(self.to_s)
191
+ file.open(mode, &block) # Create the file
192
+
193
+ file
194
+ end
195
+
196
+ def create_directory(&block)
197
+ FileUtils.mkdir_p(self.to_s)
198
+ dir = Directory.new(self.to_s)
199
+
200
+ dir.open(&block) if block_given?
201
+
202
+ dir
203
+ end
204
+
205
+ private
206
+ def path_must_exist
207
+ raise PowError, "Path (#{path}) does not exist."
208
+ end
209
+
210
+ def path=(value)
211
+ @path = ::File::expand_path(value)
212
+ end
213
+ end
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.94'
4
+ version: '1.0'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,24 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-02 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: pow
16
- requirement: !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: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
12
+ date: 2013-03-29 00:00:00.000000000 Z
13
+ dependencies: []
30
14
  description: ! 'Switch the documents directory for the iOS app you''re currently working
31
15
  on using named tags. '
32
16
  email:
@@ -45,6 +29,11 @@ files:
45
29
  - chairs.gemspec
46
30
  - lib/chairs/version.rb
47
31
  - lib/musician.rb
32
+ - lib/pow.rb
33
+ - lib/pow/License.txt
34
+ - lib/pow/directory.rb
35
+ - lib/pow/file.rb
36
+ - lib/pow/pow.rb
48
37
  homepage: http://github.com/orta/muscialchairs
49
38
  licenses: []
50
39
  post_install_message:
@@ -65,8 +54,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
54
  version: '0'
66
55
  requirements: []
67
56
  rubyforge_project: chairs
68
- rubygems_version: 1.8.24
57
+ rubygems_version: 1.8.25
69
58
  signing_key:
70
59
  specification_version: 3
71
60
  summary: A gem for swapping in/out document folders in iOS Sims
72
61
  test_files: []
62
+ has_rdoc: