forked from stringer-rss/stringer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
88 lines (71 loc) · 1.99 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
require "bundler"
Bundler.setup
require "rubygems"
require "net/http"
require "active_record"
require "delayed_job"
require "delayed_job_active_record"
require "sinatra/activerecord/rake"
ActiveRecord::Tasks::DatabaseTasks.db_dir = "db"
require "./app"
require_relative "./app/jobs/fetch_feed_job"
require_relative "./app/tasks/fetch_feeds"
require_relative "./app/tasks/change_password"
require_relative "./app/tasks/remove_old_stories.rb"
desc "Fetch all feeds."
task :fetch_feeds do
FetchFeeds.new(Feed.all).fetch_all
end
desc "Lazily fetch all feeds."
task :lazy_fetch do
if ENV["APP_URL"]
uri = URI(ENV["APP_URL"])
Net::HTTP.get_response(uri)
end
FeedRepository.list.each do |feed|
Delayed::Job.enqueue FetchFeedJob.new(feed.id)
end
end
desc "Fetch single feed"
task :fetch_feed, :id do |_t, args|
FetchFeed.new(Feed.find(args[:id])).fetch
end
desc "Clear the delayed_job queue."
task :clear_jobs do
Delayed::Job.delete_all
end
desc "Work the delayed_job queue."
task :work_jobs do
Delayed::Job.delete_all
worker_retry = Integer(ENV["WORKER_RETRY"] || 3)
worker_retry.times do
Delayed::Worker.new(
min_priority: ENV["MIN_PRIORITY"],
max_priority: ENV["MAX_PRIORITY"]
).start
end
end
desc "Change your password"
task :change_password do
ChangePassword.new.change_password
end
desc "Clean up old stories that are read and unstarred"
task :cleanup_old_stories, :number_of_days do |_t, args|
args.with_defaults(number_of_days: 30)
RemoveOldStories.remove!(args[:number_of_days].to_i)
end
desc "Start server and serve JavaScript test suite at /test"
task :test_js do
require_relative "./spec/javascript/test_controller"
Stringer.run!
end
begin
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:speedy_tests) do |t|
t.rspec_opts = "--tag ~speed:slow"
end
RSpec::Core::RakeTask.new(:spec)
task default: [:speedy_tests]
rescue LoadError # rubocop:disable Lint/HandleExceptions
# allow for bundle install --without development:test
end