frasco 0.1.0 → 0.2.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/README.md CHANGED
@@ -6,21 +6,19 @@ Test environment manager for iOS simulator.
6
6
 
7
7
  $ gem install frasco
8
8
 
9
- ## Create Snapshot of Test Environment
9
+ Execute `setup` subcommand.
10
10
 
11
- ### 1. Initialize for your project
11
+ $ frasco setup
12
12
 
13
- $ frasco init
14
-
15
- `init` subcommand create `.frasco` directory in current directory.
13
+ ## Create Snapshot of Test Environment
16
14
 
17
- ### 2. Backup the current iOS simulator environment and clear
15
+ ### 1. Backup the current iOS simulator environment and clear
18
16
 
19
17
  $ frasco stash
20
18
 
21
- If iOS simulator is running, execute with `--quit` option.
19
+ If iOS simulator is running, execute with `-f` or `--quit` option.
22
20
 
23
- ### 3. Run iOS simulator, and make environment do as you wish
21
+ ### 2. Run iOS simulator, and make environment do as you wish
24
22
 
25
23
  $ frasco simulator run
26
24
 
@@ -28,14 +26,15 @@ Example: Register Twitter accounts.
28
26
 
29
27
  If you need a clean environment, you do not need to do anything.
30
28
 
31
- ### 4. Save the snapshot
29
+ ### 3. Save the snapshot
32
30
 
33
31
  $ frasco save MySnapshot
34
32
 
35
- ### 5. Cleanup and restore 1st step's backup
33
+ ### 4. Cleanup and restore 1st step's backup
36
34
 
37
- $ frasco cleanup --quit
35
+ $ frasco cleanup -f
38
36
 
37
+
39
38
  ## Test Using the Snapshot
40
39
 
41
40
  ### 1. Restore the snapshot
@@ -50,7 +49,28 @@ Test by Xcode or xcodebuild, or manually…
50
49
 
51
50
  ### 3. Cleanup and restore 1st step's backup
52
51
 
53
- $ frasco cleanup --quit
52
+ $ frasco cleanup -f
53
+
54
+
55
+ ## Use Snapshot Archive
56
+
57
+ ### 1. Archive snapshot
58
+
59
+ $ frasco archive MySnapshot ArchivedMySnapshot.frasco-snapshot
60
+
61
+ Created "ArchivedMySnapshot.frasco-snapshot" archive file.
62
+
63
+ ### 2. Restore archived snapshot
64
+
65
+ $ frasco up-archive ArchivedMySnapshot.frasco-snapshot
66
+
67
+ ### 3. Test on iOS simulator
68
+
69
+ Test by Xcode or xcodebuild, or manually…
70
+
71
+ ### 4. Cleanup and restore 2nd step's backup
72
+
73
+ $ frasco cleanup -f
54
74
 
55
75
  ## Contributing
56
76
 
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Frasco::VERSION
9
9
  spec.authors = ["mtmta"]
10
10
  spec.email = ["d.masamoto@covelline.com"]
11
- spec.summary = %q{Test environment manager for iOS simulator.}
12
- spec.description = %q{Create a snapshot of the test environment for iOS simulator.}
11
+ spec.description = %q{Test environment manager for iOS simulator.}
12
+ spec.summary = spec.description
13
13
  spec.homepage = "http://neethouse.org/"
14
14
  spec.license = "MIT"
15
15
 
@@ -14,7 +14,7 @@ module Frasco
14
14
  if options.include?(:quit)
15
15
  method_option :quit,
16
16
  :type => :boolean,
17
- :aliases => "-q",
17
+ :aliases => "-f",
18
18
  :desc => "Quit simulator before execute command."
19
19
  end
20
20
 
@@ -40,13 +40,13 @@ module Frasco
40
40
 
41
41
  #######################################
42
42
 
43
- desc "init", "Create '.frasco' directory in current location"
44
- def init
43
+ desc "setup", "Create '.frasco' directory in home directory"
44
+ def setup
45
45
 
46
46
  raise FrascoError.new("already initialized") \
47
- if File.exists?(".frasco")
47
+ if File.exists?(_default_frasco_dir)
48
48
 
49
- FileUtils.mkdir(".frasco")
49
+ FileUtils.mkdir(_default_frasco_dir)
50
50
  end
51
51
 
52
52
 
@@ -193,6 +193,52 @@ module Frasco
193
193
  end
194
194
 
195
195
 
196
+ #######################################
197
+
198
+ desc "archive <NAME> <ARCHIVE-FILE>", "Archive snapshot of tar.gz"
199
+
200
+ method_option :overwrite,
201
+ :type => :boolean,
202
+ :aliases => "-f",
203
+ :desc => "Overwrite exists archive file"
204
+
205
+ def archive(name, archive_path)
206
+
207
+ snapshot = _get_snapshot(name)
208
+
209
+ raise FrascoError.snapshot_notfound_error(snapshot) \
210
+ unless snapshot.exists?
211
+
212
+ raise FrascoError.new("speficied archive file is already exists: #{archive_path}\nOverwrite with -f/--overwrite option.") \
213
+ if File.exists?(archive_path) && !options["overwrite"]
214
+
215
+ archive_path = File.absolute_path(archive_path)
216
+
217
+ system("cd '#{snapshot.path}' && tar czf '#{archive_path}' .")
218
+
219
+ end
220
+
221
+
222
+ #######################################
223
+
224
+ desc "up-archive <ARCHIVE-FILE>", "Backup current environment to stash, and restore archived snapshot"
225
+
226
+ preset_method_option :quit
227
+
228
+ def up_archive(archive_path)
229
+
230
+ _before_bang_command
231
+
232
+ raise FrascoError.new("no such file: #{archive_path}") \
233
+ unless File.exists?(archive_path)
234
+
235
+ stash
236
+
237
+ system("mkdir '#{@simulator_dir}' && tar xzf '#{archive_path}' -C '#{@simulator_dir}'")
238
+
239
+ end
240
+
241
+
196
242
  #######################################
197
243
 
198
244
  desc "simulator [COMMAND]", SimulatorCLI::DESC
@@ -224,7 +270,7 @@ module Frasco
224
270
  if options[:quit]
225
271
  simulator.quit
226
272
  else
227
- raise FrascoError.new("Simulator is running. Quit with --quit option.")
273
+ raise FrascoError.new("Simulator is running. Quit with -f/--quit option.")
228
274
  end
229
275
  end
230
276
  end
@@ -244,18 +290,22 @@ module Frasco
244
290
  end
245
291
 
246
292
 
247
- # Find .frasco directory from current dir to parent.
293
+ # Returns $FRASCO_DIR or $HOME/.frasco
294
+ # Raise an error when .frasco dir is not exists.
248
295
  private
249
296
  def _find_frasco_dir
250
297
 
251
- dir = Dir::pwd
298
+ dir = ENV["FRASCO_DIR"] || _default_frasco_dir
252
299
 
253
- while !File::exists? frasco_dir = dir + "/.frasco"
254
- dir = File::expand_path("..", dir);
255
- raise FrascoError.new(".frasco directory not exists\nPlease execute 'frasco init' command.") if dir == "/"
256
- end
300
+ raise FrascoError.new("frasco is not setup\nPlease execute 'frasco setup' command.") \
301
+ unless File.exists?(dir)
257
302
 
258
- frasco_dir
303
+ dir
304
+ end
305
+
306
+ private
307
+ def _default_frasco_dir
308
+ "#{Dir::home}/.frasco"
259
309
  end
260
310
 
261
311
  private
@@ -263,6 +313,10 @@ module Frasco
263
313
  _find_snapshots_dir = "#{_find_frasco_dir}/snapshots"
264
314
  end
265
315
 
316
+ def self.exit_on_failure?
317
+ true
318
+ end
319
+
266
320
  end
267
321
 
268
322
  end
@@ -1,3 +1,3 @@
1
1
  module Frasco
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frasco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-18 00:00:00.000000000 Z
12
+ date: 2014-01-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -59,7 +59,7 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
- description: Create a snapshot of the test environment for iOS simulator.
62
+ description: Test environment manager for iOS simulator.
63
63
  email:
64
64
  - d.masamoto@covelline.com
65
65
  executables: