motion_require 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +22 -6
- data/lib/motion_require/dependency_builder.rb +22 -5
- data/lib/motion_require/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
#
|
1
|
+
# motion_require
|
2
2
|
|
3
|
-
|
3
|
+
Allows you to use `require` in your RubyMotion apps just like you are used to. This allows you to use gems like you normally do and manage your
|
4
|
+
dependencies with Bundler.
|
4
5
|
|
5
6
|
## Installation
|
6
7
|
|
7
|
-
|
8
|
+
Use bundler like you normally do when writing your Ruby apps, and add this line to your application's Gemfile:
|
8
9
|
|
9
10
|
gem 'motion_require'
|
10
11
|
|
@@ -12,13 +13,28 @@ And then execute:
|
|
12
13
|
|
13
14
|
$ bundle
|
14
15
|
|
15
|
-
|
16
|
+
Then require it in your Rakefile by adding this line somewhere at the top:
|
16
17
|
|
17
|
-
|
18
|
+
require 'motion_require'
|
19
|
+
|
20
|
+
So your Rakefile will look something like this:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
require "bundler/setup"
|
24
|
+
|
25
|
+
$:.unshift('/Library/RubyMotion/lib')
|
26
|
+
require 'motion/project'
|
27
|
+
require 'motion_require'
|
28
|
+
|
29
|
+
Motion::Project::App.setup do |app|
|
30
|
+
app.name = 'KillerApp'
|
31
|
+
end
|
32
|
+
```
|
18
33
|
|
19
34
|
## Usage
|
20
35
|
|
21
|
-
|
36
|
+
Now you can use require in your application to specify the dependencies without having to maintain the compliation order in you Rakefile.
|
37
|
+
You can even require files from gems that are in you Gemfile.
|
22
38
|
|
23
39
|
## Contributing
|
24
40
|
|
@@ -30,19 +30,36 @@ module MotionRequire
|
|
30
30
|
|
31
31
|
def resolve
|
32
32
|
return if @resolved
|
33
|
-
|
33
|
+
app_delegate = find_file('app_delegate')
|
34
|
+
|
35
|
+
add_dependencies_for_file(app_delegate)
|
36
|
+
|
37
|
+
@file_list = load_order_for(app_delegate)
|
38
|
+
|
34
39
|
@resolved = true
|
35
40
|
end
|
36
41
|
|
37
|
-
def
|
38
|
-
|
42
|
+
def load_order_for(file_name)
|
43
|
+
deps = @dependencies[file_name]
|
44
|
+
|
45
|
+
if deps && !deps.empty?
|
46
|
+
deps.inject([file_name]) do |memo, dep_file_name|
|
47
|
+
if memo.include?(dep_file_name)
|
48
|
+
memo
|
49
|
+
else
|
50
|
+
load_order_for(dep_file_name) + memo
|
51
|
+
end
|
52
|
+
end
|
53
|
+
else
|
54
|
+
[file_name]
|
55
|
+
end
|
56
|
+
end
|
39
57
|
|
58
|
+
def add_dependencies_for_file(file_name)
|
40
59
|
deps = dependencies_for_file(file_name)
|
41
60
|
|
42
61
|
@dependencies[file_name] = deps unless deps.empty?
|
43
62
|
|
44
|
-
@file_list.unshift(file_name)
|
45
|
-
|
46
63
|
deps.each do |file|
|
47
64
|
add_dependencies_for_file(file)
|
48
65
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion_require
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.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: 2012-
|
12
|
+
date: 2012-07-07 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Implementation of Kernel#require for RubyMotion
|
15
15
|
email:
|