caricature 0.7.5 → 0.7.6

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.
Files changed (74) hide show
  1. data/README.rdoc +97 -97
  2. data/Rakefile +309 -310
  3. data/caricature.gemspec +123 -110
  4. data/lib/caricature/bacon/integration.rb +75 -75
  5. data/lib/caricature/bacon.rb +2 -2
  6. data/lib/caricature/clr/descriptor.rb +159 -159
  7. data/lib/caricature/clr/event_verification.rb +56 -56
  8. data/lib/caricature/clr/expectation.rb +100 -100
  9. data/lib/caricature/clr/isolation.rb +78 -78
  10. data/lib/caricature/clr/isolator.rb +252 -252
  11. data/lib/caricature/clr/messenger.rb +51 -49
  12. data/lib/caricature/clr/method_call_recorder.rb +96 -96
  13. data/lib/caricature/expectation.rb +1 -1
  14. data/lib/caricature/method_call_recorder.rb +3 -3
  15. data/lib/caricature/rspec/integration.rb +118 -118
  16. data/lib/caricature/version.rb +5 -5
  17. data/lib/caricature.rb +25 -25
  18. data/spec/bacon/integration/callback_spec.rb +156 -156
  19. data/spec/bacon/integration/clr_to_clr_spec.rb +325 -253
  20. data/spec/bacon/integration/event_spec.rb +97 -97
  21. data/spec/bacon/integration/indexer_spec.rb +27 -27
  22. data/spec/bacon/spec_helper.rb +4 -4
  23. data/spec/bacon/unit/descriptor_spec.rb +212 -212
  24. data/spec/bacon/unit/sword_spec.rb +39 -39
  25. data/spec/bacon/unit/verification_spec.rb +103 -103
  26. data/spec/bin/ClrModels.dll +0 -0
  27. data/spec/bin/ClrModels.dll.mdb +0 -0
  28. data/spec/fixtures/ExplodingCar.cs +56 -0
  29. data/spec/fixtures/ExposedChangedSubscriber.cs +26 -0
  30. data/spec/fixtures/ExposingWarrior.cs +58 -0
  31. data/spec/fixtures/IExplodingWarrior.cs +10 -0
  32. data/spec/fixtures/IExposing.cs +9 -0
  33. data/spec/fixtures/IExposingBridge.cs +9 -0
  34. data/spec/fixtures/IExposingWarrior.cs +8 -0
  35. data/spec/fixtures/IHaveAnIndexer.cs +8 -0
  36. data/spec/fixtures/IWarrior.cs +13 -0
  37. data/spec/fixtures/IWeapon.cs +9 -0
  38. data/spec/fixtures/IndexerCaller.cs +17 -0
  39. data/spec/fixtures/IndexerContained.cs +20 -0
  40. data/spec/fixtures/MyClassWithAStatic.cs +16 -0
  41. data/spec/fixtures/Ninja.cs +34 -0
  42. data/spec/fixtures/Samurai.cs +29 -0
  43. data/spec/fixtures/StaticCaller.cs +12 -0
  44. data/spec/fixtures/Sword.cs +16 -0
  45. data/spec/fixtures/SwordWithStatics.cs +19 -0
  46. data/spec/fixtures/clr_interaction.rb +61 -0
  47. data/spec/fixtures/dagger.rb +11 -0
  48. data/spec/fixtures/dagger_with_class_members.rb +11 -0
  49. data/spec/fixtures/sheath.rb +19 -0
  50. data/spec/fixtures/soldier.rb +29 -0
  51. data/spec/fixtures/soldier_with_class_members.rb +7 -0
  52. data/spec/fixtures/swift_cleanup_crew.rb +21 -0
  53. data/spec/fixtures/with_class_methods.rb +11 -0
  54. data/spec/{models → models.notused}/ClrModels.cs +241 -241
  55. data/spec/{models → models.notused}/ruby_models.rb +150 -150
  56. data/spec/rspec/integration/callback_spec.rb +156 -156
  57. data/spec/rspec/integration/clr_to_clr_spec.rb +254 -254
  58. data/spec/rspec/integration/clr_to_ruby_spec.rb +227 -227
  59. data/spec/rspec/integration/indexer_spec.rb +27 -27
  60. data/spec/rspec/integration/ruby_to_ruby_spec.rb +271 -271
  61. data/spec/rspec/spec_helper.rb +12 -12
  62. data/spec/rspec/unit/core_ext_spec.rb +87 -87
  63. data/spec/rspec/unit/descriptor_spec.rb +210 -210
  64. data/spec/rspec/unit/event_spec.rb +16 -16
  65. data/spec/rspec/unit/expectation_spec.rb +300 -300
  66. data/spec/rspec/unit/interop_spec.rb +29 -29
  67. data/spec/rspec/unit/isolation_spec.rb +86 -86
  68. data/spec/rspec/unit/isolator_spec.rb +219 -219
  69. data/spec/rspec/unit/messaging_spec.rb +310 -310
  70. data/spec/rspec/unit/method_call_spec.rb +342 -342
  71. data/spec/rspec/unit/sword_spec.rb +39 -39
  72. data/spec/rspec/unit/verification_spec.rb +103 -103
  73. data/spec/spec_helper.rb +16 -15
  74. metadata +42 -11
data/Rakefile CHANGED
@@ -1,310 +1,309 @@
1
- require 'rubygems'
2
- require 'fileutils'
3
- require 'rake/rdoctask'
4
-
5
- $:.unshift 'lib'
6
- require 'caricature'
7
-
8
- desc "The default task is to run all the specs"
9
- task :default => [:clr_models, :spec]
10
-
11
- %w(bacon spec).each do |fw|
12
-
13
- gem_name = fw == "bacon" ? fw : "r#{fw}"
14
-
15
- desc "Runs all the #{gem_name} specs"
16
- task fw.to_sym do
17
- system "i#{fw} #{Dir.glob("spec/#{gem_name}/**/*_spec.rb").join(' ')}"
18
- end
19
-
20
- namespace fw.to_sym do
21
-
22
- desc "runs the #{gem_name} examples for the different classes"
23
- task :unit do
24
- specs = Dir.glob("spec/#{gem_name}/unit/**/*_spec.rb")
25
- system "i#{fw} #{specs.join(' ')}"
26
- end
27
-
28
- desc "runs the #{gem_name} integration examples"
29
- task :integration do
30
- specs = Dir.glob("spec/#{gem_name}/integration/**/*_spec.rb")
31
- system "i#{fw} #{specs.join(' ')}"
32
- end
33
- end
34
- end
35
-
36
-
37
-
38
- def csc
39
- system "gmcs"
40
- $?.pid.zero? ? "csc" : "gmcs"
41
- end
42
-
43
- desc "Compiles the clr models"
44
- task :clr_models do
45
- Dir.chdir(File.dirname(__FILE__))
46
- files = Dir.glob("spec/models/*.cs").join(' ') #.collect { |f| f.gsub(/\//, "\\") }.join(" ")
47
- system "#{csc} /noconfig /target:library /debug+ /debug:full /out:spec/bin/ClrModels.dll #{files}"
48
- end
49
-
50
- ##############################################################################
51
- # OPTIONS
52
- ##############################################################################
53
-
54
- PKG_NAME = 'caricature'
55
- PKG_VERSION = Caricature::VERSION
56
- AUTHORS = ['Ivan Porto Carrero']
57
- EMAIL = "ivan@flanders.co.nz"
58
- HOMEPAGE = "http://casualjim.github.com/caricature"
59
- SUMMARY = "Caricature brings simple mocking to Ruby, DLR and CLR."
60
-
61
- # These are the common rdoc options that are shared between generation of
62
- # rdoc files using BOTH 'rake rdoc' and the installation by users of a
63
- # RubyGem version which builds rdoc's along with its installation. Any
64
- # rdoc options that are ONLY for developers running 'rake rdoc' should be
65
- # added in the 'Rake::RDocTask' block below.
66
- RDOC_OPTIONS = [
67
- "--quiet",
68
- "--title", SUMMARY,
69
- "--main", "README.rdoc",
70
- "--line-numbers",
71
- "--format","darkfish"
72
- ]
73
-
74
- # Extra files outside of the lib dir that should be included with the rdocs.
75
- RDOC_FILES = (%w( README.rdoc)).sort
76
-
77
- # The full file list used for rdocs, tarballs, gems, and for generating the xmpp4r.gemspec.
78
- PKG_FILES = (%w( Rakefile caricature.gemspec ) + RDOC_FILES + Dir["{lib,spec}/**/*"]).sort
79
-
80
- # RDOC
81
- #######
82
- Rake::RDocTask.new do |rd|
83
-
84
- # which dir should rdoc files be installed in?
85
- rd.rdoc_dir = 'rdoc'
86
-
87
- # the full list of files to be included
88
- rd.rdoc_files.include(RDOC_FILES, "lib/**/*.rb")
89
-
90
- # the full list of options that are common between gem build
91
- # and 'rake rdoc' build of docs.
92
- rd.options = RDOC_OPTIONS
93
-
94
- # Devs Only : Uncomment to also document private methods in the rdocs
95
- # Please don't check this change in to the source repo.
96
- #rd.options << '--all'
97
-
98
- # Devs Only : Uncomment to generate dot (graphviz) diagrams along with rdocs.
99
- # This requires that graphiz (dot) be installed as a local binary and on your path.
100
- # See : http://www.graphviz.org/
101
- # Please don't check this change in to the source repo as it introduces a binary dependency.
102
- #rd.options << '--diagram'
103
- #rd.options << '--fileboxes'
104
-
105
- end
106
-
107
- desc "Check syntax of all Ruby files."
108
- task :check_syntax do
109
- `find . -name "*.rb" |xargs -n1 ruby -c |grep -v "Syntax OK"`
110
- puts "* Done"
111
- end
112
-
113
- ##############################################################################
114
- # PACKAGING & INSTALLATION
115
- ##############################################################################
116
-
117
- # What files/dirs should 'rake clean' remove?
118
- #CLEAN.include ["*.gem", "pkg", "rdoc", "coverage"]
119
-
120
- begin
121
- require 'rake/gempackagetask'
122
-
123
- spec = Gem::Specification.new do |s|
124
- s.name = PKG_NAME
125
- s.version = PKG_VERSION
126
- s.authors = AUTHORS
127
- s.email = EMAIL
128
- s.homepage = HOMEPAGE
129
- s.rubyforge_project = PKG_NAME
130
- s.summary = SUMMARY
131
- s.description = s.summary
132
- s.platform = Gem::Platform::RUBY
133
- s.require_path = 'lib'
134
- s.executables = []
135
- s.files = PKG_FILES
136
- s.test_files = []
137
- s.has_rdoc = true
138
- s.extra_rdoc_files = RDOC_FILES
139
- s.rdoc_options = RDOC_OPTIONS
140
- s.required_ruby_version = ">= 1.8.4"
141
- s.add_dependency 'uuidtools', ">= 2.0.0"
142
- end
143
-
144
- Rake::GemPackageTask.new(spec) do |pkg|
145
- pkg.gem_spec = spec
146
- pkg.need_tar = true
147
- pkg.need_zip = true
148
- end
149
-
150
- namespace :gem do
151
-
152
- desc "Run :package and install the .gem locally"
153
- task :install => [:update_gemspec, :package] do
154
- sh %{sudo gem install --local pkg/#{PKG_NAME}-#{PKG_VERSION}.gem}
155
- end
156
-
157
- desc "Like gem:install but without ri or rdocs"
158
- task :install_fast => [:update_gemspec, :package] do
159
- sh %{sudo gem install --local pkg/#{PKG_NAME}-#{PKG_VERSION}.gem --no-rdoc --no-ri}
160
- end
161
-
162
- desc "Run :clean and uninstall the .gem"
163
- task :uninstall => :clean do
164
- sh %{sudo gem uninstall #{PKG_NAME}}
165
- end
166
-
167
- # Thanks to the Merb project for this code.
168
- desc "Update Github Gemspec"
169
- task :update_gemspec do
170
- skip_fields = %w(new_platform original_platform date)
171
-
172
- result = "# WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!\n"
173
- result << "# RUN : 'rake gem:update_gemspec'\n\n"
174
- result << "Gem::Specification.new do |s|\n"
175
- spec.instance_variables.sort.each do |ivar|
176
- value = spec.instance_variable_get(ivar)
177
- name = ivar.to_s.split("@").last
178
- next if skip_fields.include?(name) || value.nil? || value == "" || (value.respond_to?(:empty?) && value.empty?)
179
- if name == "dependencies"
180
- value.each do |d|
181
- dep, *ver = d.to_s.split(" ")
182
- result << " s.add_dependency #{dep.inspect}, #{ver.join(" ").inspect.gsub(/[()]/, "")}\n"
183
- end
184
- else
185
- case value
186
- when Array
187
- value = name != "files" ? value.inspect : value.sort.uniq.inspect.split(",").join(",\n")
188
- when String, Fixnum, true, false
189
- value = value.inspect
190
- else
191
- value = value.to_s.inspect
192
- end
193
- result << " s.#{name} = #{value}\n"
194
- end
195
- end
196
- result << "end"
197
- File.open(File.join(File.dirname(__FILE__), "#{spec.name}.gemspec"), "w"){|f| f << result}
198
- end
199
-
200
- end # namespace :gem
201
-
202
- # also keep the gemspec up to date each time we package a tarball or gem
203
- task :package => ['gem:update_gemspec']
204
- task :gem => ['gem:update_gemspec']
205
-
206
- rescue LoadError
207
- puts <<EOF
208
- ###
209
- Packaging Warning : RubyGems is apparently not installed on this
210
- system and any file add/remove/rename will not
211
- be auto-updated in the 'caricature.gemspec' when you run any
212
- package tasks. All such file changes are recommended
213
- to be packaged on a system with RubyGems installed
214
- if you intend to push commits to the Git repo so the
215
- gemspec will also stay in sync for others.
216
- ###
217
- EOF
218
- end
219
-
220
- # we are apparently on a system that does not have RubyGems installed.
221
- # Lets try to provide only the basic tarball package tasks as a fallback.
222
- unless defined? Gem
223
- begin
224
- require 'rake/packagetask'
225
- Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |p|
226
- p.package_files = PKG_FILES
227
- p.need_tar = true
228
- p.need_zip = true
229
- end
230
- rescue LoadError
231
- puts <<EOF
232
- ###
233
- Warning : Unable to require the 'rake/packagetask'. Is Rake installed?
234
- ###
235
- EOF
236
- end
237
- end
238
-
239
-
240
- # # Generate all the Rake tasks
241
- # # Run 'rake -T' to see list of generated tasks (from gem root directory)
242
- # $hoe = Hoe.spec 'cloudslide' do
243
- # self.developer 'Ivan Porto Carrero', 'ivan@flanders.co.nz'
244
- # self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
245
- # self.rubyforge_name = self.name # TODO this is default value
246
- # self.extra_deps = [['uuidtools','>= 2.0.0'], ['newgem', '>= 1.5.2']]
247
- # end
248
- #
249
- # require 'newgem/tasks'
250
- # Dir['tasks/**/*.rake'].each { |t| load t }
251
-
252
- # TODO - want other tests/tasks run by default? Add them to the list
253
- # remove_task :default
254
- # task :default => [:spec, :features]
255
-
256
- # file_list = Dir.glob("lib/**/*.rb")
257
-
258
- # desc "Create RDoc documentation"
259
- # file 'doc/index.html' => file_list do
260
- # puts "######## Creating RDoc documentation"
261
- # system "rdoc --title 'Caricature isolation framework documentation' -m README README.markdown lib/"
262
- # end
263
- #
264
- # desc "An alias for creating the RDoc documentation"
265
- # task :rdoc do
266
- # Rake::Task['doc/index.html'].invoke
267
- # end
268
-
269
- # begin
270
- #
271
- # Jeweler::Tasks.new do |gemspec|
272
- # gemspec.name = "caricature"
273
- # gemspec.summary = "Caricature - Bringing simple mocking to the DLR"
274
- # gemspec.email = "ivan@flanders.co.nz"
275
- # gemspec.homepage = "http://github.com/casualjim/caricature"
276
- # gemspec.description = "This project aims to make interop between IronRuby objects and .NET objects easier. The idea is that it integrates nicely with bacon and later rspec and that it transparently lets you mock ironruby ojbects as well as CLR objects/interfaces. Caricature handles interfaces, interface inheritance, CLR objects, CLR object instances, Ruby classes and instances of Ruby classes."
277
- # gemspec.authors = ["Ivan Porto Carrero"]
278
- # gemspec.rubyforge_project = 'caricature' # This line would be new
279
- # end
280
- # rescue LoadError
281
- # puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
282
- # end
283
- #
284
- begin
285
- require 'rake/contrib/sshpublisher'
286
- namespace :rubyforge do
287
-
288
- desc "Release gem and RDoc documentation to RubyForge"
289
- task :release => ["rubyforge:release:gem", 'rubyforge:release:docs']
290
-
291
- namespace :release do
292
- desc "Publish RDoc to RubyForge."
293
- task :docs => [:rdoc] do
294
- config = YAML.load(
295
- File.read(File.expand_path('~/.rubyforge/user-config.yml'))
296
- )
297
-
298
- host = "#{config['username']}@rubyforge.org"
299
- remote_dir = "/var/www/gforge-projects/caricature/"
300
- local_dir = 'doc'
301
-
302
- Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
303
- end
304
- end
305
- end
306
- rescue LoadError
307
- puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
308
- end
309
-
310
-
1
+ require 'rubygems'
2
+ require 'fileutils'
3
+ require 'rake/rdoctask'
4
+
5
+ $:.unshift 'lib'
6
+ require 'caricature'
7
+
8
+ desc "The default task is to run all the specs"
9
+ task :default => [:clr_models, :spec]
10
+
11
+ %w(bacon spec).each do |fw|
12
+
13
+ gem_name = fw == "bacon" ? fw : "r#{fw}"
14
+
15
+ desc "Runs all the #{gem_name} specs"
16
+ task fw.to_sym do
17
+ system "i#{fw} #{Dir.glob("spec/#{gem_name}/**/*_spec.rb").join(' ')}"
18
+ end
19
+
20
+ namespace fw.to_sym do
21
+
22
+ desc "runs the #{gem_name} examples for the different classes"
23
+ task :unit do
24
+ specs = Dir.glob("spec/#{gem_name}/unit/**/*_spec.rb")
25
+ system "i#{fw} #{specs.join(' ')}"
26
+ end
27
+
28
+ desc "runs the #{gem_name} integration examples"
29
+ task :integration do
30
+ specs = Dir.glob("spec/#{gem_name}/integration/**/*_spec.rb")
31
+ system "i#{fw} #{specs.join(' ')}"
32
+ end
33
+ end
34
+ end
35
+
36
+
37
+
38
+ def csc
39
+ system "gmcs"
40
+ $?.pid.zero? ? "csc" : "gmcs"
41
+ end
42
+
43
+ desc "Compiles the clr models"
44
+ task :clr_models do
45
+ Dir.chdir(File.dirname(__FILE__))
46
+ files = Dir.glob("spec/fixtures/*.cs").join(' ') #.collect { |f| f.gsub(/\//, "\\") }.join(" ")
47
+ system "#{csc} /noconfig /target:library /debug+ /debug:full /out:spec/bin/ClrModels.dll #{files}"
48
+ end
49
+
50
+ ##############################################################################
51
+ # OPTIONS
52
+ ##############################################################################
53
+
54
+ PKG_NAME = 'caricature'
55
+ PKG_VERSION = Caricature::VERSION
56
+ AUTHORS = ['Ivan Porto Carrero']
57
+ EMAIL = "ivan@flanders.co.nz"
58
+ HOMEPAGE = "http://casualjim.github.com/caricature"
59
+ SUMMARY = "Caricature brings simple mocking to Ruby, DLR and CLR."
60
+
61
+ # These are the common rdoc options that are shared between generation of
62
+ # rdoc files using BOTH 'rake rdoc' and the installation by users of a
63
+ # RubyGem version which builds rdoc's along with its installation. Any
64
+ # rdoc options that are ONLY for developers running 'rake rdoc' should be
65
+ # added in the 'Rake::RDocTask' block below.
66
+ RDOC_OPTIONS = [
67
+ "--quiet",
68
+ "--title", SUMMARY,
69
+ "--main", "README.rdoc",
70
+ "--line-numbers"
71
+ ]
72
+
73
+ # Extra files outside of the lib dir that should be included with the rdocs.
74
+ RDOC_FILES = (%w( README.rdoc)).sort
75
+
76
+ # The full file list used for rdocs, tarballs, gems, and for generating the xmpp4r.gemspec.
77
+ PKG_FILES = (%w( Rakefile caricature.gemspec ) + RDOC_FILES + Dir["{lib,spec}/**/*"]).sort
78
+
79
+ # RDOC
80
+ #######
81
+ Rake::RDocTask.new do |rd|
82
+
83
+ # which dir should rdoc files be installed in?
84
+ rd.rdoc_dir = 'rdoc'
85
+
86
+ # the full list of files to be included
87
+ rd.rdoc_files.include(RDOC_FILES, "lib/**/*.rb")
88
+
89
+ # the full list of options that are common between gem build
90
+ # and 'rake rdoc' build of docs.
91
+ rd.options = RDOC_OPTIONS
92
+
93
+ # Devs Only : Uncomment to also document private methods in the rdocs
94
+ # Please don't check this change in to the source repo.
95
+ #rd.options << '--all'
96
+
97
+ # Devs Only : Uncomment to generate dot (graphviz) diagrams along with rdocs.
98
+ # This requires that graphiz (dot) be installed as a local binary and on your path.
99
+ # See : http://www.graphviz.org/
100
+ # Please don't check this change in to the source repo as it introduces a binary dependency.
101
+ #rd.options << '--diagram'
102
+ #rd.options << '--fileboxes'
103
+
104
+ end
105
+
106
+ desc "Check syntax of all Ruby files."
107
+ task :check_syntax do
108
+ `find . -name "*.rb" |xargs -n1 ruby -c |grep -v "Syntax OK"`
109
+ puts "* Done"
110
+ end
111
+
112
+ ##############################################################################
113
+ # PACKAGING & INSTALLATION
114
+ ##############################################################################
115
+
116
+ # What files/dirs should 'rake clean' remove?
117
+ #CLEAN.include ["*.gem", "pkg", "rdoc", "coverage"]
118
+
119
+ begin
120
+ require 'rake/gempackagetask'
121
+
122
+ spec = Gem::Specification.new do |s|
123
+ s.name = PKG_NAME
124
+ s.version = PKG_VERSION
125
+ s.authors = AUTHORS
126
+ s.email = EMAIL
127
+ s.homepage = HOMEPAGE
128
+ s.rubyforge_project = PKG_NAME
129
+ s.summary = SUMMARY
130
+ s.description = s.summary
131
+ s.platform = Gem::Platform::RUBY
132
+ s.require_path = 'lib'
133
+ s.executables = []
134
+ s.files = PKG_FILES
135
+ s.test_files = []
136
+ s.has_rdoc = true
137
+ s.extra_rdoc_files = RDOC_FILES
138
+ s.rdoc_options = RDOC_OPTIONS
139
+ s.required_ruby_version = ">= 1.8.6"
140
+ s.add_dependency 'uuidtools', ">= 2.0.0"
141
+ end
142
+
143
+ Rake::GemPackageTask.new(spec) do |pkg|
144
+ pkg.gem_spec = spec
145
+ pkg.need_tar = true
146
+ pkg.need_zip = true
147
+ end
148
+
149
+ namespace :gem do
150
+
151
+ desc "Run :package and install the .gem locally"
152
+ task :install => [:update_gemspec, :package] do
153
+ sh %{sudo gem install --local pkg/#{PKG_NAME}-#{PKG_VERSION}.gem}
154
+ end
155
+
156
+ desc "Like gem:install but without ri or rdocs"
157
+ task :install_fast => [:update_gemspec, :package] do
158
+ sh %{sudo gem install --local pkg/#{PKG_NAME}-#{PKG_VERSION}.gem --no-rdoc --no-ri}
159
+ end
160
+
161
+ desc "Run :clean and uninstall the .gem"
162
+ task :uninstall => :clean do
163
+ sh %{sudo gem uninstall #{PKG_NAME}}
164
+ end
165
+
166
+ # Thanks to the Merb project for this code.
167
+ desc "Update Github Gemspec"
168
+ task :update_gemspec do
169
+ skip_fields = %w(new_platform original_platform date)
170
+
171
+ result = "# WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!\n"
172
+ result << "# RUN : 'rake gem:update_gemspec'\n\n"
173
+ result << "Gem::Specification.new do |s|\n"
174
+ spec.instance_variables.sort.each do |ivar|
175
+ value = spec.instance_variable_get(ivar)
176
+ name = ivar.to_s.split("@").last
177
+ next if skip_fields.include?(name) || value.nil? || value == "" || (value.respond_to?(:empty?) && value.empty?)
178
+ if name == "dependencies"
179
+ value.each do |d|
180
+ dep, *ver = d.to_s.split(" ")
181
+ result << " s.add_dependency #{dep.inspect}, #{ver.join(" ").inspect.gsub(/[()]/, "")}\n"
182
+ end
183
+ else
184
+ case value
185
+ when Array
186
+ value = name != "files" ? value.inspect : value.sort.uniq.inspect.split(",").join(",\n")
187
+ when String, Fixnum, true, false
188
+ value = value.inspect
189
+ else
190
+ value = value.to_s.inspect
191
+ end
192
+ result << " s.#{name} = #{value}\n"
193
+ end
194
+ end
195
+ result << "end"
196
+ File.open(File.join(File.dirname(__FILE__), "#{spec.name}.gemspec"), "w"){|f| f << result}
197
+ end
198
+
199
+ end # namespace :gem
200
+
201
+ # also keep the gemspec up to date each time we package a tarball or gem
202
+ task :package => ['gem:update_gemspec']
203
+ task :gem => ['gem:update_gemspec']
204
+
205
+ rescue LoadError
206
+ puts <<EOF
207
+ ###
208
+ Packaging Warning : RubyGems is apparently not installed on this
209
+ system and any file add/remove/rename will not
210
+ be auto-updated in the 'caricature.gemspec' when you run any
211
+ package tasks. All such file changes are recommended
212
+ to be packaged on a system with RubyGems installed
213
+ if you intend to push commits to the Git repo so the
214
+ gemspec will also stay in sync for others.
215
+ ###
216
+ EOF
217
+ end
218
+
219
+ # we are apparently on a system that does not have RubyGems installed.
220
+ # Lets try to provide only the basic tarball package tasks as a fallback.
221
+ unless defined? Gem
222
+ begin
223
+ require 'rake/packagetask'
224
+ Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |p|
225
+ p.package_files = PKG_FILES
226
+ p.need_tar = true
227
+ p.need_zip = true
228
+ end
229
+ rescue LoadError
230
+ puts <<EOF
231
+ ###
232
+ Warning : Unable to require the 'rake/packagetask'. Is Rake installed?
233
+ ###
234
+ EOF
235
+ end
236
+ end
237
+
238
+
239
+ # # Generate all the Rake tasks
240
+ # # Run 'rake -T' to see list of generated tasks (from gem root directory)
241
+ # $hoe = Hoe.spec 'cloudslide' do
242
+ # self.developer 'Ivan Porto Carrero', 'ivan@flanders.co.nz'
243
+ # self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
244
+ # self.rubyforge_name = self.name # TODO this is default value
245
+ # self.extra_deps = [['uuidtools','>= 2.0.0'], ['newgem', '>= 1.5.2']]
246
+ # end
247
+ #
248
+ # require 'newgem/tasks'
249
+ # Dir['tasks/**/*.rake'].each { |t| load t }
250
+
251
+ # TODO - want other tests/tasks run by default? Add them to the list
252
+ # remove_task :default
253
+ # task :default => [:spec, :features]
254
+
255
+ # file_list = Dir.glob("lib/**/*.rb")
256
+
257
+ # desc "Create RDoc documentation"
258
+ # file 'doc/index.html' => file_list do
259
+ # puts "######## Creating RDoc documentation"
260
+ # system "rdoc --title 'Caricature isolation framework documentation' -m README README.markdown lib/"
261
+ # end
262
+ #
263
+ # desc "An alias for creating the RDoc documentation"
264
+ # task :rdoc do
265
+ # Rake::Task['doc/index.html'].invoke
266
+ # end
267
+
268
+ # begin
269
+ #
270
+ # Jeweler::Tasks.new do |gemspec|
271
+ # gemspec.name = "caricature"
272
+ # gemspec.summary = "Caricature - Bringing simple mocking to the DLR"
273
+ # gemspec.email = "ivan@flanders.co.nz"
274
+ # gemspec.homepage = "http://github.com/casualjim/caricature"
275
+ # gemspec.description = "This project aims to make interop between IronRuby objects and .NET objects easier. The idea is that it integrates nicely with bacon and later rspec and that it transparently lets you mock ironruby ojbects as well as CLR objects/interfaces. Caricature handles interfaces, interface inheritance, CLR objects, CLR object instances, Ruby classes and instances of Ruby classes."
276
+ # gemspec.authors = ["Ivan Porto Carrero"]
277
+ # gemspec.rubyforge_project = 'caricature' # This line would be new
278
+ # end
279
+ # rescue LoadError
280
+ # puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
281
+ # end
282
+ #
283
+ begin
284
+ require 'rake/contrib/sshpublisher'
285
+ namespace :rubyforge do
286
+
287
+ desc "Release gem and RDoc documentation to RubyForge"
288
+ task :release => ["rubyforge:release:gem", 'rubyforge:release:docs']
289
+
290
+ namespace :release do
291
+ desc "Publish RDoc to RubyForge."
292
+ task :docs => [:rdoc] do
293
+ config = YAML.load(
294
+ File.read(File.expand_path('~/.rubyforge/user-config.yml'))
295
+ )
296
+
297
+ host = "#{config['username']}@rubyforge.org"
298
+ remote_dir = "/var/www/gforge-projects/caricature/"
299
+ local_dir = 'doc'
300
+
301
+ Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
302
+ end
303
+ end
304
+ end
305
+ rescue LoadError
306
+ puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
307
+ end
308
+
309
+