forked from arbox/wlapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
132 lines (111 loc) · 2.92 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
124
125
126
127
128
129
130
131
132
# -*- mode: ruby; -*-
lib_path = File.expand_path(File.join(File.dirname(__FILE__), 'lib'))
$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
require 'yaml'
require 'wlapi/version'
require 'time'
# Rake provides FileUtils and its own FileUtils extensions
require 'rake'
require 'rake/clean'
CLEAN.include('.*~')
CLOBBER.include('ydoc',
'rdoc',
'.yardoc',
'*.gem')
# Generate documentation.
require 'rdoc/task'
RDoc::Task.new do |rdoc|
rdoc.rdoc_files.include('README.rdoc',
'LICENSE.rdoc',
'CHANGELOG.md',
'lib/**/*'
)
rdoc.rdoc_dir = 'rdoc'
end
require 'yard'
YARD::Rake::YardocTask.new do |ydoc|
ydoc.options += ['-o', 'ydoc']
ydoc.name = 'ydoc'
end
# Testing.
# require 'rake/testtask'
# Rake::TestTask.new do |t|
# t.libs << 'test'
# t.warning
# t.ruby_opts = ['-rubygems']
# t.test_files = FileList['test/*.rb']
# end
namespace :test do
interpreter = 'ruby -rubygems -I lib -I test'
task :local do
sh "#{interpreter} test/local_*"
end
task :remote do
sh "#{interpreter} test/remote_*"
end
task all: [:local, :remote]
end
desc 'Open an irb session preloaded with this library.'
task :irb do
require 'irb'
require 'irb/completion'
require 'wlapi'
ARGV.clear
IRB.start
end
desc 'Open a Pry session in the context of this library.'
task :pry do
require 'pry'
require 'wlapi'
ARGV.clear
Pry.start
end
desc 'Show the current version.'
task :v do
puts WLAPI::VERSION
end
desc 'Document the code using Yard and RDoc.'
task doc: [:clobber, :rdoc, :ydoc]
desc 'Release the library.'
task release: [:tag, :build, :publish] do
sh "bundle exec gem push wlapi-#{WLAPI::VERSION}.gem"
end
desc 'Tag the current source code version.'
task :tag do
# cb = current branch
cb = `git branch`.split("\n").delete_if { |i| i !~ /[*]/ }
cb = cb.first.sub('* ', '')
if cb == 'master'
system "git tag 'v#{WLAPI::VERSION}'"
else
STDERR.puts "We are on branch #{cb}. Please switch to master branch."
end
end
desc 'Builds the .gem package.'
task :build do
sh 'bundle exec gem build wlapi.gemspec'
end
desc 'Publish the documentation on the homepage.'
task publish: [:clobber, :doc] do
system "scp -r ydoc/* #{YAML.load_file('SENSITIVE')['url']}"
end
task :travis do
sh 'git pull'
message = "#{Time.now}\t#{WLAPI::VERSION}\n"
File.open('.gem-version', 'w') do |file|
file.write(message)
end
sh 'git add .gem-version'
sh "git commit -m '#{message.chomp}'"
sh 'git push origin master'
end
require 'digest/sha2'
task :checksum do
built_gem_path = "wlapi-#{WLAPI::VERSION}.gem"
checksum = Digest::SHA512.new.hexdigest(File.read(built_gem_path))
checksum_path = "checksum/wlapi-#{WLAPI::VERSION}.gem.sha512"
File.open(checksum_path, 'w') do |f|
f.write(checksum + ' ' + built_gem_path)
end
end
task default: 'test:all'