Class: RemindMe::Runner
Constant Summary
Utils::Versions::INSTALLED_GEMS
Class Method Summary
collapse
Methods included from BailOut
bail_out!
colorize, green, log_error, log_info, log_with_rails, rails_being_used?, red
compare_version_numbers, condition_comparators, gem_installed?, gem_version, invalid_condition_message, valid_condition?, valid_version_string?
Class Method Details
53
54
55
56
57
58
59
|
# File 'lib/remind_me/runner.rb', line 53
def self.(file, parser)
parser.reset
source = File.read(file).force_encoding(parser.default_encoding)
buffer = Parser::Source::Buffer.new(file)
buffer.source = source
parser.(buffer).last
end
|
.check_reminders(check_path: '.') ⇒ Object
.collect_reminders(path) ⇒ Object
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/remind_me/runner.rb', line 35
def self.collect_reminders(path)
files = relevant_ruby_files(path)
return if files.empty?
Parallel.flat_map(in_groups(files, processor_count, false)) do |files|
parser = silent_parser
= (files, parser)
.flat_map { || RemindMe::Reminder::Generator.generate([0], [1], parser) }
end
end
|
.processor_count ⇒ Object
103
104
105
106
107
108
109
|
# File 'lib/remind_me/runner.rb', line 103
def self.processor_count
if using_old_parallel_gem?
super
else
Parallel.processor_count
end
end
|
.relevant_ruby_files(parse_path) ⇒ Object
68
69
70
71
72
73
74
|
# File 'lib/remind_me/runner.rb', line 68
def self.relevant_ruby_files(parse_path)
Parallel.flat_map(in_groups(collect_ruby_files(parse_path), processor_count, false)) do |files|
files.select do |file|
IO.foreach(file).any? { |line| line.include?('REMIND_ME:') }
end
end
end
|
.silent_parser ⇒ Object
46
47
48
49
50
51
|
# File 'lib/remind_me/runner.rb', line 46
def self.silent_parser
parser = Parser::CurrentRuby.new
parser.diagnostics.consumer = ->(_message) {}
parser.diagnostics.ignore_warnings = true
parser
end
|
.using_old_parallel_gem? ⇒ Boolean
19
20
21
|
# File 'lib/remind_me/runner.rb', line 19
def self.using_old_parallel_gem?
gem_version('parallel') < Gem::Version.new('1.23.0')
end
|