-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
82 lines (73 loc) · 1.88 KB
/
Rakefile
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
# encoding: utf-8
task :clean do
%w(
dev.sqlite3
test/dev.sqlite3
pkg
doc
rdoc
coverage
gem_graph.png
).each do |path|
rm_rf path, verbose: false
end
end
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
Bundler::GemHelper.install_tasks
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts 'Run `bundle install` to install missing gems'
exit e.status_code
end
require 'rake'
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib'
test.test_files = ['test/test_convertlabsdk.rb']
test.verbose = true
end
desc 'Code coverage detail'
task :simplecov do
ENV['COVERAGE'] = 'true'
Rake::Task['test'].execute
end
require 'rubocop/rake_task'
desc 'Run RuboCop on the lib and test directory'
RuboCop::RakeTask.new(:rubocop) do |task|
task.patterns = ['lib/**/*.rb', 'test/**/*.rb']
# only show the files with failures
# task.formatters = ['files']
# don't abort rake on failure
task.fail_on_error = false
end
# credit goes to https://gist.github.com/schickling/6762581
require 'active_record'
require 'convertlabsdk'
require 'yaml'
namespace :db do
desc 'Migrate the database'
task :migrate do
ConvertLab.database_yml = 'config/database.yml'
ConvertLab.establish_connection
ActiveRecord::Migrator.migrate('db/migrate/')
Rake::Task['db:schema'].invoke
puts 'Database migrated.'
end
desc 'Create a db/schema.rb file that is portable against any DB supported by AR'
task :schema do
ConvertLab.database_yml = 'config/database.yml'
ConvertLab.establish_connection
require 'active_record/schema_dumper'
filename = 'db/schema.rb'
File.open(filename, 'w:utf-8') do |file|
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
end
end
end
require 'yard'
YARD::Rake::YardocTask.new do |t|
end
task default: :test