Uh oh!
There was an error while loading. Please reload this page.
forked from ctran/annotate_models
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
Latest commit
204 lines (184 loc) · 6.96 KB
/
Copy pathRakefile
File metadata and controls
204 lines (184 loc) · 6.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
defexit_exception(e)
$stderr.putse.message
exite.status_code
end
# NOTE: this causes annoying psych warnings under Ruby 1.9.2-p180; to fix, upgrade to 1.9.3
begin
require'bundler'
Bundler.setup(:default,:development)
rescueBundler::BundlerError=>e
$stderr.puts'Run `bundle install` to install missing gems'
exit_exception(e)
end
using_dsl=false
begin
require'rake/dsl_definition'
using_dsl=true
rescueException=>e
# We might just be on an old version of Rake...
exit_exception(e)
end
require'rake'
includeRake::DSLifusing_dsl
require'./lib/annotate'
require'mg'
begin
MG.new('annotate.gemspec')
rescueException
$stderr.puts("WARNING: Couldn't read gemspec. As such, a number of tasks may be unavailable to you until you run 'rake gem:gemspec' to correct the issue.")
# Gemspec is probably in a broken state, so let's give ourselves a chance to
# build a new one...
end
DEVELOPMENT_GROUPS=[:development,:test].freeze
RUNTIME_GROUPS=Bundler.definition.groups - DEVELOPMENT_GROUPS
namespace:gemdo
task:gemspecdo
spec=Gem::Specification.newdo |gem|
# See http://docs.rubygems.org/read/chapter/20
# for more options.
gem.version=Annotate.version
gem.name='annotate'
gem.homepage='http://github.com/ctran/annotate_models'
gem.rubyforge_project='annotate'
gem.license='Ruby'
gem.summary='Annotates Rails Models, routes, fixtures, and others based on the database schema.'
gem.description='Annotates Rails/ActiveRecord Models, routes, fixtures, and others based on the database schema.'
gem.email=['alex@stinky.com','cuong@gmail.com','x@nofxx.com','turadg@aleahmad.net','jon@cloudability.com']
gem.authors=['Alex Chaffee','Cuong Tran','Marcos Piccinini','Turadg Aleahmad','Jon Frisby']
gem.require_paths=['lib']
# gem.rdoc_options = ["--charset=UTF-8"]
# gem.required_ruby_version = "> 1.9.2"
Bundler.load.dependencies_for(*RUNTIME_GROUPS).eachdo |dep|
runtime_resolved=Bundler.definition.specs_for(RUNTIME_GROUPS).find{ |spec| spec.name == dep.name}
unlessruntime_resolved.nil?
gem.add_dependency(dep.name,dep.requirement)
end
end
gem.executables=`git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f)}
gem.extra_rdoc_files=['README.md','CHANGELOG.md','TODO.md']
gem.files=`git ls-files -- .`.split("\n").rejectdo |fn|
fn =~ /^Gemfile.*/ ||
fn =~ /^Rakefile/ ||
fn =~ /^\.rvmrc/ ||
fn =~ /^\.gitignore/ ||
fn =~ /^\.rspec/ ||
fn =~ /^\.document/ ||
fn =~ /^\.yardopts/ ||
fn =~ /^pkg/ ||
fn =~ /^spec/ ||
fn =~ /^doc/ ||
fn =~ /^vendor\/cache/
end.sort
end
File.open('annotate.gemspec','wb')do |fh|
fh.write("# This file is auto-generated!\n")
fh.write("# DO NOT EDIT THIS FILE DIRECTLY!\n")
fh.write("# Instead, edit the Rakefile and run 'rake gems:gemspec'.")
fh.write(spec.to_ruby)
end
end
end
namespace:jewelerdo
task:clobberdo
FileUtils.rm_f('pkg')
end
end
taskclobber: :'jeweler:clobber'
require'rspec/core/rake_task'# RSpec 2.0
RSpec::Core::RakeTask.new(:spec)do |t|
t.pattern=['spec/*_spec.rb','spec/**/*_spec.rb']
t.rspec_opts=['--backtrace','--format d']
end
# Placeholder for running bin/* in development...
task:environment
task:integration_environmentdo
require'./spec/spec_helper'
end
namespace:gemsetsdo
desc"Completely empty any gemsets used by scenarios, so they'll be perfectly clean on the next run."
taskempty: [:integration_environment]do
Annotate::Integration::SCENARIOS.eachdo |test_rig,_base_dir,_test_name|
Annotate::Integration.empty_gemset(test_rig)
end
end
end
taskclobber: :'gemsets:empty'
namespace:integrationdo
desc"Remove any cruft generated by manual debugging runs which is .gitignore'd."
taskclean: :integration_environmentdo
Annotate::Integration.nuke_all_cruft
end
desc'Reset any changed files, and remove any untracked files in spec/integration/*/, plus run integration:clean.'
taskclobber: [:integration_environment,:'integration:clean']do
Annotate::Integration.reset_dirty_files
Annotate::Integration.clear_untracked_files
end
tasksymlink: [:integration_environment]do
require'digest/md5'
integration_dir=File.expand_path(File.join(File.dirname(__FILE__),'spec','integration'))
# fixture_dir = File.expand_path(File.join(File.dirname(__FILE__), 'spec', 'fixtures'))
target_dir=File.expand_path(ENV['TARGET'])ifENV['TARGET']
raise'Must specify TARGET=x, where x is an integration test scenario!'unlesstarget_dir && Dir.exist?(target_dir)
raise'TARGET directory must be within spec/integration/!'unlesstarget_dir.start_with?(integration_dir)
candidates={}
FileList[
"#{target_dir}/.rvmrc",
"#{target_dir}/**/*"
].select{ |fname| !(File.symlink?(fname) || File.directory?(fname))}
.map{ |fname| fname.sub(integration_dir,'')}
.rejectdo |fname|
fname =~ /\/\.gitkeep$/ ||
fname =~ /\/app\/models\// ||
fname =~ /\/routes\.rb$/ ||
fname =~ /\/fixtures\// ||
fname =~ /\/factories\// ||
fname =~ /\.sqlite3$/ ||
(fname =~ /\/test\// && fname !~ /_helper\.rb$/) ||
(fname =~ /\/spec\// && fname !~ /_helper\.rb$/)
end
.map{ |fname| "#{integration_dir}#{fname}"}
.eachdo |fname|
digest=Digest::MD5.hexdigest(File.read(fname))
candidates[digest] ||= []
candidates[digest] << fname
end
fixtures={}
FileList['spec/fixtures/**/*'].eachdo |fname|
fixtures[Digest::MD5.hexdigest(File.read(fname))]=File.expand_path(fname)
end
candidates.each_keydo |digest|
nextunlessfixtures.key?(digest)
candidates[digest].eachdo |fname|
# Double-check contents in case of hash collision...
nextunlessFileUtils.identical?(fname,fixtures[digest])
destination_dir=Pathname.new(File.dirname(fname))
relative_target=Pathname.new(fixtures[digest]).relative_path_from(destination_dir)
Dir.chdir(destination_dir)do
sh('ln','-sfn',relative_target.to_s,File.basename(fname))
end
end
end
end
end
taskclobber: :'integration:clobber'
require'yard'
YARD::Rake::YardocTask.newdo |t|
# t.files = ['features/**/*.feature', 'features/**/*.rb', 'lib/**/*.rb']
# t.options = ['--any', '--extra', '--opts'] # optional
end
namespace:yarddo
task:clobberdo
FileUtils.rm_f('.yardoc')
FileUtils.rm_f('doc')
end
end
taskclobber: :'yard:clobber'
namespace:rubiniusdo
task:clobberdo
FileList['**/*.rbc'].each{ |fname| FileUtils.rm_f(fname)}
FileList['.rbx/**/*'].each{ |fname| FileUtils.rm_f(fname)}
end
end
taskclobber: :'rubinius:clobber'
# want other tests/tasks run by default? Add them to the list
taskdefault: [:spec]