apify_scheduler 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/scheduler/application.js +19 -0
- data/app/assets/stylesheets/scheduler/application.css +15 -0
- data/app/controllers/apify/scheduler/application_controller.rb +6 -0
- data/app/controllers/apify/scheduler/histories_controller.rb +24 -0
- data/app/controllers/apify/scheduler/servers_controller.rb +71 -0
- data/app/controllers/apify/scheduler/units_controller.rb +77 -0
- data/app/helpers/apify/scheduler/application_helper.rb +6 -0
- data/app/helpers/apify/scheduler/histories_helper.rb +4 -0
- data/app/helpers/apify/scheduler/servers_helper.rb +4 -0
- data/app/helpers/apify/scheduler/units_helper.rb +4 -0
- data/app/jobs/unit_performer_job.rb +10 -0
- data/app/models/apify/scheduler/frequency_period.rb +5 -0
- data/app/models/apify/scheduler/history.rb +9 -0
- data/app/models/apify/scheduler/server.rb +12 -0
- data/app/models/apify/scheduler/unit.rb +45 -0
- data/app/views/apify/scheduler/histories/_history.html.erb +6 -0
- data/app/views/apify/scheduler/histories/index.html.erb +14 -0
- data/app/views/apify/scheduler/servers/_form.html.erb +48 -0
- data/app/views/apify/scheduler/servers/edit.html.erb +6 -0
- data/app/views/apify/scheduler/servers/index.html.erb +46 -0
- data/app/views/apify/scheduler/servers/new.html.erb +5 -0
- data/app/views/apify/scheduler/servers/show.html.erb +35 -0
- data/app/views/apify/scheduler/shared/_short_history.html.erb +39 -0
- data/app/views/apify/scheduler/units/_form.html.erb +99 -0
- data/app/views/apify/scheduler/units/_unit.html.erb +27 -0
- data/app/views/apify/scheduler/units/edit.html.erb +6 -0
- data/app/views/apify/scheduler/units/index.html.erb +37 -0
- data/app/views/apify/scheduler/units/new.html.erb +5 -0
- data/app/views/apify/scheduler/units/show.html.erb +36 -0
- data/app/views/layouts/apify/scheduler/_flash.html.erb +32 -0
- data/app/views/layouts/apify/scheduler/application.html.erb +37 -0
- data/config/routes.rb +15 -0
- data/db/migrate/20150104005044_create_apify_scheduler_units.rb +24 -0
- data/db/migrate/20150105225841_create_apify_servers.rb +14 -0
- data/db/migrate/20150105234957_create_apify_histories.rb +13 -0
- data/db/migrate/20150112223842_create_frequency_periods.rb +9 -0
- data/lib/apify_scheduler.rb +6 -0
- data/lib/apify_scheduler/engine.rb +16 -0
- data/lib/apify_scheduler/version.rb +5 -0
- data/lib/tasks/resque.rake +2 -0
- data/lib/tasks/scheduler_tasks.rake +4 -0
- data/test/controllers/apify/histories_controller_test.rb +51 -0
- data/test/controllers/apify/names_controller_test.rb +51 -0
- data/test/controllers/apify/servers_controller_test.rb +51 -0
- data/test/controllers/apify/units_controller_test.rb +51 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +78 -0
- data/test/dummy/config/environments/test.rb +39 -0
- data/test/dummy/config/initializers/assets.rb +8 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/fixtures/apify/histories.yml +11 -0
- data/test/fixtures/apify/servers.yml +11 -0
- data/test/fixtures/apify/units.yml +11 -0
- data/test/helpers/apify/histories_helper_test.rb +6 -0
- data/test/helpers/apify/names_helper_test.rb +6 -0
- data/test/helpers/apify/servers_helper_test.rb +6 -0
- data/test/helpers/apify/units_helper_test.rb +6 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/models/apify/history_test.rb +9 -0
- data/test/models/apify/server_test.rb +9 -0
- data/test/models/apify/unit_test.rb +9 -0
- data/test/scheduler_test.rb +7 -0
- data/test/test_helper.rb +17 -0
- metadata +231 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class CreateApifyServers < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :apify_scheduler_servers do |t|
|
|
4
|
+
t.string :name
|
|
5
|
+
t.string :url
|
|
6
|
+
t.text :description
|
|
7
|
+
t.string :api_key
|
|
8
|
+
|
|
9
|
+
t.timestamps
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
add_index :apify_scheduler_servers, :name, unique: true
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class CreateApifyHistories < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :apify_scheduler_histories do |t|
|
|
4
|
+
|
|
5
|
+
t.text :response_body
|
|
6
|
+
t.belongs_to :apify_scheduler_unit
|
|
7
|
+
t.boolean :queued, default: false
|
|
8
|
+
|
|
9
|
+
t.datetime :finished_at, default: nil
|
|
10
|
+
t.timestamps
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Apify
|
|
2
|
+
module Scheduler
|
|
3
|
+
class Engine < ::Rails::Engine
|
|
4
|
+
isolate_namespace Apify::Scheduler
|
|
5
|
+
|
|
6
|
+
initializer :append_migrations do |app|
|
|
7
|
+
unless app.root.to_s.match root.to_s
|
|
8
|
+
config.paths["db/migrate"].expanded.each do |expanded_path|
|
|
9
|
+
app.config.paths["db/migrate"] << expanded_path
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module Apify::Scheduler
|
|
4
|
+
class HistoriesControllerTest < ActionController::TestCase
|
|
5
|
+
setup do
|
|
6
|
+
@history = histories(:one)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
test "should get index" do
|
|
10
|
+
get :index
|
|
11
|
+
assert_response :success
|
|
12
|
+
assert_not_nil assigns(:histories)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
test "should get new" do
|
|
16
|
+
get :new
|
|
17
|
+
assert_response :success
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
test "should create history" do
|
|
21
|
+
assert_difference('History.count') do
|
|
22
|
+
post :create, history: { fail_download: @history.fail_download, response_body: @history.response_body, succ_download: @history.succ_download }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
assert_redirected_to history_path(assigns(:history))
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
test "should show history" do
|
|
29
|
+
get :show, id: @history
|
|
30
|
+
assert_response :success
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
test "should get edit" do
|
|
34
|
+
get :edit, id: @history
|
|
35
|
+
assert_response :success
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
test "should update history" do
|
|
39
|
+
patch :update, id: @history, history: { fail_download: @history.fail_download, response_body: @history.response_body, succ_download: @history.succ_download }
|
|
40
|
+
assert_redirected_to history_path(assigns(:history))
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
test "should destroy history" do
|
|
44
|
+
assert_difference('History.count', -1) do
|
|
45
|
+
delete :destroy, id: @history
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
assert_redirected_to histories_path
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module Apify::Scheduler
|
|
4
|
+
class NamesControllerTest < ActionController::TestCase
|
|
5
|
+
setup do
|
|
6
|
+
@name = names(:one)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
test "should get index" do
|
|
10
|
+
get :index
|
|
11
|
+
assert_response :success
|
|
12
|
+
assert_not_nil assigns(:names)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
test "should get new" do
|
|
16
|
+
get :new
|
|
17
|
+
assert_response :success
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
test "should create name" do
|
|
21
|
+
assert_difference('Name.count') do
|
|
22
|
+
post :create, name: { delay: @name.delay, description: @name.description, destination: @name.destination, pattern: @name.pattern, processes: @name.processes }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
assert_redirected_to name_path(assigns(:name))
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
test "should show name" do
|
|
29
|
+
get :show, id: @name
|
|
30
|
+
assert_response :success
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
test "should get edit" do
|
|
34
|
+
get :edit, id: @name
|
|
35
|
+
assert_response :success
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
test "should update name" do
|
|
39
|
+
patch :update, id: @name, name: { delay: @name.delay, description: @name.description, destination: @name.destination, pattern: @name.pattern, processes: @name.processes }
|
|
40
|
+
assert_redirected_to name_path(assigns(:name))
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
test "should destroy name" do
|
|
44
|
+
assert_difference('Name.count', -1) do
|
|
45
|
+
delete :destroy, id: @name
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
assert_redirected_to names_path
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module Apify::Scheduler
|
|
4
|
+
class ServersControllerTest < ActionController::TestCase
|
|
5
|
+
setup do
|
|
6
|
+
@server = servers(:one)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
test "should get index" do
|
|
10
|
+
get :index
|
|
11
|
+
assert_response :success
|
|
12
|
+
assert_not_nil assigns(:servers)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
test "should get new" do
|
|
16
|
+
get :new
|
|
17
|
+
assert_response :success
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
test "should create server" do
|
|
21
|
+
assert_difference('Server.count') do
|
|
22
|
+
post :create, server: { description: @server.description, name: @server.name, url: @server.url }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
assert_redirected_to server_path(assigns(:server))
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
test "should show server" do
|
|
29
|
+
get :show, id: @server
|
|
30
|
+
assert_response :success
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
test "should get edit" do
|
|
34
|
+
get :edit, id: @server
|
|
35
|
+
assert_response :success
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
test "should update server" do
|
|
39
|
+
patch :update, id: @server, server: { description: @server.description, name: @server.name, url: @server.url }
|
|
40
|
+
assert_redirected_to server_path(assigns(:server))
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
test "should destroy server" do
|
|
44
|
+
assert_difference('Server.count', -1) do
|
|
45
|
+
delete :destroy, id: @server
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
assert_redirected_to servers_path
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module Apify::Scheduler
|
|
4
|
+
class UnitsControllerTest < ActionController::TestCase
|
|
5
|
+
setup do
|
|
6
|
+
@unit = units(:one)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
test "should get index" do
|
|
10
|
+
get :index
|
|
11
|
+
assert_response :success
|
|
12
|
+
assert_not_nil assigns(:units)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
test "should get new" do
|
|
16
|
+
get :new
|
|
17
|
+
assert_response :success
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
test "should create unit" do
|
|
21
|
+
assert_difference('Unit.count') do
|
|
22
|
+
post :create, unit: { delay: @unit.delay, description: @unit.description, destination: @unit.destination, name: @unit.name, pattern: @unit.pattern, processes: @unit.processes }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
assert_redirected_to unit_path(assigns(:unit))
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
test "should show unit" do
|
|
29
|
+
get :show, id: @unit
|
|
30
|
+
assert_response :success
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
test "should get edit" do
|
|
34
|
+
get :edit, id: @unit
|
|
35
|
+
assert_response :success
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
test "should update unit" do
|
|
39
|
+
patch :update, id: @unit, unit: { delay: @unit.delay, description: @unit.description, destination: @unit.destination, name: @unit.name, pattern: @unit.pattern, processes: @unit.processes }
|
|
40
|
+
assert_redirected_to unit_path(assigns(:unit))
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
test "should destroy unit" do
|
|
44
|
+
assert_difference('Unit.count', -1) do
|
|
45
|
+
delete :destroy, id: @unit
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
assert_redirected_to units_path
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
== README
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
|
4
|
+
application up and running.
|
|
5
|
+
|
|
6
|
+
Things you may want to cover:
|
|
7
|
+
|
|
8
|
+
* Ruby version
|
|
9
|
+
|
|
10
|
+
* System dependencies
|
|
11
|
+
|
|
12
|
+
* Configuration
|
|
13
|
+
|
|
14
|
+
* Database creation
|
|
15
|
+
|
|
16
|
+
* Database initialization
|
|
17
|
+
|
|
18
|
+
* How to run the test suite
|
|
19
|
+
|
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
|
21
|
+
|
|
22
|
+
* Deployment instructions
|
|
23
|
+
|
|
24
|
+
* ...
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// compiled file.
|
|
9
|
+
//
|
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
|
11
|
+
// about supported directives.
|
|
12
|
+
//
|
|
13
|
+
//= require_tree .
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
|
11
|
+
* file per style scope.
|
|
12
|
+
*
|
|
13
|
+
*= require_tree .
|
|
14
|
+
*= require_self
|
|
15
|
+
*/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Dummy</title>
|
|
5
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
|
6
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
|
7
|
+
<%= csrf_meta_tags %>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
|
|
11
|
+
<%= yield %>
|
|
12
|
+
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
data/test/dummy/bin/rake
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
|
2
|
+
|
|
3
|
+
require 'rails/all'
|
|
4
|
+
|
|
5
|
+
Bundler.require(*Rails.groups)
|
|
6
|
+
require "scheduler"
|
|
7
|
+
|
|
8
|
+
module Dummy
|
|
9
|
+
class Application < Rails::Application
|
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
|
11
|
+
# Application configuration should go into files in config/initializers
|
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
|
13
|
+
|
|
14
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
|
15
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
|
16
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
|
17
|
+
|
|
18
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|
19
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
|
20
|
+
# config.i18n.default_locale = :de
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# SQLite version 3.x
|
|
2
|
+
# gem install sqlite3
|
|
3
|
+
#
|
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
|
5
|
+
# gem 'sqlite3'
|
|
6
|
+
#
|
|
7
|
+
default: &default
|
|
8
|
+
adapter: sqlite3
|
|
9
|
+
pool: 5
|
|
10
|
+
timeout: 5000
|
|
11
|
+
|
|
12
|
+
development:
|
|
13
|
+
<<: *default
|
|
14
|
+
database: db/development.sqlite3
|
|
15
|
+
|
|
16
|
+
# Warning: The database defined as "test" will be erased and
|
|
17
|
+
# re-generated from your development database when you run "rake".
|
|
18
|
+
# Do not set this db to the same as development or production.
|
|
19
|
+
test:
|
|
20
|
+
<<: *default
|
|
21
|
+
database: db/test.sqlite3
|
|
22
|
+
|
|
23
|
+
production:
|
|
24
|
+
<<: *default
|
|
25
|
+
database: db/production.sqlite3
|