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 ADDED
@@ -0,0 +1 @@
1
+
@@ -1,16 +1,16 @@
1
1
  CREATE TABLE clones (
2
- "site" INTEGER NOT NULL,
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
- "site" INTEGER NOT NULL,
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
- "site" INTEGER NOT NULL,
13
+ "bit" INTEGER NOT NULL,
14
14
  "status" TEXT NOT NULL DEFAULT ('pending'),
15
15
  "requested_commit" TEXT
16
16
  );
@@ -6,7 +6,7 @@ module Actions
6
6
  end
7
7
 
8
8
  def clones options
9
- src = Site.new options[:src]
9
+ src = Bit.new options[:src]
10
10
  # fail ProjectMismatch unless @project_id == src.project_id
11
11
 
12
12
  puts "cloning #{src.project_name}.#{src.name} to #{@project_name}.#{@name}"
@@ -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
- :sites => [ :rowid, :name, :project, :root, :commit, :commit_time ],
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
- "site" INTEGER NOT NULL
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 sites (
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 Site
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 :sites, data
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 :sites, @@info[:sites], @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]
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'
@@ -1,4 +1,4 @@
1
- class Site < SiteManager
1
+ class Bit < Kit
2
2
 
3
3
  attr_reader :id
4
4
 
@@ -24,7 +24,7 @@ module SQLite3Tools
24
24
  end
25
25
  end
26
26
 
27
- class Backend < SiteManager
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
 
@@ -0,0 +1,10 @@
1
+ require 'kit'
2
+
3
+ describe Kit do
4
+
5
+ describe "#new" do
6
+ k = Kit.new "/home/razorx/development/kit/kits/my_kit/"
7
+ b = { :name => "otr", :git => "git", :project_name => "otr", :root => "root" }
8
+ k.add_bit b
9
+ end
10
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
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
- - info.sql
31
- - actions.sql
32
- - ./info/devel.rb
33
- - ./site_manager.rb
34
- - ./actions/commits/otr.rb
35
- - ./actions/clones/otr.rb
36
- - ./actions/upgrades/otr.rb
37
- - ./config.rb
38
- - ./db_sqlite3.rb
39
- - ./site.rb
40
- - site_manager.rb
41
- - config.rb
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
-