motion-require 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/motion-require.rb +25 -1
- data/lib/motion-require/version.rb +1 -1
- data/spec/motion_require_spec.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22304b50b21657af16d9424db261d09516b4da9c
|
4
|
+
data.tar.gz: 249507b9927166548c649df70660b3d9089b6e56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8a308f2c0d9434d10e08069468e4780282fa72170a66494dd2415a7625d6b0b092ea83ffe7e977dc65d69f2fafe883a9c7f775f5ed90987d905a522cbda8b34
|
7
|
+
data.tar.gz: b29a2c80f8bde61c805aeceb0bb350a2ff8d9c2ce37859a04d93b0461f980cf71c4d166fecc924873e1a7c4d4257826ad88eb6017e247070f02fb7f54942dcf5
|
data/README.md
CHANGED
@@ -30,6 +30,11 @@ To enable `motion_require` for only select files:
|
|
30
30
|
|
31
31
|
```ruby
|
32
32
|
Motion::Require.all(Dir.glob('app/models/**/*.rb'))
|
33
|
+
|
34
|
+
# if you're writing a gem that supports iOS and OS X, you might need to filter
|
35
|
+
# based on the platform:
|
36
|
+
Motion::Require.all(Dir.glob('lib/ios/**/*.rb'), platform: :ios)
|
37
|
+
Motion::Require.all(Dir.glob('lib/osx/**/*.rb'), platform: :osx)
|
33
38
|
```
|
34
39
|
|
35
40
|
You **should not** use `app.files <<` in your `setup` block if using motion-require; opt to use `Motion::Require.all` and it will be taken care of.
|
data/lib/motion-require.rb
CHANGED
@@ -86,7 +86,17 @@ module Motion
|
|
86
86
|
end
|
87
87
|
|
88
88
|
# Scan specified files. When nil, fallback to RubyMotion's default (app/**/*.rb).
|
89
|
-
def all(files=nil)
|
89
|
+
def all(files=nil, options={})
|
90
|
+
# if you want the default 'app.files', you can just pass in the options
|
91
|
+
if files.is_a?(Hash) && options == {}
|
92
|
+
options = files
|
93
|
+
files = nil
|
94
|
+
end
|
95
|
+
|
96
|
+
check_platform = options.fetch(:platform, nil)
|
97
|
+
current_platform = App.respond_to?(:template) ? App.template : :ios
|
98
|
+
return unless Motion::Require.check_platform(current_platform, check_platform)
|
99
|
+
|
90
100
|
Motion::Project::App.setup do |app|
|
91
101
|
app.exclude_from_detect_dependencies << ext_file
|
92
102
|
|
@@ -107,6 +117,20 @@ module Motion
|
|
107
117
|
end
|
108
118
|
end
|
109
119
|
|
120
|
+
def check_platform(current_platform, check_platform)
|
121
|
+
case check_platform
|
122
|
+
when nil
|
123
|
+
true
|
124
|
+
when Array
|
125
|
+
check_platform.include?(current_platform)
|
126
|
+
when Symbol
|
127
|
+
current_platform == check_platform
|
128
|
+
else
|
129
|
+
puts "Unrecognized value for 'check_platform': #{check_platform.inspect}"
|
130
|
+
false
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
110
134
|
# RubyMotion prefers relative paths to be explicitly prefixed with ./
|
111
135
|
def explicit_relative(path)
|
112
136
|
# Paths that do not start with "/", "./", or "../" will be prefixed with ./
|
data/spec/motion_require_spec.rb
CHANGED
@@ -4,4 +4,20 @@ describe Motion::Require do
|
|
4
4
|
it 'should run' do
|
5
5
|
true.should == true
|
6
6
|
end
|
7
|
+
|
8
|
+
describe 'should check_platform' do
|
9
|
+
it 'should support `nil`' do
|
10
|
+
Motion::Require.check_platform(:ios, nil).should == true
|
11
|
+
end
|
12
|
+
it 'should support Symbol' do
|
13
|
+
Motion::Require.check_platform(:ios, :ios).should == true
|
14
|
+
Motion::Require.check_platform(:ios, :osx).should == false
|
15
|
+
end
|
16
|
+
it 'should support Array' do
|
17
|
+
Motion::Require.check_platform(:ios, [:ios]).should == true
|
18
|
+
Motion::Require.check_platform(:ios, [:ios, :osx]).should == true
|
19
|
+
Motion::Require.check_platform(:osx, [:ios, :osx]).should == true
|
20
|
+
Motion::Require.check_platform(:ios, [:osx]).should == false
|
21
|
+
end
|
22
|
+
end
|
7
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion-require
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clay Allsopp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|