From 81358854f23039b76a32cf2e5fcbc30b03bc78e3 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Thu, 28 Apr 2011 17:55:10 -0700 Subject: [PATCH] Refactor build system --- .travis.yml | 1 - Gemfile | 4 - Rakefile | 172 ++++--------------- VERSION | 1 - lib/omniauth/version.rb | 19 ++ oa-basic/VERSION | 1 - oa-basic/lib/omniauth/version.rb | 19 ++ oa-basic/oa-basic.gemspec | 8 +- oa-core/VERSION | 1 - oa-core/lib/omniauth/version.rb | 19 ++ oa-core/oa-core.gemspec | 8 +- oa-enterprise/VERSION | 1 - oa-enterprise/lib/omniauth/version.rb | 19 ++ oa-enterprise/oa-enterprise.gemspec | 8 +- oa-more/VERSION | 1 - oa-more/lib/omniauth/version.rb | 19 ++ oa-more/oa-more.gemspec | 8 +- oa-oauth/VERSION | 1 - oa-oauth/lib/omniauth/strategies/evernote.rb | 7 +- oa-oauth/lib/omniauth/version.rb | 19 ++ oa-oauth/oa-oauth.gemspec | 8 +- oa-openid/VERSION | 1 - oa-openid/lib/omniauth/version.rb | 19 ++ oa-openid/oa-openid.gemspec | 8 +- omniauth.gemspec | 6 +- tasks/all.rb | 132 ++++++++++++++ 26 files changed, 324 insertions(+), 186 deletions(-) delete mode 100644 VERSION create mode 100644 lib/omniauth/version.rb delete mode 100644 oa-basic/VERSION create mode 100644 oa-basic/lib/omniauth/version.rb delete mode 100644 oa-core/VERSION create mode 100644 oa-core/lib/omniauth/version.rb delete mode 100644 oa-enterprise/VERSION create mode 100644 oa-enterprise/lib/omniauth/version.rb delete mode 100644 oa-more/VERSION create mode 100644 oa-more/lib/omniauth/version.rb delete mode 100644 oa-oauth/VERSION create mode 100644 oa-oauth/lib/omniauth/version.rb delete mode 100644 oa-openid/VERSION create mode 100644 oa-openid/lib/omniauth/version.rb create mode 100644 tasks/all.rb diff --git a/.travis.yml b/.travis.yml index f09d7fe..1cdd132 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,5 @@ rvm: - 1.8.7 - 1.9.1 - 1.9.2 - - jruby - rbx - ree diff --git a/Gemfile b/Gemfile index 7131715..7caaf9a 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,3 @@ gemspec :path => 'oa-enterprise' gemspec :path => 'oa-more' gemspec :path => 'oa-oauth' gemspec :path => 'oa-openid' - -group :development do - gem "thrift_client", "0.6.1", :git => "git://github.com/sferik/thrift_client.git", :branch => "bump_version" -end diff --git a/Rakefile b/Rakefile index df78ce0..20d35d0 100644 --- a/Rakefile +++ b/Rakefile @@ -1,158 +1,48 @@ -OMNIAUTH_GEMS = %w(oa-basic oa-core oa-oauth oa-openid oa-enterprise oa-more) +$:.unshift File.expand_path('..', __FILE__) +require 'tasks/all' -def each_gem(action, &block) - OMNIAUTH_GEMS.each do |gem| - puts "#{gem} #{action}" - Dir.chdir(gem) do - yield - end - end -end +desc 'Clean up temporary files' +task :clean => 'all:clean' -def version - File.read("VERSION").strip -end +desc 'Build gem files for all projects into the package directory' +task :build => 'all:build' -def bump_version(position) - v = version.split('.').map{|s| s.to_i} - v[position] += 1 - write_version(*v) -end +desc 'Build and install gems for all projects' +task :install => 'all:install' -def write_version(major, minor, patch) - v = version.split('.').map{|s| s.to_i} - v[0] = major unless major.nil? - v[1] = minor unless minor.nil? - v[2] = patch unless patch.nil? - File.open("VERSION", 'w') do |f| - f.write v.join('.') - end - each_gem('is writing version file...') do - File.open("VERSION", 'w') do |f| - f.write v.join('.') - end - end - display_version -end +desc 'Write version with MAJOR, MINOR, PATCH, and PRE environment variables' +task 'version:write' => 'all:version:write' -def display_version - puts "Version is now #{version}" -end +desc 'Display the current version for all projects' +task :version => 'all:version' +desc 'Increment the major version for all projects' +task 'version:bump:major' => 'all:version:bump:major' +desc 'Increment the minor version for all projects' +task 'version:bump:minor' => 'all:version:bump:minor' +desc 'Increment the patch version for all projects' +task 'version:bump:patch' => 'all:version:bump:patch' -desc "Display the current version" -task :version do - display_version -end +desc 'Run specs for all projects' +task :spec => 'all:spec' +task :test => :spec +task :default => :test -namespace :version do - desc "Write version with MAJOR, MINOR, and PATCH level env variables." - task :write do - write_version(ENV['MAJOR'], ENV['MINOR'], ENV['PATCH']) - end - - namespace :bump do - desc "Increment the major version" - task :major do - bump_version(0) - end - desc "Increment the minor version" - task :minor do - bump_version(1) - end - desc "Increment the patch version" - task :patch do - bump_version(2) - end - end -end - -desc "Run specs for all of the gems" -task :spec do - error_gems = [] - each_gem('specs are running...') do |gem| - unless system('bundle exec rake spec') - error_gems << gem - end - end - - puts - if error_gems.any? - puts "#{error_gems.size} gems with failing specs: #{error_gems.join(', ')}" - exit(1) - else - puts "All gems passed specs." - end -end - -desc "Release all gems to gemcutter and create a tag" -task :release => ['tag', 'clean', 'build', 'publish'] +desc 'Generate docs for all projects' +task 'doc:yard' => 'all:doc:yard' task :tag do - system("git tag v#{version.join}") - system('git push origin --tags') + sh "git tag -a -m \"Version #{version}\" v#{version}" + sh "git push" + sh "git push --tags" end -task :publish do - each_gem('is releasing to Rubygems...') do - system("gem push pkg/#{gem}-#{version.join}.gem") - end - system("gem push pkg/omniauth-#{version.join}.gem") -end - -def build_gem - system('gem build omniauth.gemspec') - FileUtils.mkdir_p('pkg') - FileUtils.mv("omniauth-#{version}.gem", 'pkg') -end - -def install_gem - system("gem install pkg/omniauth-#{version}.gem") -end - -desc "Build gem files for all projects" -task :build do - each_gem('is building...') do - system('rake build') - end - build_gem -end - -desc "Install gems for all projects" -task :install do - each_gem('is installing...') do - system('rake install') - end - build_gem - install_gem -end - -desc "Clean pkg and other stuff" -task :clean do - OMNIAUTH_GEMS.each do |gem| - Dir.chdir(gem) do - %w(tmp pkg coverage dist).each do |directory| - FileUtils.rm_rf directory - end - end - %w(tmp pkg coverage dist).each do |directory| - FileUtils.rm_rf directory - end - end - Dir["**/*.gem"].each do |gem| - FileUtils.rm_rf gem - end -end - -task :default => :spec -task :test => :spec +desc 'Build, tag, and push gems for all projects to Rubygems' +task :release => [:build, :tag, :push] namespace :doc do require 'yard' YARD::Rake::YardocTask.new do |task| - task.files = OMNIAUTH_GEMS.map{|gem| ["#{gem}/lib/**/*.rb"]} + ['README.markdown', 'LICENSE'] - task.options = [ - '--markup', 'markdown', - '--markup-provider', 'maruku', - ] + task.files = PROJECTS.map{|project| "#{root}/#{project}/lib/**/*.rb"} + ['README.markdown', 'LICENSE'] end end + diff --git a/VERSION b/VERSION deleted file mode 100644 index 72f9fa8..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.2.4 \ No newline at end of file diff --git a/lib/omniauth/version.rb b/lib/omniauth/version.rb new file mode 100644 index 0000000..bba2171 --- /dev/null +++ b/lib/omniauth/version.rb @@ -0,0 +1,19 @@ +module OmniAuth + module Version + unless defined?(::OmniAuth::Version::MAJOR) + MAJOR = 0 + end + unless defined?(::OmniAuth::Version::MINOR) + MINOR = 2 + end + unless defined?(::OmniAuth::Version::PATCH) + PATCH = 4 + end + unless defined?(::OmniAuth::Version::PRE) + PRE = nil + end + unless defined?(::OmniAuth::Version::STRING) + STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') + end + end +end diff --git a/oa-basic/VERSION b/oa-basic/VERSION deleted file mode 100644 index 72f9fa8..0000000 --- a/oa-basic/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.2.4 \ No newline at end of file diff --git a/oa-basic/lib/omniauth/version.rb b/oa-basic/lib/omniauth/version.rb new file mode 100644 index 0000000..bba2171 --- /dev/null +++ b/oa-basic/lib/omniauth/version.rb @@ -0,0 +1,19 @@ +module OmniAuth + module Version + unless defined?(::OmniAuth::Version::MAJOR) + MAJOR = 0 + end + unless defined?(::OmniAuth::Version::MINOR) + MINOR = 2 + end + unless defined?(::OmniAuth::Version::PATCH) + PATCH = 4 + end + unless defined?(::OmniAuth::Version::PRE) + PRE = nil + end + unless defined?(::OmniAuth::Version::STRING) + STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') + end + end +end diff --git a/oa-basic/oa-basic.gemspec b/oa-basic/oa-basic.gemspec index 4714d45..642cc9c 100644 --- a/oa-basic/oa-basic.gemspec +++ b/oa-basic/oa-basic.gemspec @@ -1,8 +1,8 @@ # -*- encoding: utf-8 -*- -version = File.read("VERSION").strip +require File.expand_path('../lib/omniauth/version', __FILE__) Gem::Specification.new do |gem| - gem.add_runtime_dependency 'oa-core', version + gem.add_runtime_dependency 'oa-core', OmniAuth::Version::STRING gem.add_runtime_dependency 'jruby-openssl', '~> 0.7.3' if RUBY_PLATFORM == 'java' gem.add_runtime_dependency 'rest-client', '~> 1.6.0' gem.add_development_dependency 'maruku', '~> 0.6' @@ -14,9 +14,9 @@ Gem::Specification.new do |gem| gem.add_development_dependency 'yard', '~> 0.6' gem.add_development_dependency 'ZenTest', '~> 4.5' gem.name = 'oa-basic' - gem.version = version - gem.summary = %q{HTTP Basic strategies for OmniAuth.} + gem.version = OmniAuth::Version::STRING gem.description = %q{HTTP Basic strategies for OmniAuth.} + gem.summary = gem.description gem.email = ['michael@intridea.com', 'sferik@gmail.com'] gem.homepage = 'http://github.com/intridea/omniauth' gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober'] diff --git a/oa-core/VERSION b/oa-core/VERSION deleted file mode 100644 index 72f9fa8..0000000 --- a/oa-core/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.2.4 \ No newline at end of file diff --git a/oa-core/lib/omniauth/version.rb b/oa-core/lib/omniauth/version.rb new file mode 100644 index 0000000..bba2171 --- /dev/null +++ b/oa-core/lib/omniauth/version.rb @@ -0,0 +1,19 @@ +module OmniAuth + module Version + unless defined?(::OmniAuth::Version::MAJOR) + MAJOR = 0 + end + unless defined?(::OmniAuth::Version::MINOR) + MINOR = 2 + end + unless defined?(::OmniAuth::Version::PATCH) + PATCH = 4 + end + unless defined?(::OmniAuth::Version::PRE) + PRE = nil + end + unless defined?(::OmniAuth::Version::STRING) + STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') + end + end +end diff --git a/oa-core/oa-core.gemspec b/oa-core/oa-core.gemspec index 12ecce7..82f7620 100644 --- a/oa-core/oa-core.gemspec +++ b/oa-core/oa-core.gemspec @@ -1,5 +1,5 @@ # -*- encoding: utf-8 -*- -version = File.read("VERSION").strip +require File.expand_path('../lib/omniauth/version', __FILE__) Gem::Specification.new do |gem| gem.add_development_dependency 'maruku', '~> 0.6' @@ -10,9 +10,9 @@ Gem::Specification.new do |gem| gem.add_development_dependency 'yard', '~> 0.6' gem.add_development_dependency 'ZenTest', '~> 4.5' gem.name = 'oa-core' - gem.version = version - gem.summary = %q{HTTP Basic strategies for OmniAuth.} - gem.description = %q{HTTP Basic strategies for OmniAuth.} + gem.version = OmniAuth::Version::STRING + gem.description = %q{Core strategies for OmniAuth.} + gem.summary = gem.description gem.email = ['michael@intridea.com', 'sferik@gmail.com'] gem.homepage = 'http://github.com/intridea/omniauth' gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober'] diff --git a/oa-enterprise/VERSION b/oa-enterprise/VERSION deleted file mode 100644 index 72f9fa8..0000000 --- a/oa-enterprise/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.2.4 \ No newline at end of file diff --git a/oa-enterprise/lib/omniauth/version.rb b/oa-enterprise/lib/omniauth/version.rb new file mode 100644 index 0000000..bba2171 --- /dev/null +++ b/oa-enterprise/lib/omniauth/version.rb @@ -0,0 +1,19 @@ +module OmniAuth + module Version + unless defined?(::OmniAuth::Version::MAJOR) + MAJOR = 0 + end + unless defined?(::OmniAuth::Version::MINOR) + MINOR = 2 + end + unless defined?(::OmniAuth::Version::PATCH) + PATCH = 4 + end + unless defined?(::OmniAuth::Version::PRE) + PRE = nil + end + unless defined?(::OmniAuth::Version::STRING) + STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') + end + end +end diff --git a/oa-enterprise/oa-enterprise.gemspec b/oa-enterprise/oa-enterprise.gemspec index d85b76f..e0946a2 100644 --- a/oa-enterprise/oa-enterprise.gemspec +++ b/oa-enterprise/oa-enterprise.gemspec @@ -1,12 +1,12 @@ # -*- encoding: utf-8 -*- -version = File.read("VERSION").strip +require File.expand_path('../lib/omniauth/version', __FILE__) Gem::Specification.new do |gem| gem.add_runtime_dependency 'addressable', '2.2.4' gem.add_runtime_dependency 'jruby-openssl', '~> 0.7.3' if RUBY_PLATFORM == 'java' gem.add_runtime_dependency 'nokogiri', '~> 1.4.2' gem.add_runtime_dependency 'net-ldap', '~> 0.2.2' - gem.add_runtime_dependency 'oa-core', version + gem.add_runtime_dependency 'oa-core', OmniAuth::Version::STRING gem.add_runtime_dependency 'pyu-ruby-sasl', '~> 0.0.3.1' gem.add_runtime_dependency 'rubyntlm', '~> 0.1.1' gem.add_development_dependency 'maruku', '~> 0.6' @@ -18,9 +18,9 @@ Gem::Specification.new do |gem| gem.add_development_dependency 'yard', '~> 0.6' gem.add_development_dependency 'ZenTest', '~> 4.5' gem.name = 'oa-enterprise' - gem.version = version - gem.summary = %q{Enterprise strategies for OmniAuth.} + gem.version = OmniAuth::Version::STRING gem.description = %q{Enterprise strategies for OmniAuth.} + gem.summary = gem.description gem.email = ['james.a.rosen@gmail.com', 'ping@intridea.com', 'michael@intridea.com', 'sferik@gmail.com'] gem.homepage = 'http://github.com/intridea/omniauth' gem.authors = ['James A. Rosen', 'Ping Yu', 'Michael Bleigh', 'Erik Michaels-Ober'] diff --git a/oa-more/VERSION b/oa-more/VERSION deleted file mode 100644 index 72f9fa8..0000000 --- a/oa-more/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.2.4 \ No newline at end of file diff --git a/oa-more/lib/omniauth/version.rb b/oa-more/lib/omniauth/version.rb new file mode 100644 index 0000000..bba2171 --- /dev/null +++ b/oa-more/lib/omniauth/version.rb @@ -0,0 +1,19 @@ +module OmniAuth + module Version + unless defined?(::OmniAuth::Version::MAJOR) + MAJOR = 0 + end + unless defined?(::OmniAuth::Version::MINOR) + MINOR = 2 + end + unless defined?(::OmniAuth::Version::PATCH) + PATCH = 4 + end + unless defined?(::OmniAuth::Version::PRE) + PRE = nil + end + unless defined?(::OmniAuth::Version::STRING) + STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') + end + end +end diff --git a/oa-more/oa-more.gemspec b/oa-more/oa-more.gemspec index de35401..ffd6b2e 100644 --- a/oa-more/oa-more.gemspec +++ b/oa-more/oa-more.gemspec @@ -1,10 +1,10 @@ # -*- encoding: utf-8 -*- -version = File.read("VERSION").strip +require File.expand_path('../lib/omniauth/version', __FILE__) Gem::Specification.new do |gem| gem.add_runtime_dependency 'jruby-openssl', '~> 0.7.3' if RUBY_PLATFORM == 'java' gem.add_runtime_dependency 'multi_json', '~> 1.0.0' - gem.add_runtime_dependency 'oa-core', version + gem.add_runtime_dependency 'oa-core', OmniAuth::Version::STRING gem.add_runtime_dependency 'rest-client', '~> 1.6.0' gem.add_development_dependency 'json_pure', '~> 1.5' gem.add_development_dependency 'maruku', '~> 0.6' @@ -16,9 +16,9 @@ Gem::Specification.new do |gem| gem.add_development_dependency 'yard', '~> 0.6' gem.add_development_dependency 'ZenTest', '~> 4.5' gem.name = 'oa-more' - gem.version = version - gem.summary = %q{Additional strategies for OmniAuth.} + gem.version = OmniAuth::Version::STRING gem.description = %q{Additional strategies for OmniAuth.} + gem.summary = gem.description gem.email = 'michael@intridea.com' gem.homepage = 'http://github.com/intridea/omniauth' gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober'] diff --git a/oa-oauth/VERSION b/oa-oauth/VERSION deleted file mode 100644 index 72f9fa8..0000000 --- a/oa-oauth/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.2.4 \ No newline at end of file diff --git a/oa-oauth/lib/omniauth/strategies/evernote.rb b/oa-oauth/lib/omniauth/strategies/evernote.rb index 5cbe15c..76cd88f 100644 --- a/oa-oauth/lib/omniauth/strategies/evernote.rb +++ b/oa-oauth/lib/omniauth/strategies/evernote.rb @@ -1,11 +1,6 @@ require 'omniauth/oauth' require 'multi_json' - -begin - require 'evernote' -rescue LoadError => e - raise "Omniauth Evernote strategy requires 'evernote' gem. Add it to your Gemfile: gem 'evernote'" -end +require 'evernote' module OmniAuth module Strategies diff --git a/oa-oauth/lib/omniauth/version.rb b/oa-oauth/lib/omniauth/version.rb new file mode 100644 index 0000000..bba2171 --- /dev/null +++ b/oa-oauth/lib/omniauth/version.rb @@ -0,0 +1,19 @@ +module OmniAuth + module Version + unless defined?(::OmniAuth::Version::MAJOR) + MAJOR = 0 + end + unless defined?(::OmniAuth::Version::MINOR) + MINOR = 2 + end + unless defined?(::OmniAuth::Version::PATCH) + PATCH = 4 + end + unless defined?(::OmniAuth::Version::PRE) + PRE = nil + end + unless defined?(::OmniAuth::Version::STRING) + STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') + end + end +end diff --git a/oa-oauth/oa-oauth.gemspec b/oa-oauth/oa-oauth.gemspec index 633550c..7608183 100644 --- a/oa-oauth/oa-oauth.gemspec +++ b/oa-oauth/oa-oauth.gemspec @@ -1,12 +1,12 @@ # -*- encoding: utf-8 -*- -version = File.read("VERSION").strip +require File.expand_path('../lib/omniauth/version', __FILE__) Gem::Specification.new do |gem| gem.add_runtime_dependency 'faraday', '~> 0.6.1' gem.add_runtime_dependency 'jruby-openssl', '~> 0.7.3' if RUBY_PLATFORM == 'java' gem.add_runtime_dependency 'multi_json', '~> 1.0.0' gem.add_runtime_dependency 'multi_xml', '~> 0.2.2' - gem.add_runtime_dependency 'oa-core', version + gem.add_runtime_dependency 'oa-core', OmniAuth::Version::STRING gem.add_runtime_dependency 'oauth', '~> 0.4.0' gem.add_runtime_dependency 'oauth2', '~> 0.4.1' gem.add_development_dependency 'evernote', '~> 0.9' @@ -19,9 +19,9 @@ Gem::Specification.new do |gem| gem.add_development_dependency 'yard', '~> 0.6' gem.add_development_dependency 'ZenTest', '~> 4.5' gem.name = 'oa-oauth' - gem.version = version - gem.summary = %q{OAuth strategies for OmniAuth.} + gem.version = OmniAuth::Version::STRING gem.description = %q{OAuth strategies for OmniAuth.} + gem.summary = gem.description gem.email = ['michael@intridea.com', 'sferik@gmail.com'] gem.homepage = 'http://github.com/intridea/omniauth' gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober'] diff --git a/oa-openid/VERSION b/oa-openid/VERSION deleted file mode 100644 index 72f9fa8..0000000 --- a/oa-openid/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.2.4 \ No newline at end of file diff --git a/oa-openid/lib/omniauth/version.rb b/oa-openid/lib/omniauth/version.rb new file mode 100644 index 0000000..bba2171 --- /dev/null +++ b/oa-openid/lib/omniauth/version.rb @@ -0,0 +1,19 @@ +module OmniAuth + module Version + unless defined?(::OmniAuth::Version::MAJOR) + MAJOR = 0 + end + unless defined?(::OmniAuth::Version::MINOR) + MINOR = 2 + end + unless defined?(::OmniAuth::Version::PATCH) + PATCH = 4 + end + unless defined?(::OmniAuth::Version::PRE) + PRE = nil + end + unless defined?(::OmniAuth::Version::STRING) + STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') + end + end +end diff --git a/oa-openid/oa-openid.gemspec b/oa-openid/oa-openid.gemspec index 0b96221..7033956 100644 --- a/oa-openid/oa-openid.gemspec +++ b/oa-openid/oa-openid.gemspec @@ -1,9 +1,9 @@ # -*- encoding: utf-8 -*- -version = File.read("VERSION").strip +require File.expand_path('../lib/omniauth/version', __FILE__) Gem::Specification.new do |gem| gem.add_runtime_dependency 'jruby-openssl', '~> 0.7.3' if RUBY_PLATFORM == 'java' - gem.add_runtime_dependency 'oa-core', version + gem.add_runtime_dependency 'oa-core', OmniAuth::Version::STRING gem.add_runtime_dependency 'rack-openid', '~> 1.3.1' gem.add_runtime_dependency 'ruby-openid-apps-discovery', '~> 1.2.0' gem.add_development_dependency 'maruku', '~> 0.6' @@ -15,9 +15,9 @@ Gem::Specification.new do |gem| gem.add_development_dependency 'yard', '~> 0.6' gem.add_development_dependency 'ZenTest', '~> 4.5' gem.name = 'oa-openid' - gem.version = version - gem.summary = %q{OpenID strategies for OmniAuth.} + gem.version = OmniAuth::Version::STRING gem.description = %q{OpenID strategies for OmniAuth.} + gem.summary = gem.description gem.email = ['michael@intridea.com', 'sferik@gmail.com'] gem.homepage = 'http://github.com/intridea/omniauth' gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober'] diff --git a/omniauth.gemspec b/omniauth.gemspec index 293fee5..e0e571c 100644 --- a/omniauth.gemspec +++ b/omniauth.gemspec @@ -1,12 +1,12 @@ # -*- encoding: utf-8 -*- -version = File.read("VERSION").strip +require File.expand_path('../lib/omniauth/version', __FILE__) Gem::Specification.new do |gem| %w(oa-core oa-oauth oa-basic oa-openid oa-enterprise oa-more).each do |subgem| - gem.add_runtime_dependency subgem, version + gem.add_runtime_dependency subgem, OmniAuth::Version::STRING end gem.name = 'omniauth' - gem.version = version + gem.version = OmniAuth::Version::STRING gem.summary = %q{Rack middleware for standardized multi-provider authentication.} gem.description = %q{OmniAuth is an authentication framework that that separates the concept of authentiation from the concept of identity, providing simple hooks for any application to have one or multiple authentication providers for a user.} gem.email = ['michael@intridea.com', 'sferik@gmail.com'] diff --git a/tasks/all.rb b/tasks/all.rb new file mode 100644 index 0000000..1e26bbf --- /dev/null +++ b/tasks/all.rb @@ -0,0 +1,132 @@ +PROJECTS = %w(oa-core oa-basic oa-enterprise oa-more oa-oauth oa-openid omniauth) + +def root + File.expand_path('../../', __FILE__) +end + +require root + '/lib/omniauth/version' + +def version + ::OmniAuth::Version.constants.each do |const| + ::OmniAuth::Version.send(:remove_const, const) + end + load root + '/lib/omniauth/version.rb' + OmniAuth::Version::STRING +end + +PROJECTS.each do |project| + namespace project.to_sym do + dir = root + (project == 'omniauth' ? '' : "/#{project}") + package_dir = "#{dir}/pkg" + coverage_dir = "#{dir}/converage" + temp_dir = "#{dir}/tmp" + gem = "#{project}-#{version}.gem" + gemspec = "#{project}.gemspec" + + task :clean do + rm_rf package_dir + rm_rf coverage_dir + rm_rf temp_dir + end + + task :build => :clean do + cd dir + sh "gem build #{gemspec}" + mkdir_p package_dir unless Dir.exists?(package_dir) + mv gem, "#{package_dir}/#{gem}" + end + + task :install => :build do + sh "gem install #{package_dir}/#{gem}" + end + + task :push => :build do + sh "gem push #{package_dir}/#{gem}" + end + + task :version do + puts "#{project}: #{version}" + end + + namespace :version do + + destination = "#{dir}/lib/omniauth/version.rb" + + task :write do + write_version(destination, ENV['MAJOR'], ENV['MINOR'], ENV['PATCH'], ENV['PRE']) + end + + namespace :bump do + + task :major do + bump_version(destination, 0) + end + + task :minor do + bump_version(destination, 1) + end + + task :patch do + bump_version(destination, 2) + end + + end + + end + + task :spec do + cd dir + sh "#{$0} spec" + end + + end +end + +namespace :all do + task :clean => PROJECTS.map{|project| "#{project}:clean"} + task :build => PROJECTS.map{|project| "#{project}:build"} + task :install => PROJECTS.map{|project| "#{project}:install"} + task :push => PROJECTS.map{|project| "#{project}:push"} + task "version" => PROJECTS.map{|project| "#{project}:version"} + task "version:write" => PROJECTS.map{|project| "#{project}:version:write"} + [:version] + task "version:bump:major" => PROJECTS.map{|project| "#{project}:version:bump:major"} + [:version] + task "version:bump:minor" => PROJECTS.map{|project| "#{project}:version:bump:minor"} + [:version] + task "version:bump:patch" => PROJECTS.map{|project| "#{project}:version:bump:patch"} + [:version] + task :spec do + errors = [] + PROJECTS.map do |project| + next if project == "omniauth" + Rake::Task["#{project}:spec"].invoke || errors << project + end + fail("Errors in #{errors.join(', ')}") unless errors.empty? + end +end + +def write_version(destination, major=nil, minor=nil, patch=nil, pre=nil) + source = "#{root}/lib/omniauth/version.rb" + v = version.split('.') + v[0] = major if major + v[1] = minor if minor + v[2] = patch if patch + v[3] = pre if pre + v[3] = v[3] ? v[3].to_s : "nil" + + ruby = File.read(source) + ruby.gsub! /^(\s*)MAJOR = .*?$/, "\\1MAJOR = #{v[0]}" + fail "Could not insert MAJOR in #{source}" unless $1 + ruby.gsub! /^(\s*)MINOR = .*?$/, "\\1MINOR = #{v[1]}" + fail "Could not insert MINOR in #{source}" unless $1 + ruby.gsub! /^(\s*)PATCH = .*?$/, "\\1PATCH = #{v[2]}" + fail "Could not insert PATCH in #{source}" unless $1 + ruby.gsub! /^(\s*)PRE = .*?$/, "\\1PRE = #{v[3]}" + fail "Could not insert PRE in #{source}" unless $1 + File.open(destination, 'w') do |file| + file.write ruby + end +end + +def bump_version(destination, position) + v = version.split('.').map{|s| s.to_i} + v[position] += 1 + write_version(destination, *v) +end