hitimes 1.1.1-java → 1.2.0-java

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 (46) hide show
  1. data/CONTRIBUTING.md +45 -0
  2. data/{HISTORY → HISTORY.rdoc} +14 -1
  3. data/LICENSE +11 -8
  4. data/Manifest.txt +44 -0
  5. data/{README → README.rdoc} +18 -5
  6. data/Rakefile +20 -62
  7. data/ext/hitimes/{extconf.rb → c/extconf.rb} +3 -3
  8. data/ext/hitimes/{hitimes_ext.c → c/hitimes.c} +1 -1
  9. data/ext/hitimes/{hitimes_instant_clock_gettime.c → c/hitimes_instant_clock_gettime.c} +0 -0
  10. data/ext/hitimes/c/hitimes_instant_osx.c +45 -0
  11. data/ext/hitimes/{hitimes_instant_windows.c → c/hitimes_instant_windows.c} +0 -0
  12. data/ext/hitimes/{hitimes_interval.c → c/hitimes_interval.c} +15 -7
  13. data/ext/hitimes/{hitimes_interval.h → c/hitimes_interval.h} +5 -5
  14. data/ext/hitimes/{hitimes_stats.c → c/hitimes_stats.c} +0 -0
  15. data/ext/hitimes/{hitimes_stats.h → c/hitimes_stats.h} +0 -0
  16. data/ext/{java → hitimes/java}/src/hitimes/Hitimes.java +1 -1
  17. data/ext/{java → hitimes/java}/src/hitimes/HitimesInterval.java +8 -1
  18. data/ext/{java → hitimes/java}/src/hitimes/HitimesService.java +0 -0
  19. data/ext/{java → hitimes/java}/src/hitimes/HitimesStats.java +0 -0
  20. data/lib/hitimes.rb +15 -5
  21. data/lib/hitimes/hitimes.jar +0 -0
  22. data/lib/hitimes/version.rb +1 -50
  23. data/spec/hitimes_spec.rb +14 -0
  24. data/spec/interval_spec.rb +24 -21
  25. data/spec/metric_spec.rb +8 -10
  26. data/spec/mutex_stats_spec.rb +8 -6
  27. data/spec/paths_spec.rb +1 -3
  28. data/spec/spec_helper.rb +7 -3
  29. data/spec/stats_spec.rb +26 -28
  30. data/spec/timed_metric_spec.rb +33 -33
  31. data/spec/timed_value_metric_spec.rb +45 -46
  32. data/spec/value_metric_spec.rb +21 -23
  33. data/spec/version_spec.rb +4 -30
  34. data/tasks/default.rake +267 -0
  35. data/tasks/extension.rake +31 -101
  36. data/tasks/this.rb +209 -0
  37. metadata +185 -182
  38. data/ext/hitimes/hitimes_instant_osx.c +0 -16
  39. data/gemspec.rb +0 -64
  40. data/tasks/announce.rake +0 -42
  41. data/tasks/config.rb +0 -109
  42. data/tasks/distribution.rake +0 -93
  43. data/tasks/documentation.rake +0 -32
  44. data/tasks/rspec.rake +0 -33
  45. data/tasks/rubyforge.rake +0 -55
  46. data/tasks/utils.rb +0 -80
data/spec/version_spec.rb CHANGED
@@ -1,33 +1,7 @@
1
- require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper" ) )
1
+ require "spec_helper"
2
2
 
3
3
  describe "Hitimes::Version" do
4
- it "should have a major numbers that is >= 0" do
5
- Hitimes::Version::MAJOR.should >= 0
6
- end
7
-
8
- it "should have a minor number that is >= 0" do
9
- Hitimes::Version::MINOR.should >= 0
10
- end
11
-
12
- it "should have a tiny number that is >= 0" do
13
- Hitimes::Version::BUILD.should >= 0
14
- end
15
-
16
- it "should have an array representation" do
17
- Hitimes::Version.to_a.should have(3).items
18
- end
19
-
20
- it "should have a string representation" do
21
- Hitimes::Version.to_s.should match(/\d+\.\d+\.\d+/)
22
- end
23
-
24
- it "should have a hash representation" do
25
- [ :major, :minor, :build ].each do |k|
26
- Hitimes::Version.to_hash[k].should_not be_nil
27
- end
28
- end
29
-
30
- it "should be accessable as a constant" do
31
- Hitimes::VERSION.should match(/\d+\.\d+\.\d+/)
32
- end
4
+ it "should be accessable as a constant" do
5
+ Hitimes::VERSION.should match(/\d+\.\d+\.\d+/)
6
+ end
33
7
  end
@@ -0,0 +1,267 @@
1
+ # vim: syntax=ruby
2
+ require 'rake/clean'
3
+ #------------------------------------------------------------------------------
4
+ # If you want to Develop on this project just run 'rake develop' and you'll
5
+ # have all you need to get going. If you want to use bundler for development,
6
+ # then run 'rake develop:using_bundler'
7
+ #------------------------------------------------------------------------------
8
+ namespace :develop do
9
+
10
+ # Install all the development and runtime dependencies of this gem using the
11
+ # gemspec.
12
+ task :default do
13
+ require 'rubygems/dependency_installer'
14
+ installer = Gem::DependencyInstaller.new
15
+
16
+ This.set_coverage_gem
17
+
18
+ puts "Installing gem depedencies needed for development"
19
+ This.platform_gemspec.dependencies.each do |dep|
20
+ if dep.matching_specs.empty? then
21
+ puts "Installing : #{dep}"
22
+ installer.install dep
23
+ else
24
+ puts "Skipping : #{dep} -> already installed #{dep.matching_specs.first.full_name}"
25
+ end
26
+ end
27
+ puts "\n\nNow run 'rake test'"
28
+ end
29
+
30
+ # Create a Gemfile that just references the gemspec
31
+ file 'Gemfile' => :gemspec do
32
+ File.open( "Gemfile", "w+" ) do |f|
33
+ f.puts 'source :rubygems'
34
+ f.puts 'gemspec'
35
+ end
36
+ end
37
+
38
+ desc "Create a bundler Gemfile"
39
+ task :using_bundler => 'Gemfile' do
40
+ puts "Now you can 'bundle'"
41
+ end
42
+
43
+ # Gemfiles are build artifacts
44
+ CLOBBER << FileList['Gemfile*']
45
+ end
46
+ desc "Boostrap development"
47
+ task :develop => "develop:default"
48
+
49
+ #------------------------------------------------------------------------------
50
+ # Minitest - standard TestTask
51
+ #------------------------------------------------------------------------------
52
+ begin
53
+ require 'rake/testtask'
54
+ Rake::TestTask.new( :test ) do |t|
55
+ t.ruby_opts = %w[ -w -rubygems ]
56
+ t.libs = %w[ lib spec ]
57
+ t.pattern = "spec/**/*_spec.rb"
58
+ end
59
+
60
+ task :test_requirements
61
+ task :test => :test_requirements
62
+ task :default => :test
63
+ rescue LoadError
64
+ This.task_warning( 'test' )
65
+ end
66
+
67
+ #------------------------------------------------------------------------------
68
+ # RDoc - standard rdoc rake task, although we must make sure to use a more
69
+ # recent version of rdoc since it is the one that has 'tomdoc' markup
70
+ #------------------------------------------------------------------------------
71
+ begin
72
+ gem 'rdoc' # otherwise we get the wrong task from stdlib
73
+ require 'rdoc/task'
74
+ RDoc::Task.new do |t|
75
+ t.markup = 'tomdoc'
76
+ t.rdoc_dir = 'doc'
77
+ t.main = 'README.rdoc'
78
+ t.title = "#{This.name} #{This.version}"
79
+ t.rdoc_files.include( '*.rdoc', 'lib/**/*.rb' )
80
+ end
81
+ rescue LoadError => le
82
+ This.task_warning( 'rdoc' )
83
+ end
84
+
85
+ #------------------------------------------------------------------------------
86
+ # Coverage - optional code coverage, rcov for 1.8 and simplecov for 1.9, so
87
+ # for the moment only rcov is listed.
88
+ #------------------------------------------------------------------------------
89
+ if RUBY_VERSION < "1.9.0"
90
+ begin
91
+ require 'rcov/rcovtask'
92
+ Rcov::RcovTask.new( 'coverage' ) do |t|
93
+ t.libs << 'spec'
94
+ t.pattern = 'spec/**/*_spec.rb'
95
+ t.verbose = true
96
+ t.rcov_opts << "-x ^/" # remove all the global files
97
+ t.rcov_opts << "--sort coverage" # so we see the worst files at the top
98
+ end
99
+ rescue LoadError
100
+ This.task_warning( 'rcov' )
101
+ end
102
+ else
103
+ begin
104
+ require 'simplecov'
105
+ desc 'Run tests with code coverage'
106
+ task :coverage do
107
+ ENV['COVERAGE'] = 'true'
108
+ Rake::Task[:test].execute
109
+ end
110
+ CLOBBER << FileList["coverage"]
111
+ rescue LoadError
112
+ This.task_warning( 'simplecov' )
113
+ end
114
+ end
115
+
116
+ #------------------------------------------------------------------------------
117
+ # Manifest - We want an explicit list of thos files that are to be packaged in
118
+ # the gem. Most of this is from Hoe.
119
+ #------------------------------------------------------------------------------
120
+ namespace 'manifest' do
121
+ desc "Check the manifest"
122
+ task :check => :clean do
123
+ files = FileList["**/*", ".*"].exclude( This.exclude_from_manifest ).to_a.sort
124
+ files = files.select{ |f| File.file?( f ) }
125
+
126
+ tmp = "Manifest.tmp"
127
+ File.open( tmp, 'w' ) do |f|
128
+ f.puts files.join("\n")
129
+ end
130
+
131
+ begin
132
+ sh "diff -du Manifest.txt #{tmp}"
133
+ ensure
134
+ rm tmp
135
+ end
136
+ puts "Manifest looks good"
137
+ end
138
+
139
+ desc "Generate the manifest"
140
+ task :generate => :clean do
141
+ files = %x[ git ls-files ].split("\n").sort
142
+ files.reject! { |f| f =~ This.exclude_from_manifest }
143
+ File.open( "Manifest.txt", "w" ) do |f|
144
+ f.puts files.join("\n")
145
+ end
146
+ end
147
+ end
148
+
149
+ #------------------------------------------------------------------------------
150
+ # Fixme - look for fixmes and report them
151
+ #------------------------------------------------------------------------------
152
+ namespace :fixme do
153
+ task :default => 'manifest:check' do
154
+ This.manifest.each do |file|
155
+ next if file == __FILE__
156
+ next unless file =~ %r/(txt|rb|md|rdoc|css|html|xml|css)\Z/
157
+ puts "FIXME: Rename #{file}" if file =~ /fixme/i
158
+ IO.readlines( file ).each_with_index do |line, idx|
159
+ prefix = "FIXME: #{file}:#{idx+1}".ljust(42)
160
+ puts "#{prefix} => #{line.strip}" if line =~ /fixme/i
161
+ end
162
+ end
163
+ end
164
+
165
+ def fixme_project_root
166
+ This.project_path( '../fixme' )
167
+ end
168
+
169
+ def fixme_project_path( subtree )
170
+ fixme_project_root.join( subtree )
171
+ end
172
+
173
+ def local_fixme_files
174
+ This.manifest.select { |p| p =~ %r|^tasks/| }
175
+ end
176
+
177
+ def outdated_fixme_files
178
+ local_fixme_files.reject do |local|
179
+ upstream = fixme_project_path( local )
180
+ Digest::SHA256.file( local ) == Digest::SHA256.file( upstream )
181
+ end
182
+ end
183
+
184
+ def fixme_up_to_date?
185
+ outdated_fixme_files.empty?
186
+ end
187
+
188
+ desc "See if the fixme tools are outdated"
189
+ task :outdated => :release_check do
190
+ if fixme_up_to_date? then
191
+ puts "Fixme files are up to date."
192
+ else
193
+ outdated_fixme_files.each do |f|
194
+ puts "#{f} is outdated"
195
+ end
196
+ end
197
+ end
198
+
199
+ desc "Update outdated fixme files"
200
+ task :update => :release_check do
201
+ if fixme_up_to_date? then
202
+ puts "Fixme files are already up to date."
203
+ else
204
+ puts "Updating fixme files:"
205
+ outdated_fixme_files.each do |local|
206
+ upstream = fixme_project_path( local )
207
+ puts " * #{local}"
208
+ FileUtils.cp( upstream, local )
209
+ end
210
+ puts "Use your git commands as appropriate."
211
+ end
212
+ end
213
+ end
214
+ desc "Look for fixmes and report them"
215
+ task :fixme => "fixme:default"
216
+
217
+ #------------------------------------------------------------------------------
218
+ # Gem Specification
219
+ #------------------------------------------------------------------------------
220
+ # Really this is only here to support those who use bundler
221
+ desc "Build the #{This.name}.gemspec file"
222
+ task :gemspec do
223
+ File.open( This.gemspec_file, "wb+" ) do |f|
224
+ f.write This.platform_gemspec.to_ruby
225
+ end
226
+ end
227
+
228
+ # the gemspec is also a dev artifact and should not be kept around.
229
+ CLOBBER << This.gemspec_file.to_s
230
+
231
+ # The standard gem packaging task, everyone has it.
232
+ require 'rubygems/package_task'
233
+ Gem::PackageTask.new( This.platform_gemspec ) do
234
+ # nothing
235
+ end
236
+
237
+ #------------------------------------------------------------------------------
238
+ # Release - the steps we go through to do a final release, this is pulled from
239
+ # a compbination of mojombo's rakegem, hoe and hoe-git
240
+ #
241
+ # 1) make sure we are on the master branch
242
+ # 2) make sure there are no uncommitted items
243
+ # 3) check the manifest and make sure all looks good
244
+ # 4) build the gem
245
+ # 5) do an empty commit to have the commit message of the version
246
+ # 6) tag that commit as the version
247
+ # 7) push master
248
+ # 8) push the tag
249
+ # 7) pus the gem
250
+ #------------------------------------------------------------------------------
251
+ task :release_check do
252
+ unless `git branch` =~ /^\* master$/
253
+ abort "You must be on the master branch to release!"
254
+ end
255
+ unless `git status` =~ /^nothing to commit/m
256
+ abort "Nope, sorry, you have unfinished business"
257
+ end
258
+ end
259
+
260
+ desc "Create tag v#{This.version}, build and push #{This.platform_gemspec.full_name} to rubygems.org"
261
+ task :release => [ :release_check, 'manifest:check', :gem ] do
262
+ sh "git commit --allow-empty -a -m 'Release #{This.version}'"
263
+ sh "git tag -a -m 'v#{This.version}' v#{This.version}"
264
+ sh "git push origin master"
265
+ sh "git push origin v#{This.version}"
266
+ sh "gem push pkg/#{This.platform_gemspec.full_name}.gem"
267
+ end
data/tasks/extension.rake CHANGED
@@ -1,108 +1,38 @@
1
- require 'tasks/config'
2
- require 'pathname'
3
-
4
- #-----------------------------------------------------------------------
5
- # Extensions
6
- #-----------------------------------------------------------------------
7
-
8
- if ext_config = Configuration.for_if_exist?('extension') then
9
- namespace :ext do
10
- desc "Build the extension(s)"
11
- task :build => :clobber do
12
- ext_config.configs.each do |extension|
13
- path = Pathname.new(extension)
14
- parts = path.split
15
- conf = parts.last
16
- Dir.chdir(path.dirname) do |d|
17
- ruby conf.to_s
18
- sh "make"
19
-
20
- # install into requireable location so specs will run
21
- subdir = "hitimes/#{RUBY_VERSION.sub(/\.\d$/,'')}"
22
- dest_dir = Hitimes::Paths.lib_path( subdir )
23
- mkdir_p dest_dir, :verbose => true
24
- cp "hitimes_ext.#{Config::CONFIG['DLEXT']}", dest_dir, :verbose => true
25
- end
26
- end
27
- end
28
-
29
- if RUBY_PLATFORM == "java" then
30
- desc "Build the jruby extension"
31
- task :build_java => [ :clobber, "lib/hitimes/hitimes.jar" ]
32
-
33
- file "lib/hitimes/hitimes.jar" => FileList["ext/java/src/hitimes/*.java"] do |t|
34
- jruby_home = Config::CONFIG['prefix']
35
- jruby_jar = File.join( jruby_home, 'lib', 'jruby.jar' )
36
-
37
- mkdir_p 'pkg/classes'
38
- sh "javac -classpath #{jruby_jar} -d pkg/classes #{t.prerequisites.join(' ')}"
39
-
40
- dest_dir = File.dirname(t.name)
41
- sh "jar cf #{t.name} -C pkg/classes ."
42
- end
1
+ # To be used if the gem has extensions.
2
+ # If this task set is inclueded then you will need to also have
3
+ #
4
+ # spec.add_development_dependency( 'rake-compiler', '~> 0.8.1' )
5
+ #
6
+ # in your top level rakefile
7
+ begin
8
+ require 'rake/extensiontask'
9
+ require 'rake/javaextensiontask'
10
+
11
+ if RUBY_PLATFORM == "java" then
12
+
13
+ Rake::JavaExtensionTask.new( This.name) do |ext|
14
+ ext.ext_dir = File.join( 'ext', This.name, "java" )
15
+ ext.lib_dir = File.join( 'lib', This.name )
16
+ ext.gem_spec = This.java_gemspec
43
17
  end
44
18
 
19
+ else
45
20
 
46
- def build_win( version = "1.8.6" )
47
- ext_config = Configuration.for("extension")
48
- rbconfig = ext_config.cross_rbconfig["rbconfig-#{version}"]
49
- raise ArgumentError, "No cross compiler for version #{version}, we have #{ext_config.cross_rbconfig.keys.join(",")}" unless rbconfig
50
- Hitimes::GEM_SPEC.extensions.each do |extension|
51
- path = Pathname.new(extension)
52
- parts = path.split
53
- conf = parts.last
54
- rvm = File.expand_path( "~/.rvm/bin/rvm" )
55
- Dir.chdir(path.dirname) do |d|
56
- if File.exist?( "Makefile" ) then
57
- sh "make clean distclean"
58
- end
59
- cp "#{rbconfig}", "rbconfig.rb"
60
- rubylib = ENV['RUBYLIB']
61
- ENV['RUBYLIB'] = "."
62
- sh %[#{rvm} #{version} -S extconf.rb]
63
- ENV['RUBYLIB'] = rubylib
64
- sh "make"
65
- end
66
- end
67
- end
68
-
69
- win_builds = []
70
- ext_config.cross_rbconfig.keys.each do |v|
71
- s = v.split("-").last
72
- desc "Build the extension for windows version #{s}"
73
- win_bname = "build_win-#{s}"
74
- win_builds << win_bname
75
- task win_bname => :clean do
76
- build_win( s )
77
- end
78
- end
21
+ Rake::ExtensionTask.new( This.name ) do |ext|
22
+ ext.ext_dir = File.join( 'ext', This.name, "c" )
23
+ ext.lib_dir = File.join( 'lib', This.name )
24
+ ext.gem_spec = This.ruby_gemspec
79
25
 
80
- task :clean do
81
- ext_config.configs.each do |extension|
82
- path = Pathname.new(extension)
83
- parts = path.split
84
- conf = parts.last
85
- Dir.chdir(path.dirname) do |d|
86
- if File.exist?( "Makefile" ) then
87
- sh "make clean"
88
- end
89
- rm_f "rbconfig.rb"
90
- end
91
- end
92
- end
93
-
94
- task :clobber do
95
- ext_config.configs.each do |extension|
96
- path = Pathname.new(extension)
97
- parts = path.split
98
- conf = parts.last
99
- Dir.chdir(path.dirname) do |d|
100
- if File.exist?( "Makefile" ) then
101
- sh "make distclean"
102
- end
103
- rm_f "rbconfig.rb"
104
- end
105
- end
26
+ ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
27
+ ext.cross_platform = 'i386-mswin32' # forces the Windows platform instead of the default one
28
+ # configure options only for cross compile
106
29
  end
107
30
  end
31
+
32
+ task :test_requirements => :compile
33
+ rescue LoadError
34
+ This.task_warning( 'extension' )
108
35
  end
36
+
37
+ CLOBBER << FileList["lib/**/*.{jar,so,bundle}"]
38
+ CLOBBER << FileList["lib/#{This.name}/1.{8,9}/"]
data/tasks/this.rb ADDED
@@ -0,0 +1,209 @@
1
+ require 'pathname'
2
+
3
+ # Public: A Class containing all the metadata and utilities needed to manage a
4
+ # ruby project.
5
+ class ThisProject
6
+ # The name of this project
7
+ attr_accessor :name
8
+
9
+ # The author's name
10
+ attr_accessor :author
11
+
12
+ # The email address of the author(s)
13
+ attr_accessor :email
14
+
15
+ # The homepage of this project
16
+ attr_accessor :homepage
17
+
18
+ # The regex of files to exclude from the manifest
19
+ attr_accessor :exclude_from_manifest
20
+
21
+ # The hash of Gem::Specifications keyed' by platform
22
+ attr_accessor :gemspecs
23
+
24
+ # Public: Initialize ThisProject
25
+ #
26
+ # Yields self
27
+ def initialize(&block)
28
+ @exclude_from_manifest = %r/\.(git|DS_Store)|^(doc|coverage|pkg|tmp)|Gemfile*|\.(gemspec|swp|jar|bundle|so|rvmrc)$|~$/
29
+ @gemspecs = Hash.new
30
+ yield self if block_given?
31
+ end
32
+
33
+ # Public: return the version of ThisProject
34
+ #
35
+ # Search the ruby files in the project looking for the one that has the
36
+ # version string in it. This does not eval any code in the project, it parses
37
+ # the source code looking for the string.
38
+ #
39
+ # Returns a String version
40
+ def version
41
+ [ "lib/#{ name }.rb", "lib/#{ name }/version.rb" ].each do |v|
42
+ path = project_path( v )
43
+ line = path.read[/^\s*VERSION\s*=\s*.*/]
44
+ if line then
45
+ return line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
46
+ end
47
+ end
48
+ end
49
+
50
+ # Internal: Return a section of an RDoc file with the given section name
51
+ #
52
+ # path - the relative path in the project of the file to parse
53
+ # section_name - the section out of the file from which to parse data
54
+ #
55
+ # Retuns the text of the section as an array of paragrphs.
56
+ def section_of( file, section_name )
57
+ re = /^=+ (.*)$/
58
+ sectional = project_path( file )
59
+ parts = sectional.read.split( re )[1..-1]
60
+ parts.map! { |p| p.strip }
61
+
62
+ sections = Hash.new
63
+ Hash[*parts].each do |k,v|
64
+ sections[k] = v.split("\n\n")
65
+ end
66
+ return sections[section_name]
67
+ end
68
+
69
+ # Internal: print out a warning about the give task
70
+ def task_warning( task )
71
+ warn "WARNING: '#{task}' tasks are not defined. Please run 'rake develop'"
72
+ end
73
+
74
+ # Internal: Return the full path to the file that is relative to the project
75
+ # root.
76
+ #
77
+ # path - the relative path of the file from the project root
78
+ #
79
+ # Returns the Pathname of the file
80
+ def project_path( *relative_path )
81
+ project_root.join( *relative_path )
82
+ end
83
+
84
+ # Internal: The absolute path of this file
85
+ #
86
+ # Returns the Pathname of this file.
87
+ def this_file_path
88
+ Pathname.new( __FILE__ ).expand_path
89
+ end
90
+
91
+ # Internal: The root directory of this project
92
+ #
93
+ # This is defined as being the directory that is in the path of this project
94
+ # that has the first Rakefile
95
+ #
96
+ # Returns the Pathname of the directory
97
+ def project_root
98
+ this_file_path.ascend do |p|
99
+ rakefile = p.join( 'Rakefile' )
100
+ return p if rakefile.exist?
101
+ end
102
+ end
103
+
104
+ # Internal: Returns the contents of the Manifest.txt file as an array
105
+ #
106
+ # Returns an Array of strings
107
+ def manifest
108
+ manifest_file = project_path( "Manifest.txt" )
109
+ abort "You need a Manifest.txt" unless manifest_file.readable?
110
+ manifest_file.readlines.map { |l| l.strip }
111
+ end
112
+
113
+ # Internal: Return the files that define the extensions
114
+ #
115
+ # Returns an Array
116
+ def extension_conf_files
117
+ manifest.grep( /extconf.rb\Z/ )
118
+ end
119
+
120
+ # Internal: Returns the gemspace associated with the current ruby platform
121
+ def platform_gemspec
122
+ gemspecs[platform]
123
+ end
124
+
125
+ def core_gemspec
126
+ Gem::Specification.new do |spec|
127
+ spec.name = name
128
+ spec.version = version
129
+ spec.author = author
130
+ spec.email = email
131
+ spec.homepage = homepage
132
+
133
+ spec.summary = summary
134
+ spec.description = description
135
+
136
+ spec.files = manifest
137
+ spec.executables = spec.files.grep(/^bin/) { |f| File.basename(f) }
138
+ spec.test_files = spec.files.grep(/^spec/)
139
+
140
+ spec.extra_rdoc_files += spec.files.grep(/(txt|rdoc)$/)
141
+ spec.rdoc_options = [ "--main" , 'README.rdoc',
142
+ "--markup", "tomdoc" ]
143
+ end
144
+ end
145
+
146
+ # Internal: Return the gemspec for the ruby platform
147
+ def ruby_gemspec( core = core_gemspec, &block )
148
+ yielding_gemspec( 'ruby', core, &block )
149
+ end
150
+
151
+ # Internal: Return the gemspec for the jruby platform
152
+ def java_gemspec( core = core_gemspec, &block )
153
+ yielding_gemspec( 'java', core, &block )
154
+ end
155
+
156
+ # Internal: give an initial spec and a key, create a new gemspec based off of
157
+ # it.
158
+ #
159
+ # This will force the new gemspecs 'platform' to be that of the key, since the
160
+ # only reason you would have multiple gemspecs at this point is to deal with
161
+ # different platforms.
162
+ def yielding_gemspec( key, core )
163
+ spec = gemspecs[key] ||= core.dup
164
+ spec.platform = key
165
+ yield spec if block_given?
166
+ return spec
167
+ end
168
+
169
+ # Internal: Set the recovery gem development dependency
170
+ #
171
+ # These are dynamically set since they cannot be hard coded as there is
172
+ # no way to ship them correctly in the gemspec
173
+ #
174
+ # Returns nothing.
175
+ def set_coverage_gem
176
+ if RUBY_VERSION < "1.9.0"
177
+ platform_gemspec.add_development_dependency( 'rcov', '~> 1.0.0' )
178
+ else
179
+ platform_gemspec.add_development_dependency( 'simplecov', '~> 0.7.1' )
180
+ end
181
+ end
182
+
183
+ # Internal: Return the platform of ThisProject at the current moment in time.
184
+ def platform
185
+ (RUBY_PLATFORM == "java") ? 'java' : Gem::Platform::RUBY
186
+ end
187
+
188
+ # Internal: Return the DESCRIPTION section of the README.rdoc file
189
+ def description_section
190
+ section_of( 'README.rdoc', 'DESCRIPTION')
191
+ end
192
+
193
+ # Internal: Return the summary text from the README
194
+ def summary
195
+ description_section.first
196
+ end
197
+
198
+ # Internal: Return the full description text from the READEM
199
+ def description
200
+ description_section.join(" ").tr("\n", ' ').gsub(/[{}]/,'').gsub(/\[[^\]]+\]/,'') # strip rdoc
201
+ end
202
+
203
+ # Internal: The path to the gemspec file
204
+ def gemspec_file
205
+ project_path( "#{ name }.gemspec" )
206
+ end
207
+ end
208
+
209
+ This = ThisProject.new