limelight 0.2.1-java → 0.3.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. data/bin/ll.bat +1 -1
  2. data/lib/i4jruntime.jar +0 -0
  3. data/lib/junit-4.4.jar +0 -0
  4. data/lib/limelight.jar +0 -0
  5. data/lib/limelight/animation.rb +3 -3
  6. data/lib/limelight/builtin/players.rb +2 -1
  7. data/lib/limelight/builtin/players/combo_box.rb +8 -2
  8. data/lib/limelight/builtin/players/image.rb +47 -0
  9. data/lib/limelight/builtin/styles.rb +1 -1
  10. data/lib/limelight/casting_director.rb +70 -39
  11. data/lib/limelight/commands/command.rb +150 -0
  12. data/lib/limelight/commands/create_command.rb +79 -0
  13. data/lib/limelight/commands/freeze_command.rb +113 -0
  14. data/lib/limelight/commands/open_command.rb +49 -0
  15. data/lib/limelight/commands/pack_command.rb +45 -0
  16. data/lib/limelight/dsl/build_exception.rb +51 -0
  17. data/lib/limelight/dsl/menu_bar.rb +71 -0
  18. data/lib/limelight/dsl/production_builder.rb +71 -0
  19. data/lib/limelight/dsl/prop_builder.rb +155 -0
  20. data/lib/limelight/dsl/stage_builder.rb +105 -0
  21. data/lib/limelight/dsl/styles_builder.rb +134 -0
  22. data/lib/limelight/file_loader.rb +46 -0
  23. data/lib/limelight/gems.rb +45 -0
  24. data/lib/limelight/java_couplings.rb +7 -2
  25. data/lib/limelight/java_util.rb +2 -15
  26. data/lib/limelight/main.rb +7 -5
  27. data/lib/limelight/producer.rb +87 -66
  28. data/lib/limelight/production.rb +42 -4
  29. data/lib/limelight/prop.rb +84 -70
  30. data/lib/limelight/scene.rb +75 -20
  31. data/lib/limelight/specs/spec_helper.rb +58 -0
  32. data/lib/limelight/stage.rb +11 -6
  33. data/lib/limelight/string.rb +35 -0
  34. data/lib/limelight/studio.rb +29 -0
  35. data/lib/limelight/templates/production_templater.rb +42 -0
  36. data/lib/limelight/templates/scene_templater.rb +41 -0
  37. data/lib/limelight/templates/sources/freezing/limelight_init.rb.template +5 -0
  38. data/lib/limelight/templates/sources/production/init.rb.template +15 -0
  39. data/lib/limelight/templates/sources/production/production.rb.template +9 -0
  40. data/lib/limelight/templates/sources/production/stages.rb.template +17 -0
  41. data/lib/limelight/templates/sources/production/styles.rb.template +12 -0
  42. data/lib/limelight/templates/sources/scene/props.rb.template +6 -0
  43. data/lib/limelight/templates/sources/scene/styles.rb.template +18 -0
  44. data/lib/limelight/templates/templater.rb +128 -0
  45. data/lib/limelight/templates/templater_logger.rb +36 -0
  46. data/lib/limelight/theater.rb +21 -7
  47. data/lib/limelight/util.rb +22 -6
  48. data/lib/limelight/version.rb +2 -2
  49. data/productions/examples/8thlight.com/styles.rb +1 -1
  50. data/productions/examples/langstons_ant/html_javascript/ant.html +1 -1
  51. data/productions/examples/langstons_ant/init.rb +1 -0
  52. data/productions/examples/langstons_ant/players/log.rb +2 -2
  53. data/productions/examples/langstons_ant/players/world.rb +0 -26
  54. data/productions/examples/sandbox.llp +0 -0
  55. data/productions/examples/sandbox/click_me/players/chromaton.rb +10 -4
  56. data/productions/examples/sandbox/floaters/players/floater.rb +4 -2
  57. data/productions/examples/sandbox/gradients/players/spinner.rb +5 -1
  58. data/productions/examples/sandbox/gradients/players/teaser.rb +2 -2
  59. data/productions/examples/sandbox/gradients/players/wave.rb +2 -2
  60. data/productions/examples/sandbox/gradients/players/waves.rb +2 -2
  61. data/productions/examples/sandbox/header.rb +1 -0
  62. data/productions/examples/sandbox/images/logo.png +0 -0
  63. data/productions/examples/sandbox/images_scene/props.rb +25 -0
  64. data/productions/examples/sandbox/images_scene/styles.rb +30 -0
  65. data/productions/examples/sandbox/inputs/styles.rb +1 -1
  66. data/productions/examples/sandbox/scrolling/props.rb +12 -12
  67. data/productions/examples/sandbox/teaser/players/fader.rb +2 -8
  68. data/productions/stage_composer/inspector/styles.rb +2 -2
  69. data/productions/startup/styles.rb +2 -2
  70. data/spec/builtin/players/button_spec.rb +0 -1
  71. data/spec/builtin/players/image_spec.rb +41 -0
  72. data/spec/casting_director_spec.rb +114 -44
  73. data/spec/commands/command_spec.rb +18 -0
  74. data/spec/commands/create_command_spec.rb +74 -0
  75. data/spec/commands/freeze_command_spec.rb +59 -0
  76. data/spec/commands/open_command_spec.rb +30 -0
  77. data/spec/commands/pack_command_spec.rb +23 -0
  78. data/spec/dsl/production_builder_spec.rb +46 -0
  79. data/spec/{prop_builder_spec.rb → dsl/prop_builder_spec.rb} +80 -24
  80. data/spec/{stage_builder_spec.rb → dsl/stage_builder_spec.rb} +4 -4
  81. data/spec/{styles_builder_spec.rb → dsl/styles_builder_spec.rb} +6 -6
  82. data/spec/{loaders/file_loader_spec.rb → file_loader_spec.rb} +4 -4
  83. data/spec/gems_spec.rb +83 -0
  84. data/spec/java_util_spec.rb +1 -17
  85. data/spec/main_spec.rb +17 -0
  86. data/spec/producer_spec.rb +89 -79
  87. data/spec/production_spec.rb +28 -3
  88. data/spec/prop_spec.rb +82 -16
  89. data/spec/scene_spec.rb +73 -3
  90. data/spec/spec_helper.rb +37 -1
  91. data/spec/stage_spec.rb +10 -1
  92. data/spec/string_spec.rb +35 -0
  93. data/spec/studio_spec.rb +14 -0
  94. data/spec/styles_spec.rb +14 -0
  95. data/spec/templates/production_templater_spec.rb +44 -0
  96. data/spec/templates/scene_templater_spec.rb +25 -0
  97. data/spec/templates/templater_logger_spec.rb +38 -0
  98. data/spec/templates/templater_spec.rb +104 -0
  99. data/spec/theater_spec.rb +12 -21
  100. metadata +75 -23
  101. data/bin/icons/splash.png +0 -0
  102. data/lib/limelight/build_exception.rb +0 -48
  103. data/lib/limelight/commands.rb +0 -52
  104. data/lib/limelight/loaders/file_scene_loader.rb +0 -49
  105. data/lib/limelight/menu_bar.rb +0 -68
  106. data/lib/limelight/production_builder.rb +0 -66
  107. data/lib/limelight/prop_builder.rb +0 -119
  108. data/lib/limelight/stage_builder.rb +0 -103
  109. data/lib/limelight/styles_builder.rb +0 -131
  110. data/spec/commands_spec.rb +0 -34
  111. data/spec/production_builder_spec.rb +0 -48
@@ -0,0 +1,30 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+ require 'limelight/commands/open_command'
3
+ require 'limelight/producer'
4
+
5
+ describe Limelight::Commands::OpenCommand do
6
+
7
+ before(:all) do
8
+ @command_class = Limelight::Commands::OpenCommand
9
+ @command = @command_class.new
10
+ end
11
+
12
+ it "should be listed" do
13
+ Limelight::Commands::LISTING["open"].should == @command_class
14
+ end
15
+
16
+ it "should open a production" do
17
+ Limelight::Main.should_receive(:initialize_context)
18
+ Limelight::Producer.should_receive(:open).with("production_name")
19
+
20
+ @command.run(["production_name"])
21
+ end
22
+
23
+ it "should open the default production" do
24
+ Limelight::Main.should_receive(:initialize_context)
25
+ Limelight::Producer.should_receive(:open).with(@command_class::DEFAULT_PRODUCTION)
26
+
27
+ @command.run([])
28
+ end
29
+
30
+ end
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+ require 'limelight/commands/pack_command'
3
+
4
+ describe Limelight::Commands::PackCommand do
5
+
6
+ before(:all) do
7
+ @command_class = Limelight::Commands::PackCommand
8
+ @command = @command_class.new
9
+ end
10
+
11
+ it "should be listed" do
12
+ Limelight::Commands::LISTING["pack"].should == @command_class
13
+ end
14
+
15
+ it "should pack a production" do
16
+ mock_packer = make_mock("packer")
17
+ Limelight::Util::Packer.should_receive(:new).and_return(mock_packer)
18
+ mock_packer.should_receive(:pack).with("production_to_pack")
19
+
20
+ @command.run(["production_to_pack"])
21
+ end
22
+
23
+ end
@@ -0,0 +1,46 @@
1
+ #- Copyright 2008 8th Light, Inc. All Rights Reserved.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
5
+ require 'limelight/dsl/production_builder'
6
+
7
+ describe Limelight::DSL::ProductionBuilder do
8
+
9
+ before(:each) do
10
+ @production = Limelight::Production.new("/tmp")
11
+ end
12
+
13
+ it "should build a production" do
14
+ result = Limelight.build_production(@production)
15
+
16
+ result.should == @production
17
+ result.path.should == "/tmp"
18
+ end
19
+
20
+ it "should build able to set the production's name" do
21
+ result = Limelight.build_production(@production) do
22
+ name "My Production"
23
+ end
24
+
25
+ result.name.should == "My Production"
26
+ end
27
+
28
+ it "should build attribute accessors" do
29
+ result = Limelight.build_production(@production) do
30
+ name "My Production2"
31
+ attribute :foo
32
+ end
33
+
34
+ result.respond_to?(:foo).should == true
35
+ result.foo = "foo"
36
+ result.foo.should == "foo"
37
+ end
38
+
39
+ it "should raise an exception when setting an invalid property" do
40
+ lambda do
41
+ Limelight::build_production(@production) do
42
+ blah "blah"
43
+ end
44
+ end.should raise_error(Limelight::DSL::ProductionBuilderException, "'blah' is not a valid production property")
45
+ end
46
+ end
@@ -1,18 +1,19 @@
1
1
  #- Copyright 2008 8th Light, Inc. All Rights Reserved.
2
2
  #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
3
 
4
- require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
5
- require 'limelight/prop_builder'
4
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
5
+ require 'limelight/dsl/prop_builder'
6
6
 
7
- describe Limelight::SceneBuilder do
7
+ describe Limelight::DSL::PropBuilder do
8
8
 
9
9
  before(:each) do
10
10
  @caster = make_mock("caster", :fill_cast => nil)
11
- @options = { :name => "root", :casting_director => @caster}
11
+ @scene = Limelight::Scene.new(:name => "root", :casting_director => @caster)
12
12
  end
13
13
 
14
14
  it "should build root" do
15
- root = Limelight.build_scene(@options)
15
+ root = Limelight.build_scene(@scene)
16
+ root.illuminate
16
17
 
17
18
  root.class.should == Limelight::Scene
18
19
  root.name.should == "root"
@@ -21,9 +22,10 @@ describe Limelight::SceneBuilder do
21
22
  end
22
23
 
23
24
  it "should build one child prop" do
24
- root = Limelight::build_scene(@options) do
25
+ root = Limelight::build_scene(@scene) do
25
26
  child
26
27
  end
28
+ root.illuminate
27
29
 
28
30
  root.children.size.should == 1
29
31
  child = root.children[0]
@@ -34,10 +36,11 @@ describe Limelight::SceneBuilder do
34
36
  end
35
37
 
36
38
  it "should allow multiple children" do
37
- root = Limelight::build_scene(@options) do
39
+ root = Limelight::build_scene(@scene) do
38
40
  child1
39
41
  child2
40
42
  end
43
+ root.illuminate
41
44
 
42
45
  root.children.size.should == 2
43
46
  root.children[0].name.should == "child1"
@@ -45,11 +48,12 @@ describe Limelight::SceneBuilder do
45
48
  end
46
49
 
47
50
  it "should allow nested children" do
48
- root = Limelight::build_scene(@options) do
51
+ root = Limelight::build_scene(@scene) do
49
52
  child do
50
53
  grandchild
51
54
  end
52
55
  end
56
+ root.illuminate
53
57
 
54
58
  root.children.size.should == 1
55
59
  root.children[0].name.should == "child"
@@ -58,9 +62,10 @@ describe Limelight::SceneBuilder do
58
62
  end
59
63
 
60
64
  it "should be able to set the id" do
61
- root = Limelight::build_scene(@options) do
65
+ root = Limelight::build_scene(@scene) do
62
66
  child :id => "child_1", :players => "x, y, z"
63
67
  end
68
+ root.illuminate
64
69
 
65
70
  child = root.children[0]
66
71
  child.id.should == "child_1"
@@ -68,29 +73,32 @@ describe Limelight::SceneBuilder do
68
73
  end
69
74
 
70
75
  it "should allow setting styles" do
71
- root = Limelight::build_scene(@options) do
76
+ root = Limelight::build_scene(@scene) do
72
77
  child :width => "100", :font_size => "10", :top_border_color => "blue"
73
78
  end
79
+ root.illuminate
74
80
 
75
81
  child = root.children[0]
76
82
  child.style.width.should == "100"
77
83
  child.style.font_size.should == "10"
78
- child.style.top_border_color.should == "blue"
84
+ child.style.top_border_color.should == "#0000ffff"
79
85
  end
80
86
 
81
87
  it "should allow defining events through constructor" do
82
- root = Limelight::build_scene(@options) do
88
+ root = Limelight::build_scene(@scene) do
83
89
  child :on_mouse_entered => "return [self, event]"
84
90
  end
91
+ root.illuminate
85
92
 
86
93
  child = root.children[0]
87
94
  child.mouse_entered("blah").should == [child, "blah"]
88
95
  end
89
96
 
90
97
  it "should allow scene configuration" do
91
- root = Limelight::build_scene(@options) do
98
+ root = Limelight::build_scene(@scene) do
92
99
  __ :name => "root", :id => "123"
93
100
  end
101
+ root.illuminate
94
102
 
95
103
  root.children.size.should == 0
96
104
  root.name.should == "root"
@@ -98,7 +106,7 @@ describe Limelight::SceneBuilder do
98
106
  end
99
107
 
100
108
  it "should give every prop their scene" do
101
- root = Limelight::build_scene(@options) do
109
+ root = Limelight::build_scene(@scene) do
102
110
  child do
103
111
  grandchild
104
112
  end
@@ -113,20 +121,21 @@ describe Limelight::SceneBuilder do
113
121
  loader = make_mock("loader", :exists? => true)
114
122
  loader.should_receive(:load).with("external.rb").and_return("child :id => 123")
115
123
 
116
- root = Limelight::build_scene(:id => 321, :build_loader => loader, :casting_director => @caster) do
124
+ root = Limelight::build_scene(@scene, :id => 321, :build_loader => loader, :casting_director => @caster) do
117
125
  __install "external.rb"
118
126
  end
127
+ root.illuminate
119
128
 
120
- root.id.should == 321
129
+ root.id.should == "321"
121
130
  root.children.size.should == 1
122
131
  child = root.children[0]
123
132
  child.name.should == "child"
124
- child.id.should == 123
133
+ child.id.should == "123"
125
134
  end
126
135
 
127
136
  it "should fail if no loader is provided" do
128
137
  begin
129
- root = Limelight::build_scene(@options.merge(:id => 321, :build_loader => nil)) do
138
+ root = Limelight::build_scene(@scene, :id => 321, :build_loader => nil) do
130
139
  __install "external.rb"
131
140
  end
132
141
  root.should == nil # should never get here
@@ -140,7 +149,7 @@ describe Limelight::SceneBuilder do
140
149
  loader.should_receive(:exists?).with("external.rb").and_return(false)
141
150
 
142
151
  begin
143
- root = Limelight::build_scene(@options.merge(:id => 321, :build_loader => loader)) do
152
+ root = Limelight::build_scene(@scene, :id => 321, :build_loader => loader) do
144
153
  __install "external.rb"
145
154
  end
146
155
  rescue Exception => e
@@ -153,20 +162,22 @@ describe Limelight::SceneBuilder do
153
162
  loader.should_receive(:load).with("external.rb").and_return("+")
154
163
 
155
164
  begin
156
- root = Limelight::build_scene(@options.merge(:id => 321, :build_loader => loader)) do
165
+ root = Limelight::build_scene(@scene, :id => 321, :build_loader => loader) do
157
166
  __install "external.rb"
158
167
  end
159
- rescue Limelight::BuildException => e
168
+ rescue Limelight::DSL::BuildException => e
160
169
  e.message.should include("external.rb:1: (eval):1: , unexpected end-of-file")
161
170
  end
162
171
  end
163
172
 
164
173
  it "should build onto an existing block" do
165
174
  prop = Limelight::Prop.new
166
- prop.set_scene(Limelight::Scene.new(:casting_director => make_mock(:casting_director, :fill_cast => nil)))
167
- builder = Limelight::PropBuilder.new(prop)
175
+ scene = Limelight::Scene.new(:casting_director => make_mock(:casting_director, :fill_cast => nil))
176
+ scene << prop
177
+ builder = Limelight::DSL::PropBuilder.new(prop)
168
178
  block = Proc.new { one; two { three } }
169
179
  builder.instance_eval(&block)
180
+ scene.illuminate
170
181
 
171
182
  prop.children.length.should == 2
172
183
  prop.children[0].name.should == "one"
@@ -176,9 +187,10 @@ describe Limelight::SceneBuilder do
176
187
  end
177
188
 
178
189
  it "should not crash with prop named display" do
179
- root = Limelight::build_scene(@options) do
190
+ root = Limelight::build_scene(@scene) do
180
191
  display :id => "display"
181
192
  end
193
+ root.illuminate
182
194
 
183
195
  root.children.size.should == 1
184
196
  display = root.children[0]
@@ -186,4 +198,48 @@ describe Limelight::SceneBuilder do
186
198
  display.id.should == "display"
187
199
  end
188
200
 
201
+ it "should allow instance variables" do
202
+ root = Limelight::build_scene(@scene, :instance_variables => { :id1 => "abc", :id2 => "xyz" } ) do
203
+ __ :id => @id1
204
+ child :id => @id2
205
+ end
206
+ root.illuminate
207
+
208
+ root.id.should == "abc"
209
+ child = root.children[0]
210
+ child.id.should == "xyz"
211
+ end
212
+
213
+ it "should propogate instance variables to nested levels" do
214
+ root = Limelight::build_scene(@scene, :instance_variables => { :name => "blah" } ) do
215
+ child :id => "child", :name => @name do
216
+ grand_child :id => "grand_child", :name => @name do
217
+ great_grand_child :id => "great_grand_child", :name => @name do
218
+ baby :id => "baby", :name => @name
219
+ end
220
+ end
221
+ end
222
+ end
223
+ root.illuminate
224
+
225
+ root.find("child").name.should == "blah"
226
+ root.find("grand_child").name.should == "blah"
227
+ root.find("great_grand_child").name.should == "blah"
228
+ root.find("baby").name.should == "blah"
229
+ end
230
+
231
+ it "should allow instance_variable when installing an external props file" do
232
+ loader = make_mock("loader", :exists? => true)
233
+ loader.should_receive(:load).with("external.rb").and_return("child :id => @desired_id")
234
+
235
+ root = Limelight::build_scene(@scene, :id => 321, :build_loader => loader, :casting_director => @caster) do
236
+ __install "external.rb", :desired_id => "123"
237
+ end
238
+ root.illuminate
239
+
240
+ child = root.children[0]
241
+ child.name.should == "child"
242
+ child.id.should == "123"
243
+ end
244
+
189
245
  end
@@ -1,11 +1,11 @@
1
1
  #- Copyright 2008 8th Light, Inc. All Rights Reserved.
2
2
  #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
3
 
4
- require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
5
- require 'limelight/stage_builder'
4
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
5
+ require 'limelight/dsl/stage_builder'
6
6
  require 'limelight/theater'
7
7
 
8
- describe Limelight::StageBuilder do
8
+ describe Limelight::DSL::StageBuilder do
9
9
 
10
10
  before(:each) do
11
11
  @theater = Limelight::Theater.new
@@ -57,7 +57,7 @@ describe Limelight::StageBuilder do
57
57
  blah "blah"
58
58
  end
59
59
  end
60
- end.should raise_error(Limelight::StageBuilderException, "'blah' is not a valid stage property")
60
+ end.should raise_error(Limelight::DSL::StageBuilderException, "'blah' is not a valid stage property")
61
61
  end
62
62
 
63
63
  it "should add stages to the theater" do
@@ -1,10 +1,10 @@
1
1
  #- Copyright 2008 8th Light, Inc. All Rights Reserved.
2
2
  #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
3
 
4
- require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
5
- require 'limelight/styles_builder'
4
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
5
+ require 'limelight/dsl/styles_builder'
6
6
 
7
- describe Limelight::StylesBuilder do
7
+ describe Limelight::DSL::StylesBuilder do
8
8
 
9
9
  before(:each) do
10
10
  end
@@ -37,7 +37,7 @@ describe Limelight::StylesBuilder do
37
37
  result.size.should == 1
38
38
  style = result["root"]
39
39
  style.width.should == "100"
40
- style.top_border_color.should == "blue"
40
+ style.top_border_color.should == "#0000ffff"
41
41
  style.transparency.should == "50%"
42
42
  end
43
43
 
@@ -48,7 +48,7 @@ describe Limelight::StylesBuilder do
48
48
  blah 100
49
49
  end
50
50
  end
51
- end.should raise_error(Limelight::StyleBuilderException)
51
+ end.should raise_error(Limelight::DSL::StyleBuilderException)
52
52
  end
53
53
 
54
54
  it "should build multiple styles" do
@@ -116,7 +116,7 @@ describe Limelight::StylesBuilder do
116
116
  end
117
117
 
118
118
  it "should raise an exception when attempting to extend a missing style" do
119
- lambda { Limelight.build_styles { one { extends :blah } } }.should raise_error(Limelight::StyleBuilderException, "Can't extend missing style: 'blah'")
119
+ lambda { Limelight.build_styles { one { extends :blah } } }.should raise_error(Limelight::DSL::StyleBuilderException, "Can't extend missing style: 'blah'")
120
120
  end
121
121
 
122
122
  it "should allow styles to be repopened" do
@@ -1,13 +1,13 @@
1
1
  #- Copyright 2008 8th Light, Inc. All Rights Reserved.
2
2
  #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
3
 
4
- require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
5
- require 'limelight/loaders/file_scene_loader'
4
+ require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
5
+ require 'limelight/file_loader'
6
6
 
7
- describe Limelight::Loaders::FileSceneLoader do
7
+ describe Limelight::FileLoader do
8
8
 
9
9
  before(:each) do
10
- @loader = Limelight::Loaders::FileSceneLoader.for_root("/Users/micahmartin/Projects/limelight/example")
10
+ @loader = Limelight::FileLoader.for_root("/Users/micahmartin/Projects/limelight/example")
11
11
  end
12
12
 
13
13
  it "should load path parts" do
data/spec/gems_spec.rb ADDED
@@ -0,0 +1,83 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
2
+ require "limelight/gems"
3
+ require 'limelight/production'
4
+
5
+ describe Limelight::Gems do
6
+
7
+ before(:each) do
8
+ @production = Limelight::Production.new(TestDir.path("prod"))
9
+ end
10
+
11
+ it "should know the load path" do
12
+ Limelight::Gems.load_path.should be($:)
13
+ Limelight::Gems.current_production = @production
14
+ end
15
+
16
+ it "add a gem to load path" do
17
+ path = []
18
+ Limelight::Gems.stub!(:load_path).and_return(path)
19
+
20
+ Limelight::Gems.install("gem_dir_name", ["lib"])
21
+
22
+ path.length.should == 1
23
+ path[0].should == File.join(@production.gems_directory, "gem_dir_name/lib")
24
+ end
25
+
26
+ it "add a gem to the beginning of the load path" do
27
+ path = ["foo"]
28
+ Limelight::Gems.stub!(:load_path).and_return(path)
29
+
30
+ Limelight::Gems.install("gem_dir_name", ["lib"])
31
+
32
+ path.length.should == 2
33
+ path[0].should == File.join(@production.gems_directory, "gem_dir_name/lib")
34
+ path[1].should == "foo"
35
+ end
36
+
37
+ it "add a gem to the beginning of the load path in the same order provided" do
38
+ path = ["foo"]
39
+ Limelight::Gems.stub!(:load_path).and_return(path)
40
+
41
+ Limelight::Gems.install("gem_dir_name", ["lib", "src", "ruby"])
42
+
43
+ path.length.should == 4
44
+ path[0].should == File.join(@production.gems_directory, "gem_dir_name/lib")
45
+ path[1].should == File.join(@production.gems_directory, "gem_dir_name/src")
46
+ path[2].should == File.join(@production.gems_directory, "gem_dir_name/ruby")
47
+ path[3].should == "foo"
48
+ end
49
+
50
+ describe "finding gems" do
51
+
52
+ before(:each) do
53
+ TestDir.clean
54
+ end
55
+
56
+ it "should load all the gems in a production" do
57
+ TestDir.create_file("prod/__resources/gems/gem1/limelight_init.rb", "Limelight::Gems.install('gem1', ['fee'])")
58
+ TestDir.create_file("prod/__resources/gems/gem2/limelight_init.rb", "Limelight::Gems.install('gem2', ['fie'])")
59
+ TestDir.create_file("prod/__resources/gems/gem3/limelight_init.rb", "Limelight::Gems.install('gem3', ['foe', 'fum'])")
60
+ path = []
61
+ Limelight::Gems.stub!(:load_path).and_return(path)
62
+
63
+ Limelight::Gems.install_gems_in_production(@production)
64
+
65
+ path.length.should == 4
66
+ path[0].should == File.join(@production.gems_directory, "gem1/fee")
67
+ path[1].should == File.join(@production.gems_directory, "gem2/fie")
68
+ path[2].should == File.join(@production.gems_directory, "gem3/foe")
69
+ path[3].should == File.join(@production.gems_directory, "gem3/fum")
70
+ end
71
+
72
+ it "should gracefully handle missing gems dir" do
73
+ TestDir.establish_dir("prod")
74
+
75
+ path = []
76
+ Limelight::Gems.stub!(:load_path).and_return(path)
77
+ Limelight::Gems.install_gems_in_production(@production)
78
+
79
+ path.length.should == 0
80
+ end
81
+ end
82
+
83
+ end