forked from binford2k/showoff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
115 lines (93 loc) · 2.61 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
require 'fileutils'
task :default do
system("rake -T")
end
def version
`git describe --tags --abbrev=0`.chomp.sub('v','')
end
def next_version(type = :patch)
section = [:major,:minor,:patch].index type
n = version.split '.'
n[section] = n[section].to_i + 1
n.join '.'
end
desc "Build Docker image"
task 'docker' do
Dir.chdir('build') do
system("docker build --no-cache=true -t binford2k/showoff:#{version} -t binford2k/showoff:latest .")
end
puts
puts 'Start container with: docker run -p 9090:9090 binford2k/showoff'
end
desc "Upload image to Docker Hub"
task 'docker:push' => ['docker'] do
system("docker push binford2k/showoff:#{version}")
system("docker push binford2k/showoff:latest")
end
desc "Build HTML documentation"
task :doc do
FileUtils.rm_rf('doc')
Dir.chdir('documentation') do
system("rdoc --main -HOME.rdoc /*.rdoc --op ../doc")
end
end
desc "Update docs for webpage"
task 'doc:website' => [:doc] do
if system('git checkout gh-pages')
FileUtils.rm_rf('documentation')
FileUtils.mv('doc', 'documentation')
system('git add documentation')
system('git commit -m "updating docs"')
system('git checkout -')
puts "Publish updates by pushing to Github:"
puts
puts " git push upstream gh-pages"
puts
end
end
desc "Run tests"
task :test do
require 'rake/testtask'
Rake::TestTask.new do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
suffix = "-n #{ENV['TEST']}" if ENV['TEST']
sh "turn test/*_test.rb #{suffix}"
end
desc 'Validate translation files'
task 'lang:check' do
require 'yaml'
def compare_keys(left, right, name, stack=nil)
left.each do |key, val|
inner = stack.nil? ? key : "#{stack}.#{key}"
compare = right[key]
case compare
when Hash
compare_keys(val, compare, name, inner)
when String
next
when NilClass
puts "Error: '#{inner}' is missing from #{name}"
else
puts "Error: '#{inner}' in #{name} is a #{compare.class}, not a Hash"
end
end
end
canonical = YAML.load_file('locales/en.yml')
languages = Dir.glob('locales/*.yml').reject {|lang| lang == 'locales/en.yml' }
languages.each do |langfile|
lang = YAML.load_file(langfile)
code = File.basename(langfile, '.yml')
key = lang.keys.first
puts "Error: #{langfile} has the wrong language code (#{key})" unless code == key
compare_keys(canonical['en'], lang[key], langfile)
end
end
begin
require 'mg'
MG.new("showoff.gemspec")
rescue LoadError
puts "'gem install mg' to get helper gem publishing tasks. (optional)"
end