forked from lyndsey-ferguson/fastlane-plugin-test_center
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
69 lines (61 loc) · 2.09 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
require 'bundler/gem_tasks'
require 'colorize'
require 'rspec/core/rake_task'
require_relative 'fastlane/test_center_utils'
require 'fastlane'
RSpec::Core::RakeTask.new
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop)
GEMS_BLACKLISTED_FROM_RELEASE = [
'pry-byebug'
]
desc 'Ensures that no blacklisted require "x" exist in the code'
task :check_for_blacklisted_requires do
errors = []
gem_blacklist_regex = "('|\")(?<blacklisted_gem>#{GEMS_BLACKLISTED_FROM_RELEASE.join('|')})('|\")"
Dir["lib/**/*.rb"].each do |file|
File.foreach(file) do |line|
if (m = /\s*require\s+#{gem_blacklist_regex}/.match(line))
errors << "require '#{m[:blacklisted_gem]}' found in '#{file}'"
end
end
end
unless errors.empty?
errors.each { |line| puts line }
abort 'Error: blacklisted require(s) found'.red
end
puts 'No blacklisted requires found'.green
end
desc 'Updates the README with the latest examples for each action'
task :update_readme_action_examples do
readme = File.read('README.md')
examples = action_examples
placeholder_example_begin_found = false
File.open('README.md', 'w') do |file|
action_name = nil
readme.lines do |line|
if /<!-- (?<found_action_name>\w+) examples: begin -->/ =~ line
placeholder_example_begin_found = true
action_name = found_action_name
elsif placeholder_example_begin_found
if /<!-- #{action_name} examples: end -->/ =~ line
file.puts "<!-- #{action_name} examples: begin -->"
examples[action_name].each do |example_code_snippet|
file.puts ''
file.puts '```ruby'
example_code_snippet.lines do |example_code_snippet_line|
file.puts example_code_snippet_line.sub(' ', '')
end
file.puts '```'
end
file.puts "<!-- #{action_name} examples: end -->"
placeholder_example_begin_found = false
end
else
file.puts line
end
end
end
end
Rake::Task[:build].enhance [:check_for_blacklisted_requires, :spec, :rubocop]
task default: [:spec, :rubocop]