forked from zendesk/zendesk_api_client_rb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
57 lines (48 loc) · 1.72 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
require 'rake/testtask'
require 'bundler/gem_tasks'
require 'bump/tasks'
require 'rubocop/rake_task'
begin
require 'rspec/core/rake_task'
rescue LoadError
puts "WARN: #{$ERROR_INFO.message} Continuing..."
end
if defined?(RSpec)
desc "Run specs"
RSpec::Core::RakeTask.new("spec") do |t|
t.pattern = "spec/core/**/*_spec.rb"
end
desc "Run live specs"
RSpec::Core::RakeTask.new("spec:live") do |t|
t.pattern = "spec/live/**/*_spec.rb"
end
task :clean_live do
sh "rm -rf spec/fixtures/cassettes"
end
task :set_ci_credentials do
File.open("spec/fixtures/credentials.yml", "w") do |f|
f.write(
File.read("spec/fixtures/credentials.yml.example")
.sub("your_username", ENV.fetch("SPEC_LIVE_USERNAME"))
.sub("your_password", ENV.fetch("SPEC_LIVE_PASSWORD"))
.sub("your_zendesk_host", ENV.fetch("SPEC_LIVE_ZENDESK_HOST"))
)
end
end
desc 'Default: run specs.'
task :default => "spec"
end
# extracted from https://github.com/grosser/project_template
rule(/^version:bump:.*/) do |t|
sh "git status | grep 'nothing to commit'" # ensure we are not dirty
index = %w(major minor patch).index(t.name.split(':').last)
file = 'lib/zendesk_api/version.rb'
version_file = File.read(file)
old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
version_parts[index] = version_parts[index].to_i + 1
version_parts[2] = 0 if index < 2 # remove patch for minor
version_parts[1] = 0 if index < 1 # remove minor for major
new_version = version_parts * '.'
File.open(file, 'w') { |f| f.write(version_file.sub(old_version, new_version)) }
sh "bundle && git add #{file} Gemfile.lock && git commit -m 'bump version to #{new_version}'"
end