motion_blender 0.1.4 → 0.1.5
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 +4 -4
- data/README.md +7 -6
- data/lib/motion_blender/analyzer/require.rb +7 -1
- data/lib/motion_blender/analyzer.rb +3 -2
- data/lib/motion_blender/config.rb +17 -0
- data/lib/motion_blender/ext/raketime.rb +56 -0
- data/lib/motion_blender/ext/require_suppressor.rb +12 -0
- data/lib/motion_blender/ext/runtime.rb +35 -0
- data/lib/motion_blender/ext.rb +6 -0
- data/lib/motion_blender/rake_tasks.rb +42 -2
- data/lib/motion_blender/version.rb +1 -1
- data/lib/motion_blender.rb +3 -65
- metadata +7 -3
- data/motion/ext.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c76d8d1b39159de5422acb1a2483f60176b3a245
|
4
|
+
data.tar.gz: 247ea6963b4eb853c80c4660dab0d8e408c69dd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8f4329c0066cf08dae85cd5fb4ead5e74588213b829241da88bc42dad9fe4b69dbca2bfb1c59ffc4da9db48dd994a5779eb5f8794b5b051b39654adc9c29c19
|
7
|
+
data.tar.gz: 21c6f104b72287e9c5ae393f1c61d738475eaea0e7ea06ec90f3ddfbe250e7282d86c3c81d19a7c1fb92b37577df86c9adaa9be6db91a7ad2224673d4a7ae2d2
|
data/README.md
CHANGED
@@ -58,7 +58,7 @@ Add RubyMotion-compatible gem into your project (may be an application or a gem)
|
|
58
58
|
And just call `require` from anywhare:
|
59
59
|
|
60
60
|
```ruby
|
61
|
-
require '
|
61
|
+
require 'rubymotion_compatible_gem'
|
62
62
|
|
63
63
|
# your code goes on...
|
64
64
|
```
|
@@ -68,18 +68,19 @@ Writing a gem (*motion_hoge*), this idiom is handy:
|
|
68
68
|
```ruby
|
69
69
|
# in lib/motion_hoge.rb
|
70
70
|
require 'motion_blender'
|
71
|
-
MotionBlender.
|
71
|
+
MotionBlender.incept
|
72
72
|
|
73
|
+
require 'motion_hoge/version'
|
73
74
|
require 'motion_hoge/simsim'
|
74
75
|
require 'motion_hoge/mishmish'
|
75
|
-
require 'motion_hoge/version'
|
76
76
|
# ...
|
77
77
|
```
|
78
78
|
|
79
|
-
|
79
|
+
`MotionBlender.incept` adds this file to RubyMotion's `app.files` and targets for analyzing.
|
80
|
+
To require this *motion_hoge* makes an application or a gem to load functionalities properly.
|
80
81
|
|
81
|
-
|
82
|
-
|
82
|
+
`motion_blender` itself is excepted for analyzing,
|
83
|
+
so don't worry to require `motion_blender` in *incept*-ed files.
|
83
84
|
|
84
85
|
### Limitation
|
85
86
|
|
@@ -26,7 +26,7 @@ module MotionBlender
|
|
26
26
|
else
|
27
27
|
Pathname.new(arg)
|
28
28
|
end
|
29
|
-
dirs =
|
29
|
+
dirs = path.relative? && load_path || ['']
|
30
30
|
exts = path.extname.empty? ? ['', '.rb'] : ['']
|
31
31
|
Enumerator.new do |y|
|
32
32
|
dirs.product(exts).each do |dir, ext|
|
@@ -42,6 +42,12 @@ module MotionBlender
|
|
42
42
|
def uses_load_path?
|
43
43
|
method == :require
|
44
44
|
end
|
45
|
+
|
46
|
+
def load_path
|
47
|
+
if uses_load_path?
|
48
|
+
$LOAD_PATH
|
49
|
+
end
|
50
|
+
end
|
45
51
|
end
|
46
52
|
end
|
47
53
|
end
|
@@ -14,10 +14,11 @@ module MotionBlender
|
|
14
14
|
@dependencies = {}
|
15
15
|
end
|
16
16
|
|
17
|
-
def analyze file, backtrace = []
|
17
|
+
def analyze file, backtrace = [], &proc
|
18
18
|
return if @exclude_files.include? file
|
19
19
|
return if @analyzed_files.include? file
|
20
20
|
@analyzed_files << file
|
21
|
+
proc.call file if proc
|
21
22
|
|
22
23
|
parser = Parser.new file
|
23
24
|
parser.exclude_files = @exclude_files
|
@@ -33,7 +34,7 @@ module MotionBlender
|
|
33
34
|
@dependencies[file] = requires.map(&:file)
|
34
35
|
@files = [*@files, file, *@dependencies[file]].uniq
|
35
36
|
requires.each do |req|
|
36
|
-
analyze req.file, [req.trace, *backtrace]
|
37
|
+
analyze req.file, [req.trace, *backtrace], &proc
|
37
38
|
end
|
38
39
|
end
|
39
40
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module MotionBlender
|
2
|
+
class Config
|
3
|
+
attr_reader :incepted_files, :excepted_files, :motion_dirs
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@incepted_files = []
|
7
|
+
@excepted_files = []
|
8
|
+
@motion_dirs = []
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module_function
|
13
|
+
|
14
|
+
def config
|
15
|
+
@config ||= Config.new
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'motion_blender/config'
|
2
|
+
|
3
|
+
module MotionBlender
|
4
|
+
module Ext
|
5
|
+
module Raketime
|
6
|
+
def incept file = nil
|
7
|
+
file ||= caller.first.split(':', 2).first
|
8
|
+
config.incepted_files << file
|
9
|
+
end
|
10
|
+
|
11
|
+
def except file = nil
|
12
|
+
file ||= caller.first.split(':', 2).first
|
13
|
+
config.excepted_files << file
|
14
|
+
end
|
15
|
+
|
16
|
+
def use_motion_dir dir = nil
|
17
|
+
return unless motion?
|
18
|
+
|
19
|
+
unless dir
|
20
|
+
file = caller.first.split(':', 2).first
|
21
|
+
Pathname.new(file).dirname.ascend do |path|
|
22
|
+
if $LOAD_PATH.include?(path.to_s)
|
23
|
+
dir = path.dirname.join('motion').to_s
|
24
|
+
break
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
unless config.motion_dirs.include? dir
|
29
|
+
config.motion_dirs << dir
|
30
|
+
$LOAD_PATH.unshift dir
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def motion?
|
35
|
+
!!(defined?(Motion) && defined?(Motion::Project))
|
36
|
+
end
|
37
|
+
|
38
|
+
def raketime?
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
42
|
+
def runtime?
|
43
|
+
false
|
44
|
+
end
|
45
|
+
|
46
|
+
def raketime
|
47
|
+
yield if motion?
|
48
|
+
end
|
49
|
+
|
50
|
+
def runtime
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
extend Ext::Raketime
|
56
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module MotionBlender
|
2
|
+
module Ext
|
3
|
+
module Runtime
|
4
|
+
def incept _ = nil
|
5
|
+
end
|
6
|
+
|
7
|
+
def except _ = nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def use_motion_dir _ = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def motion?
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
def raketime?
|
18
|
+
false
|
19
|
+
end
|
20
|
+
|
21
|
+
def runtime?
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
def raketime &_
|
26
|
+
end
|
27
|
+
|
28
|
+
def runtime &proc
|
29
|
+
proc.call
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
extend Ext::Runtime
|
35
|
+
end
|
@@ -1,9 +1,49 @@
|
|
1
1
|
require 'rake'
|
2
|
-
require 'motion_blender'
|
2
|
+
require 'motion_blender/config'
|
3
|
+
require 'motion_blender/analyzer'
|
4
|
+
|
5
|
+
module MotionBlender
|
6
|
+
class RakeTasks
|
7
|
+
def config
|
8
|
+
MotionBlender.config
|
9
|
+
end
|
10
|
+
|
11
|
+
def analyze &proc
|
12
|
+
Motion::Project::App.setup do |app|
|
13
|
+
files = config.incepted_files + app.files
|
14
|
+
analyzer = analyze_files files, &proc
|
15
|
+
|
16
|
+
if analyzer.files.any?
|
17
|
+
new_files = analyzer.files - app.files
|
18
|
+
app.exclude_from_detect_dependencies += new_files
|
19
|
+
app.files = new_files + app.files
|
20
|
+
app.files_dependencies analyzer.dependencies
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def analyze_files files, &proc
|
26
|
+
analyzer = Analyzer.new
|
27
|
+
analyzer.exclude_files += [*builtin_features, *config.excepted_files]
|
28
|
+
|
29
|
+
files.flatten.each do |file|
|
30
|
+
analyzer.analyze file, &proc
|
31
|
+
end
|
32
|
+
analyzer
|
33
|
+
end
|
34
|
+
|
35
|
+
def builtin_features
|
36
|
+
%w(bigdecimal rational date thread)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
3
40
|
|
4
41
|
namespace :motion_blender do
|
5
42
|
task :analyze do
|
6
|
-
MotionBlender.
|
43
|
+
tasks = MotionBlender::RakeTasks.new
|
44
|
+
tasks.analyze do |file|
|
45
|
+
Motion::Project::App.info('Analyze', file)
|
46
|
+
end
|
7
47
|
end
|
8
48
|
end
|
9
49
|
|
data/lib/motion_blender.rb
CHANGED
@@ -1,68 +1,6 @@
|
|
1
1
|
require 'motion_blender/version'
|
2
|
-
require 'motion_blender/analyzer'
|
3
2
|
require 'motion_blender/rake_tasks'
|
3
|
+
require 'motion_blender/ext/raketime'
|
4
|
+
require 'motion_blender/ext'
|
4
5
|
|
5
|
-
|
6
|
-
module_function
|
7
|
-
|
8
|
-
def analyze
|
9
|
-
Motion::Project::App.setup do |app|
|
10
|
-
analyzer = Analyzer.new
|
11
|
-
analyzer.exclude_files += Dir[File.expand_path('../**/*.rb', __FILE__)]
|
12
|
-
analyzer.exclude_files += builtin_features
|
13
|
-
app.files.flatten.each do |file|
|
14
|
-
analyzer.analyze file
|
15
|
-
end
|
16
|
-
|
17
|
-
if analyzer.files.any?
|
18
|
-
app.exclude_from_detect_dependencies += [ext_file, *analyzer.files]
|
19
|
-
app.files = [ext_file, *(analyzer.files - app.files), *app.files]
|
20
|
-
app.files_dependencies analyzer.dependencies
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def add file = nil
|
26
|
-
return unless motion?
|
27
|
-
|
28
|
-
file ||= caller.first.split(':', 2).first
|
29
|
-
Motion::Project::App.setup do |app|
|
30
|
-
app.files.unshift file
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def use_motion_dir dir = nil
|
35
|
-
return unless motion?
|
36
|
-
|
37
|
-
unless dir
|
38
|
-
file = caller.first.split(':', 2).first
|
39
|
-
Pathname.new(file).dirname.ascend do |path|
|
40
|
-
if $LOAD_PATH.include?(path.to_s)
|
41
|
-
dir = path.dirname.join('motion').to_s
|
42
|
-
break
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
$LOAD_PATH.delete dir
|
47
|
-
$LOAD_PATH.unshift dir
|
48
|
-
end
|
49
|
-
|
50
|
-
def motion?
|
51
|
-
defined?(Motion::Project::Config)
|
52
|
-
end
|
53
|
-
|
54
|
-
def raketime &proc
|
55
|
-
proc.call
|
56
|
-
end
|
57
|
-
|
58
|
-
def runtime &_
|
59
|
-
end
|
60
|
-
|
61
|
-
def ext_file
|
62
|
-
File.expand_path('../../motion/ext.rb', __FILE__)
|
63
|
-
end
|
64
|
-
|
65
|
-
def builtin_features
|
66
|
-
%w(bigdecimal rational date thread)
|
67
|
-
end
|
68
|
-
end
|
6
|
+
MotionBlender.except
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion_blender
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kayhide
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -231,9 +231,13 @@ files:
|
|
231
231
|
- lib/motion_blender/analyzer/hooker.rb
|
232
232
|
- lib/motion_blender/analyzer/parser.rb
|
233
233
|
- lib/motion_blender/analyzer/require.rb
|
234
|
+
- lib/motion_blender/config.rb
|
235
|
+
- lib/motion_blender/ext.rb
|
236
|
+
- lib/motion_blender/ext/raketime.rb
|
237
|
+
- lib/motion_blender/ext/require_suppressor.rb
|
238
|
+
- lib/motion_blender/ext/runtime.rb
|
234
239
|
- lib/motion_blender/rake_tasks.rb
|
235
240
|
- lib/motion_blender/version.rb
|
236
|
-
- motion/ext.rb
|
237
241
|
- motion_blender.gemspec
|
238
242
|
homepage: https://github.com/kayhide/motion_blender
|
239
243
|
licenses:
|
data/motion/ext.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
Module.new do
|
2
|
-
def require _
|
3
|
-
end
|
4
|
-
|
5
|
-
def require_relative _
|
6
|
-
end
|
7
|
-
|
8
|
-
def motion_require _
|
9
|
-
end
|
10
|
-
|
11
|
-
Object.send :include, self
|
12
|
-
end
|
13
|
-
|
14
|
-
module MotionBlender
|
15
|
-
module_function
|
16
|
-
|
17
|
-
def add _ = nil
|
18
|
-
end
|
19
|
-
|
20
|
-
def use_motion_dir _ = nil
|
21
|
-
end
|
22
|
-
|
23
|
-
def motion?
|
24
|
-
true
|
25
|
-
end
|
26
|
-
|
27
|
-
def raketime &_
|
28
|
-
end
|
29
|
-
|
30
|
-
def runtime &proc
|
31
|
-
proc.call
|
32
|
-
end
|
33
|
-
end
|