monos 0.2.0 → 0.5.0
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 +4 -4
- data/Manifest.txt +2 -2
- data/README.md +38 -3
- data/Rakefile +6 -4
- data/lib/mono.rb +19 -9
- data/lib/mono/base.rb +40 -40
- data/lib/mono/commands/backup.rb +15 -0
- data/lib/mono/commands/env.rb +26 -13
- data/lib/mono/commands/fetch.rb +44 -49
- data/lib/mono/commands/run.rb +47 -0
- data/lib/mono/commands/status.rb +65 -71
- data/lib/mono/commands/sync.rb +53 -59
- data/lib/mono/tool.rb +40 -36
- data/lib/mono/version.rb +19 -14
- data/test/test_base.rb +29 -2
- metadata +43 -9
- data/lib/mono/git/base.rb +0 -225
- data/lib/mono/sportdb.rb +0 -101
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7785eb99b7c2f8d35ea8b0f11e06ae8cf366f613
|
4
|
+
data.tar.gz: f141af65145dd3b7095f7145314558b6245ad54a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db773ecea48e74063358fb5c862aaa940bdef1601244e395c54f7f61de7e870525b2c747f77d75c84ff4cd3b4bcdfc221a8eee477085ec56ba426b6ab24f12bd
|
7
|
+
data.tar.gz: 8076d1725422bce4a74dc07d7dd4eec7252b4e5dea8abbb335fd8663f59bbc5295ecf5353c9147fa36a7c79c6827d9b4d43e97029dc0c2f6379f69a9b0fbece2
|
data/Manifest.txt
CHANGED
@@ -6,12 +6,12 @@ bin/mo
|
|
6
6
|
bin/mono
|
7
7
|
lib/mono.rb
|
8
8
|
lib/mono/base.rb
|
9
|
+
lib/mono/commands/backup.rb
|
9
10
|
lib/mono/commands/env.rb
|
10
11
|
lib/mono/commands/fetch.rb
|
12
|
+
lib/mono/commands/run.rb
|
11
13
|
lib/mono/commands/status.rb
|
12
14
|
lib/mono/commands/sync.rb
|
13
|
-
lib/mono/git/base.rb
|
14
|
-
lib/mono/sportdb.rb
|
15
15
|
lib/mono/tool.rb
|
16
16
|
lib/mono/version.rb
|
17
17
|
lib/monos.rb
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# monos - monorepo / mono source tree tools and (startup) scripts
|
2
2
|
|
3
3
|
|
4
|
-
* home :: [github.com/
|
5
|
-
* bugs :: [github.com/
|
4
|
+
* home :: [github.com/rubycoco/git](https://github.com/rubycoco/git)
|
5
|
+
* bugs :: [github.com/rubycoco/git/issues](https://github.com/rubycoco/git/issues)
|
6
6
|
* gem :: [rubygems.org/gems/monos](https://rubygems.org/gems/monos)
|
7
7
|
* rdoc :: [rubydoc.info/gems/monos](http://rubydoc.info/gems/monos)
|
8
8
|
* forum :: [opensport](http://groups.google.com/group/opensport)
|
@@ -52,7 +52,7 @@ openfootball:
|
|
52
52
|
|
53
53
|
### Commands
|
54
54
|
|
55
|
-
`status` • `fetch` • `sync` • `env`
|
55
|
+
`status` • `fetch` • `sync` • `run` • `env` • `backup`
|
56
56
|
|
57
57
|
### `status` Command
|
58
58
|
|
@@ -114,12 +114,47 @@ $ mo get
|
|
114
114
|
Note: `install` or `get` or `up` are all aliases that you can use for `sync`.
|
115
115
|
|
116
116
|
|
117
|
+
### `run` Command
|
118
|
+
|
119
|
+
Use the `run` command to run any command in all repos. Example:
|
120
|
+
|
121
|
+
```
|
122
|
+
$ mono run git ls-files
|
123
|
+
$ mono exec git ls-files # exec is an alias for run
|
124
|
+
$ mo run git ls-files # mo is a "shortcut" convenience alias for mono
|
125
|
+
$ mo exec git ls-files
|
126
|
+
|
127
|
+
# -or-
|
128
|
+
|
129
|
+
$ mono run tree
|
130
|
+
$ mono exec tree
|
131
|
+
$ mo run tree
|
132
|
+
$ mo exec tree
|
133
|
+
```
|
134
|
+
|
135
|
+
Note: `exec` is an alias that you can use for `run`.
|
136
|
+
|
137
|
+
|
117
138
|
|
118
139
|
### `env` Command
|
119
140
|
|
120
141
|
Use the `env` command to check your `mono` environment setup.
|
121
142
|
|
122
143
|
|
144
|
+
|
145
|
+
|
146
|
+
### `backup` Command
|
147
|
+
|
148
|
+
Use the `backup` command to backup all repos using
|
149
|
+
the [`gitti-backup` machinery »](https://github.com/rubycoco/gitti/tree/master/gitti-backup)
|
150
|
+
|
151
|
+
In a nutshell backup will backup all repos by using
|
152
|
+
1. `git clone --mirror` or
|
153
|
+
2. `git remote update` (if the local backup already exists)
|
154
|
+
and store all bare repos (without workspace) in the `~/backup` directory.
|
155
|
+
|
156
|
+
|
157
|
+
|
123
158
|
That's all for now.
|
124
159
|
|
125
160
|
|
data/Rakefile
CHANGED
@@ -3,13 +3,12 @@ require './lib/mono/version.rb'
|
|
3
3
|
|
4
4
|
Hoe.spec 'monos' do
|
5
5
|
|
6
|
-
self.version =
|
6
|
+
self.version = MonoCore::VERSION
|
7
7
|
|
8
8
|
self.summary = "monos - monorepo / mono source tree tools and (startup) scripts"
|
9
9
|
self.description = summary
|
10
10
|
|
11
|
-
|
12
|
-
self.urls = { home: 'https://github.com/sportdb/sport.db' }
|
11
|
+
self.urls = { home: 'https://github.com/rubycoco/git' }
|
13
12
|
|
14
13
|
self.author = 'Gerald Bauer'
|
15
14
|
self.email = 'opensport@googlegroups.com'
|
@@ -20,7 +19,10 @@ Hoe.spec 'monos' do
|
|
20
19
|
|
21
20
|
self.licenses = ['Public Domain']
|
22
21
|
|
23
|
-
self.extra_deps = [
|
22
|
+
self.extra_deps = [
|
23
|
+
['gitti', '>= 0.6.0' ],
|
24
|
+
['gitti-backup', '>= 0.4.1' ],
|
25
|
+
]
|
24
26
|
|
25
27
|
self.spec_extras = {
|
26
28
|
required_ruby_version: '>= 2.2.2'
|
data/lib/mono.rb
CHANGED
@@ -1,24 +1,34 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
|
7
|
-
|
1
|
+
## first add git support
|
2
|
+
## note: use the "modular" version WITHOUT auto-include gitti,
|
3
|
+
## thus, require 'gitti/base' (and NOT 'gitti')
|
4
|
+
require 'gitti/base'
|
5
|
+
require 'gitti/backup/base'
|
6
|
+
|
7
|
+
|
8
|
+
module Mono
|
9
|
+
## note: make Git, GitProject, GitRepoSet, etc. available without Gitti::
|
10
|
+
include Gitti
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
## some more stdlibs
|
15
|
+
# require 'optparse'
|
16
|
+
|
8
17
|
|
9
18
|
|
10
19
|
###
|
11
20
|
# our own code
|
12
21
|
require 'mono/version' # let version always go first
|
13
22
|
require 'mono/base'
|
14
|
-
require 'mono/git/base'
|
15
23
|
|
16
24
|
require 'mono/commands/status'
|
17
25
|
require 'mono/commands/fetch'
|
18
26
|
require 'mono/commands/sync'
|
19
27
|
require 'mono/commands/env'
|
28
|
+
require 'mono/commands/backup'
|
29
|
+
require 'mono/commands/run'
|
20
30
|
require 'mono/tool'
|
21
31
|
|
22
32
|
|
23
33
|
|
24
|
-
puts
|
34
|
+
puts MonoCore.banner # say hello
|
data/lib/mono/base.rb
CHANGED
@@ -1,40 +1,40 @@
|
|
1
|
-
|
2
|
-
module Mono
|
3
|
-
|
4
|
-
def self.root ## root of single (monorepo) source tree
|
5
|
-
@@root ||= begin
|
6
|
-
## todo/fix:
|
7
|
-
## check if windows - otherwise use /sites
|
8
|
-
## check if root directory exists?
|
9
|
-
if ENV['MOPATH']
|
10
|
-
ENV['MOPATH']
|
11
|
-
elsif Dir.exist?( 'C:/Sites' )
|
12
|
-
'C:/Sites'
|
13
|
-
else
|
14
|
-
'/sites'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.monofile
|
20
|
-
path = if File.exist?( './monorepo.yml' )
|
21
|
-
'./monorepo.yml'
|
22
|
-
elsif File.exist?( './monotree.yml' )
|
23
|
-
'./monotree.yml'
|
24
|
-
elsif File.exist?( './repos.yml' )
|
25
|
-
'./repos.yml'
|
26
|
-
else
|
27
|
-
puts "!! WARN: no mono configuration file (that is, {monorepo,monotree,repos}.yml) found in >#{Dir.getwd}<"
|
28
|
-
nil
|
29
|
-
end
|
30
|
-
|
31
|
-
if path
|
32
|
-
|
33
|
-
else
|
34
|
-
{}
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
end ## module Mono
|
39
|
-
|
40
|
-
|
1
|
+
|
2
|
+
module Mono
|
3
|
+
|
4
|
+
def self.root ## root of single (monorepo) source tree
|
5
|
+
@@root ||= begin
|
6
|
+
## todo/fix:
|
7
|
+
## check if windows - otherwise use /sites
|
8
|
+
## check if root directory exists?
|
9
|
+
if ENV['MOPATH']
|
10
|
+
ENV['MOPATH']
|
11
|
+
elsif Dir.exist?( 'C:/Sites' )
|
12
|
+
'C:/Sites'
|
13
|
+
else
|
14
|
+
'/sites'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.monofile
|
20
|
+
path = if File.exist?( './monorepo.yml' )
|
21
|
+
'./monorepo.yml'
|
22
|
+
elsif File.exist?( './monotree.yml' )
|
23
|
+
'./monotree.yml'
|
24
|
+
elsif File.exist?( './repos.yml' )
|
25
|
+
'./repos.yml'
|
26
|
+
else
|
27
|
+
puts "!! WARN: no mono configuration file (that is, {monorepo,monotree,repos}.yml) found in >#{Dir.getwd}<"
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
|
31
|
+
if path
|
32
|
+
GitRepoSet.read( path )
|
33
|
+
else
|
34
|
+
GitRepoSet.new( {} ) ## return empty set -todo/check: return nil - why? why not?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end ## module Mono
|
39
|
+
|
40
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Mono
|
2
|
+
|
3
|
+
## pass along hash of repos (e.g. monorepo.yml or repos.yml )
|
4
|
+
def self.backup
|
5
|
+
repos = Mono.monofile
|
6
|
+
|
7
|
+
backup = GitBackup.new
|
8
|
+
|
9
|
+
## step 2: pass in all repos to backup by using
|
10
|
+
## 1) git clone --mirror or
|
11
|
+
## 2) git remote update (if local backup already exists)
|
12
|
+
backup.backup( repos )
|
13
|
+
end # method backup
|
14
|
+
|
15
|
+
end # module Mono
|
data/lib/mono/commands/env.rb
CHANGED
@@ -1,13 +1,26 @@
|
|
1
|
-
module Mono
|
2
|
-
|
3
|
-
def self.env ## check environment setup
|
4
|
-
puts "Mono.root (MOPATH): >#{Mono.root}<"
|
5
|
-
puts "
|
6
|
-
puts
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
1
|
+
module Mono
|
2
|
+
|
3
|
+
def self.env ## check environment setup
|
4
|
+
puts "Mono.root (MOPATH): >#{Mono.root}<"
|
5
|
+
puts "MonoCore.root: >#{MonoCore.root}<"
|
6
|
+
puts
|
7
|
+
|
8
|
+
## add ruby version and path - why? why not? e.g.
|
9
|
+
## ruby:
|
10
|
+
## bin: C:/ri330/Ruby2.0.0/bin/ruby.exe
|
11
|
+
## version: ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32]
|
12
|
+
|
13
|
+
puts "git version:"
|
14
|
+
Git.version
|
15
|
+
## Git.config( 'user.name' )
|
16
|
+
## Git.config( 'user.email', show_origin: true )
|
17
|
+
|
18
|
+
## dump/print all user.* settings e.g. user.name, user.email
|
19
|
+
Git.config( /user/, show_origin: true )
|
20
|
+
|
21
|
+
puts
|
22
|
+
puts "monorepo.yml:"
|
23
|
+
pp Mono.monofile
|
24
|
+
end
|
25
|
+
|
26
|
+
end # module Mono
|
data/lib/mono/commands/fetch.rb
CHANGED
@@ -1,49 +1,44 @@
|
|
1
|
-
module Mono
|
2
|
-
|
3
|
-
## pass along hash of repos (e.g. monorepo.yml or repos.yml )
|
4
|
-
def self.fetch
|
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
|
-
print "#{count_repos} repo(s) @ #{count_orgs} org(s)"
|
46
|
-
print "\n"
|
47
|
-
end # method fetch
|
48
|
-
|
49
|
-
end # module Mono
|
1
|
+
module Mono
|
2
|
+
|
3
|
+
## pass along hash of repos (e.g. monorepo.yml or repos.yml )
|
4
|
+
def self.fetch
|
5
|
+
repos = Mono.monofile
|
6
|
+
|
7
|
+
count_orgs = 0
|
8
|
+
count_repos = 0
|
9
|
+
|
10
|
+
total_repos = repos.size
|
11
|
+
|
12
|
+
|
13
|
+
repos.each do |org,names|
|
14
|
+
|
15
|
+
org_path = "#{Mono.root}/#{org}"
|
16
|
+
|
17
|
+
names.each do |name|
|
18
|
+
puts "[#{count_repos+1}/#{total_repos}] #{org}@#{name}..."
|
19
|
+
|
20
|
+
repo = GitHubRepo.new( org, name ) ## owner, name e.g. rubylibs/webservice
|
21
|
+
|
22
|
+
Dir.chdir( org_path ) do
|
23
|
+
if Dir.exist?( repo.name )
|
24
|
+
GitProject.open( repo.name ) do |proj|
|
25
|
+
proj.fetch
|
26
|
+
end
|
27
|
+
else
|
28
|
+
puts "!! repo not found / missing"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
count_repos += 1
|
33
|
+
end
|
34
|
+
count_orgs += 1
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
## print stats & changes summary
|
39
|
+
puts
|
40
|
+
print "#{count_repos} repo(s) @ #{count_orgs} org(s)"
|
41
|
+
print "\n"
|
42
|
+
end # method fetch
|
43
|
+
|
44
|
+
end # module Mono
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Mono
|
2
|
+
|
3
|
+
def self.run( *args )
|
4
|
+
## todo/fix: use a "standard" argument to pass along hash of repos
|
5
|
+
## (e.g. monorepo.yml or repos.yml ) how? - why? why not?
|
6
|
+
repos = Mono.monofile
|
7
|
+
|
8
|
+
|
9
|
+
cmd = args.join( ' ' )
|
10
|
+
|
11
|
+
count_orgs = 0
|
12
|
+
count_repos = 0
|
13
|
+
|
14
|
+
total_repos = repos.size
|
15
|
+
|
16
|
+
repos.each do |org,names|
|
17
|
+
|
18
|
+
org_path = "#{Mono.root}/#{org}"
|
19
|
+
|
20
|
+
names.each do |name|
|
21
|
+
puts "[#{count_repos+1}/#{total_repos}] #{org}@#{name}..."
|
22
|
+
|
23
|
+
repo = GitHubRepo.new( org, name ) ## owner, name e.g. rubylibs/webservice
|
24
|
+
|
25
|
+
Dir.chdir( org_path ) do
|
26
|
+
if Dir.exist?( repo.name )
|
27
|
+
GitProject.open( repo.name ) do |proj|
|
28
|
+
proj.run( cmd )
|
29
|
+
end
|
30
|
+
else
|
31
|
+
puts "!! repo not found / missing"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
count_repos += 1
|
36
|
+
end
|
37
|
+
count_orgs += 1
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
## print stats & changes summary
|
42
|
+
puts
|
43
|
+
print "#{count_repos} repo(s) @ #{count_orgs} org(s)"
|
44
|
+
print "\n"
|
45
|
+
end # method run
|
46
|
+
|
47
|
+
end # module Mono
|
data/lib/mono/commands/status.rb
CHANGED
@@ -1,71 +1,65 @@
|
|
1
|
-
module Mono
|
2
|
-
|
3
|
-
## pass along hash of repos (e.g. monorepo.yml or repos.yml )
|
4
|
-
def self.status
|
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
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
end # method status
|
70
|
-
|
71
|
-
end # module Mono
|
1
|
+
module Mono
|
2
|
+
|
3
|
+
## pass along hash of repos (e.g. monorepo.yml or repos.yml )
|
4
|
+
def self.status
|
5
|
+
repos = Mono.monofile
|
6
|
+
|
7
|
+
changes = [] ## track changes
|
8
|
+
|
9
|
+
count_orgs = 0
|
10
|
+
count_repos = 0
|
11
|
+
|
12
|
+
total_repos = repos.size
|
13
|
+
|
14
|
+
repos.each do |org,names|
|
15
|
+
|
16
|
+
org_path = "#{Mono.root}/#{org}"
|
17
|
+
|
18
|
+
names.each do |name|
|
19
|
+
puts "[#{count_repos+1}/#{total_repos}] #{org}@#{name}..."
|
20
|
+
|
21
|
+
repo = GitHubRepo.new( org, name ) ## owner, name e.g. rubylibs/webservice
|
22
|
+
|
23
|
+
Dir.chdir( org_path ) do
|
24
|
+
if Dir.exist?( repo.name )
|
25
|
+
GitProject.open( repo.name ) do |proj|
|
26
|
+
output = proj.changes
|
27
|
+
if output.empty?
|
28
|
+
puts " - no changes -"
|
29
|
+
else
|
30
|
+
changes << ["#{org}@#{name}", :CHANGES, output]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
else
|
34
|
+
puts "!! repo not found / missing"
|
35
|
+
changes << ["#{org}@#{name}", :NOT_FOUND]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
count_repos += 1
|
40
|
+
end
|
41
|
+
count_orgs += 1
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
## print stats & changes summary
|
46
|
+
puts
|
47
|
+
print "#{changes.size} change(s) in "
|
48
|
+
print "#{count_repos} repo(s) @ #{count_orgs} org(s)"
|
49
|
+
print "\n"
|
50
|
+
|
51
|
+
changes.each do |item|
|
52
|
+
puts
|
53
|
+
print "== #{item[0]} - #{item[1]}"
|
54
|
+
case item[1]
|
55
|
+
when :CHANGES
|
56
|
+
print ":\n"
|
57
|
+
print item[2]
|
58
|
+
when :NOT_FOUND
|
59
|
+
print "\n"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end # method status
|
64
|
+
|
65
|
+
end # module Mono
|
data/lib/mono/commands/sync.rb
CHANGED
@@ -1,59 +1,53 @@
|
|
1
|
-
module Mono
|
2
|
-
|
3
|
-
## pass along hash of repos (e.g. monorepo.yml or repos.yml )
|
4
|
-
def self.sync
|
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
|
-
## print stats
|
56
|
-
puts "#{count_repos} repo(s) @ #{count_orgs} org(s)"
|
57
|
-
end # method sync
|
58
|
-
|
59
|
-
end # module Mono
|
1
|
+
module Mono
|
2
|
+
|
3
|
+
## pass along hash of repos (e.g. monorepo.yml or repos.yml )
|
4
|
+
def self.sync
|
5
|
+
repos = Mono.monofile
|
6
|
+
|
7
|
+
count_orgs = 0
|
8
|
+
count_repos = 0
|
9
|
+
|
10
|
+
total_repos = repos.size
|
11
|
+
|
12
|
+
repos.each do |org,names|
|
13
|
+
org_path = "#{Mono.root}/#{org}"
|
14
|
+
FileUtils.mkdir_p( org_path ) unless Dir.exist?( org_path ) ## make sure path exists
|
15
|
+
|
16
|
+
names.each do |name|
|
17
|
+
puts "[#{count_repos+1}/#{total_repos}] #{org}@#{name}..."
|
18
|
+
|
19
|
+
repo = GitHubRepo.new( org, name ) ## owner, name e.g. rubylibs/webservice
|
20
|
+
|
21
|
+
Dir.chdir( org_path ) do
|
22
|
+
if Dir.exist?( repo.name )
|
23
|
+
GitProject.open( repo.name ) do |proj|
|
24
|
+
if proj.changes?
|
25
|
+
puts "!! WARN - local changes in workdir; skipping fast forward (remote) sync / merge"
|
26
|
+
else
|
27
|
+
proj.fast_forward ## note: use git pull --ff-only (fast forward only - do NOT merge)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
else
|
31
|
+
Git.clone( repo.ssh_clone_url )
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# todo/fix: add (back) error log !!!!!!!!!!!!
|
37
|
+
# rescue GitError => ex
|
38
|
+
# puts "!! ERROR: #{ex.message}"
|
39
|
+
#
|
40
|
+
# File.open( './errors.log', 'a' ) do |f|
|
41
|
+
# f.write "#{Time.now} -- repo #{org}/#{name} - #{ex.message}\n"
|
42
|
+
# end
|
43
|
+
|
44
|
+
count_repos += 1
|
45
|
+
end
|
46
|
+
count_orgs += 1
|
47
|
+
end
|
48
|
+
|
49
|
+
## print stats
|
50
|
+
puts "#{count_repos} repo(s) @ #{count_orgs} org(s)"
|
51
|
+
end # method sync
|
52
|
+
|
53
|
+
end # module Mono
|
data/lib/mono/tool.rb
CHANGED
@@ -1,37 +1,41 @@
|
|
1
|
-
module Mono
|
2
|
-
|
3
|
-
|
4
|
-
class Tool
|
5
|
-
def self.main( args=ARGV )
|
6
|
-
|
7
|
-
## note: for now assume first argument is command
|
8
|
-
## add options later
|
9
|
-
|
10
|
-
cmd = if args.size == 0
|
11
|
-
'status' ## make status "default" command
|
12
|
-
else
|
13
|
-
args.shift ## remove first (head) element
|
14
|
-
end
|
15
|
-
|
16
|
-
## note: allow shortcut for commands
|
17
|
-
case cmd.downcase
|
18
|
-
when 'status', 'stati', 'stat', 'st', 's'
|
19
|
-
Mono.status
|
20
|
-
when 'sync', 'syn', 'sy', ## note: allow aliases such as install, get & up too
|
21
|
-
'get', 'g',
|
22
|
-
'install', 'insta', 'inst', 'ins', 'i',
|
23
|
-
'up', 'u'
|
24
|
-
Mono.sync
|
25
|
-
when 'fetch', 'f'
|
26
|
-
Mono.fetch
|
27
|
-
when 'env', 'e'
|
28
|
-
Mono.env
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
1
|
+
module Mono
|
2
|
+
|
3
|
+
|
4
|
+
class Tool
|
5
|
+
def self.main( args=ARGV )
|
6
|
+
|
7
|
+
## note: for now assume first argument is command
|
8
|
+
## add options later
|
9
|
+
|
10
|
+
cmd = if args.size == 0
|
11
|
+
'status' ## make status "default" command
|
12
|
+
else
|
13
|
+
args.shift ## remove first (head) element
|
14
|
+
end
|
15
|
+
|
16
|
+
## note: allow shortcut for commands
|
17
|
+
case cmd.downcase
|
18
|
+
when 'status', 'stati', 'stat', 'st', 's'
|
19
|
+
Mono.status
|
20
|
+
when 'sync', 'syn', 'sy', ## note: allow aliases such as install, get & up too
|
21
|
+
'get', 'g',
|
22
|
+
'install', 'insta', 'inst', 'ins', 'i',
|
23
|
+
'up', 'u'
|
24
|
+
Mono.sync
|
25
|
+
when 'fetch', 'f'
|
26
|
+
Mono.fetch
|
27
|
+
when 'env', 'e'
|
28
|
+
Mono.env
|
29
|
+
when 'backup', 'back', 'b'
|
30
|
+
Mono.backup
|
31
|
+
when 'run', 'r', 'exec'
|
32
|
+
Mono.run( args )
|
33
|
+
else
|
34
|
+
puts "!! ERROR: unknown command >#{cmd}<"
|
35
|
+
exit 1
|
36
|
+
end
|
37
|
+
|
38
|
+
end # method self.main
|
39
|
+
end # class Tool
|
40
|
+
|
37
41
|
end # module Mono
|
data/lib/mono/version.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
## note: use a different module/namespace
|
2
|
-
## for the gem version info e.g.
|
2
|
+
## for the gem version info e.g. MonoCore vs Mono
|
3
3
|
|
4
|
-
module
|
4
|
+
module MonoCore ## todo/check: rename to MonoMeta, MonoModule or such - why? why not?
|
5
|
+
|
6
|
+
## note: move root to its own namespace to avoid
|
7
|
+
## conflict with Mono.root!!!!
|
5
8
|
MAJOR = 0 ## todo: namespace inside version or something - why? why not??
|
6
|
-
MINOR =
|
9
|
+
MINOR = 5
|
7
10
|
PATCH = 0
|
8
11
|
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
9
12
|
|
@@ -11,18 +14,20 @@ module Mono
|
|
11
14
|
VERSION
|
12
15
|
end
|
13
16
|
|
17
|
+
def self.banner
|
18
|
+
"monos/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.root
|
22
|
+
File.expand_path( File.dirname(File.dirname(__FILE__) ))
|
23
|
+
end
|
14
24
|
|
15
|
-
|
16
|
-
## note: move root to its own namespace to avoid
|
17
|
-
## conflict with Mono.root!!!!
|
25
|
+
end # module MonoCore
|
18
26
|
|
19
|
-
def self.banner
|
20
|
-
"monos/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
21
|
-
end
|
22
27
|
|
23
|
-
|
24
|
-
|
25
|
-
|
28
|
+
##################################
|
29
|
+
# add a convenience shortcut for now - why? why not?
|
30
|
+
module Mono
|
31
|
+
VERSION = MonoCore::VERSION
|
32
|
+
end
|
26
33
|
|
27
|
-
end # module Module
|
28
|
-
end # module Mono
|
data/test/test_base.rb
CHANGED
@@ -6,10 +6,14 @@ require 'helper'
|
|
6
6
|
|
7
7
|
class TestBase < MiniTest::Test
|
8
8
|
|
9
|
+
Git = Mono::Git
|
10
|
+
|
9
11
|
def test_version
|
12
|
+
puts MonoCore::VERSION
|
13
|
+
puts MonoCore.banner
|
14
|
+
puts MonoCore.root
|
15
|
+
|
10
16
|
puts Mono::VERSION
|
11
|
-
puts Mono::Module.banner
|
12
|
-
puts Mono::Module.root
|
13
17
|
end
|
14
18
|
|
15
19
|
def test_root
|
@@ -20,5 +24,28 @@ class TestBase < MiniTest::Test
|
|
20
24
|
puts Mono.env
|
21
25
|
end
|
22
26
|
|
27
|
+
|
28
|
+
def test_git_config
|
29
|
+
puts "---"
|
30
|
+
Git.config( 'user.name' )
|
31
|
+
Git.config( 'user.name', show_origin: true )
|
32
|
+
# Git.config( 'user.name', show_scope: true )
|
33
|
+
|
34
|
+
puts "---"
|
35
|
+
Git.config( /user/ ) ## note: pass in regex for regex match/search
|
36
|
+
Git.config( /user/, show_origin: true )
|
37
|
+
# Git.config( /user/, show_scope: true )
|
38
|
+
|
39
|
+
puts "---"
|
40
|
+
Git.config( /user\./ ) ## note: pass in regex for regex match/search
|
41
|
+
|
42
|
+
puts "---"
|
43
|
+
## note: if NOT found Mono::Git.config will exit(1) !!!
|
44
|
+
## Mono::Git.config( /proxy/, show_origin: true )
|
45
|
+
## Mono::Git.config( /http/, show_origin: true )
|
46
|
+
|
47
|
+
puts "---"
|
48
|
+
end
|
49
|
+
|
23
50
|
end # class TestBase
|
24
51
|
|
metadata
CHANGED
@@ -1,43 +1,77 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gitti
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.6.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.6.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: gitti-backup
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.4.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.4.1
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: rdoc
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
16
44
|
requirements:
|
17
|
-
- - "
|
45
|
+
- - ">="
|
18
46
|
- !ruby/object:Gem::Version
|
19
47
|
version: '4.0'
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '7'
|
20
51
|
type: :development
|
21
52
|
prerelease: false
|
22
53
|
version_requirements: !ruby/object:Gem::Requirement
|
23
54
|
requirements:
|
24
|
-
- - "
|
55
|
+
- - ">="
|
25
56
|
- !ruby/object:Gem::Version
|
26
57
|
version: '4.0'
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '7'
|
27
61
|
- !ruby/object:Gem::Dependency
|
28
62
|
name: hoe
|
29
63
|
requirement: !ruby/object:Gem::Requirement
|
30
64
|
requirements:
|
31
65
|
- - "~>"
|
32
66
|
- !ruby/object:Gem::Version
|
33
|
-
version: '3.
|
67
|
+
version: '3.22'
|
34
68
|
type: :development
|
35
69
|
prerelease: false
|
36
70
|
version_requirements: !ruby/object:Gem::Requirement
|
37
71
|
requirements:
|
38
72
|
- - "~>"
|
39
73
|
- !ruby/object:Gem::Version
|
40
|
-
version: '3.
|
74
|
+
version: '3.22'
|
41
75
|
description: monos - monorepo / mono source tree tools and (startup) scripts
|
42
76
|
email: opensport@googlegroups.com
|
43
77
|
executables:
|
@@ -57,18 +91,18 @@ files:
|
|
57
91
|
- bin/mono
|
58
92
|
- lib/mono.rb
|
59
93
|
- lib/mono/base.rb
|
94
|
+
- lib/mono/commands/backup.rb
|
60
95
|
- lib/mono/commands/env.rb
|
61
96
|
- lib/mono/commands/fetch.rb
|
97
|
+
- lib/mono/commands/run.rb
|
62
98
|
- lib/mono/commands/status.rb
|
63
99
|
- lib/mono/commands/sync.rb
|
64
|
-
- lib/mono/git/base.rb
|
65
|
-
- lib/mono/sportdb.rb
|
66
100
|
- lib/mono/tool.rb
|
67
101
|
- lib/mono/version.rb
|
68
102
|
- lib/monos.rb
|
69
103
|
- test/helper.rb
|
70
104
|
- test/test_base.rb
|
71
|
-
homepage: https://github.com/
|
105
|
+
homepage: https://github.com/rubycoco/git
|
72
106
|
licenses:
|
73
107
|
- Public Domain
|
74
108
|
metadata: {}
|
data/lib/mono/git/base.rb
DELETED
@@ -1,225 +0,0 @@
|
|
1
|
-
|
2
|
-
class GitError < StandardError
|
3
|
-
end
|
4
|
-
|
5
|
-
class Git ## make Git a module - why? why not?
|
6
|
-
|
7
|
-
###
|
8
|
-
## todo/fix: change opts=nil to *args or such - why? why not?
|
9
|
-
|
10
|
-
|
11
|
-
###############
|
12
|
-
## "setup" starter git commands
|
13
|
-
|
14
|
-
def self.clone( repo, name=nil )
|
15
|
-
cmd = "git clone #{repo}"
|
16
|
-
cmd << " #{name}" unless name.nil? || name.empty?
|
17
|
-
Shell.run( cmd )
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.mirror( repo )
|
21
|
-
cmd = "git clone --mirror #{repo}"
|
22
|
-
Shell.run( cmd )
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
|
-
#################
|
27
|
-
## standard git commands
|
28
|
-
|
29
|
-
def self.version
|
30
|
-
cmd = 'git --version'
|
31
|
-
Shell.run( cmd )
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.status( short: false )
|
35
|
-
cmd = 'git status'
|
36
|
-
cmd << " --short" if short
|
37
|
-
Shell.run( cmd )
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.changes ## same as git status --short - keep shortcut / alias - why? why not?
|
41
|
-
## returns changed files - one per line or empty if no changes
|
42
|
-
cmd = 'git status --short'
|
43
|
-
Shell.run( cmd )
|
44
|
-
end
|
45
|
-
|
46
|
-
#####################
|
47
|
-
## status helpers
|
48
|
-
|
49
|
-
## git status --short returns empty stdout/list
|
50
|
-
def self.clean?() changes.empty?; end
|
51
|
-
|
52
|
-
def self.changes?() clean? == false; end ## reverse of clean?
|
53
|
-
class << self
|
54
|
-
alias_method :dirty?, :changes? ## add alias
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
#######
|
59
|
-
## more (major) git commands
|
60
|
-
|
61
|
-
def self.fetch
|
62
|
-
cmd = 'git fetch'
|
63
|
-
Shell.run( cmd )
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.pull
|
67
|
-
cmd = 'git pull'
|
68
|
-
Shell.run( cmd )
|
69
|
-
end
|
70
|
-
|
71
|
-
def self.fast_forward
|
72
|
-
cmd = 'git pull --ff-only'
|
73
|
-
Shell.run( cmd )
|
74
|
-
end
|
75
|
-
class << self
|
76
|
-
alias_method :ff, :fast_forward ## add alias
|
77
|
-
end
|
78
|
-
|
79
|
-
|
80
|
-
def self.push
|
81
|
-
cmd = 'git push'
|
82
|
-
Shell.run( cmd )
|
83
|
-
end
|
84
|
-
|
85
|
-
def self.add( pathspec=nil ) ## e.g. git add . or git add *.rb or such
|
86
|
-
cmd = 'git add'
|
87
|
-
cmd << " #{pathspec}" unless pathspec.nil? || pathspec.empty?
|
88
|
-
Shell.run( cmd )
|
89
|
-
end
|
90
|
-
|
91
|
-
def self.add_all
|
92
|
-
cmd = 'git add --all'
|
93
|
-
Shell.run( cmd )
|
94
|
-
end
|
95
|
-
|
96
|
-
def self.commit( message: )
|
97
|
-
cmd = 'git commit'
|
98
|
-
cmd << %Q{ -m "#{message}"} unless message.nil? || message.empty?
|
99
|
-
Shell.run( cmd )
|
100
|
-
end
|
101
|
-
|
102
|
-
|
103
|
-
#############
|
104
|
-
# change git ls-files to git ls-tree ... - why? why not?
|
105
|
-
#
|
106
|
-
# git ls-tree --full-tree --name-only -r HEAD
|
107
|
-
# --full-tree makes the command run as if you were in the repo's root directory.
|
108
|
-
# -r recurses into subdirectories. Combined with --full-tree, this gives you all committed, tracked files.
|
109
|
-
# --name-only removes SHA / permission info for when you just want the file paths.
|
110
|
-
# HEAD specifies which branch you want the list of tracked, committed files for.
|
111
|
-
# You could change this to master or any other branch name, but HEAD is the commit you have checked out right now.
|
112
|
-
#
|
113
|
-
# see https://stackoverflow.com/questions/15606955/how-can-i-make-git-show-a-list-of-the-files-that-are-being-tracked
|
114
|
-
|
115
|
-
def self.files( pathspec=nil ) ## e.g. git ls-files . or git ls-files *.rb or such
|
116
|
-
cmd = 'git ls-files'
|
117
|
-
cmd << " #{pathspec}" unless pathspec.nil? || pathspec.empty?
|
118
|
-
Shell.run( cmd )
|
119
|
-
end
|
120
|
-
## add list_files or ls_files alias - why? why not?
|
121
|
-
|
122
|
-
|
123
|
-
###
|
124
|
-
# use nested class for "base" for running commands - why? why not?
|
125
|
-
class Shell
|
126
|
-
def self.run( cmd )
|
127
|
-
print "cmd exec >#{cmd}<..."
|
128
|
-
stdout, stderr, status = Open3.capture3( cmd )
|
129
|
-
|
130
|
-
if status.success?
|
131
|
-
print " OK"
|
132
|
-
print "\n"
|
133
|
-
else
|
134
|
-
print " FAIL (#{status.exitstatus})"
|
135
|
-
print "\n"
|
136
|
-
end
|
137
|
-
|
138
|
-
unless stdout.empty?
|
139
|
-
puts stdout
|
140
|
-
end
|
141
|
-
|
142
|
-
unless stderr.empty?
|
143
|
-
## todo/check: or use >2: or &2: or such
|
144
|
-
## stderr output not always an error (that is, exit status might be 0)
|
145
|
-
puts "STDERR:"
|
146
|
-
puts stderr
|
147
|
-
end
|
148
|
-
|
149
|
-
if status.success?
|
150
|
-
stdout # return stdout string
|
151
|
-
else
|
152
|
-
puts "!! ERROR: cmd exec >#{cmd}< failed with exit status #{status.exitstatus}:"
|
153
|
-
puts stderr
|
154
|
-
raise GitError, "git cmd exec >#{cmd}< failed with exit status #{status.exitstatus}<: #{stderr}"
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end # class Shell
|
158
|
-
|
159
|
-
end # class Git
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
class GitProject
|
164
|
-
def self.open( path, &blk )
|
165
|
-
new( path ).open( &blk )
|
166
|
-
end
|
167
|
-
|
168
|
-
def initialize( path )
|
169
|
-
raise ArgumentError, "dir >#{path}< not found; dir MUST already exist for GitProject class - sorry" unless Dir.exist?( path )
|
170
|
-
raise ArgumentError, "dir >#{path}/.git< not found; dir MUST already be initialized with git for GitProject class - sorry" unless Dir.exist?( "#{path}/.git" )
|
171
|
-
@path = path
|
172
|
-
end
|
173
|
-
|
174
|
-
|
175
|
-
def open( &blk )
|
176
|
-
## puts "Dir.getwd: #{Dir.getwd}"
|
177
|
-
Dir.chdir( @path ) do
|
178
|
-
blk.call( self )
|
179
|
-
end
|
180
|
-
## puts "Dir.getwd: #{Dir.getwd}"
|
181
|
-
end
|
182
|
-
|
183
|
-
|
184
|
-
def status( short: false ) Git.status( short: short ); end
|
185
|
-
def changes() Git.changes; end
|
186
|
-
def clean?() Git.clean?; end
|
187
|
-
def changes?() Git.changes?; end
|
188
|
-
alias_method :dirty?, :changes?
|
189
|
-
|
190
|
-
|
191
|
-
def fetch() Git.fetch; end
|
192
|
-
def pull() Git.pull; end
|
193
|
-
def fast_forward() Git.fast_forward; end
|
194
|
-
alias_method :ff, :fast_forward
|
195
|
-
|
196
|
-
def push() Git.push; end
|
197
|
-
|
198
|
-
def add( pathspec ) Git.add( pathspec ); end
|
199
|
-
def add_all() Git.add_all; end
|
200
|
-
def commit( message: ) Git.commit( message: message ); end
|
201
|
-
|
202
|
-
def files( pathspec=nil ) Git.files( pathspec ); end
|
203
|
-
|
204
|
-
end # class GitProject
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
## todo: change to GitHubRepoRef or GitHubProject
|
210
|
-
## or Git::GitHub or Git::Source::GitHub or such - why? why not?
|
211
|
-
class GitHubRepo
|
212
|
-
attr_reader :owner, :name
|
213
|
-
|
214
|
-
def initialize( owner, name )
|
215
|
-
@owner = owner ## use/rename to login or something - why? why not??
|
216
|
-
@name = name # e.g. "rubylibs/webservice"
|
217
|
-
end
|
218
|
-
|
219
|
-
def ssh_clone_url
|
220
|
-
## check: use https: as default? for github - http:// still supported? or redirected?
|
221
|
-
## "http://github.com/#{@owner}/#{@name}"
|
222
|
-
"git@github.com:#{@owner}/#{@name}.git"
|
223
|
-
end
|
224
|
-
end ## class GitHubRepo
|
225
|
-
|
data/lib/mono/sportdb.rb
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
##########
|
2
|
-
# setup load path
|
3
|
-
# lets you use environments
|
4
|
-
# e.g. dev/development or production
|
5
|
-
|
6
|
-
|
7
|
-
## todo/fix: move later app/gem-family/-specific configs
|
8
|
-
## to its own gem e.g. mono-sportdb or such - why? why not?
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
$RUBYLIBS_DEBUG = true
|
15
|
-
$RUBYCOCO_DEBUG = true ## always include (NOT just in sportdb?)
|
16
|
-
|
17
|
-
|
18
|
-
### include / check for ruby debug flag too - why? why not?
|
19
|
-
def debug? ## always include (NOT just insportdb?)
|
20
|
-
value = ENV['DEBUG']
|
21
|
-
if value && ['true', 't',
|
22
|
-
'yes', 'y',
|
23
|
-
'on'].include?( value.downcase )
|
24
|
-
true
|
25
|
-
else
|
26
|
-
false
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
require_relative '../mono'
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
SPORTDB_DIR = "#{Mono.root}/sportdb" # path to libs
|
37
|
-
OPENFOOTBALL_DIR = "#{Mono.root}/openfootball"
|
38
|
-
## add more "standard" dirs - why? why not? - why? why not?
|
39
|
-
## use
|
40
|
-
## module SportDb::Source / Code / Boot or such????
|
41
|
-
##
|
42
|
-
## use module SportDb::Boot - yes, yes, yes - why? why not?
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
## convenience pre-configured/pre-built shortcut - lets you use
|
47
|
-
## require 'mono/sportdb'
|
48
|
-
## Mono.setup
|
49
|
-
|
50
|
-
## use SportDb::Boot.setup (setup_load_path) or such??? - why? why not?
|
51
|
-
|
52
|
-
module Mono
|
53
|
-
def self.setup ## setup load path
|
54
|
-
### note: for now always assume dev/development
|
55
|
-
### add ENV check later or pass in as args or such
|
56
|
-
|
57
|
-
puts "Mono.root: >#{root}<"
|
58
|
-
|
59
|
-
$LOAD_PATH.unshift( "#{root}/yorobot/sport.db.more/sportdb-exporters/lib" )
|
60
|
-
$LOAD_PATH.unshift( "#{root}/yorobot/sport.db.more/sportdb-writers/lib" )
|
61
|
-
$LOAD_PATH.unshift( "#{root}/yorobot/sport.db.more/sportdb-linters/lib" )
|
62
|
-
|
63
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sports/lib" )
|
64
|
-
|
65
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-importers/lib" )
|
66
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-readers/lib" )
|
67
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-sync/lib" )
|
68
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-models/lib" )
|
69
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-catalogs/lib" )
|
70
|
-
|
71
|
-
## todo/check:
|
72
|
-
## add fifa, footballdb-leagues, footballdb-clubs too ???
|
73
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/football.db/footballdb-clubs/lib" ))
|
74
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/football.db/footballdb-leagues/lib" ))
|
75
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/football.db/fifa/lib" ))
|
76
|
-
|
77
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-formats/lib" )
|
78
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-structs/lib" )
|
79
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-langs/lib" )
|
80
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/score-formats/lib" )
|
81
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/date-formats/lib" )
|
82
|
-
$LOAD_PATH.unshift( "#{root}/sportdb/sport.db/alphabets/lib" )
|
83
|
-
|
84
|
-
pp $: # print load path
|
85
|
-
end
|
86
|
-
end # module Mono
|
87
|
-
|
88
|
-
|
89
|
-
## todo/fix:
|
90
|
-
## use
|
91
|
-
## module Starter
|
92
|
-
## module SportDb
|
93
|
-
## def setup ...
|
94
|
-
## end
|
95
|
-
## end
|
96
|
-
##
|
97
|
-
## or such? and use Mono.extend - why? why not?
|
98
|
-
## module Mono
|
99
|
-
## extend Starter::SportDb
|
100
|
-
## end
|
101
|
-
|