motion-require 0.1.1 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65d2009b53c5642252ae63eab604f55900d3bc46
4
- data.tar.gz: 132b227bd9b8b57fc58bbb3937682205ea5db72a
3
+ metadata.gz: 22304b50b21657af16d9424db261d09516b4da9c
4
+ data.tar.gz: 249507b9927166548c649df70660b3d9089b6e56
5
5
  SHA512:
6
- metadata.gz: 0b1d2ecdd20c39be8644dae728e50b441ad7d85e88c70ea7965e704f982cc88f87550f7b0933d1b5182a064d21f2e17958b0c298cbfff5b06be5bae728282a7f
7
- data.tar.gz: aa95e01fe0bfb2b2e296ebcd973b933a0219e11360027b64572e505e7e2eafed4dcfdd5d9dc4d26bb14c78e313d39bdb5bffffd55bec49d9ed4668850083beb3
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.
@@ -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 ./
@@ -1,5 +1,5 @@
1
1
  module Motion
2
2
  module Require
3
- VERSION="0.1.1"
3
+ VERSION="0.2.0"
4
4
  end
5
5
  end
@@ -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.1.1
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-02-16 00:00:00.000000000 Z
11
+ date: 2014-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec