Permalink
Browse files

Leverage VERSION constants from gemspecs to avoid tedious updates whe…

…n releasing
  • Loading branch information...
1 parent a4111bb commit f221a6f19f4cee31e2d103ea9a1930f59223fc25 @brynary brynary committed Mar 2, 2010
View
13 Rakefile
@@ -3,10 +3,15 @@ require 'rake/rdoctask'
require 'rake/gempackagetask'
PROJECTS = %w(activesupport activemodel actionpack actionmailer activeresource activerecord railties)
-
-Dir["#{File.dirname(__FILE__)}/*/lib/*/version.rb"].each do |version_path|
- require version_path
-end
+PROJECTS.each { |project| $:.unshift "#{project}/lib" }
+
+require "active_support/version"
+require "active_model/version"
+require "action_pack/version"
+require "action_mailer/version"
+require "active_resource/version"
+require "active_record/version"
+require "rails/version"
desc 'Run all tests by default'
task :default => %w(test test:isolated)
View
1 actionmailer/Rakefile
@@ -4,7 +4,6 @@ require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/packagetask'
require 'rake/gempackagetask'
-require File.join(File.dirname(__FILE__), 'lib', 'action_mailer', 'version')
desc "Default Task"
task :default => [ :test ]
View
7 actionmailer/actionmailer.gemspec
@@ -1,7 +1,10 @@
+$:.unshift "lib"
+require "action_mailer/version"
+
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'actionmailer'
- s.version = '3.0.0.beta1'
+ s.version = ActionMailer::VERSION::STRING
s.summary = 'Email composition, delivery, and recieval framework (part of Rails).'
s.description = 'Email composition, delivery, and recieval framework (part of Rails).'
s.required_ruby_version = '>= 1.8.7'
@@ -17,7 +20,7 @@ Gem::Specification.new do |s|
s.has_rdoc = true
- s.add_dependency('actionpack', '= 3.0.0.beta1')
+ s.add_dependency('actionpack', "= #{ActionMailer::VERSION::STRING}")
s.add_dependency('mail', '~> 2.1.3')
s.add_dependency('text-format', '~> 1.0.0')
end
View
1 actionpack/Rakefile
@@ -4,7 +4,6 @@ require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/packagetask'
require 'rake/gempackagetask'
-require File.join(File.dirname(__FILE__), 'lib', 'action_pack', 'version')
desc "Default Task"
task :default => :test
View
9 actionpack/actionpack.gemspec
@@ -1,7 +1,10 @@
+$:.unshift "lib"
+require "action_pack/version"
+
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'actionpack'
- s.version = '3.0.0.beta1'
+ s.version = ActionPack::VERSION::STRING
s.summary = 'Web-flow and rendering framework putting the VC in MVC (part of Rails).'
s.description = 'Web-flow and rendering framework putting the VC in MVC (part of Rails).'
s.required_ruby_version = '>= 1.8.7'
@@ -17,8 +20,8 @@ Gem::Specification.new do |s|
s.has_rdoc = true
- s.add_dependency('activesupport', '= 3.0.0.beta1')
- s.add_dependency('activemodel', '= 3.0.0.beta1')
+ s.add_dependency('activesupport', "= #{ActionPack::VERSION::STRING}")
+ s.add_dependency('activemodel', "= #{ActionPack::VERSION::STRING}")
s.add_dependency('rack', '~> 1.1.0')
s.add_dependency('rack-test', '~> 0.5.0')
s.add_dependency('rack-mount', '~> 0.5.1')
View
1 activemodel/Rakefile
@@ -1,5 +1,4 @@
dir = File.dirname(__FILE__)
-require "#{dir}/lib/active_model/version"
require 'rake/testtask'
View
7 activemodel/activemodel.gemspec
@@ -1,7 +1,10 @@
+$:.unshift "lib"
+require "active_model/version"
+
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'activemodel'
- s.version = '3.0.0.beta1'
+ s.version = ActiveModel::VERSION::STRING
s.summary = "A toolkit for building other modeling frameworks like ActiveRecord"
s.description = %q{Extracts common modeling concerns from ActiveRecord to share between similar frameworks like ActiveResource.}
s.required_ruby_version = '>= 1.8.7'
@@ -13,7 +16,7 @@ Gem::Specification.new do |s|
s.has_rdoc = true
- s.add_dependency('activesupport', '= 3.0.0.beta1')
+ s.add_dependency('activesupport', "= #{ActiveModel::VERSION::STRING}")
s.require_path = 'lib'
s.files = Dir["CHANGELOG", "MIT-LICENSE", "README", "lib/**/*"]
View
1 activerecord/Rakefile
@@ -5,7 +5,6 @@ require 'rake/rdoctask'
require 'rake/packagetask'
require 'rake/gempackagetask'
-require File.join(File.dirname(__FILE__), 'lib', 'active_record', 'version')
require File.expand_path(File.dirname(__FILE__)) + "/test/config"
MYSQL_DB_USER = 'rails'
View
9 activerecord/activerecord.gemspec
@@ -1,7 +1,10 @@
+$:.unshift "lib"
+require "active_record/version"
+
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'activerecord'
- s.version = '3.0.0.beta1'
+ s.version = ActiveRecord::VERSION::STRING
s.summary = 'Object-relational mapper framework (part of Rails).'
s.description = 'Object-relational mapper framework (part of Rails).'
s.required_ruby_version = '>= 1.8.7'
@@ -18,7 +21,7 @@ Gem::Specification.new do |s|
s.extra_rdoc_files = %w( README )
s.rdoc_options.concat ['--main', 'README']
- s.add_dependency('activesupport', '= 3.0.0.beta1')
- s.add_dependency('activemodel', '= 3.0.0.beta1')
+ s.add_dependency('activesupport', "= #{ActiveRecord::VERSION::STRING}")
+ s.add_dependency('activemodel', "= #{ActiveRecord::VERSION::STRING}")
s.add_dependency('arel', '~> 0.2.1')
end
View
2 activeresource/Rakefile
@@ -5,8 +5,6 @@ require 'rake/rdoctask'
require 'rake/packagetask'
require 'rake/gempackagetask'
-require File.join(File.dirname(__FILE__), 'lib', 'active_resource', 'version')
-
desc "Default Task"
task :default => [ :test ]
View
9 activeresource/activeresource.gemspec
@@ -1,7 +1,10 @@
+$:.unshift "lib"
+require "active_resource/version"
+
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'activeresource'
- s.version = '3.0.0.beta1'
+ s.version = ActiveResource::VERSION::STRING
s.summary = 'REST-model framework (part of Rails).'
s.description = 'REST-model framework (part of Rails).'
s.required_ruby_version = '>= 1.8.7'
@@ -18,6 +21,6 @@ Gem::Specification.new do |s|
s.extra_rdoc_files = %w( README )
s.rdoc_options.concat ['--main', 'README']
- s.add_dependency('activesupport', '= 3.0.0.beta1')
- s.add_dependency('activemodel', '= 3.0.0.beta1')
+ s.add_dependency('activesupport', "= #{ActiveResource::VERSION::STRING}")
+ s.add_dependency('activemodel', "= #{ActiveResource::VERSION::STRING}")
end
View
2 activesupport/Rakefile
@@ -2,8 +2,6 @@ require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/gempackagetask'
-require File.join(File.dirname(__FILE__), 'lib', 'active_support', 'version')
-
task :default => :test
Rake::TestTask.new do |t|
t.libs << 'test'
View
5 activesupport/activesupport.gemspec
@@ -1,7 +1,10 @@
+$:.unshift "lib"
+require "active_support/version"
+
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'activesupport'
- s.version = '3.0.0.beta1'
+ s.version = ActiveSupport::VERSION::STRING
s.summary = 'Support and utility classes used by the Rails framework.'
s.description = 'Support and utility classes used by the Rails framework.'
s.required_ruby_version = '>= 1.8.7'
View
17 rails.gemspec
@@ -1,7 +1,10 @@
+$:.unshift "railties/lib"
+require "rails/version"
+
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'rails'
- s.version = '3.0.0.beta1'
+ s.version = Rails::VERSION::STRING
s.summary = 'Full-stack web-application framework.'
s.description = 'Full-stack web-application framework.'
s.required_ruby_version = '>= 1.8.7'
@@ -14,11 +17,11 @@ Gem::Specification.new do |s|
s.files = []
s.require_path = []
- s.add_dependency('activesupport', '= 3.0.0.beta1')
- s.add_dependency('actionpack', '= 3.0.0.beta1')
- s.add_dependency('activerecord', '= 3.0.0.beta1')
- s.add_dependency('activeresource', '= 3.0.0.beta1')
- s.add_dependency('actionmailer', '= 3.0.0.beta1')
- s.add_dependency('railties', '= 3.0.0.beta1')
+ s.add_dependency('activesupport', "= #{Rails::VERSION::STRING}")
+ s.add_dependency('actionpack', "= #{Rails::VERSION::STRING}")
+ s.add_dependency('activerecord', "= #{Rails::VERSION::STRING}")
+ s.add_dependency('activeresource', "= #{Rails::VERSION::STRING}")
+ s.add_dependency('actionmailer', "= #{Rails::VERSION::STRING}")
+ s.add_dependency('railties', "= #{Rails::VERSION::STRING}")
s.add_dependency('bundler', '>= 0.9.8')
end
View
3 railties/Rakefile
@@ -8,9 +8,6 @@ require 'rake/gempackagetask'
require 'date'
require 'rbconfig'
-$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/lib"
-require 'rails/version'
-
task :default => :test
task :test => 'test:isolated'
View
2 railties/lib/rails/tasks/documentation.rake
@@ -14,7 +14,7 @@ namespace :doc do
desc 'Generate documentation for the Rails framework. Specify path with PATH="/path/to/rails"'
Rake::RDocTask.new("rails") { |rdoc|
path = ENV['RAILS_PATH'] || 'vendor/gems/gems'
- version = '-3.0.0.beta1' unless ENV['RAILS_PATH']
+ version = "-#{Rails::VERSION::STRING}" unless ENV['RAILS_PATH']
rdoc.rdoc_dir = 'doc/api'
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
rdoc.title = "Rails Framework Documentation"
View
9 railties/railties.gemspec
@@ -1,7 +1,10 @@
+$:.unshift "lib"
+require "rails/version"
+
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'railties'
- s.version = '3.0.0.beta1'
+ s.version = Rails::VERSION::STRING
s.summary = 'Controls boot-up, rake tasks and generators for the Rails framework.'
s.description = 'Controls boot-up, rake tasks and generators for the Rails framework.'
s.required_ruby_version = '>= 1.8.7'
@@ -22,6 +25,6 @@ Gem::Specification.new do |s|
s.add_dependency('rake', '>= 0.8.3')
s.add_dependency('thor', '~> 0.13.4')
- s.add_dependency('activesupport', '= 3.0.0.beta1')
- s.add_dependency('actionpack', '= 3.0.0.beta1')
+ s.add_dependency('activesupport', "= #{Rails::VERSION::STRING}")
+ s.add_dependency('actionpack', "= #{Rails::VERSION::STRING}")
end

11 comments on commit f221a6f

@sundbp

Just FYI: I believe this commit breaks use with bundler under jruby. It doesn't like it when it gets to the require x/version in the gemspec when called from the eval when going through gemspecs in .bundle/environment.rb. I'm not sure why.

@snusnu

Yes it definitely does!

Inspecting ObjectSpace at the time when active_support/whiny_nil.rb is loaded, shows that ActiveRecord::VERSION and ActiveRecord are defined at that time. This is when running inside a datamapper application that doesn't even have ActiveRecord bundled !!! nor required :P

@snusnu

Heh, just realised that I'm describing a different problem here it seems ... sorry if i was too fast. However, there's a "reason" I was a bit fast with thinking this commit is to blame.

There's definitely a problem with current master, where an app that doesn't even have AR bundled fails on line

http://github.com/rails/rails/blob/master/activesupport/lib/active_support/whiny_nil.rb#L29

because ActiveRecord is defined? at that point, but ActiveRecord::Base isn't. This is inside a datamapper rails app that has no need for activerecord at all. I added the following to active_support/whiny_nil.rb

ObjectSpace.each_object(Module) do |o|
  puts o.name if o.name =~ /ActiveRecord/
end

and here's what I get when booting the application

ActiveRecord::VERSION
ActiveRecord
ActionView::Helpers::ActiveRecordInstanceTag

I'm not entirely sure yet if this is really the commit to blame, but maybe it explains a bit why I initially thought so :P
I will check this out and post more info here

@snusnu

For reference, here's the Gemfile I used for the application:

http://pastie.org/851119

and the output I get when running the app:

http://pastie.org/851123

@snusnu

So it looks like my initial feeling was right (somehow): this commit requires active_record/version in the gemspec

http://github.com/rails/rails/commit/f221a6f19f4cee31e2d103ea9a1930f59223fc25#L8R2

which gets evaled by bundler for some (good) reason. That's why the ActiveRecord constant is defined, and ActiveRecord::Base is not. Which is the reason why active_support/whiny_nil.rb prevents to boot a rails app that doesn't need activerecord

@snusnu

Oh and to reproduce it, I added

::ActiveRecord = nil

as first statement in my applications script/rails file, which gave me http://pastie.org/851136

@snusnu

I can confirm that when i reset my rails clone to one revision before that commit, everything still works fine. The commit doesn't revert cleanly, and I'm too tired now to investigate further.

@hassox

I got this working on ruby 1.9.1. Not sure if if I've done something extra or not.

Cheers
Daniel

∴ ruby --version
ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-darwin10.2.0]

dneighman@Sox #615 (0) ~/Work/rails3_test [git:master]

∴ script/rails server
=> Booting WEBrick
=> Rails 3.0.0.beta1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[datamapper] Setting up the "development" environment:
[datamapper] Setting up :default repository: 'rails3_test_development' on postgres
[2010-03-03 15:41:17] INFO WEBrick 1.3.1
[2010-03-03 15:41:17] INFO ruby 1.9.1 (2010-01-10) [i386-darwin10.2.0]
[2010-03-03 15:41:17] INFO WEBrick::HTTPServer#start: pid=22819 port=3000

@sundbp

ah. so i'm not alone in ending up investigating this area. I also concluded that ActiveRecord get's defined by Bundler.require when it shouldn't, and only way it'd happen is from the gemspecs.

I'm also doing some work with rails3 and datamapper (both on 1.9.1 and jruby 1.5).

@sundbp

I can confirm that the revision previous to this commit works well for my non-activerecord use case under both 1.9.1 and jruby 1.5.

Please sign in to comment.