motion-require 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -2
- data/lib/motion-require/version.rb +1 -1
- data/lib/motion-require.rb +32 -0
- metadata +1 -1
data/README.md
CHANGED
@@ -17,7 +17,7 @@ end
|
|
17
17
|
require 'motion/project'
|
18
18
|
|
19
19
|
require 'motion-require'
|
20
|
-
Motion::Require.all(Dir.glob("app/**/*.rb")
|
20
|
+
Motion::Require.all(Dir.glob("app/**/*.rb"))
|
21
21
|
|
22
22
|
Motion::Project::App.setup do |app|
|
23
23
|
# ...
|
@@ -50,4 +50,4 @@ Clay Allsopp ([http://clayallsopp.com](http://clayallsopp.com))
|
|
50
50
|
|
51
51
|
## License
|
52
52
|
|
53
|
-
motion-require is available under the MIT license. See the LICENSE file for more info.
|
53
|
+
motion-require is available under the MIT license. See the LICENSE file for more info.
|
data/lib/motion-require.rb
CHANGED
@@ -1,5 +1,37 @@
|
|
1
1
|
require 'ripper'
|
2
2
|
|
3
|
+
# Hack until HipByte accepts https://github.com/HipByte/RubyMotion/pull/82
|
4
|
+
# Stolen from BubbleWrap
|
5
|
+
module Motion::Require
|
6
|
+
module Ext
|
7
|
+
module ConfigTask
|
8
|
+
|
9
|
+
def self.included(base)
|
10
|
+
base.class_eval do
|
11
|
+
alias_method :files_dependencies_without_require, :files_dependencies
|
12
|
+
alias_method :files_dependencies, :files_dependencies_with_require
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def files_dependencies_with_require(deps_hash)
|
17
|
+
res_path = lambda do |x|
|
18
|
+
path = /^\.?\//.match(x) ? x : File.join('.', x)
|
19
|
+
unless @files.flatten.include?(path)
|
20
|
+
Motion::Project::App.send(:fail, "Can't resolve dependency `#{x}'")
|
21
|
+
end
|
22
|
+
path
|
23
|
+
end
|
24
|
+
deps_hash.each do |path, deps|
|
25
|
+
deps = [deps] unless deps.is_a?(Array)
|
26
|
+
@dependencies[res_path.call(path)] = deps.map(&res_path)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
Motion::Project::Config.send(:include, Motion::Require::Ext::ConfigTask)
|
34
|
+
|
3
35
|
module Motion
|
4
36
|
module Require
|
5
37
|
class RequireBuilder < Ripper::SexpBuilder
|