motion-fixtures 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in motion-fixtures.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Vladimir Pouzanov
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.
@@ -0,0 +1,27 @@
1
+ # Motion::Fixtures
2
+
3
+ This gem adds support for simple fixtures installation to simulator
4
+
5
+ ## Usage
6
+
7
+ 1. Require `'motion-fixtures'` in your `Rakefile` (or use Bundler)
8
+ 2. Place your fixture files into `spec/fixtures/`
9
+ 3. There's no step 3!
10
+
11
+ ## Customization
12
+
13
+ By default, fixtures are taken from `spec/fixtures/` and are copied to `Documents`
14
+ directory of your application. To customize the behaviour use `app.fixtures` property.
15
+ It's **an Array of Arrays**, where each fixture is a pair of *file name* and destination
16
+ directory name (see NSSearchPathDirectory in Cocoa docs).
17
+
18
+ Example:
19
+
20
+ ```ruby
21
+ app.fixtures = [
22
+ ['./spec/fixtures/test.db', :NSDocumentDirectory], # notice the Symbol
23
+ ['./spec/fixtures/stub_cache', :NSCachesDirectory]
24
+ ]
25
+ ```
26
+
27
+ Note: subdirectories are not [yet] supported. Patches are welcome.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ require "motion-fixtures/version"
2
+ require "motion-fixtures/config"
@@ -0,0 +1,45 @@
1
+ module Motion; module Project
2
+ class Config
3
+ alias :motion_fixtures_original_spec_files :spec_files
4
+ def spec_files
5
+ fixtures_loader = File.expand_path(fixtures_loader_config)
6
+ return motion_fixtures_original_spec_files if motion_fixtures_original_spec_files.include? fixtures_loader
7
+
8
+ index = motion_fixtures_original_spec_files.find_index do |file|
9
+ file.include? "/lib/motion/spec.rb"
10
+ end
11
+
12
+ motion_fixtures_original_spec_files.insert(index + 1, fixtures_loader)
13
+ end
14
+
15
+ attr_accessor :fixtures
16
+
17
+ def fixtures
18
+ unless @fixtures
19
+ @fixtures = Dir.glob('./spec/fixtures/*').map { |fn| [fn, :NSDocumentDirectory] }
20
+ end
21
+ @fixtures
22
+ end
23
+
24
+ def fixtures_loader_config
25
+ loader_file = File.join(build_dir, 'fixtures_loader.rb')
26
+
27
+ f = open(loader_file, 'wb')
28
+
29
+ abs_fixtures = fixtures.map { |fn, dest| [File.absolute_path(fn), dest] }
30
+ abs_fixtures.each do |fn, dest|
31
+ base_fn = File.basename(fn)
32
+ f.write(
33
+ "NSFileManager.defaultManager.copyItemAtURL(NSURL.fileURLWithPath(\"#{fn}\"),
34
+ toURL:NSFileManager.defaultManager.URLForDirectory(#{dest.to_s}, inDomain:NSUserDomainMask, appropriateForURL:nil, create:true, error:nil).
35
+ URLByAppendingPathComponent(\"#{base_fn}\"), error:nil)\n"
36
+ )
37
+
38
+ end
39
+
40
+
41
+ f.close
42
+ loader_file
43
+ end
44
+ end
45
+ end ; end
@@ -0,0 +1,5 @@
1
+ module Motion
2
+ module Fixtures
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/motion-fixtures/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Vladimir Pouzanov"]
6
+ gem.email = ["farcaller@gmail.com"]
7
+ gem.description = "Fixtures support for RubyMotion"
8
+ gem.summary = "Fixtures support for RubyMotion"
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 = "motion-fixtures"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Motion::Fixtures::VERSION
17
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-fixtures
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Vladimir Pouzanov
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-27 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Fixtures support for RubyMotion
15
+ email:
16
+ - farcaller@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE
24
+ - README.md
25
+ - Rakefile
26
+ - lib/motion-fixtures.rb
27
+ - lib/motion-fixtures/config.rb
28
+ - lib/motion-fixtures/version.rb
29
+ - motion-fixtures.gemspec
30
+ homepage: ''
31
+ licenses: []
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project:
50
+ rubygems_version: 1.8.21
51
+ signing_key:
52
+ specification_version: 3
53
+ summary: Fixtures support for RubyMotion
54
+ test_files: []
55
+ has_rdoc: