-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathRakefile
More file actions
117 lines (98 loc) · 2.78 KB
/
Rakefile
File metadata and controls
117 lines (98 loc) · 2.78 KB
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
# Automate serpapi ruby gem end to end
#
# rake --task
#
# main targets:
#
# rake dependency # to install dependency
# rake oobt # pre
#
require 'rake'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'yard'
require_relative 'lib/serpapi'
desc "run out of box testing using the local gem file pre-release"
task oobt: %i[check readme doc build install demo]
desc "execute all the steps except release"
task default: %i[check dependency version readme doc build test oobt]
desc "update README.md from the template"
task readme: ['README.md.erb'] do
`erb -T '-' README.md.erb > README.md`
end
YARD::Rake::YardocTask.new(:doc) do |t|
t.files = ['lib/*/*.rb', 'LICENSE']
t.options = ['--markup=markdown']
t.stats_options = ['--list-undoc']
end
desc 'validate core client spec files'
RSpec::Core::RakeTask.new(:test) do |t|
t.pattern = Dir.glob('spec/serpapi/client/*_spec.rb') + Dir.glob('spec/serpapi/*_spec.rb')
t.rspec_opts = '--format documentation'
end
desc 'run tests under spec/serpapi/client/ with coverage'
RSpec::Core::RakeTask.new(:coverage) do |t|
t.pattern = Dir.glob('spec/serpapi/client/*_spec.rb')
t.rspec_opts = '--format documentation'
end
desc 'validate all the examples (comprehensive set of tests)'
RSpec::Core::RakeTask.new(:regression) do |t|
t.pattern = Dir.glob('spec/serpapi/client/example/*_spec.rb')
t.rspec_opts = '--format documentation'
end
desc 'run benchmark tests'
RSpec::Core::RakeTask.new(:benchmark) do |t|
t.pattern = Dir.glob('spec/serpapi/client/benchmark/*_spec.rb')
t.rspec_opts = '--format documentation'
end
RuboCop::RakeTask.new(:lint) do |t|
t.options = ['--display-cop-names']
end
desc "format ruby code using rubocop"
task :format do
sh('rubocop --auto-correct')
end
desc 'install project dependencies'
task :dependency do
sh 'bundle install'
end
desc 'build serpapi library as a gem'
task :build do
sh 'gem build serpapi'
end
desc 'install serpapi library locally from the .gem'
task :install do
sh "gem install ./serpapi-#{SerpApi::VERSION}.gem"
end
desc 'run demo example'
task :demo do
Dir.glob('demo/*.rb').each do |file|
puts "running demo: #{file}"
sh "ruby #{file}"
end
end
desc 'release the gem to the public rubygems.org'
task release: [:oobt] do
sh 'gem push `ls -t1 *.gem | head -1`'
puts 'release public on: https://rubygems.org/gems/serpapi/versions'
end
# private
task :check do
if ENV['SERPAPI_KEY']
puts 'check: found $SERPAPI_KEY'
else
puts 'check: SERPAPI_KEY must be defined'
exit 1
end
end
desc 'print current version'
task :version do
puts 'current version: ' + SerpApi::VERSION
end
desc 'create a tag'
task :tag do
version = SerpApi::VERSION
puts "create git tag #{version}"
sh "git tag #{version}"
puts "now publish the tag:\n$ git push origin #{version}"
end