kit 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -0
- data/{actions.sql → kits/my_kit/actions.sql} +3 -3
- data/{actions/clones/otr.rb → kits/my_kit/clones/my_project.rb} +1 -1
- data/{actions/commits/otr.rb → kits/my_kit/commits/my_project.rb} +0 -0
- data/{config.rb → kits/my_kit/config.rb} +5 -6
- data/{info.sql → kits/my_kit/info.sql} +2 -2
- data/{info/devel.rb → kits/my_kit/my_kit.rb} +3 -3
- data/{actions/upgrades/otr.rb → kits/my_kit/upgrades/my_project.rb} +0 -0
- data/lib/kit.rb +64 -0
- data/{site.rb → lib/kit/bit.rb} +1 -1
- data/{db_sqlite3.rb → lib/kit/db_sqlite3.rb} +2 -2
- data/spec/my_kit_spec.rb +10 -0
- metadata +14 -16
- data/site_manager.rb +0 -73
data/README
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -1,16 +1,16 @@
|
|
1
1
|
CREATE TABLE clones (
|
2
|
-
"
|
2
|
+
"bit" INTEGER NOT NULL,
|
3
3
|
"status" TEXT NOT NULL DEFAULT ('pending'),
|
4
4
|
"src" INTEGER NOT NULL
|
5
5
|
);
|
6
6
|
CREATE TABLE upgrades (
|
7
|
-
"
|
7
|
+
"bit" INTEGER NOT NULL,
|
8
8
|
"status" TEXT NOT NULL DEFAULT ('pending'),
|
9
9
|
"component" TEXT NOT NULL,
|
10
10
|
"file" TEXT NOT NULL
|
11
11
|
);
|
12
12
|
CREATE TABLE commits (
|
13
|
-
"
|
13
|
+
"bit" INTEGER NOT NULL,
|
14
14
|
"status" TEXT NOT NULL DEFAULT ('pending'),
|
15
15
|
"requested_commit" TEXT
|
16
16
|
);
|
File without changes
|
@@ -1,16 +1,15 @@
|
|
1
|
+
NAME = "my_kit"
|
1
2
|
DB_BACKEND = :sqlite3
|
2
3
|
DB_CONFIG = {
|
3
|
-
:info => "info.db",
|
4
|
-
:actions => "actions.db"
|
4
|
+
:info => "/home/razorx/development/kit/kits/my_kit/info.db",
|
5
|
+
:actions => "/home/razorx/development/kit/kits/my_kit/actions.db"
|
5
6
|
}
|
6
7
|
INFO = {
|
7
|
-
:
|
8
|
+
:bits => [ :rowid, :name, :project, :root, :commit, :commit_time ],
|
8
9
|
:projects => [ :rowid, :name, :git ]
|
9
10
|
}
|
10
11
|
ACTIONS = {
|
11
12
|
:clones => [ :rowid, :status, :src, :site ],
|
12
13
|
:upgrades => [ :rowid, :status, :site, :component, :file ],
|
13
14
|
:commits => [ :rowid, :status, :site, :requested_commit ]
|
14
|
-
}
|
15
|
-
ACTIONS_PATH = "./actions"
|
16
|
-
NAME = "devel"
|
15
|
+
}
|
@@ -1,12 +1,12 @@
|
|
1
1
|
CREATE TABLE "permissions" (
|
2
2
|
"name" INTEGER NOT NULL,
|
3
|
-
"
|
3
|
+
"bit" INTEGER NOT NULL
|
4
4
|
);
|
5
5
|
CREATE TABLE projects (
|
6
6
|
"name" TEXT NOT NULL,
|
7
7
|
"git" TEXT NOT NULL
|
8
8
|
);
|
9
|
-
CREATE TABLE
|
9
|
+
CREATE TABLE bits (
|
10
10
|
"name" TEXT NOT NULL,
|
11
11
|
"project" INTEGER NOT NULL,
|
12
12
|
"root" TEXT NOT NULL,
|
@@ -1,10 +1,10 @@
|
|
1
|
-
class
|
1
|
+
class Bit
|
2
2
|
|
3
3
|
def insert_new
|
4
4
|
@project_id = insert_new_project unless @project_id
|
5
5
|
|
6
6
|
data = { :name => @name, :project => @project_id, :root => @root, :commit => nil, :commit_time => nil }
|
7
|
-
@@db.insert_info :
|
7
|
+
@@db.insert_info :bits, data
|
8
8
|
end
|
9
9
|
|
10
10
|
def insert_new_project
|
@@ -17,7 +17,7 @@ class Site
|
|
17
17
|
|
18
18
|
def load_info
|
19
19
|
|
20
|
-
info = @@db.select_info_by_id :
|
20
|
+
info = @@db.select_info_by_id :bits, @@info[:bits], @id
|
21
21
|
|
22
22
|
@name = info[:name]
|
23
23
|
@project_id = info[:project]
|
File without changes
|
data/lib/kit.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
class Kit
|
2
|
+
|
3
|
+
def initialize path
|
4
|
+
|
5
|
+
load path + "config.rb"
|
6
|
+
|
7
|
+
load 'kit/db_sqlite3.rb' if DB_BACKEND == :sqlite3
|
8
|
+
|
9
|
+
load path + NAME + ".rb"
|
10
|
+
|
11
|
+
@@kit_path = path
|
12
|
+
@@db = Backend.new DB_CONFIG
|
13
|
+
@@info = INFO
|
14
|
+
@@actions = ACTIONS
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_bit info
|
18
|
+
Bit.new info
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_task action, options
|
22
|
+
fail NoAction unless @@actions.include? action
|
23
|
+
@@db.insert_action action, options
|
24
|
+
end
|
25
|
+
|
26
|
+
def run_tasks
|
27
|
+
|
28
|
+
collect_tasks_by_bit.each do |bit, tasks|
|
29
|
+
s = Bit.new bit
|
30
|
+
|
31
|
+
actions = tasks.group_by { |t| t[:action] } . keys
|
32
|
+
|
33
|
+
actions.each do |a|
|
34
|
+
load @@kit_path + "/#{a}/#{s.project_name}.rb"
|
35
|
+
s.extend Actions
|
36
|
+
end
|
37
|
+
|
38
|
+
tasks.each do |t|
|
39
|
+
s.add_task t
|
40
|
+
end
|
41
|
+
|
42
|
+
s.run_all
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
def collect_tasks_by_bit
|
49
|
+
|
50
|
+
tasks = []
|
51
|
+
@@actions.each_key do |action|
|
52
|
+
tasks.push @@db.select_all_actions_by_status action, @@actions[action], :pending
|
53
|
+
end
|
54
|
+
tasks.flatten!
|
55
|
+
|
56
|
+
tasks.group_by { |t| t[:bit] }
|
57
|
+
end
|
58
|
+
|
59
|
+
class NoAction < StandardError
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
require 'kit/bit'
|
data/{site.rb → lib/kit/bit.rb}
RENAMED
@@ -24,7 +24,7 @@ module SQLite3Tools
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
class Backend <
|
27
|
+
class Backend < Kit
|
28
28
|
|
29
29
|
include SQLite3Tools
|
30
30
|
|
@@ -38,7 +38,7 @@ class Backend < SiteManager
|
|
38
38
|
def db_prepare db_paths
|
39
39
|
|
40
40
|
def db_initialize type, db
|
41
|
-
sql = File.read "#{type}.sql"
|
41
|
+
sql = File.read @@kit_path + "#{type}.sql"
|
42
42
|
db.execute_batch sql
|
43
43
|
end
|
44
44
|
|
data/spec/my_kit_spec.rb
ADDED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Evan Boyd Sosenko
|
@@ -27,20 +27,18 @@ extensions: []
|
|
27
27
|
extra_rdoc_files: []
|
28
28
|
|
29
29
|
files:
|
30
|
-
-
|
31
|
-
-
|
32
|
-
-
|
33
|
-
-
|
34
|
-
-
|
35
|
-
-
|
36
|
-
-
|
37
|
-
-
|
38
|
-
-
|
39
|
-
-
|
40
|
-
-
|
41
|
-
-
|
42
|
-
- db_sqlite3.rb
|
43
|
-
- site.rb
|
30
|
+
- lib/kit/bit.rb
|
31
|
+
- lib/kit/db_sqlite3.rb
|
32
|
+
- lib/kit.rb
|
33
|
+
- README
|
34
|
+
- kits/my_kit/commits/my_project.rb
|
35
|
+
- kits/my_kit/info.sql
|
36
|
+
- kits/my_kit/clones/my_project.rb
|
37
|
+
- kits/my_kit/my_kit.rb
|
38
|
+
- kits/my_kit/actions.sql
|
39
|
+
- kits/my_kit/config.rb
|
40
|
+
- kits/my_kit/upgrades/my_project.rb
|
41
|
+
- spec/my_kit_spec.rb
|
44
42
|
has_rdoc: true
|
45
43
|
homepage:
|
46
44
|
licenses:
|
data/site_manager.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
class SiteManager
|
2
|
-
|
3
|
-
def initialize name, db_backend, db_config, info, actions
|
4
|
-
|
5
|
-
load './db_sqlite3.rb' if db_backend == :sqlite3
|
6
|
-
|
7
|
-
load './info/' + name + ".rb"
|
8
|
-
|
9
|
-
|
10
|
-
@@db = Backend.new db_config
|
11
|
-
@@actions = actions
|
12
|
-
@@info = info
|
13
|
-
end
|
14
|
-
|
15
|
-
def add_site info
|
16
|
-
Site.new info
|
17
|
-
end
|
18
|
-
|
19
|
-
def add_task action, options
|
20
|
-
fail NoAction unless @@actions.include? action
|
21
|
-
@@db.insert_action action, options
|
22
|
-
end
|
23
|
-
|
24
|
-
def run_tasks
|
25
|
-
|
26
|
-
collect_tasks_by_site.each do |site, tasks|
|
27
|
-
s = Site.new site
|
28
|
-
|
29
|
-
actions = tasks.group_by { |t| t[:action] } . keys
|
30
|
-
|
31
|
-
actions.each do |a|
|
32
|
-
load ACTIONS_PATH + "/#{a}/#{s.project_name}.rb"
|
33
|
-
s.extend Actions
|
34
|
-
end
|
35
|
-
|
36
|
-
tasks.each do |t|
|
37
|
-
s.add_task t
|
38
|
-
end
|
39
|
-
|
40
|
-
s.run_all
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
def collect_tasks_by_site
|
47
|
-
|
48
|
-
tasks = []
|
49
|
-
@@actions.each_key do |action|
|
50
|
-
tasks.push @@db.select_all_actions_by_status action, @@actions[action], :pending
|
51
|
-
end
|
52
|
-
tasks.flatten!
|
53
|
-
|
54
|
-
tasks.group_by { |t| t[:site] }
|
55
|
-
end
|
56
|
-
|
57
|
-
class NoAction < StandardError
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
require './config.rb'
|
63
|
-
require './site.rb'
|
64
|
-
|
65
|
-
|
66
|
-
sm = SiteManager.new NAME, DB_BACKEND, DB_CONFIG, INFO, ACTIONS
|
67
|
-
|
68
|
-
p = { :project_name => "otr", :name => "live", :root => "rootLive/", :git => "gitPath" }
|
69
|
-
sm.add_site p
|
70
|
-
ac = { :site => 1, :requested_commit => "co" }
|
71
|
-
sm.add_task :commits, ac
|
72
|
-
sm.run_tasks
|
73
|
-
|