1+ # Automate serpapi ruby gem end to end
2+ #
3+ # rake --task
4+ #
5+ # main targets:
6+ #
7+ # rake dependency # to install dependency
8+ # rake oobt # pre
9+ #
10+
111require 'rake'
212require 'rspec/core/rake_task'
313require 'rubocop/rake_task'
414require 'yard'
515require_relative 'lib/serpapi'
616
7- task :check do
8- if ENV [ 'API_KEY' ]
9- puts 'check: found $API_KEY'
10- else
11- puts 'check: API_KEY must be defined'
12- exit 1
13- end
14- end
17+ desc "run out of box testing using the local gem file pre-release"
18+ task oobt : %i[ check readme doc check build install demo ]
1519
20+ desc "execute all the steps except release"
21+ task default : %i[ check dependency version readme doc build test oobt ]
22+
23+ desc "update README.md from the template"
1624task readme : [ 'README.md.erb' ] do
1725 `erb -T '-' README.md.erb > README.md`
1826end
@@ -32,45 +40,56 @@ RuboCop::RakeTask.new(:lint) do |t|
3240 t . options = [ '--display-cop-names' ]
3341end
3442
43+ desc "format ruby code using rubocop"
44+ task :format do
45+ sh ( 'rubocop --auto-correct' )
46+ end
47+
48+ desc 'install project dependencies'
3549task :dependency do
3650 sh 'bundle install'
3751end
3852
53+ desc 'build serpapi library as a gem'
3954task :build do
4055 sh 'gem build serpapi'
4156end
4257
58+ desc 'install serpapi library from the .gem'
4359task :install do
4460 sh "gem install ./serpapi-#{ SerpApi ::VERSION } .gem"
4561end
4662
63+ desc 'run demo example'
4764task :demo do
4865 sh 'ruby oobt/demo.rb'
4966end
5067
68+ desc 'release the gem to the public rubygems.org'
69+ task release : [ :oobt ] do
70+ sh 'gem push `ls -t1 *.gem | head -1`'
71+ puts 'release public on: https://rubygems.org/gems/serpapi/versions'
72+ end
73+
74+ # private
75+ task :check do
76+ if ENV [ 'API_KEY' ]
77+ puts 'check: found $API_KEY'
78+ else
79+ puts 'check: API_KEY must be defined'
80+ exit 1
81+ end
82+ end
83+
84+ desc 'print current version'
5185task :version do
5286 puts 'current version: ' + SerpApi ::VERSION
5387end
5488
89+ desc 'create a tag'
5590task :tag do
5691 version = SerpApi ::VERSION
5792 puts "create git tag #{ version } "
5893 sh "git tag #{ version } "
5994 puts "now publish the tag:\n $ git push origin #{ version } "
60- end
61-
62- task release : [ :oobt ] do
63- sh 'gem push `ls -t1 *.gem | head -1`'
64- puts 'release public on: https://rubygems.org/gems/serpapi/versions'
65- end
66-
67- desc "run out of box testing using the gem file"
68- task oobt : %i[ readme doc check build install demo ]
69-
70- desc "execute all the steps"
71- task default : %i[ dependency version readme doc build test oobt ]
72-
73- desc "format ruby code using rubocop"
74- task :format do
75- sh ( 'rubocop --auto-correct' )
7695end
0 commit comments