Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 124 lines (102 sloc) 3.685 kb
7ba3758 Bryan Helmkamp Release v0.2.0
brynary authored
1 require "active_support"
2
efc167d Bryan Helmkamp Dropping Jeweler in favor of some simple Thor tasks (for Gemcutter)
brynary authored
3 module GemHelpers
4
5 def generate_gemspec
19d7ee3 Bryan Helmkamp Need to add Rails components to $LOAD_PATH to require "arel" reliably
brynary authored
6 $LOAD_PATH << "#{File.dirname(__FILE__)}/vendor/rails/activerecord/lib"
7 $LOAD_PATH << "#{File.dirname(__FILE__)}/vendor/rails/activesupport/lib"
8
efc167d Bryan Helmkamp Dropping Jeweler in favor of some simple Thor tasks (for Gemcutter)
brynary authored
9 $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), "lib")))
10 require "arel"
11
12 Gem::Specification.new do |s|
13 s.name = "arel"
14 s.version = Arel::VERSION
15 s.authors = ["Bryan Helmkamp", "Nick Kallen"]
16 s.email = "bryan@brynary.com"
17 s.homepage = "http://github.com/brynary/arel"
18 s.summary = "Arel is a relational algebra engine for Ruby"
19 s.description = <<-EOS.strip
20 Arel is a Relational Algebra for Ruby. It 1) simplifies the generation complex
21 of SQL queries and it 2) adapts to various RDBMS systems. It is intended to be
22 a framework framework; that is, you can build your own ORM with it, focusing on
23 innovative object and collection modeling as opposed to database compatibility
24 and query generation.
25 EOS
26 s.rubyforge_project = "arel"
27
28 require "git"
29 repo = Git.open(".")
30
31 s.files = normalize_files(repo.ls_files.keys - repo.lib.ignored_files)
32 s.test_files = normalize_files(Dir['spec/**/*.rb'] - repo.lib.ignored_files)
33
34 s.has_rdoc = true
3dbdaa3 Bryan Helmkamp Add History.txt to RDoc
brynary authored
35 s.extra_rdoc_files = %w[History.txt README.markdown]
efc167d Bryan Helmkamp Dropping Jeweler in favor of some simple Thor tasks (for Gemcutter)
brynary authored
36
42aa39b Bryan Helmkamp Don't declare ActiveRecord gem dependency for now
brynary authored
37 # Arel required ActiveRecord, but we're not declaring it to avoid a
38 # circular dependency chain. The solution is for ActiveRecord to release
39 # the connection adapters which Arel uses in a separate gem
a923cf7 Bryan Helmkamp Correct version number for prerelease Rails components. Note the additio...
brynary authored
40 # s.add_dependency "activerecord", ">= 3.0.pre"
41 s.add_dependency "activesupport", ">= 3.0.pre"
efc167d Bryan Helmkamp Dropping Jeweler in favor of some simple Thor tasks (for Gemcutter)
brynary authored
42 end
43 end
44
45 def normalize_files(array)
46 # only keep files, no directories, and sort
47 array.select do |path|
48 File.file?(path)
49 end.sort
50 end
51
52 # Adds extra space when outputting an array. This helps create better version
53 # control diffs, because otherwise it is all on the same line.
54 def prettyify_array(gemspec_ruby, array_name)
55 gemspec_ruby.gsub(/s\.#{array_name.to_s} = \[.+?\]/) do |match|
56 leadin, files = match[0..-2].split("[")
57 leadin + "[\n #{files.split(",").join(",\n ")}\n ]"
58 end
59 end
60
61 def read_gemspec
62 @read_gemspec ||= eval(File.read("arel.gemspec"))
63 end
64
65 def sh(command)
66 puts command
67 system command
68 end
69 end
70
71 class Default < Thor
72 include GemHelpers
73
74 desc "gemspec", "Regenerate arel.gemspec"
75 def gemspec
76 File.open("arel.gemspec", "w") do |file|
77 gemspec_ruby = generate_gemspec.to_ruby
78 gemspec_ruby = prettyify_array(gemspec_ruby, :files)
79 gemspec_ruby = prettyify_array(gemspec_ruby, :test_files)
80 gemspec_ruby = prettyify_array(gemspec_ruby, :extra_rdoc_files)
81
82 file.write gemspec_ruby
83 end
84
85 puts "Wrote gemspec to arel.gemspec"
86 read_gemspec.validate
87 end
88
89 desc "build", "Build a arel gem"
90 def build
91 sh "gem build arel.gemspec"
92 FileUtils.mkdir_p "pkg"
93 FileUtils.mv read_gemspec.file_name, "pkg"
94 end
95
96 desc "install", "Install the latest built gem"
97 def install
98 sh "gem install --local pkg/#{read_gemspec.file_name}"
99 end
100
101 desc "release", "Release the current branch to GitHub and Gemcutter"
102 def release
103 gemspec
104 build
105 Release.new.tag
106 Release.new.gem
107 end
108 end
109
110 class Release < Thor
111 include GemHelpers
112
113 desc "tag", "Tag the gem on the origin server"
114 def tag
115 release_tag = "v#{read_gemspec.version}"
116 sh "git tag -a #{release_tag} -m 'Tagging #{release_tag}'"
117 sh "git push origin #{release_tag}"
118 end
119
120 desc "gem", "Push the gem to Gemcutter"
121 def gem
122 sh "gem push pkg/#{read_gemspec.file_name}"
123 end
124 end
Something went wrong with that request. Please try again.