forked from clbustos/buhos
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
123 lines (92 loc) · 2.95 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
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
# Buhos
# https://github.com/clbustos/buhos
# Copyright (c) 2016-2018, Claudio Bustos Navarrete
# All rights reserved.
# Licensed BSD 3-Clause License
# See LICENSE file for more information
require 'dotenv'
require 'logger'
require 'fileutils'
require 'rake'
require 'rspec/core'
require 'rspec/core/rake_task'
require 'yard'
require 'yard-sinatra'
Dotenv.load("./.env")
YARD::Rake::YardocTask.new do |t|
t.files = ['lib/**/*.rb', 'model/**/*.rb', 'controllers/**/*.rb', '-', 'docs/rspec.html', 'LICENSE'] # optional
t.options = ['--plugin yard-sinatra', '-odocs/api', '--embed-mixin'] # optional
t.stats_options = ['--list-undoc'] # optional
end
# USE NO_CROSSREF_MOCKUP=1 to test crossref services
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = Dir.glob('spec/**/*_spec.rb')
t.rspec_opts = '--format documentation'
# t.rspec_opts << ' more options'
#t.rcov = true
end
RSpec::Core::RakeTask.new(:spec_html) do |t|
t.pattern = Dir.glob('spec/**/*_spec.rb')
t.rspec_opts = '--format html '
t.rspec_opts << '--out docs/rspec.html '
#t.rcov = true
end
task :default => :spec
namespace :reflection do
desc "Show authorizations"
task :auth do |t|
require_relative 'lib/buhos/reflection'
app=Object.new
def app.dir_base
File.expand_path(File.dirname(__FILE__))
end
auth=Buhos::Reflection.get_authorizations(app)
puts "Authorizations"
puts "=============="
puts auth.permits.join("\n")
end
end
desc "Build .deb package"
task :build_deb do |t|
require 'tmpdir'
current_dir=File.expand_path(File.dirname(__FILE__))
puts current_dir
Dir.mktmpdir("buhos_pkgr") {|dir|
sh %{git clone ./ "#{dir}"}
sh %{rvmsudo pkgr package --name buhos "#{dir}"}
}
Dir.mkdir 'packages' unless Dir.exist? "packages"
Dir.glob("*.deb") do |f|
FileUtils.move f, "packages"
end
end
namespace :db do
desc "Run migrations"
task :migrate, [:version] do |t, args|
require "sequel"
require 'i18n'
locales_root=File.join(File.dirname(__FILE__),'config','locales', '*.yml')
::I18n.load_path+=Dir[locales_root]
#::I18n.locale=:en
require_relative 'lib/buhos/create_schema'
base_dir=File.dirname(__FILE__)
Sequel.extension :migration
db = Sequel.connect(ENV["DATABASE_URL"])
if args[:version]
puts "Migrating to version #{args[:version]}"
Sequel::Migrator.run(db, "#{base_dir}/db/migrations", target: args[:version].to_i)
else
puts "Migrating to latest"
Sequel::Migrator.run(db, "#{base_dir}/db/migrations")
Buhos::SchemaCreation.create_bootstrap_data(db)
end
end
desc "Update sqlite blank file"
task :blank_sqlite => "db/blank.sqlite"
file "db/blank.sqlite" => ["lib/buhos/create_schema.rb"] do
require_relative 'lib//buhos/create_schema'
log = Logger.new(STDOUT)
FileUtils.rm("db/blank.sqlite") if File.exist? "db/blank.sqlite"
Buhos::SchemaCreation.create_db_from_scratch("sqlite://db/blank.sqlite", "en",log)
end
end