monos 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 938f3fee4f29836650bf78e6a65caed685bda945
4
- data.tar.gz: 294077f35cb57a027a82d0b9533f1a80cc1f1fe5
3
+ metadata.gz: 0ed5ea6cba9c516588dc37be7d6f5fb8d3b34b55
4
+ data.tar.gz: ec4093fb26ef80b80a808d790b969cf8bc78994b
5
5
  SHA512:
6
- metadata.gz: cb3f0d236dc69a7599115f31ab4a198b49c79e103e20162f158093a201bedeae26613b32e5126105aab00e2acba765d0525c9e3c73ed5aaa20eff9a9385c4010
7
- data.tar.gz: 5f728eddb54857a5f3983e8be2bfc8a490c8b4ea4707a3f9928ab5ac223ae9a0c79545662c88e7e3217822ecc3f0cb906e41cd82d60f062158b26c8987427aed
6
+ metadata.gz: 646e57745308c2b3863531a1972497f98a5d17d0af62eef68b27ca82fcd605f5212cf5025f106ce3f053133ccdd5743279a00b8177724ea5b45f9f67eaebea52
7
+ data.tar.gz: 55b9207a778b841ec19885ccbbe035ea40a990eac5ea36189d02091e36ceae474d2b11b66ea24209b34ea001f1b1193f582371518644734cefd1bec0c61624b7
@@ -3,15 +3,16 @@ Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
5
  bin/mo
6
- bin/moget
7
6
  bin/mono
8
7
  lib/mono.rb
9
8
  lib/mono/base.rb
9
+ lib/mono/commands/env.rb
10
+ lib/mono/commands/fetch.rb
11
+ lib/mono/commands/status.rb
12
+ lib/mono/commands/sync.rb
10
13
  lib/mono/git/base.rb
11
- lib/mono/git/status.rb
12
- lib/mono/git/sync.rb
13
- lib/mono/git/tool.rb
14
14
  lib/mono/sportdb.rb
15
+ lib/mono/tool.rb
15
16
  lib/mono/version.rb
16
17
  lib/monos.rb
17
18
  test/helper.rb
data/README.md CHANGED
@@ -32,23 +32,17 @@ to be part of the "virtual" all-in-one / single mono source tree
32
32
  in your project. Example:
33
33
 
34
34
  ``` yaml
35
- ####################
36
- # checkout skripts (auto-update machinery)
37
- yorobot:
38
- - cache.csv ## incl. self
39
- - sport.db.more
40
- - football.db
41
- - football.csv
42
-
43
- ###############
44
- # use latest sportdb machinery (from source)
45
35
  sportdb:
46
36
  - sport.db
47
37
  - sport.db.sources
48
38
  - football.db
49
39
 
50
- #####################
51
- # football.db - open football
40
+ yorobot:
41
+ - cache.csv
42
+ - sport.db.more
43
+ - football.db
44
+ - football.csv
45
+
52
46
  openfootball:
53
47
  - leagues
54
48
  - clubs
@@ -58,7 +52,7 @@ openfootball:
58
52
 
59
53
  ### Commands
60
54
 
61
- `status` • `sync` • `env`
55
+ `status` • `fetch` • `sync` • `env`
62
56
 
63
57
  ### `status` Command
64
58
 
@@ -77,7 +71,7 @@ resulting in something like:
77
71
  ```
78
72
  2 change(s) in 9 repo(s) @ 3 org(s)
79
73
 
80
- == yorobot@cache.csv - CHANGES:
74
+ -- sportdb@sport.db - CHANGES:
81
75
  M monos/Manifest.txt
82
76
  M monos/README.md
83
77
  M monos/Rakefile
@@ -88,18 +82,26 @@ RM monos/lib/monoscript.rb -> monos/lib/monos.rb
88
82
  M monos/test/test_base.rb
89
83
  ?? monos/bin/
90
84
 
91
- == yorobot@football.csv - CHANGES:
85
+ -- yorobot@football.csv - CHANGES:
92
86
  ?? footballdata/
93
87
  ```
94
88
 
95
89
 
90
+ ### `fetch` Command
96
91
 
97
- ### `sync` Command
92
+ Use the `fetch` command to fetch all (remote) changes (will use `git fetch`) on all existing repos and warn about not-yet-cloned repos. Example:
98
93
 
94
+ ```
95
+ $ mono fetch
96
+ $ mo fetch # mo is a "shortcut" convenience alias for mono
97
+ ```
99
98
 
100
- Use the `sync` command to sync up (pull) changes (will use `git pull --ff-only`) on all existing repos and `git clone` for new not-yet-cloned repos.
101
99
 
102
- Example:
100
+
101
+ ### `sync` Command
102
+
103
+
104
+ Use the `sync` command to sync up (pull) changes (will use `git pull --ff-only`) on all existing repos and `git clone` for new not-yet-cloned repos. Example:
103
105
 
104
106
  ```
105
107
  $ mono sync
@@ -107,13 +109,10 @@ $ mono install # install is an alias for sync
107
109
  $ mono get # get is another alias for sync
108
110
  $ mo sync # mo is a "shortcut" convenience alias for mono
109
111
  $ mo get
110
- $ moget # moget is a "shortcut" convenience alis for mono get
111
112
  ```
112
113
 
113
114
  Note: `install` or `get` or `up` are all aliases that you can use for `sync`.
114
115
 
115
- Note: `moget` is a shortcut convenience command for `mono get` (or, that is, `mono sync`).
116
-
117
116
 
118
117
 
119
118
  ### `env` Command
data/Rakefile CHANGED
@@ -3,15 +3,16 @@ require './lib/mono/version.rb'
3
3
 
4
4
  Hoe.spec 'monos' do
5
5
 
6
- self.version = Mono::Module::VERSION
6
+ self.version = Mono::VERSION
7
7
 
8
8
  self.summary = "monos - monorepo / mono source tree tools and (startup) scripts"
9
9
  self.description = summary
10
10
 
11
- self.urls = ['https://github.com/sportdb/sport.db']
11
+ # self.urls = ['https://github.com/sportdb/sport.db' ]
12
+ self.urls = { home: 'https://github.com/sportdb/sport.db' }
12
13
 
13
14
  self.author = 'Gerald Bauer'
14
- self.email = 'opensport@googlegroups.com'
15
+ self.email = 'opensport@googlegroups.com'
15
16
 
16
17
  # switch extension to .markdown for gihub formatting
17
18
  self.readme_file = 'README.md'
@@ -12,24 +12,12 @@ require 'optparse'
12
12
  require 'mono/version' # let version always go first
13
13
  require 'mono/base'
14
14
  require 'mono/git/base'
15
- require 'mono/git/sync'
16
- require 'mono/git/status'
17
- require 'mono/git/tool'
18
15
 
19
-
20
-
21
-
22
- module Mono
23
- def self.env ## check environment setup
24
- puts "Mono.root (MOPATH): >#{Mono.root}<"
25
- puts "Mono::Module.root: >#{Mono::Module.root}<"
26
- puts "git version:"
27
- Git.version
28
- puts
29
- puts "monorepo.yml:"
30
- pp Mono.monofile
31
- end
32
- end # module Mono
16
+ require 'mono/commands/status'
17
+ require 'mono/commands/fetch'
18
+ require 'mono/commands/sync'
19
+ require 'mono/commands/env'
20
+ require 'mono/tool'
33
21
 
34
22
 
35
23
 
@@ -16,6 +16,25 @@ module Mono
16
16
  end
17
17
  end
18
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
+ YAML.load_file( path )
33
+ else
34
+ {}
35
+ end
36
+ end
37
+
19
38
  end ## module Mono
20
39
 
21
40
 
@@ -0,0 +1,13 @@
1
+ module Mono
2
+
3
+ def self.env ## check environment setup
4
+ puts "Mono.root (MOPATH): >#{Mono.root}<"
5
+ puts "Mono::Module.root: >#{Mono::Module.root}<"
6
+ puts "git version:"
7
+ Git.version
8
+ puts
9
+ puts "monorepo.yml:"
10
+ pp Mono.monofile
11
+ end
12
+
13
+ end # module Mono
@@ -0,0 +1,49 @@
1
+ module Mono
2
+
3
+ ## pass along hash of repos (e.g. monorepo.yml or repos.yml )
4
+ def self.fetch( h=Mono.monofile )
5
+ count_orgs = 0
6
+ count_repos = 0
7
+
8
+ ## sum up total number of repos
9
+ total_repos = h.reduce(0) {|sum,(_,names)| sum+= names.size; sum }
10
+
11
+
12
+ h.each do |org_with_counter,names|
13
+
14
+ ## remove optional number from key e.g.
15
+ ## mrhydescripts (3) => mrhydescripts
16
+ ## footballjs (4) => footballjs
17
+ ## etc.
18
+ org = org_with_counter.sub( /\([0-9]+\)/, '' ).strip
19
+
20
+ org_path = "#{Mono.root}/#{org}"
21
+
22
+ names.each do |name|
23
+ puts "[#{count_repos+1}/#{total_repos}] #{org}@#{name}..."
24
+
25
+ repo = GitHubRepo.new( org, name ) ## owner, name e.g. rubylibs/webservice
26
+
27
+ Dir.chdir( org_path ) do
28
+ if Dir.exist?( repo.name )
29
+ GitProject.open( repo.name ) do |git|
30
+ git.fetch
31
+ end
32
+ else
33
+ puts "!! repo not found / missing"
34
+ end
35
+ end
36
+
37
+ count_repos += 1
38
+ end
39
+ count_orgs += 1
40
+ end
41
+
42
+
43
+ ## print stats & changes summary
44
+ puts
45
+ print "#{count_repos} repo(s) @ #{count_orgs} org(s)"
46
+ print "\n"
47
+ end # method fetch
48
+
49
+ end # module Mono
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  module Mono
4
2
 
5
3
  ## pass along hash of repos (e.g. monorepo.yml or repos.yml )
@@ -30,7 +28,7 @@ module Mono
30
28
 
31
29
  Dir.chdir( org_path ) do
32
30
  if Dir.exist?( repo.name )
33
- GitRepo.open( repo.name ) do |git|
31
+ GitProject.open( repo.name ) do |git|
34
32
  output = git.changes
35
33
  if output.empty?
36
34
  puts " - no changes -"
@@ -1,44 +1,5 @@
1
-
2
-
3
- class GitHubRepo ## todo: change to GitHubRepoRef or such - why? why not?
4
- attr_reader :owner, :name
5
-
6
- def initialize( owner, name )
7
- @owner = owner ## use/rename to login or something - why? why not??
8
- @name = name # e.g. "rubylibs/webservice"
9
- end
10
-
11
- def ssh_clone_url
12
- ## check: use https: as default? for github - http:// still supported? or redirected?
13
- ## "http://github.com/#{@owner}/#{@name}"
14
- "git@github.com:#{@owner}/#{@name}.git"
15
- end
16
- end ## class GitHubRepo
17
-
18
-
19
-
20
1
  module Mono
21
2
 
22
- def self.monofile
23
- path = if File.exist?( './monorepo.yml' )
24
- './monorepo.yml'
25
- elsif File.exist?( './monotree.yml' )
26
- './monotree.yml'
27
- elsif File.exist?( './repos.yml' )
28
- './repos.yml'
29
- else
30
- puts "!! WARN: no mo|moget|mono configuration file (that is, monorepo|monotree|repos.yml) found in >#{Dir.getwd}<"
31
- nil
32
- end
33
-
34
- if path
35
- YAML.load_file( path )
36
- else
37
- {}
38
- end
39
- end
40
-
41
-
42
3
  ## pass along hash of repos (e.g. monorepo.yml or repos.yml )
43
4
  def self.sync( h=Mono.monofile )
44
5
  count_orgs = 0
@@ -65,7 +26,7 @@ module Mono
65
26
 
66
27
  Dir.chdir( org_path ) do
67
28
  if Dir.exist?( repo.name )
68
- GitRepo.open( repo.name ) do |git|
29
+ GitProject.open( repo.name ) do |git|
69
30
  if git.changes?
70
31
  puts "!! WARN - local changes in workdir; skipping fast forward (remote) sync / merge"
71
32
  else
@@ -58,6 +58,11 @@ class Git ## make Git a module - why? why not?
58
58
  #######
59
59
  ## more (major) git commands
60
60
 
61
+ def self.fetch
62
+ cmd = 'git fetch'
63
+ Shell.run( cmd )
64
+ end
65
+
61
66
  def self.pull
62
67
  cmd = 'git pull'
63
68
  Shell.run( cmd )
@@ -95,6 +100,26 @@ class Git ## make Git a module - why? why not?
95
100
  end
96
101
 
97
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
+
98
123
  ###
99
124
  # use nested class for "base" for running commands - why? why not?
100
125
  class Shell
@@ -135,16 +160,18 @@ end # class Git
135
160
 
136
161
 
137
162
 
138
- class GitRepo
163
+ class GitProject
139
164
  def self.open( path, &blk )
140
165
  new( path ).open( &blk )
141
166
  end
142
167
 
143
168
  def initialize( path )
144
- raise ArgumentError, "dir >#{path}< not found; dir MUST already exist for GitRepo class - sorry" unless Dir.exist?( 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" )
145
171
  @path = path
146
172
  end
147
173
 
174
+
148
175
  def open( &blk )
149
176
  ## puts "Dir.getwd: #{Dir.getwd}"
150
177
  Dir.chdir( @path ) do
@@ -160,6 +187,8 @@ class GitRepo
160
187
  def changes?() Git.changes?; end
161
188
  alias_method :dirty?, :changes?
162
189
 
190
+
191
+ def fetch() Git.fetch; end
163
192
  def pull() Git.pull; end
164
193
  def fast_forward() Git.fast_forward; end
165
194
  alias_method :ff, :fast_forward
@@ -170,5 +199,27 @@ class GitRepo
170
199
  def add_all() Git.add_all; end
171
200
  def commit( message: ) Git.commit( message: message ); end
172
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
173
225
 
174
- end # class GitRepo
@@ -9,13 +9,45 @@
9
9
 
10
10
 
11
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
+
12
31
  require_relative '../mono'
13
32
 
14
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
+
15
46
  ## convenience pre-configured/pre-built shortcut - lets you use
16
47
  ## require 'mono/sportdb'
17
48
  ## Mono.setup
18
49
 
50
+ ## use SportDb::Boot.setup (setup_load_path) or such??? - why? why not?
19
51
 
20
52
  module Mono
21
53
  def self.setup ## setup load path
@@ -31,15 +63,23 @@ module Mono
31
63
  $LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sports/lib" )
32
64
 
33
65
  $LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-importers/lib" )
34
- ## todo - add readers, models, sync, etc.
35
-
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" )
36
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
+
37
77
  $LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-formats/lib" )
38
78
  $LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-structs/lib" )
39
79
  $LOAD_PATH.unshift( "#{root}/sportdb/sport.db/sportdb-langs/lib" )
40
80
  $LOAD_PATH.unshift( "#{root}/sportdb/sport.db/score-formats/lib" )
41
81
  $LOAD_PATH.unshift( "#{root}/sportdb/sport.db/date-formats/lib" )
42
-
82
+ $LOAD_PATH.unshift( "#{root}/sportdb/sport.db/alphabets/lib" )
43
83
 
44
84
  pp $: # print load path
45
85
  end
@@ -15,13 +15,15 @@ class Tool
15
15
 
16
16
  ## note: allow shortcut for commands
17
17
  case cmd.downcase
18
- when 'status', 'stati', 'stat', 's'
18
+ when 'status', 'stati', 'stat', 'st', 's'
19
19
  Mono.status
20
20
  when 'sync', 'syn', 'sy', ## note: allow aliases such as install, get & up too
21
21
  'get', 'g',
22
22
  'install', 'insta', 'inst', 'ins', 'i',
23
23
  'up', 'u'
24
24
  Mono.sync
25
+ when 'fetch', 'f'
26
+ Mono.fetch
25
27
  when 'env', 'e'
26
28
  Mono.env
27
29
  else
@@ -2,16 +2,19 @@
2
2
  ## for the gem version info e.g. Mono::Module vs Mono
3
3
 
4
4
  module Mono
5
- module Module
5
+ MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
+ MINOR = 2
7
+ PATCH = 0
8
+ VERSION = [MAJOR,MINOR,PATCH].join('.')
6
9
 
7
- MAJOR = 0 ## todo: namespace inside version or something - why? why not??
8
- MINOR = 1
9
- PATCH = 2
10
- VERSION = [MAJOR,MINOR,PATCH].join('.')
10
+ def self.version
11
+ VERSION
12
+ end
11
13
 
12
- def self.version
13
- VERSION
14
- end
14
+
15
+ module Module
16
+ ## note: move root to its own namespace to avoid
17
+ ## conflict with Mono.root!!!!
15
18
 
16
19
  def self.banner
17
20
  "monos/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
@@ -7,7 +7,7 @@ require 'helper'
7
7
  class TestBase < MiniTest::Test
8
8
 
9
9
  def test_version
10
- puts Mono::Module::VERSION
10
+ puts Mono::VERSION
11
11
  puts Mono::Module.banner
12
12
  puts Mono::Module.root
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.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-09-01 00:00:00.000000000 Z
11
+ date: 2020-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -42,7 +42,6 @@ description: monos - monorepo / mono source tree tools and (startup) scripts
42
42
  email: opensport@googlegroups.com
43
43
  executables:
44
44
  - mo
45
- - moget
46
45
  - mono
47
46
  extensions: []
48
47
  extra_rdoc_files:
@@ -55,15 +54,16 @@ files:
55
54
  - README.md
56
55
  - Rakefile
57
56
  - bin/mo
58
- - bin/moget
59
57
  - bin/mono
60
58
  - lib/mono.rb
61
59
  - lib/mono/base.rb
60
+ - lib/mono/commands/env.rb
61
+ - lib/mono/commands/fetch.rb
62
+ - lib/mono/commands/status.rb
63
+ - lib/mono/commands/sync.rb
62
64
  - lib/mono/git/base.rb
63
- - lib/mono/git/status.rb
64
- - lib/mono/git/sync.rb
65
- - lib/mono/git/tool.rb
66
65
  - lib/mono/sportdb.rb
66
+ - lib/mono/tool.rb
67
67
  - lib/mono/version.rb
68
68
  - lib/monos.rb
69
69
  - test/helper.rb
data/bin/moget DELETED
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- ###################
4
- # DEV TIPS:
5
- #
6
- # For local testing run like:
7
- #
8
- # ruby -Ilib bin/moget
9
- #
10
- # Set the executable bit in Linux. Example:
11
- #
12
- # % chmod a+x bin/moget
13
- #
14
-
15
- require 'mono'
16
-
17
- Mono::Tool.main( ['sync'] )