sprout 1.0.29.pre → 1.0.31.pre

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sprout might be problematic. Click here for more details.

data/Gemfile.lock ADDED
@@ -0,0 +1,51 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ ParseTree (3.0.6)
5
+ RubyInline (>= 3.7.0)
6
+ sexp_processor (>= 3.0.0)
7
+ RubyInline (3.8.6)
8
+ ZenTest (~> 4.3)
9
+ ZenTest (4.4.0)
10
+ archive-tar-minitar (0.5.2)
11
+ flay (1.4.1)
12
+ ruby_parser (~> 2.0)
13
+ sexp_processor (~> 3.0)
14
+ flog (2.5.0)
15
+ ruby_parser (~> 2.0)
16
+ sexp_processor (~> 3.0)
17
+ heckle (1.4.3)
18
+ ParseTree (>= 2.0.0)
19
+ ZenTest (>= 3.5.2)
20
+ ruby2ruby (>= 1.1.6)
21
+ mocha (0.9.8)
22
+ rake
23
+ open4 (1.0.1)
24
+ rake (0.8.7)
25
+ rcov (0.9.9)
26
+ rdoc (2.5.11)
27
+ ruby2ruby (1.2.5)
28
+ ruby_parser (~> 2.0)
29
+ sexp_processor (~> 3.0)
30
+ ruby_parser (2.0.5)
31
+ sexp_processor (~> 3.0)
32
+ rubyzip (0.9.4)
33
+ sexp_processor (3.0.5)
34
+ shoulda (2.11.3)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ archive-tar-minitar (= 0.5.2)
41
+ bundler (>= 0.9.19)
42
+ flay
43
+ flog
44
+ heckle
45
+ mocha
46
+ open4 (>= 0.9.6)
47
+ rake (>= 0.8.7)
48
+ rcov
49
+ rdoc (>= 2.5.8)
50
+ rubyzip (= 0.9.4)
51
+ shoulda
@@ -27,6 +27,14 @@ module Sprout
27
27
  yield self if block_given?
28
28
  end
29
29
 
30
+ ##
31
+ # This is a template method that will be called
32
+ # so that RemoteFileTarget subclasses and load
33
+ # the appropriate files at the appropriate time.
34
+ # Admittedly kind of smelly, other ideas welcome...
35
+ def resolve
36
+ end
37
+
30
38
  ##
31
39
  # Add a library to the RubyGem package.
32
40
  #
@@ -39,11 +47,11 @@ module Sprout
39
47
  #
40
48
  def add_library name, path
41
49
  if path.is_a?(Array)
42
- path = path.collect { |p| expand_executable_path(p) }
50
+ path = path.collect { |p| expand_local_path(p) }
43
51
  else
44
- path = expand_executable_path path
52
+ path = expand_local_path path
45
53
  end
46
- libraries << Sprout::Library.new( :name => name, :path => path, :file_target => self )
54
+ libraries << OpenStruct.new( :name => name, :path => path, :file_target => self )
47
55
  end
48
56
 
49
57
  ##
@@ -54,7 +62,7 @@ module Sprout
54
62
  # with this name.
55
63
  #
56
64
  def add_executable name, path
57
- path = expand_executable_path path
65
+ path = expand_local_path path
58
66
  executables << OpenStruct.new( :name => name, :path => path, :file_target => self )
59
67
  end
60
68
 
@@ -67,7 +75,10 @@ module Sprout
67
75
  raise Sprout::Errors::UsageError.new "FileTarget.pkg_version is required" if pkg_version.nil?
68
76
  end
69
77
 
70
- def expand_executable_path path
78
+ ##
79
+ # This is a template method that is overridden
80
+ # by RemoteFileTarget.
81
+ def expand_local_path path
71
82
  File.join load_path, path
72
83
  end
73
84
 
@@ -11,6 +11,7 @@ module Sprout
11
11
  attr_accessor :path
12
12
  attr_accessor :pkg_name
13
13
  attr_accessor :pkg_version
14
+ attr_accessor :platform
14
15
 
15
16
  class << self
16
17
  ##
@@ -17,7 +17,7 @@ module Sprout
17
17
  begin
18
18
  return open_uri uri, display_name
19
19
  rescue SocketError => sock_err
20
- raise Sprout::Errors::RemoteFileLoaderError.new("[ERROR] #{sock_err.to_s}")
20
+ raise Sprout::Errors::RemoteFileLoaderError.new("[ERROR] Failed to load file from: '#{uri.to_s}' - Please check that your machine has a connection to the internet.\n[REMOTE ERROR] #{sock_err.to_s}")
21
21
  rescue OpenURI::HTTPError => http_err
22
22
  raise Sprout::Errors::RemoteFileLoaderError.new("[ERROR] Failed to load file from: '#{uri.to_s}'\n[REMOTE ERROR] #{http_err.io.read.strip}")
23
23
  rescue Errno::ECONNREFUSED => econ_err
@@ -23,10 +23,7 @@ module Sprout
23
23
 
24
24
  protected
25
25
 
26
- def expand_executable_path path
27
- # TODO: This is failing b/c it gets called before
28
- # we can set pkg_name and pkg_version - so join
29
- # raises null pointer error.
26
+ def expand_local_path path
30
27
  File.join unpacked_file, path
31
28
  end
32
29
 
@@ -76,6 +76,8 @@ module Sprout
76
76
  message << "to update your local gems.\n\n"
77
77
  raise Sprout::Errors::LoadError.new message
78
78
  end
79
+
80
+ resolve_file_target entity
79
81
  entity
80
82
  end
81
83
 
@@ -85,6 +87,17 @@ module Sprout
85
87
 
86
88
  protected
87
89
 
90
+ def resolve_file_target entity
91
+ if(entity.respond_to? :resolve)
92
+ entity.resolve
93
+ elsif(entity.respond_to? :file_target)
94
+ file_target = entity.file_target
95
+ if(file_target.respond_to? :resolve)
96
+ file_target.resolve
97
+ end
98
+ end
99
+ end
100
+
88
101
  def validate_registration entity
89
102
  if(!entity.respond_to?(:name) || entity.name.nil?)
90
103
  raise Sprout::Errors::UsageError.new "Cannot register a RubyFeature without a 'name' getter"
@@ -103,7 +116,7 @@ module Sprout
103
116
  #puts "+++++++++++++++++++++++++++"
104
117
  #puts ">> entity_for #{name_or_names} pkg_name: #{pkg_name} version: #{version_requirement}"
105
118
  #registered_entities.each do |entity|
106
- #puts ">> entity: #{entity.name} pkg_name: #{entity.pkg_name} version: #{entity.pkg_version}"
119
+ #puts ">> entity: #{entity.name} platform: #{entity.platform} pkg_name: #{entity.pkg_name} version: #{entity.pkg_version}"
107
120
  #end
108
121
  registered_entities.reverse.select do |entity|
109
122
  satisfies_name?(entity, name_or_names) &&
@@ -134,6 +147,7 @@ module Sprout
134
147
 
135
148
  def satisfies_platform? entity
136
149
  #puts">> satisfies platform?"
150
+ # If not platform is defined, it's assumed to work on all platforms:
137
151
  return true if !entity.respond_to?(:platform) || entity.platform.nil?
138
152
  #puts ">> platform: #{entity.platform}"
139
153
  Sprout.current_system.can_execute?(entity.platform)
@@ -135,11 +135,8 @@ module Sprout
135
135
  # If the archive has not been downloaded, it will be downloaded, unpacked
136
136
  # and the path to the requested executable will be returned.
137
137
  def add_remote_file_target &block
138
- target = RemoteFileTarget.new do |t|
139
- configure_target t, &block
140
- end
141
- target.resolve
142
- register_file_target target
138
+ target = RemoteFileTarget.new
139
+ configure_target target, &block
143
140
  end
144
141
 
145
142
  # Add a file to the RubyGem itself. This is a great way to package smallish libraries in either
@@ -157,10 +154,8 @@ module Sprout
157
154
  # end
158
155
  #
159
156
  def add_file_target &block
160
- target = FileTarget.new do |t|
161
- configure_target t, &block
162
- end
163
- register_file_target target
157
+ target = FileTarget.new
158
+ configure_target target, &block
164
159
  end
165
160
 
166
161
  private
@@ -170,9 +165,10 @@ module Sprout
170
165
  t.pkg_name = name
171
166
  t.pkg_version = version
172
167
  yield t if block_given?
168
+ register_file_target_libs_and_exes t
173
169
  end
174
170
 
175
- def register_file_target target
171
+ def register_file_target_libs_and_exes target
176
172
  register_items target.executables, Sprout::Executable, target
177
173
  # Reversing the libraries makes it so that definitions like:
178
174
  #
@@ -184,11 +180,13 @@ module Sprout
184
180
  register_items target.libraries, Sprout::Library, target
185
181
  end
186
182
 
187
- def register_items collection, source, target
188
- collection.each do |item|
189
- item.pkg_name = target.pkg_name
190
- item.pkg_version = target.pkg_version
191
- source.register item
183
+ def register_items collection, ruby_feature, target
184
+ collection.each do |exe_or_lib|
185
+ exe_or_lib.pkg_name = target.pkg_name
186
+ exe_or_lib.pkg_version = target.pkg_version
187
+ exe_or_lib.platform = target.platform
188
+ exe_or_lib.file_target = target
189
+ ruby_feature.register exe_or_lib
192
190
  end
193
191
  end
194
192
 
@@ -140,7 +140,7 @@ module SproutTestCase # :nodoc:[all]
140
140
  # Ugh - This is way too greedy... We're killing all mocks in here
141
141
  # Doing it anyway b/c we need to get Windows support in place...
142
142
  # TODO: Implement this feature without clobbering all stubs/mocks
143
- Mocha::Mockery.instance.teardown
143
+ #Mocha::Mockery.instance.teardown
144
144
  end
145
145
 
146
146
  def as_a_mac_system
@@ -150,7 +150,7 @@ module SproutTestCase # :nodoc:[all]
150
150
  # Ugh - This is way too greedy... We're killing all mocks in here
151
151
  # Doing it anyway b/c we need to get Windows support in place...
152
152
  # TODO: Implement this feature without clobbering all stubs/mocks
153
- Mocha::Mockery.instance.teardown
153
+ #Mocha::Mockery.instance.teardown
154
154
  end
155
155
 
156
156
  def as_a_windows_system
@@ -160,7 +160,17 @@ module SproutTestCase # :nodoc:[all]
160
160
  # Ugh - This is way too greedy... We're killing all mocks in here
161
161
  # Doing it anyway b/c we need to get Windows support in place...
162
162
  # TODO: Implement this feature without clobbering all stubs/mocks
163
- Mocha::Mockery.instance.teardown
163
+ #Mocha::Mockery.instance.teardown
164
+ end
165
+
166
+ def as_a_win_nix_system
167
+ sys = Sprout::System::WinNixSystem.new
168
+ Sprout::System.stubs(:create).returns sys
169
+ yield sys if block_given?
170
+ # Ugh - This is way too greedy... We're killing all mocks in here
171
+ # Doing it anyway b/c we need to get Windows support in place...
172
+ # TODO: Implement this feature without clobbering all stubs/mocks
173
+ #Mocha::Mockery.instance.teardown
164
174
  end
165
175
 
166
176
 
@@ -217,5 +227,5 @@ end
217
227
 
218
228
  # Prevent log messages from interrupting the test output:
219
229
  Sprout::Log.debug = true
220
- Sprout::ProgressBar.debug = true
230
+ #Sprout::ProgressBar.debug = true
221
231
 
@@ -6,7 +6,7 @@ module Sprout
6
6
  module VERSION #:nodoc:
7
7
  MAJOR = 1
8
8
  MINOR = 0
9
- TINY = 29
9
+ TINY = 31
10
10
  RELEASE = 'pre'
11
11
 
12
12
  STRING = [MAJOR, MINOR, TINY, RELEASE].join('.')
@@ -41,8 +41,22 @@ class RubyFeatureTest < Test::Unit::TestCase
41
41
  end
42
42
  end
43
43
 
44
+ should "not call resolve on register" do
45
+ plugin = FakePlugin.new({:name => :foo2})
46
+ plugin.expects(:resolve).never
47
+ FakePlugin.register plugin
48
+ end
49
+
50
+ should "call resolve on load" do
51
+ plugin = FakePlugin.new({:name => :foo2})
52
+ FakePlugin.register plugin
53
+
54
+ plugin.expects(:resolve)
55
+ FakePlugin.load :foo2
56
+ end
57
+
44
58
  should "allow registration and load without ruby package or version" do
45
- FakePlugin.register OpenStruct.new({:name => :foo2})
59
+ FakePlugin.register FakePlugin.new({:name => :foo2})
46
60
  assert_not_nil FakePlugin.load :foo2
47
61
  end
48
62
 
@@ -68,12 +82,12 @@ class RubyFeatureTest < Test::Unit::TestCase
68
82
  end
69
83
 
70
84
  should "load when request is a string" do
71
- FakePlugin.register(OpenStruct.new({:name => :foo3}))
85
+ FakePlugin.register(FakePlugin.new({:name => :foo3}))
72
86
  assert_not_nil FakePlugin.load 'foo3'
73
87
  end
74
88
 
75
89
  should "load when registration is a string" do
76
- FakePlugin.register(OpenStruct.new({:name => :swc, :pkg_name => 'asunit4'}))
90
+ FakePlugin.register(FakePlugin.new({:name => :swc, :pkg_name => 'asunit4'}))
77
91
  assert_not_nil FakePlugin.load nil, :asunit4
78
92
  end
79
93
 
@@ -91,13 +105,32 @@ class RubyFeatureTest < Test::Unit::TestCase
91
105
 
92
106
  should "find platform-specific remote file target" do
93
107
  osx = create_item(:platform => :osx)
108
+ windows = create_item(:platform => :windows)
94
109
  linux = create_item(:platform => :linux)
110
+
95
111
  FakePlugin.register osx
112
+ FakePlugin.register windows
96
113
  FakePlugin.register linux
114
+
97
115
  as_a_mac_system do
98
116
  result = FakePlugin.load :foo
99
117
  assert_equal osx, result
100
118
  end
119
+
120
+ as_a_windows_system do
121
+ result = FakePlugin.load :foo
122
+ assert_equal windows, result
123
+ end
124
+
125
+ as_a_win_nix_system do
126
+ result = FakePlugin.load :foo
127
+ assert_equal windows, result
128
+ end
129
+
130
+ as_a_unix_system do
131
+ result = FakePlugin.load :foo
132
+ assert_equal linux, result
133
+ end
101
134
  end
102
135
 
103
136
  end
@@ -105,11 +138,16 @@ class RubyFeatureTest < Test::Unit::TestCase
105
138
  private
106
139
 
107
140
  def create_item options={}
108
- OpenStruct.new({:name => :foo, :pkg_name => 'sprout/base', :pkg_version => '1.0.pre', :platform => :universal}.merge(options))
141
+ FakePlugin.new({:name => :foo, :pkg_name => 'sprout/base', :pkg_version => '1.0.pre', :platform => :universal}.merge(options))
109
142
  end
110
143
 
111
- class FakePlugin
144
+ class FakePlugin < OpenStruct
112
145
  include Sprout::RubyFeature
146
+
147
+ ##
148
+ # Implement resolve like RemoteFileTargets..
149
+ def resolve
150
+ end
113
151
  end
114
152
 
115
153
  class OtherFakePlugin
@@ -24,13 +24,29 @@ class SpecificationTest < Test::Unit::TestCase
24
24
  @spec.version = '1.0.pre'
25
25
  end
26
26
 
27
- should "register executables" do
27
+ should "register executables with file_target reference" do
28
28
  @spec.add_file_target do |t|
29
29
  t.add_executable :foo, 'bin/foo'
30
30
  end
31
31
 
32
32
  Sprout::Executable.stubs :require_ruby_package
33
- assert_not_nil Sprout::Executable.load :foo, 'foo_sdk', '1.0.pre'
33
+ exe = Sprout::Executable.load :foo, 'foo_sdk', '1.0.pre'
34
+ assert_equal Sprout::FileTarget, exe.file_target.class
35
+ end
36
+
37
+ should "register executable with remote_file_target instances" do
38
+ @spec.add_remote_file_target do |t|
39
+ t.url = 'http://www.example.com'
40
+ t.md5 = 'abcd'
41
+ t.archive_type = :zip
42
+ t.add_executable :foo, 'bin/foo'
43
+ end
44
+
45
+ Sprout::RemoteFileTarget.any_instance.stubs :resolve
46
+ Sprout::Executable.stubs :require_ruby_package
47
+ exe = Sprout::Executable.load :foo, 'foo_sdk', '1.0.pre'
48
+ assert_equal Sprout::RemoteFileTarget, exe.file_target.class
49
+ assert exe.path =~ /cache/, "RemoteFileTarget local path should include Sprout CACHE directory"
34
50
  end
35
51
 
36
52
  should "load returns libraries in expected order" do
@@ -43,11 +59,92 @@ class SpecificationTest < Test::Unit::TestCase
43
59
  library = Sprout::Library.load nil, 'foo_sdk'
44
60
  assert_equal 'foo', File.basename(library.path)
45
61
  end
46
-
47
62
 
48
63
  end
49
64
  end
50
65
 
66
+ context "a platform-specific, remote executable specification" do
67
+
68
+ setup do
69
+ @spec = Sprout::Specification.new do |s|
70
+ s.name = 'fake_flashplayer_spec'
71
+ s.version = '10.1.53'
72
+
73
+ s.add_remote_file_target do |t|
74
+ t.platform = :windows
75
+ t.add_executable :fake_flashplayer, "flashplayer_10_sa_debug.exe"
76
+ end
77
+
78
+ s.add_remote_file_target do |t|
79
+ t.platform = :osx
80
+ t.add_executable :fake_flashplayer, "Flash Player Debugger.app"
81
+ end
82
+
83
+ s.add_remote_file_target do |t|
84
+ t.platform = :linux
85
+ t.add_executable :fake_flashplayer, "flashplayerdebugger"
86
+ end
87
+ end
88
+
89
+ end
90
+
91
+ should "be resolved for Windows systems" do
92
+ Sprout::RemoteFileTarget.any_instance.expects(:resolve)
93
+ as_a_windows_system do
94
+ target = Sprout::Executable.load 'fake_flashplayer'
95
+ assert_equal :windows, target.platform
96
+ end
97
+ end
98
+
99
+ should "be resolved for OSX systems" do
100
+ Sprout::RemoteFileTarget.any_instance.expects(:resolve)
101
+ as_a_mac_system do
102
+ target = Sprout::Executable.load 'fake_flashplayer'
103
+ assert_equal :osx, target.platform
104
+ end
105
+ end
106
+
107
+ should "be resolved for Unix systems" do
108
+ Sprout::RemoteFileTarget.any_instance.expects(:resolve)
109
+ as_a_unix_system do
110
+ target = Sprout::Executable.load 'fake_flashplayer'
111
+ assert_equal :linux, target.platform
112
+ end
113
+ end
114
+ end
115
+
116
+ context "a universal collection of executables" do
117
+
118
+ setup do
119
+ @spec = Sprout::Specification.new do |s|
120
+ s.name = 'flex4'
121
+ s.version = '4.0.pre'
122
+
123
+ s.add_remote_file_target do |t|
124
+ # Apply the windows-specific configuration:
125
+ t.platform = :universal
126
+ # Apply the shared platform configuration:
127
+ # Remote Archive:
128
+ t.archive_type = :zip
129
+ t.url = "http://download.macromedia.com/pub/labs/flex/4/flex4sdk_b2_100509.zip"
130
+ t.md5 = "6a0838c5cb33145fe88933778ddb966d"
131
+
132
+ # Executables: (add .exe suffix if it was passed in)
133
+ t.add_executable :compc, "bin/compc"
134
+ t.add_executable :fcsh, "bin/fcsh"
135
+ t.add_executable :fdb, "bin/fdb"
136
+ t.add_executable :mxmlc, "bin/mxmlc"
137
+ end
138
+ end
139
+
140
+ end
141
+
142
+ should "make binaries available" do
143
+ mxmlc = Sprout::Executable.load :mxmlc
144
+ assert_not_nil mxmlc
145
+ end
146
+ end
147
+
51
148
  context "a newly included executable" do
52
149
  setup do
53
150
  @echo_chamber = File.join fixtures, 'executable', 'echochamber_gem', 'echo_chamber'
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 29
8
+ - 31
9
9
  - pre
10
- version: 1.0.29.pre
10
+ version: 1.0.31.pre
11
11
  platform: ruby
12
12
  authors:
13
13
  - Luke Bayes
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-10 00:00:00 -07:00
18
+ date: 2010-10-12 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -209,6 +209,7 @@ files:
209
209
  - bin/sprout-test
210
210
  - bin/sprout-tool
211
211
  - Gemfile
212
+ - Gemfile.lock
212
213
  - lib/sprout/archive_unpacker.rb
213
214
  - lib/sprout/base.rb
214
215
  - lib/sprout/concern.rb