motion-bundler 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.rdoc +7 -0
- data/VERSION +1 -1
- data/lib/motion-bundler/require/ripper.rb +21 -18
- data/lib/motion-bundler/version.rb +1 -1
- data/lib/motion-bundler.rb +39 -14
- data/test/.gemfiles/simulator/test_setup.lock +1 -1
- data/test/motion/simulator/test_setup.rb +3 -3
- data/test/test_helper.rb +11 -0
- data/test/unit/require/test_ripper.rb +14 -0
- data/test/unit/test_motion-bundler.rb +9 -3
- metadata +9 -23
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f5db7eef27452db03cec3069345404b2782c6e9d
|
4
|
+
data.tar.gz: f7e198110cf2ed95529df59957a5dc662e4bb8dc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 14a40f729b2ec900abb0f4f1e244617fb5a438f5b9b792baa63e9dab486cff3aa4d79547af3b74cdce96f287461182378a41eeaa8223b7655221cba2ac7356af
|
7
|
+
data.tar.gz: c5ddd7429a457a06d7ba1dd6296e13a83163b0b05226f44e321c79a0f4cc6cff882aaedb8f0512d029ede239d4957f864ad5117c1ecebfe2824712a104550066
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
= MotionBundler CHANGELOG
|
2
2
|
|
3
|
+
== Version 0.1.5 (May 30, 2013)
|
4
|
+
|
5
|
+
* Being able to require multiple files (e.g. `require "./config/**/*.rb"` within `app/app_delegate.rb`)
|
6
|
+
* Expanding paths when registering files and files dependencies
|
7
|
+
* Corrected files order when registering
|
8
|
+
* Fixed `duplicate symbol` error (for real this time)
|
9
|
+
|
3
10
|
== Version 0.1.4 (May 29, 2013)
|
4
11
|
|
5
12
|
* Not using colorize as gem dependency anymore: defining String#yellow, String#green, String#red in MotionBundler itself
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
@@ -29,33 +29,36 @@ module MotionBundler
|
|
29
29
|
|
30
30
|
def parse
|
31
31
|
@sources.each do |source|
|
32
|
-
next if @
|
32
|
+
next if @requires.include?(source)
|
33
33
|
added_sources = []
|
34
34
|
|
35
35
|
builder = Builder.new source
|
36
36
|
builder.requires.each do |method, args|
|
37
|
-
(@requires[source] ||= []) << args[0]
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
38
|
+
(@requires[source] ||= []) << args[0]
|
39
|
+
((arg = args[0]).include?("*.rb") ? Dir[arg] : [arg]).each do |file|
|
40
|
+
file = begin
|
41
|
+
if method == :require_relative
|
42
|
+
File.expand_path("../#{file}.rb", source)
|
43
|
+
else
|
44
|
+
Require.resolve(file)
|
45
|
+
end
|
44
46
|
end
|
45
|
-
end
|
46
47
|
|
47
|
-
|
48
|
+
@files << source
|
49
|
+
@files << file
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
-
else
|
52
|
-
MotionBundler.app_require file
|
53
|
-
end
|
51
|
+
(@files_dependencies[source] ||= []) << file
|
52
|
+
expanded_path = File.expand_path(file)
|
54
53
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
54
|
+
unless @sources.any?{|x| File.expand_path(x) == expanded_path}
|
55
|
+
if expanded_path.include?(MotionBundler::PROJECT_PATH)
|
56
|
+
added_sources << file
|
57
|
+
else
|
58
|
+
MotionBundler.app_require file
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
59
62
|
end
|
60
63
|
|
61
64
|
unless added_sources.empty?
|
data/lib/motion-bundler.rb
CHANGED
@@ -7,7 +7,8 @@ require "motion-bundler/version"
|
|
7
7
|
module MotionBundler
|
8
8
|
extend self
|
9
9
|
|
10
|
-
|
10
|
+
PROJECT_PATH = File.expand_path "."
|
11
|
+
MOTION_BUNDLER_FILE = "#{PROJECT_PATH}/.motion-bundler.rb"
|
11
12
|
|
12
13
|
def app_require(file)
|
13
14
|
app_requires << file
|
@@ -21,10 +22,14 @@ module MotionBundler
|
|
21
22
|
ripper_require files, files_dependencies, required
|
22
23
|
tracer_require files, files_dependencies, required, &block
|
23
24
|
|
24
|
-
|
25
|
-
|
25
|
+
normalize! files
|
26
|
+
normalize! files_dependencies
|
27
|
+
required.sort!.uniq!
|
26
28
|
|
27
29
|
write_motion_bundler files, files_dependencies, required
|
30
|
+
|
31
|
+
app.files = files
|
32
|
+
app.files_dependencies files_dependencies
|
28
33
|
end
|
29
34
|
end
|
30
35
|
|
@@ -57,11 +62,15 @@ private
|
|
57
62
|
def ripper_require(files, files_dependencies, required)
|
58
63
|
ripper = Require::Ripper.new *Dir["app/**/*.rb"].collect{|x| "./#{x}"}
|
59
64
|
|
60
|
-
files.replace(
|
61
|
-
|
62
|
-
|
63
|
-
files_dependencies.
|
64
|
-
|
65
|
+
files.replace(
|
66
|
+
ripper.files + files
|
67
|
+
)
|
68
|
+
files_dependencies.merge!(
|
69
|
+
ripper.files_dependencies
|
70
|
+
)
|
71
|
+
required.concat(
|
72
|
+
ripper.requires.values.flatten
|
73
|
+
)
|
65
74
|
end
|
66
75
|
|
67
76
|
def tracer_require(files, files_dependencies, required)
|
@@ -82,7 +91,7 @@ private
|
|
82
91
|
|
83
92
|
files.replace(
|
84
93
|
Require.files + files - ["APP", "BUNDLER", __FILE__]
|
85
|
-
)
|
94
|
+
)
|
86
95
|
files_dependencies.merge!(
|
87
96
|
Require.files_dependencies.tap do |dependencies|
|
88
97
|
(dependencies.delete("BUNDLER") || []).each do |file|
|
@@ -92,11 +101,9 @@ private
|
|
92
101
|
dependencies.delete(__FILE__)
|
93
102
|
end
|
94
103
|
)
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
true
|
104
|
+
required.concat(
|
105
|
+
Require.requires.values.flatten
|
106
|
+
)
|
100
107
|
end
|
101
108
|
|
102
109
|
def write_motion_bundler(files, files_dependencies, required)
|
@@ -116,6 +123,24 @@ private
|
|
116
123
|
end
|
117
124
|
end
|
118
125
|
|
126
|
+
def normalize!(object)
|
127
|
+
object.replace(
|
128
|
+
if object.is_a?(Array)
|
129
|
+
object.inject(Set.new) do |a, v|
|
130
|
+
a << File.expand_path(v)
|
131
|
+
a
|
132
|
+
end.to_a.partition do |v|
|
133
|
+
(v == MOTION_BUNDLER_FILE) || !v.include?(PROJECT_PATH)
|
134
|
+
end.flatten
|
135
|
+
elsif object.is_a?(Hash)
|
136
|
+
object.inject({}) do |h, (k, v)|
|
137
|
+
(h[File.expand_path(k)] ||= []).concat normalize!(v)
|
138
|
+
h
|
139
|
+
end
|
140
|
+
end
|
141
|
+
)
|
142
|
+
end
|
143
|
+
|
119
144
|
def pretty_inspect(object, indent = 0)
|
120
145
|
if object.is_a?(Array)
|
121
146
|
entries = object.collect{|x| " #{pretty_inspect x, indent + 2}"}
|
@@ -22,7 +22,7 @@ module Motion
|
|
22
22
|
/Users/paulengel/bar.rb
|
23
23
|
)
|
24
24
|
|
25
|
-
Motion::Project::App.any_instance.expects(:files=).with([
|
25
|
+
Motion::Project::App.any_instance.expects(:files=).with(expand_paths [
|
26
26
|
MotionBundler::MOTION_BUNDLER_FILE,
|
27
27
|
motion_bundler_file("motion-bundler/simulator/boot.rb"),
|
28
28
|
motion_bundler_file("motion-bundler/simulator/core_ext.rb"),
|
@@ -41,7 +41,7 @@ module Motion
|
|
41
41
|
"/Users/paulengel/bar.rb"
|
42
42
|
])
|
43
43
|
|
44
|
-
Motion::Project::App.any_instance.expects(:files_dependencies).with(
|
44
|
+
Motion::Project::App.any_instance.expects(:files_dependencies).with(expand_paths({
|
45
45
|
motion_bundler_file("motion-bundler/simulator/boot.rb") => [
|
46
46
|
motion_bundler_file("motion-bundler/simulator/core_ext.rb"),
|
47
47
|
motion_bundler_file("motion-bundler/simulator/console.rb")
|
@@ -56,7 +56,7 @@ module Motion
|
|
56
56
|
gem_path("slot_machine/lib/time_slot.rb"),
|
57
57
|
gem_path("slot_machine/lib/time_slots.rb")
|
58
58
|
]
|
59
|
-
)
|
59
|
+
}))
|
60
60
|
|
61
61
|
MotionBundler.setup do |app|
|
62
62
|
app.require "a"
|
data/test/test_helper.rb
CHANGED
@@ -37,6 +37,17 @@ def mocks_dir
|
|
37
37
|
File.expand_path "../mocks", __FILE__
|
38
38
|
end
|
39
39
|
|
40
|
+
def expand_paths(paths)
|
41
|
+
if paths.is_a? Array
|
42
|
+
paths.collect{|v| File.expand_path v}
|
43
|
+
else
|
44
|
+
paths.inject({}) do |h, (k, v)|
|
45
|
+
h[File.expand_path(k)] = expand_paths(v)
|
46
|
+
h
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
40
51
|
def motion_gemfile(content)
|
41
52
|
content = "source \"https://rubygems.org\"\n\n#{content}"
|
42
53
|
dirname = File.dirname __FILE__
|
@@ -33,6 +33,18 @@ module Unit
|
|
33
33
|
bar_builder.expects(:requires).returns []
|
34
34
|
MotionBundler::Require::Ripper::Builder.expects(:new).with(File.expand_path("./app/controllers/bar.rb")).returns bar_builder
|
35
35
|
|
36
|
+
stringio_builder = mock "object"
|
37
|
+
stringio_builder.expects(:requires).returns []
|
38
|
+
MotionBundler::Require::Ripper::Builder.expects(:new).with("stdlib/stringio.rb").returns stringio_builder
|
39
|
+
|
40
|
+
strscan_builder = mock "object"
|
41
|
+
strscan_builder.expects(:requires).returns []
|
42
|
+
MotionBundler::Require::Ripper::Builder.expects(:new).with("mocks/strscan.rb").returns strscan_builder
|
43
|
+
|
44
|
+
lib_baz_builder = mock "object"
|
45
|
+
lib_baz_builder.expects(:requires).returns []
|
46
|
+
MotionBundler::Require::Ripper::Builder.expects(:new).with("lib/baz.rb").returns lib_baz_builder
|
47
|
+
|
36
48
|
MotionBundler::Require.expects(:resolve).with("stringio").returns("stdlib/stringio.rb")
|
37
49
|
MotionBundler::Require.expects(:resolve).with("strscan").returns("mocks/strscan.rb")
|
38
50
|
MotionBundler::Require.expects(:resolve).with("baz").returns("lib/baz.rb")
|
@@ -50,6 +62,7 @@ module Unit
|
|
50
62
|
"mocks/strscan.rb",
|
51
63
|
"./app/controllers/foo_controller.rb",
|
52
64
|
"lib/baz.rb",
|
65
|
+
File.expand_path("app/controllers/qux.rb"),
|
53
66
|
File.expand_path("app/controllers/bar.rb")
|
54
67
|
], ripper.files)
|
55
68
|
assert_equal({
|
@@ -59,6 +72,7 @@ module Unit
|
|
59
72
|
],
|
60
73
|
"./app/controllers/foo_controller.rb" => [
|
61
74
|
"lib/baz.rb",
|
75
|
+
File.expand_path("app/controllers/qux.rb"),
|
62
76
|
File.expand_path("app/controllers/bar.rb")
|
63
77
|
]
|
64
78
|
}, ripper.files_dependencies)
|
@@ -58,6 +58,12 @@ module Unit
|
|
58
58
|
MotionBundler.send :write_motion_bundler, [], {}, []
|
59
59
|
end
|
60
60
|
|
61
|
+
it "should be able to register files to require" do
|
62
|
+
assert_equal [], MotionBundler.send(:app_requires)
|
63
|
+
MotionBundler.app_require "foo/bar.rb"
|
64
|
+
assert_equal ["foo/bar.rb"], MotionBundler.send(:app_requires)
|
65
|
+
end
|
66
|
+
|
61
67
|
describe "calling `setup`" do
|
62
68
|
it "should require the :motion Bundler group and trace requires" do
|
63
69
|
object = mock "object"
|
@@ -113,7 +119,7 @@ module Unit
|
|
113
119
|
]
|
114
120
|
})
|
115
121
|
|
116
|
-
Motion::Project::App.any_instance.expects(:files=).with([
|
122
|
+
Motion::Project::App.any_instance.expects(:files=).with(expand_paths [
|
117
123
|
motion_bundler_file("motion-bundler/simulator/boot.rb"),
|
118
124
|
motion_bundler_file("motion-bundler/simulator/core_ext.rb"),
|
119
125
|
motion_bundler_file("motion-bundler/simulator/motion-bundler.rb"),
|
@@ -125,7 +131,7 @@ module Unit
|
|
125
131
|
"controller.rb"
|
126
132
|
])
|
127
133
|
|
128
|
-
Motion::Project::App.any_instance.expects(:files_dependencies).with({
|
134
|
+
Motion::Project::App.any_instance.expects(:files_dependencies).with(expand_paths({
|
129
135
|
motion_bundler_file("motion-bundler/simulator/boot.rb") => [
|
130
136
|
motion_bundler_file("motion-bundler/simulator/core_ext.rb"),
|
131
137
|
motion_bundler_file("motion-bundler/simulator/motion-bundler.rb")
|
@@ -135,7 +141,7 @@ module Unit
|
|
135
141
|
"gems/foo-0.1.0/lib/foo/bar.rb",
|
136
142
|
"gems/foo-0.1.0/lib/foo/version.rb"
|
137
143
|
]
|
138
|
-
})
|
144
|
+
}))
|
139
145
|
|
140
146
|
MotionBundler.setup
|
141
147
|
end
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion-bundler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Paul Engel
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-30 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: minitest
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - '='
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - '='
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: mocha
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - '='
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - '='
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,17 +41,15 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
description: Use Ruby gems and mock require statements within RubyMotion applications
|
@@ -171,33 +164,26 @@ files:
|
|
171
164
|
- test/unit/test_require.rb
|
172
165
|
homepage: https://github.com/archan937/motion-bundler
|
173
166
|
licenses: []
|
167
|
+
metadata: {}
|
174
168
|
post_install_message:
|
175
169
|
rdoc_options: []
|
176
170
|
require_paths:
|
177
171
|
- lib
|
178
172
|
required_ruby_version: !ruby/object:Gem::Requirement
|
179
|
-
none: false
|
180
173
|
requirements:
|
181
|
-
- -
|
174
|
+
- - '>='
|
182
175
|
- !ruby/object:Gem::Version
|
183
176
|
version: '0'
|
184
|
-
segments:
|
185
|
-
- 0
|
186
|
-
hash: 3894260479550083785
|
187
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
|
-
none: false
|
189
178
|
requirements:
|
190
|
-
- -
|
179
|
+
- - '>='
|
191
180
|
- !ruby/object:Gem::Version
|
192
181
|
version: '0'
|
193
|
-
segments:
|
194
|
-
- 0
|
195
|
-
hash: 3894260479550083785
|
196
182
|
requirements: []
|
197
183
|
rubyforge_project:
|
198
|
-
rubygems_version:
|
184
|
+
rubygems_version: 2.0.3
|
199
185
|
signing_key:
|
200
|
-
specification_version:
|
186
|
+
specification_version: 4
|
201
187
|
summary: Use Ruby gems and mock require statements within RubyMotion applications
|
202
188
|
test_files:
|
203
189
|
- test/gems/slot_machine/CHANGELOG.rdoc
|