synchronisable 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.rspec +3 -0
- data/.ruby-version +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +9 -0
- data/Guardfile +14 -0
- data/LICENSE.txt +22 -0
- data/README.md +22 -0
- data/Rakefile +7 -0
- data/TODO.md +20 -0
- data/bin/autospec +16 -0
- data/bin/rake +16 -0
- data/bin/rspec +16 -0
- data/lib/generators/synchronizable/USAGE +2 -0
- data/lib/generators/synchronizable/install_generator.rb +24 -0
- data/lib/generators/synchronizable/templates/create_imports_migration.rb +21 -0
- data/lib/generators/synchronizable/templates/initializer.rb +14 -0
- data/lib/synchronizable.rb +92 -0
- data/lib/synchronizable/context.rb +25 -0
- data/lib/synchronizable/dsl/associations.rb +57 -0
- data/lib/synchronizable/dsl/associations/association.rb +59 -0
- data/lib/synchronizable/dsl/associations/has_many.rb +12 -0
- data/lib/synchronizable/dsl/associations/has_one.rb +13 -0
- data/lib/synchronizable/dsl/macro.rb +100 -0
- data/lib/synchronizable/dsl/macro/attribute.rb +41 -0
- data/lib/synchronizable/dsl/macro/expression.rb +51 -0
- data/lib/synchronizable/dsl/macro/method.rb +15 -0
- data/lib/synchronizable/error_handler.rb +50 -0
- data/lib/synchronizable/exceptions.rb +8 -0
- data/lib/synchronizable/locale/en.yml +17 -0
- data/lib/synchronizable/locale/ru.yml +17 -0
- data/lib/synchronizable/model.rb +54 -0
- data/lib/synchronizable/model/methods.rb +55 -0
- data/lib/synchronizable/models/import.rb +24 -0
- data/lib/synchronizable/source.rb +72 -0
- data/lib/synchronizable/synchronizer.rb +177 -0
- data/lib/synchronizable/synchronizers/synchronizer_default.rb +10 -0
- data/lib/synchronizable/version.rb +10 -0
- data/lib/synchronizable/worker.rb +191 -0
- data/spec/dummy/.gitignore +16 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +16 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/gateways/gateway_base.rb +19 -0
- data/spec/dummy/app/gateways/match_gateway.rb +15 -0
- data/spec/dummy/app/gateways/player_gateway.rb +26 -0
- data/spec/dummy/app/gateways/stage_gateway.rb +18 -0
- data/spec/dummy/app/gateways/team_gateway.rb +18 -0
- data/spec/dummy/app/gateways/tournament_gateway.rb +15 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/match.rb +10 -0
- data/spec/dummy/app/models/match_player.rb +15 -0
- data/spec/dummy/app/models/player.rb +5 -0
- data/spec/dummy/app/models/stadium.rb +7 -0
- data/spec/dummy/app/models/stage.rb +6 -0
- data/spec/dummy/app/models/team.rb +5 -0
- data/spec/dummy/app/models/tournament.rb +7 -0
- data/spec/dummy/app/synchronizers/break_convention_team_synchronizer.rb +14 -0
- data/spec/dummy/app/synchronizers/match_synchronizer.rb +71 -0
- data/spec/dummy/app/synchronizers/player_synchronizer.rb +19 -0
- data/spec/dummy/app/synchronizers/stage_synchronizer.rb +20 -0
- data/spec/dummy/app/synchronizers/tournament_synchronizer.rb +20 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +26 -0
- data/spec/dummy/config/boot.rb +6 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +33 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +20 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/synchronizable.rb +2 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +56 -0
- data/spec/dummy/db/migrate/20140422132431_create_teams.rb +11 -0
- data/spec/dummy/db/migrate/20140422132544_create_matches.rb +12 -0
- data/spec/dummy/db/migrate/20140422132708_create_players.rb +15 -0
- data/spec/dummy/db/migrate/20140422133122_create_match_players.rb +12 -0
- data/spec/dummy/db/migrate/20140422135244_create_imports.rb +21 -0
- data/spec/dummy/db/migrate/20140422140817_create_stadiums.rb +10 -0
- data/spec/dummy/db/migrate/20140507135800_create_tournaments.rb +13 -0
- data/spec/dummy/db/migrate/20140507135837_create_stages.rb +13 -0
- data/spec/dummy/db/migrate/20140507140039_add_stage_id_to_matches.rb +6 -0
- data/spec/dummy/db/schema.rb +103 -0
- data/spec/dummy/db/seeds.rb +7 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/lib/tasks/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/robots.txt +5 -0
- data/spec/dummy/vendor/assets/javascripts/.keep +0 -0
- data/spec/dummy/vendor/assets/stylesheets/.keep +0 -0
- data/spec/factories/import.rb +5 -0
- data/spec/factories/match.rb +9 -0
- data/spec/factories/match_player.rb +9 -0
- data/spec/factories/player.rb +10 -0
- data/spec/factories/remote/match.rb +21 -0
- data/spec/factories/remote/player.rb +18 -0
- data/spec/factories/remote/stage.rb +26 -0
- data/spec/factories/remote/team.rb +21 -0
- data/spec/factories/remote/tournament.rb +18 -0
- data/spec/factories/stadium.rb +7 -0
- data/spec/factories/team.rb +16 -0
- data/spec/models/match_spec.rb +41 -0
- data/spec/models/team_spec.rb +85 -0
- data/spec/spec_helper.rb +64 -0
- data/spec/synchronizable/dsl/macro_spec.rb +59 -0
- data/spec/synchronizable/models/import_spec.rb +10 -0
- data/spec/synchronizable/support/has_macro.rb +12 -0
- data/spec/synchronizable/support/has_macro_subclass.rb +9 -0
- data/spec/synchronizable/synchronizable_spec.rb +60 -0
- data/synchronizable.gemspec +39 -0
- metadata +506 -0
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateMatchPlayers < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :match_players do |t|
|
4
|
+
t.references :match, index: true
|
5
|
+
t.references :player, index: true
|
6
|
+
t.string :ref_type
|
7
|
+
t.integer :formation_index
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class CreateImports < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :imports do |t|
|
4
|
+
t.string :synchronizable_type, null: false
|
5
|
+
t.integer :synchronizable_id, null: false
|
6
|
+
t.text :attrs
|
7
|
+
t.string :remote_id, null: false
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
|
12
|
+
add_index :imports, :remote_id
|
13
|
+
add_index :imports, [:synchronizable_type, :synchronizable_id]
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.down
|
17
|
+
remove_index :imports, :remote_id
|
18
|
+
remove_index :imports, [:synchronizable_type, :synchronizable_id]
|
19
|
+
drop_table :imports
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateTournaments < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :tournaments do |t|
|
4
|
+
t.string :name
|
5
|
+
t.string :short_name
|
6
|
+
t.date :beginning
|
7
|
+
t.date :ending
|
8
|
+
t.boolean :is_current, default: false, null: false
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended that you check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(version: 20140507140039) do
|
15
|
+
|
16
|
+
create_table "imports", force: true do |t|
|
17
|
+
t.string "synchronizable_type", null: false
|
18
|
+
t.integer "synchronizable_id", null: false
|
19
|
+
t.text "attrs"
|
20
|
+
t.string "remote_id", null: false
|
21
|
+
t.datetime "created_at"
|
22
|
+
t.datetime "updated_at"
|
23
|
+
end
|
24
|
+
|
25
|
+
add_index "imports", ["remote_id"], name: "index_imports_on_remote_id"
|
26
|
+
add_index "imports", ["synchronizable_type", "synchronizable_id"], name: "index_imports_on_synchronizable_type_and_synchronizable_id"
|
27
|
+
|
28
|
+
create_table "match_players", force: true do |t|
|
29
|
+
t.integer "match_id"
|
30
|
+
t.integer "player_id"
|
31
|
+
t.string "ref_type"
|
32
|
+
t.integer "formation_index"
|
33
|
+
t.datetime "created_at"
|
34
|
+
t.datetime "updated_at"
|
35
|
+
end
|
36
|
+
|
37
|
+
add_index "match_players", ["match_id"], name: "index_match_players_on_match_id"
|
38
|
+
add_index "match_players", ["player_id"], name: "index_match_players_on_player_id"
|
39
|
+
|
40
|
+
create_table "matches", force: true do |t|
|
41
|
+
t.integer "beginning"
|
42
|
+
t.integer "home_team_id"
|
43
|
+
t.integer "away_team_id"
|
44
|
+
t.string "weather"
|
45
|
+
t.datetime "created_at"
|
46
|
+
t.datetime "updated_at"
|
47
|
+
t.integer "stage_id"
|
48
|
+
end
|
49
|
+
|
50
|
+
add_index "matches", ["stage_id"], name: "index_matches_on_stage_id"
|
51
|
+
|
52
|
+
create_table "players", force: true do |t|
|
53
|
+
t.string "first_name"
|
54
|
+
t.string "last_name"
|
55
|
+
t.date "birthday"
|
56
|
+
t.string "citizenship"
|
57
|
+
t.float "height"
|
58
|
+
t.float "weight"
|
59
|
+
t.integer "team_id"
|
60
|
+
t.datetime "created_at"
|
61
|
+
t.datetime "updated_at"
|
62
|
+
end
|
63
|
+
|
64
|
+
add_index "players", ["team_id"], name: "index_players_on_team_id"
|
65
|
+
|
66
|
+
create_table "stadiums", force: true do |t|
|
67
|
+
t.string "name"
|
68
|
+
t.integer "capacity"
|
69
|
+
t.datetime "created_at"
|
70
|
+
t.datetime "updated_at"
|
71
|
+
end
|
72
|
+
|
73
|
+
create_table "stages", force: true do |t|
|
74
|
+
t.date "beginning"
|
75
|
+
t.date "ending"
|
76
|
+
t.integer "tournament_id"
|
77
|
+
t.string "name"
|
78
|
+
t.integer "number"
|
79
|
+
t.datetime "created_at"
|
80
|
+
t.datetime "updated_at"
|
81
|
+
end
|
82
|
+
|
83
|
+
add_index "stages", ["tournament_id"], name: "index_stages_on_tournament_id"
|
84
|
+
|
85
|
+
create_table "teams", force: true do |t|
|
86
|
+
t.string "name"
|
87
|
+
t.string "country"
|
88
|
+
t.string "city"
|
89
|
+
t.datetime "created_at"
|
90
|
+
t.datetime "updated_at"
|
91
|
+
end
|
92
|
+
|
93
|
+
create_table "tournaments", force: true do |t|
|
94
|
+
t.string "name"
|
95
|
+
t.string "short_name"
|
96
|
+
t.date "beginning"
|
97
|
+
t.date "ending"
|
98
|
+
t.boolean "is_current", default: false, null: false
|
99
|
+
t.datetime "created_at"
|
100
|
+
t.datetime "updated_at"
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
2
|
+
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
3
|
+
#
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
7
|
+
# Mayor.create(name: 'Emanuel', city: cities.first)
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/404.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
54
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
55
|
+
</div>
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
57
|
+
</body>
|
58
|
+
</html>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/422.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>The change you wanted was rejected.</h1>
|
54
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
55
|
+
</div>
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
57
|
+
</body>
|
58
|
+
</html>
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/500.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>We're sorry, but something went wrong.</h1>
|
54
|
+
</div>
|
55
|
+
<p>If you are the application owner check the logs for more information.</p>
|
56
|
+
</body>
|
57
|
+
</html>
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :remote_match, class: Hash do
|
3
|
+
match_id { generate :match_id }
|
4
|
+
home_team { generate :team_id }
|
5
|
+
away_team { generate :team_id }
|
6
|
+
|
7
|
+
gninnigeb { generate :timestamp }
|
8
|
+
rehtaew { %w(worm cold rainy).sample }
|
9
|
+
|
10
|
+
ignored_1 { generate :string }
|
11
|
+
ignored_2 { generate :timestamp }
|
12
|
+
|
13
|
+
line_up_home ['player_0']
|
14
|
+
line_up_away ['player_1']
|
15
|
+
|
16
|
+
substitutes_home ['player_2']
|
17
|
+
substitutes_away ['player_3']
|
18
|
+
|
19
|
+
initialize_with { attributes }
|
20
|
+
end
|
21
|
+
end
|