forked from agorf/thyme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
59 lines (47 loc) · 1.17 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
lib = File.expand_path('../lib', __FILE__)
$:.unshift(lib) if !$:.include?(lib)
require 'rake/clean'
require 'thyme/db'
require 'thyme/server'
require 'thyme/photo'
CLOBBER.include('index.db', Thyme::Server.thumbs_path)
task :upgrade_schema do
require 'data_mapper'
DataMapper.auto_upgrade!
end
task :make_thumbs_dir do
mkdir_p Thyme::Server.thumbs_path
end
desc 'Scan library for photos and build database'
task :scan, [:library_path] => [:upgrade_schema] do |t, args|
require 'thyme/set'
FileList[
File.join(
File.expand_path(args.library_path),
'**',
'*.{jpg,jpeg,JPG,JPEG}'
)
].each do |filename|
Thyme::Photo.create_from_file(filename)
end
Thyme::Set.each(&:update_taken_at!)
end
desc 'Generate photo thumbnails from database'
task generate_thumbs: [:upgrade_schema, :make_thumbs_dir] do
Thyme::Photo.each(&:generate_thumbs!)
end
desc 'Run application'
task :serve do
Thyme::Server.run!
end
task :rerun do
exec "bundle exec rerun 'bundle exec rake serve'"
end
desc 'Open application in browser'
task :open do
fork do
sleep 2
exec 'xdg-open http://localhost:4567/index.html'
end
Rake::Task['serve'].execute
end