diff options
author | Carl Lerche <carllerche@mac.com> | 2010-03-23 11:23:21 -0700 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-03-23 11:23:21 -0700 |
commit | 195cc1402284d0e965cd96e572514fe2ff300788 (patch) | |
tree | 928588a9cc5cb2346d4324b3a9d9842d2b1f00aa | |
parent | 30fb25d3abfc002b85f290587b979d54c35a2e98 (diff) | |
download | rails-195cc1402284d0e965cd96e572514fe2ff300788.tar.gz rails-195cc1402284d0e965cd96e572514fe2ff300788.tar.bz2 rails-195cc1402284d0e965cd96e572514fe2ff300788.zip |
Rake is a better build tool than Thor. Move the gem building and releasing tasks to the Rakefile.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Rakefile | 41 | ||||
-rw-r--r-- | Thorfile | 124 | ||||
-rw-r--r-- | arel.gemspec | 273 | ||||
-rw-r--r-- | lib/arel.rb | 4 | ||||
-rw-r--r-- | lib/arel/version.rb | 3 |
6 files changed, 70 insertions, 376 deletions
diff --git a/.gitignore b/.gitignore index 3fec2d912b..30bd888ba6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ spec/support/fixtures/*database* *.DS_Store debug.log pkg +.bundle
\ No newline at end of file @@ -1,5 +1,12 @@ require "rubygems" +def gemspec + @gemspec ||= begin + gemspec_file = File.expand_path('../arel.gemspec', __FILE__) + gemspec = eval(File.read(gemspec_file), binding, gemspec_file) + end +end + begin require "spec/rake/spectask" rescue LoadError @@ -46,3 +53,37 @@ desc 'Removes trailing whitespace' task :whitespace do sh %{find . -name '*.rb' -exec sed -i '' 's/ *$//g' {} \\;} end + +desc "Build pkg/#{gemspec.full_name}.gem" +task :build => "gemspec:validate" do + sh %{gem build arel.gemspec} + FileUtils.mkdir_p "pkg" + FileUtils.mv gemspec.file_name, "pkg" +end + +desc "Install the latest built gem" +task :install => :build do + sh "gem install --local pkg/#{gemspec.file_name}" +end + +namespace :release do + task :tag do + release_tag = "v#{gemspec.version}" + sh "git tag -a #{release_tag} -m 'Tagging #{release_tag}'" + sh "git push origin #{release_tag}" + end + + task :gem => :build do + sh "gem push pkg/#{gemspec.file_name}" + end +end + +desc "Release the current branch to GitHub and Gemcutter" +task :release => %w(release:tag release:gem) + +namespace :gemspec do + desc 'Validate the gemspec' + task :validate do + gemspec.validate + end +end
\ No newline at end of file diff --git a/Thorfile b/Thorfile deleted file mode 100644 index 3b55e45a91..0000000000 --- a/Thorfile +++ /dev/null @@ -1,124 +0,0 @@ -require "active_support" - -module GemHelpers - - def generate_gemspec - $LOAD_PATH << "#{File.dirname(__FILE__)}/vendor/rails/activerecord/lib" - $LOAD_PATH << "#{File.dirname(__FILE__)}/vendor/rails/activesupport/lib" - - $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), "lib"))) - require "arel" - - Gem::Specification.new do |s| - s.name = "arel" - s.version = Arel::VERSION - s.authors = ["Bryan Helmkamp", "Nick Kallen", "Emilio Tagua"] - s.email = "bryan@brynary.com" - s.homepage = "http://github.com/brynary/arel" - s.summary = "Arel is a relational algebra engine for Ruby" - s.description = <<-EOS.strip -Arel is a Relational Algebra for Ruby. It 1) simplifies the generation complex -of SQL queries and it 2) adapts to various RDBMS systems. It is intended to be -a framework framework; that is, you can build your own ORM with it, focusing on -innovative object and collection modeling as opposed to database compatibility -and query generation. - EOS - s.rubyforge_project = "arel" - - require "git" - repo = Git.open(".") - - s.files = normalize_files(repo.ls_files.keys - repo.lib.ignored_files) - s.test_files = normalize_files(Dir['spec/**/*.rb'] - repo.lib.ignored_files) - - s.has_rdoc = true - s.extra_rdoc_files = %w[History.txt README.markdown] - - # Arel required ActiveRecord, but we're not declaring it to avoid a - # circular dependency chain. The solution is for ActiveRecord to release - # the connection adapters which Arel uses in a separate gem - # s.add_dependency "activerecord", ">= 3.0.pre" - s.add_dependency "activesupport", ">= 3.0.0.beta" - end - end - - def normalize_files(array) - # only keep files, no directories, and sort - array.select do |path| - File.file?(path) - end.sort - end - - # Adds extra space when outputting an array. This helps create better version - # control diffs, because otherwise it is all on the same line. - def prettyify_array(gemspec_ruby, array_name) - gemspec_ruby.gsub(/s\.#{array_name.to_s} = \[.+?\]/) do |match| - leadin, files = match[0..-2].split("[") - leadin + "[\n #{files.split(",").join(",\n ")}\n ]" - end - end - - def read_gemspec - @read_gemspec ||= eval(File.read("arel.gemspec")) - end - - def sh(command) - puts command - system command - end -end - -class Default < Thor - include GemHelpers - - desc "gemspec", "Regenerate arel.gemspec" - def gemspec - File.open("arel.gemspec", "w") do |file| - gemspec_ruby = generate_gemspec.to_ruby - gemspec_ruby = prettyify_array(gemspec_ruby, :files) - gemspec_ruby = prettyify_array(gemspec_ruby, :test_files) - gemspec_ruby = prettyify_array(gemspec_ruby, :extra_rdoc_files) - - file.write gemspec_ruby - end - - puts "Wrote gemspec to arel.gemspec" - read_gemspec.validate - end - - desc "build", "Build a arel gem" - def build - sh "gem build arel.gemspec" - FileUtils.mkdir_p "pkg" - FileUtils.mv read_gemspec.file_name, "pkg" - end - - desc "install", "Install the latest built gem" - def install - sh "gem install --local pkg/#{read_gemspec.file_name}" - end - - desc "release", "Release the current branch to GitHub and Gemcutter" - def release - gemspec - build - Release.new.tag - Release.new.gem - end -end - -class Release < Thor - include GemHelpers - - desc "tag", "Tag the gem on the origin server" - def tag - release_tag = "v#{read_gemspec.version}" - sh "git tag -a #{release_tag} -m 'Tagging #{release_tag}'" - sh "git push origin #{release_tag}" - end - - desc "gem", "Push the gem to Gemcutter" - def gem - sh "gem push pkg/#{read_gemspec.file_name}" - end -end
\ No newline at end of file diff --git a/arel.gemspec b/arel.gemspec index 695f504203..31a3b558a9 100644 --- a/arel.gemspec +++ b/arel.gemspec @@ -1,258 +1,31 @@ # -*- encoding: utf-8 -*- +require File.expand_path('../lib/arel/version.rb', __FILE__) Gem::Specification.new do |s| - s.name = %q{arel} - s.version = "0.3.1" - - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Bryan Helmkamp", "Nick Kallen", "Emilio Tagua"] - s.date = %q{2010-03-10} - s.description = %q{Arel is a Relational Algebra for Ruby. It 1) simplifies the generation complex + s.name = "arel" + s.version = Arel::VERSION + s.authors = ["Bryan Helmkamp", "Nick Kallen", "Emilio Tagua"] + s.email = "bryan@brynary.com" + s.homepage = "http://github.com/brynary/arel" + s.summary = "Arel is a relational algebra engine for Ruby" + s.description = <<-EOS.strip +Arel is a Relational Algebra for Ruby. It 1) simplifies the generation complex of SQL queries and it 2) adapts to various RDBMS systems. It is intended to be a framework framework; that is, you can build your own ORM with it, focusing on innovative object and collection modeling as opposed to database compatibility -and query generation.} - s.email = %q{bryan@brynary.com} - s.extra_rdoc_files = [ - "History.txt", - "README.markdown" - ] - s.files = [ - ".gitignore", - ".gitmodules", - "History.txt", - "README.markdown", - "Rakefile", - "Thorfile", - "arel.gemspec", - "doc/CONVENTIONS", - "doc/TODO", - "lib/arel.rb", - "lib/arel/algebra.rb", - "lib/arel/algebra/attribute.rb", - "lib/arel/algebra/core_extensions.rb", - "lib/arel/algebra/core_extensions/class.rb", - "lib/arel/algebra/core_extensions/hash.rb", - "lib/arel/algebra/core_extensions/object.rb", - "lib/arel/algebra/core_extensions/symbol.rb", - "lib/arel/algebra/expression.rb", - "lib/arel/algebra/ordering.rb", - "lib/arel/algebra/predicates.rb", - "lib/arel/algebra/relations.rb", - "lib/arel/algebra/relations/operations/alias.rb", - "lib/arel/algebra/relations/operations/from.rb", - "lib/arel/algebra/relations/operations/group.rb", - "lib/arel/algebra/relations/operations/having.rb", - "lib/arel/algebra/relations/operations/join.rb", - "lib/arel/algebra/relations/operations/lock.rb", - "lib/arel/algebra/relations/operations/order.rb", - "lib/arel/algebra/relations/operations/project.rb", - "lib/arel/algebra/relations/operations/skip.rb", - "lib/arel/algebra/relations/operations/take.rb", - "lib/arel/algebra/relations/operations/where.rb", - "lib/arel/algebra/relations/relation.rb", - "lib/arel/algebra/relations/row.rb", - "lib/arel/algebra/relations/utilities/compound.rb", - "lib/arel/algebra/relations/utilities/externalization.rb", - "lib/arel/algebra/relations/utilities/nil.rb", - "lib/arel/algebra/relations/writes.rb", - "lib/arel/algebra/value.rb", - "lib/arel/engines.rb", - "lib/arel/engines/memory.rb", - "lib/arel/engines/memory/engine.rb", - "lib/arel/engines/memory/predicates.rb", - "lib/arel/engines/memory/primitives.rb", - "lib/arel/engines/memory/relations.rb", - "lib/arel/engines/memory/relations/array.rb", - "lib/arel/engines/memory/relations/compound.rb", - "lib/arel/engines/memory/relations/operations.rb", - "lib/arel/engines/memory/relations/writes.rb", - "lib/arel/engines/sql.rb", - "lib/arel/engines/sql/christener.rb", - "lib/arel/engines/sql/compilers/ibm_db_compiler.rb", - "lib/arel/engines/sql/compilers/mysql_compiler.rb", - "lib/arel/engines/sql/compilers/oracle_compiler.rb", - "lib/arel/engines/sql/compilers/postgresql_compiler.rb", - "lib/arel/engines/sql/compilers/sqlite_compiler.rb", - "lib/arel/engines/sql/core_extensions.rb", - "lib/arel/engines/sql/core_extensions/array.rb", - "lib/arel/engines/sql/core_extensions/nil_class.rb", - "lib/arel/engines/sql/core_extensions/object.rb", - "lib/arel/engines/sql/core_extensions/range.rb", - "lib/arel/engines/sql/engine.rb", - "lib/arel/engines/sql/formatters.rb", - "lib/arel/engines/sql/predicates.rb", - "lib/arel/engines/sql/primitives.rb", - "lib/arel/engines/sql/relations.rb", - "lib/arel/engines/sql/relations/compiler.rb", - "lib/arel/engines/sql/relations/operations/alias.rb", - "lib/arel/engines/sql/relations/operations/join.rb", - "lib/arel/engines/sql/relations/relation.rb", - "lib/arel/engines/sql/relations/table.rb", - "lib/arel/engines/sql/relations/utilities/compound.rb", - "lib/arel/engines/sql/relations/utilities/externalization.rb", - "lib/arel/engines/sql/relations/utilities/nil.rb", - "lib/arel/engines/sql/relations/utilities/recursion.rb", - "lib/arel/engines/sql/relations/writes.rb", - "lib/arel/session.rb", - "spec/arel/algebra/unit/predicates/binary_spec.rb", - "spec/arel/algebra/unit/predicates/equality_spec.rb", - "spec/arel/algebra/unit/predicates/in_spec.rb", - "spec/arel/algebra/unit/primitives/attribute_spec.rb", - "spec/arel/algebra/unit/primitives/expression_spec.rb", - "spec/arel/algebra/unit/primitives/value_spec.rb", - "spec/arel/algebra/unit/relations/alias_spec.rb", - "spec/arel/algebra/unit/relations/delete_spec.rb", - "spec/arel/algebra/unit/relations/group_spec.rb", - "spec/arel/algebra/unit/relations/insert_spec.rb", - "spec/arel/algebra/unit/relations/join_spec.rb", - "spec/arel/algebra/unit/relations/order_spec.rb", - "spec/arel/algebra/unit/relations/project_spec.rb", - "spec/arel/algebra/unit/relations/relation_spec.rb", - "spec/arel/algebra/unit/relations/skip_spec.rb", - "spec/arel/algebra/unit/relations/table_spec.rb", - "spec/arel/algebra/unit/relations/take_spec.rb", - "spec/arel/algebra/unit/relations/update_spec.rb", - "spec/arel/algebra/unit/relations/where_spec.rb", - "spec/arel/algebra/unit/session/session_spec.rb", - "spec/arel/engines/memory/integration/joins/cross_engine_spec.rb", - "spec/arel/engines/memory/unit/relations/array_spec.rb", - "spec/arel/engines/memory/unit/relations/insert_spec.rb", - "spec/arel/engines/memory/unit/relations/join_spec.rb", - "spec/arel/engines/memory/unit/relations/order_spec.rb", - "spec/arel/engines/memory/unit/relations/project_spec.rb", - "spec/arel/engines/memory/unit/relations/skip_spec.rb", - "spec/arel/engines/memory/unit/relations/take_spec.rb", - "spec/arel/engines/memory/unit/relations/where_spec.rb", - "spec/arel/engines/sql/integration/joins/with_adjacency_spec.rb", - "spec/arel/engines/sql/integration/joins/with_aggregations_spec.rb", - "spec/arel/engines/sql/integration/joins/with_compounds_spec.rb", - "spec/arel/engines/sql/unit/engine_spec.rb", - "spec/arel/engines/sql/unit/predicates/binary_spec.rb", - "spec/arel/engines/sql/unit/predicates/equality_spec.rb", - "spec/arel/engines/sql/unit/predicates/in_spec.rb", - "spec/arel/engines/sql/unit/predicates/predicates_spec.rb", - "spec/arel/engines/sql/unit/primitives/attribute_spec.rb", - "spec/arel/engines/sql/unit/primitives/expression_spec.rb", - "spec/arel/engines/sql/unit/primitives/literal_spec.rb", - "spec/arel/engines/sql/unit/primitives/value_spec.rb", - "spec/arel/engines/sql/unit/relations/alias_spec.rb", - "spec/arel/engines/sql/unit/relations/delete_spec.rb", - "spec/arel/engines/sql/unit/relations/from_spec.rb", - "spec/arel/engines/sql/unit/relations/group_spec.rb", - "spec/arel/engines/sql/unit/relations/having_spec.rb", - "spec/arel/engines/sql/unit/relations/insert_spec.rb", - "spec/arel/engines/sql/unit/relations/join_spec.rb", - "spec/arel/engines/sql/unit/relations/lock_spec.rb", - "spec/arel/engines/sql/unit/relations/order_spec.rb", - "spec/arel/engines/sql/unit/relations/project_spec.rb", - "spec/arel/engines/sql/unit/relations/skip_spec.rb", - "spec/arel/engines/sql/unit/relations/table_spec.rb", - "spec/arel/engines/sql/unit/relations/take_spec.rb", - "spec/arel/engines/sql/unit/relations/update_spec.rb", - "spec/arel/engines/sql/unit/relations/where_spec.rb", - "spec/connections/mysql_connection.rb", - "spec/connections/oracle_connection.rb", - "spec/connections/postgresql_connection.rb", - "spec/connections/sqlite3_connection.rb", - "spec/doubles/hash.rb", - "spec/matchers/be_like.rb", - "spec/matchers/disambiguate_attributes.rb", - "spec/matchers/hash_the_same_as.rb", - "spec/schemas/mysql_schema.rb", - "spec/schemas/oracle_schema.rb", - "spec/schemas/postgresql_schema.rb", - "spec/schemas/sqlite3_schema.rb", - "spec/spec.opts", - "spec/spec_helper.rb" - ] - s.homepage = %q{http://github.com/brynary/arel} - s.require_paths = ["lib"] - s.rubyforge_project = %q{arel} - s.rubygems_version = %q{1.3.6} - s.summary = %q{Arel is a relational algebra engine for Ruby} - s.test_files = [ - "spec/arel/algebra/unit/predicates/binary_spec.rb", - "spec/arel/algebra/unit/predicates/equality_spec.rb", - "spec/arel/algebra/unit/predicates/in_spec.rb", - "spec/arel/algebra/unit/primitives/attribute_spec.rb", - "spec/arel/algebra/unit/primitives/expression_spec.rb", - "spec/arel/algebra/unit/primitives/value_spec.rb", - "spec/arel/algebra/unit/relations/alias_spec.rb", - "spec/arel/algebra/unit/relations/delete_spec.rb", - "spec/arel/algebra/unit/relations/group_spec.rb", - "spec/arel/algebra/unit/relations/insert_spec.rb", - "spec/arel/algebra/unit/relations/join_spec.rb", - "spec/arel/algebra/unit/relations/order_spec.rb", - "spec/arel/algebra/unit/relations/project_spec.rb", - "spec/arel/algebra/unit/relations/relation_spec.rb", - "spec/arel/algebra/unit/relations/skip_spec.rb", - "spec/arel/algebra/unit/relations/table_spec.rb", - "spec/arel/algebra/unit/relations/take_spec.rb", - "spec/arel/algebra/unit/relations/update_spec.rb", - "spec/arel/algebra/unit/relations/where_spec.rb", - "spec/arel/algebra/unit/session/session_spec.rb", - "spec/arel/engines/memory/integration/joins/cross_engine_spec.rb", - "spec/arel/engines/memory/unit/relations/array_spec.rb", - "spec/arel/engines/memory/unit/relations/insert_spec.rb", - "spec/arel/engines/memory/unit/relations/join_spec.rb", - "spec/arel/engines/memory/unit/relations/order_spec.rb", - "spec/arel/engines/memory/unit/relations/project_spec.rb", - "spec/arel/engines/memory/unit/relations/skip_spec.rb", - "spec/arel/engines/memory/unit/relations/take_spec.rb", - "spec/arel/engines/memory/unit/relations/where_spec.rb", - "spec/arel/engines/sql/integration/joins/with_adjacency_spec.rb", - "spec/arel/engines/sql/integration/joins/with_aggregations_spec.rb", - "spec/arel/engines/sql/integration/joins/with_compounds_spec.rb", - "spec/arel/engines/sql/unit/engine_spec.rb", - "spec/arel/engines/sql/unit/predicates/binary_spec.rb", - "spec/arel/engines/sql/unit/predicates/equality_spec.rb", - "spec/arel/engines/sql/unit/predicates/in_spec.rb", - "spec/arel/engines/sql/unit/predicates/predicates_spec.rb", - "spec/arel/engines/sql/unit/primitives/attribute_spec.rb", - "spec/arel/engines/sql/unit/primitives/expression_spec.rb", - "spec/arel/engines/sql/unit/primitives/literal_spec.rb", - "spec/arel/engines/sql/unit/primitives/value_spec.rb", - "spec/arel/engines/sql/unit/relations/alias_spec.rb", - "spec/arel/engines/sql/unit/relations/delete_spec.rb", - "spec/arel/engines/sql/unit/relations/from_spec.rb", - "spec/arel/engines/sql/unit/relations/group_spec.rb", - "spec/arel/engines/sql/unit/relations/having_spec.rb", - "spec/arel/engines/sql/unit/relations/insert_spec.rb", - "spec/arel/engines/sql/unit/relations/join_spec.rb", - "spec/arel/engines/sql/unit/relations/lock_spec.rb", - "spec/arel/engines/sql/unit/relations/order_spec.rb", - "spec/arel/engines/sql/unit/relations/project_spec.rb", - "spec/arel/engines/sql/unit/relations/skip_spec.rb", - "spec/arel/engines/sql/unit/relations/table_spec.rb", - "spec/arel/engines/sql/unit/relations/take_spec.rb", - "spec/arel/engines/sql/unit/relations/update_spec.rb", - "spec/arel/engines/sql/unit/relations/where_spec.rb", - "spec/connections/mysql_connection.rb", - "spec/connections/oracle_connection.rb", - "spec/connections/postgresql_connection.rb", - "spec/connections/sqlite3_connection.rb", - "spec/doubles/hash.rb", - "spec/matchers/be_like.rb", - "spec/matchers/disambiguate_attributes.rb", - "spec/matchers/hash_the_same_as.rb", - "spec/schemas/mysql_schema.rb", - "spec/schemas/oracle_schema.rb", - "spec/schemas/postgresql_schema.rb", - "spec/schemas/sqlite3_schema.rb", - "spec/spec_helper.rb" - ] +and query generation. + EOS + s.rubyforge_project = "arel" + + s.files = Dir['lib/**/*'] + s.test_files = Dir['spec/**/*.rb'] - Dir['spec/support/fixtures/**/*.rb'] - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 3 + s.has_rdoc = true + s.extra_rdoc_files = %w[History.txt README.markdown] - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q<activesupport>, [">= 3.0.0.beta"]) - else - s.add_dependency(%q<activesupport>, [">= 3.0.0.beta"]) - end - else - s.add_dependency(%q<activesupport>, [">= 3.0.0.beta"]) - end -end + # Arel required ActiveRecord, but we're not declaring it to avoid a + # circular dependency chain. The solution is for ActiveRecord to release + # the connection adapters which Arel uses in a separate gem + # s.add_dependency "activerecord", ">= 3.0.pre" + s.add_dependency "activesupport", ">= 3.0.0.beta" +end
\ No newline at end of file diff --git a/lib/arel.rb b/lib/arel.rb index ef2308ca53..ae4240bf8a 100644 --- a/lib/arel.rb +++ b/lib/arel.rb @@ -6,7 +6,7 @@ require 'active_support/core_ext/object/blank' module Arel require 'arel/algebra' require 'arel/engines' - autoload :Session, 'arel/session' + require 'arel/version' - VERSION = "0.3.1" + autoload :Session, 'arel/session' end diff --git a/lib/arel/version.rb b/lib/arel/version.rb new file mode 100644 index 0000000000..ab126caff4 --- /dev/null +++ b/lib/arel/version.rb @@ -0,0 +1,3 @@ +module Arel + VERSION = "0.3.1" +end
\ No newline at end of file |